Hello Everyone,
I am using Keil uversion4 for writing my embedded program. I have written a sample program for STM32F437 micro controller(content of which is not important), after compiling my sample code i am getting a hex file along with the .axf file. Now I am trying to built a C program in Visual Studio, that would take this hex or .axf file(not yet decided) as input, extract the staring & ending address of the flash where the code will reside(along with the vector tables), then create an structure that would hold these values, this structure will also contain the entry point to the code.
As per my information the vector table of STM32F4 starts at an address multiple of 128 bytes, So if my flash starts at address 0x08000000 & my vector table starts from address 0x08000128 followed by the code, then I want to place the Structure, that i have created using Visual studio, at memory address 0x8000000, as the 1st structure element is an entry point to the embedded code so i think it won't be a problem to place it at the start of the sector.
I want my Visual studio application to xtract the desired information from the hex file, create a structure that would hold these value(along with some essential information such as the entry point value) & then I want to burn the code along with Structure to my STM32F4 such that in the flash the Structure would be placed 1st(at 0x08000000) followed by some padding, followed by the vector table(0x08000128) & Code.
So kindly suggest me some process through which i can combine the structure with the hex file & burn it to my micro controller flash in the desired sequence
Please help me out guys...as u could see Im in real mess
Thanks & Regards, Amit
If you have read the documentation for the hex file format, then you would see how trivial it is to dump some binary data into hex records.
You could even use existing programs to do it, if you first generate your record as a block of binary data, and then use a program that takes a start offset as a command-line parameter, so it knows what address range to use when generating the hex data.
Most tools do not require the lines in a hex file to be in strictly increasing address order. So it is normally ok, to add extra data just before the final line of a hex file - the last line is a special end-of-file marker so a programming tool can spot a partial file and complain.
It's even allowed to have lines of different length.
The main thing that isn't allowed is to have overlapping address ranges.
By the way - you haven't managed to explain why you must have this extra data first. Quite often, people "must" things just because they think that they must.
Dumping out a structure in Intel HEX format might take a few hundred lines of C, it's not at all complicated. Simple enough to do on a 1970-1980 era CPU in assembler.
There's an open source app called "srecord" as I recall, and probably plenty of other code in the public domain if you need inspiration.