Skip to main content
Snowopolis
Associate II
June 26, 2020
Question

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

  • June 26, 2020
  • 2 replies
  • 1041 views

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?

This topic has been closed for replies.

2 replies

TDK
Super User
June 26, 2020

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
Chief
June 26, 2020

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.