2016-09-28 09:21 AM
Hi.
I would like to periodically calculate CRC over code in Flash. Is it possible to see runtime the end address of the code located in flash? Most of the flash is free, so I will not like to calculate CRC over those free pages.
I saw that the size of used flash is stored in .map file, but I don't know how to include that into application.
Any idea?
Thanks
2016-09-28 10:59 AM
Post process the .HEX so you know what the Size and CRC should be of a valid image.
Use a linker symbol to mark the end, and use that symbol in your code.For Keil use Region$$Table$$Base and Region$$Table$$Limit, walk the table and determine the end of ROM, and size of the statics copied.2016-09-28 12:01 PM
>> Post process the .HEX so you know what the Size and CRC should be of a valid image.
Probably I have to create .bin file this way: http://www.keil.com/support/docs/274.htmAnd from .bin I can see the size and CRC that .bin file?>> Use a linker symbol to mark the end, and use that symbol in your code.I don't understand what do you mean with ''linker symbol''. Could you explain, please?>> For Keil use Region$$Table$$Base and Region$$Table$$Limit, walk the table and determine the end of ROM, and size of the statics copied.Also don't know where I could read Region$$Table$$Base and Region$$Table$$Limit or how can I use them. I would be very grateful, if you can provide any more detailed information.Thank you
2016-09-28 01:18 PM
The linkers job is binding symbols together, ie your functions, variables, things in the linker script, etc. If it's in the .MAP file and has an address, it is probably a *symbol*.
Observe how GNU/GCC uses _sidata, _sdata and _edata to describe the placement and length of static data copied in the Reset_Handler code in startup_stm32fxxx.s file. In Keil the linker builds structures related to the LOAD REGIONS used by your scatter file.extern uint32_t Region$$Table$$Base; // Symbol used by Keil Linker to describe static memory regions copied at startup
{ // Quick-n-dirty method of using available symbols to plot end of image
uint32_t *p = &Region$$Table$$Base;
printf(''End Of ROM %08l
X'', p[0] + p[2]); // Static Copy Base, Static Copy Size
} // sourcer32@gmail.com