Hello,
I need to put an ID string (file name and version) at a particular address in a flash, so the programming application can read it from a hex / binary file. I can probably use a scatter file, but is there any simpler solution ?
Cortex-M3 STM32F107 MDK-ARM 4.12
thank you, Gennady
Hi Gennady
const char string[] __attribute__((at(0x0xxxxxxx)) = "Version 1.xxxxdfdf";
willi
Thank you Willi,
well, now I have another question. Is there any way to put this string at the end of a program flash used ? I have some considerations where it will be more beneficial to have it at the end instead of a fixed address.
Gennady
I normally place some meta data (such as crc, version info etc) in last bytes of flash. But if I place the information in the last 16 bytes, that is still at a fixed position. I might decide to have the normal build place 12 byte of info at the end, but leave the last four byte. Then run a post-process program that computes CRC32 and fills the last four bytes with the CRC of the image.
Actually that is exactly what I need (except that post-processing app will write a program size along with checksum there). So the question is still the same - how do I make a build to place this metadata array at the end of a program ?
I tried to follow the procedure suggested by Pontus Thuvesson in http://www.keil.com/forum/docs/thread16466.asp
That is what I did: in a main:
#pragma arm section rodata = "codeEnd" const uint8_t metadata[19] = {'J','0','0','_','1,'1',1, 3,57,0x08,0x00,0x00,0x00,0x44,0x44,0x44,0x44,0x55};
=================== then I edited the scatter file to this:
; ************************************************************* ; *** Scatter-Loading Description File generated by uVision *** ; ************************************************************* LR_IROM1 0x08000000 0x00020000 { ; load region size_region ER_IROM1 0x08000000 0x00020000 { ; load address = execution address *.o (RESET, +First) *(InRoot$$Sections) .ANY (+RO) *.o(codeEnd, +Last) } RW_IRAM1 0x20000000 0x0000C000 { ; RW data .ANY (+RW +ZI) } }
and unchecked 'used memory layout from a target dialog'.
Nevertheless the metadata[] array does not appear at the end of a program. Is there anything i did wrong ? or haven't done ?
I am still trying to get rid of extra data appearing at the end of an image after my string. According to http://www.keil.com/support/docs/3512.htm these is compressed RW initialization data. According to the difference between sizes of Load Region LR_IROM1 and Execution Region ER_IROM1 in a memory map, amount of these data is 124 bytes. I actually have 125, but maybe I miscalculated something.
Anyway, all attempts to eliminate these data were unsuccessful. I tried adding --datacompressor=off in a linker options, some other staff - no luck.
While doing extensive research on a forum, I saw quite a few references to 'putting metadata / special data at the very end of a rom image'. So it seems like there is a lot of expertise on this issue.
Please, could someone point me in a right direction.
I think that what your wanting is similar to what I described in:
http://www.keil.com/forum/docs/thread16898.asp
Unfortunately, I found/got no solution.
How about this?
; ************************************************************* ; *** Scatter-Loading Description File generated by uVision *** ; ************************************************************* LR_IROM1 0x08000000 0x00020000 { ; load region size_region ER_IROM1 0x08000000 0x00020000 { ; load address = execution address *.o (RESET, +First) *(InRoot$Sections) .ANY (+RO) } RW_IRAM1 0x20000000 0x0000C000 { ; RW data .ANY (+RW +ZI) } } LR_IROM2 +0 { ER_IROM2 +0 { *.o(codeEnd, +Last) } }
Mike, thank you so much !
It works, and I see how you've done it. Beautiful.