cancel
Showing results for 
Search instead for 
Did you mean: 

I have a need to fix a function to a particular page of flash. How do I do that?

MDiSa.1
Associate

I am developing FW Update capability. I need to place all the functions that erase and program flash in a fixed location so I can erase my application without erasing the functions.

I do not know the compiler/linker syntax to make a function reside at a particular flash address.

1 REPLY 1
Andreas Bolsch
Lead II

This depends on your (top secret?) toolchain: Split flash area in linker/loader script into several parts, one 'default' part where the usual .text sections etc. go, and one separate part for each block (maybe individual flash pages, or even smaller blocks) which must be kept independent of each other. Then, in the sources, prefix each of the special functions with the proper pragma/attribute to indicate in which section it should go.

This will ensure each of your special functions will be located *somewhere* in one of the prescribed blocks. If you want precise address for each of these functions, just use a separate block for each one. Note that this gets slightly cumbersome, as you won't know the required size for each section in advance, so some experiments are necessary (and the size will change with each change of compiler version and settings).

Regarding the syntax for your particular toochain: Look into the Cube samplex, e.g. for the STM32F746-Disco where there are two separate flash sections end even several RAM sections.