STM32 - Preserve a section of FLASH memory

1.9k views Asked by At

Following in the directions of this post, I am able to reserve and write to (and read back) from a section of FLASH dedicated to calibration data.

Problem:
However, when I reprogram the device, the IDE wipes the whole memory clean before programming and we lose all the data. Since we are in a debugging cycle, we are constantly reprogramming and have to write the calibration back as a first step every time.

Is there a way to tell the IDE to only erase a certain region of memory corresponding to the program data? Thanks.

1

There are 1 answers

1
walkingcrane On

The ST Community came to my aid. Answer is to use (NOLOAD) in the linker file to tell the compiler not to put initialization data in the .elf file. Details can be found here: https://mcuoneclipse.com/2014/04/19/gnu-linker-can-you-not-initialize-my-variable/