cancel
Showing results for 
Search instead for 
Did you mean: 

ST32F7 Internal Flash INIT/READ/WRITE for application settings (KEIL)

Mdi c
Associate III

Dear all,

for my application I need to store some user settings in the internal Flash and be able to modify/read them during execution. I have been succesfully familiarising with the Erase/write ans read functions with no particular struggle. Now I want to initialise the flash sector to some dafault settings that the user can later on modify. I have been reading that I should define a region in the Keil scatter file and then use static const to define my settings variables. However, I cannot find any guide about how to create the scatter file and achieve my goal. Could you please direct me ? thank you

4 REPLIES 4

Not looking to tutorialize​ Scatter Files and Linker Scripts. Generally you'd identify sections via attribute or #pragma

Better to use structures and pointers, and have code to write defaults when data is missing or corrupt. Also allows for a reset to factory defaults.​

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

Hello @Community member​ , thank you for your answer. What I have done so far is just define my variable like follows:

struct config PROGs[4] __attribute__((section(".ARM.__at_0x080C0000"))) = {...}

It works nice, the data are loaded into the location I want.

How would you address the following problem : I need to modify only a limited and configurable set of bytes in the memory, however the flash memory sector needs to be fully erased. Should I store the full sector in RAM, modify it and write it before turning off? thank you

Piranha
Chief II

Get an inspiration from AN3390 and AN4894, think about it thoroughly and make your own smarter configuration storage system. Make it like a record storage database. Also you don't need to emulate EEPROM addresses - you can use different IDs for your records, if that's more suitable.

Mdi c
Associate III

thanks! very good application notes :)