cancel
Showing results for 
Search instead for 
Did you mean: 

CRC calculation over code in Flash?

matic
Associate III
Posted on September 28, 2016 at 18:21

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 

3 REPLIES 3
Posted on September 28, 2016 at 19:59

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
matic
Associate III
Posted on September 28, 2016 at 21:01

>> 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.htm

And 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

Posted on September 28, 2016 at 22:18

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..