cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way I can reserve a region of flash to read/write at runtime? I’m using STM32CubeIDE.

Snowopolis
Associate II

My application has a few hundred bytes of data that need to be stored in flash. It won’t change often, but will be changed. I’d like to reserve an address range. I know how to read/write flash. Not sure how to decide where to put the data. Any mechanism for this?

2 REPLIES 2
TDK
Guru

Typically this is done by using the last page of flash to store nonvolatile data. To do so, reduce the size of the flash in the linker script so that it doesnt contain this page. Then, in your application, erase that page and write/rewrite data as needed. You can’t erase less than a page of flash, so you need to reserve it all, even in you only need a small portion.

If you feel a post has answered your question, please click "Accept as Solution".
Uwe Bonnes
Principal III

Reserve two pages, so when page one is full when various variables have been overwritten and replaced you can transfer to the other page without needing for a lot of intermediate RAM.