We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello everybody. I would know if a way exixts to find a match between the map file (where the memory allocation is illustrated) produced at the end of the compilation and the HEX file (that I download on my target). I mean, the HEX file is composed by HEX records (each line of it) where the 4 hex digits, after the two representing the length, stand for the address. But I am not able to find a match between these addresses and the one on the map file. Could anyone help?
I can put the question in a different way, explaining what I should do, in order to have alternative suggestions. I would edit the HEX file (for example running a script file) generating n-HEX files starting from it, where each one of it has modified a specific variable (for example representing the Identifier of the system where downloading the HEX file). But to do so, I was thinking to put the variable that represents this Identifier in a fixed and known location, then searching it on the HEX file and modifying according to my needs. But, how I told before, I find the variable on the map file of course, but I am not able to find it on the HEX file. Thanks to all.
First off, you can't do it with a normal variable, since a variable is not represented in the hex file. The hex file only covers the address range of data placed in the flash (or, for some chips also data stored in EEPROM).
You must declare your variable as const and stored in the code segment.
Then you have to realize that each hex line only mentions the address of the first byte on the line. Another thing is that each HEX line only has a 16-bit offset. For processors with more than 64kB of code, there will be special records that points to the start of a code segment to allow the hex file to address more than 64kB.
Thank you!
You could create a variable/string/section located at a certain location, using the linker, perhaps with default information inside it, and use your scripts to overwrite the specific information with your custom data. I.e. reserve a memory buffer at a specific memory location and modify it at HEX level. Not sure how to do this for ARM though, sorry.
The srecord tool might be useful to manipulate the HEX files, see srecord.sourceforge.net/.
In other words:
- Have a variable point to a buffer at a certain location, possibly with default info, generate the application HEX file.
- Create a module/"app" with a linker file that says it will be placed in the memory slot, generate the HEX file. You can do this for each custom piece of data.
- Use scripts to merge the application HEX file with the custom data HEX file and create the final image you can flash.