Skip to main content
Mdi c
Associate III
March 17, 2020
Question

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

  • March 17, 2020
  • 4 replies
  • 977 views

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

This topic has been closed for replies.

4 replies

Tesla DeLorean
Guru
March 17, 2020

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 VenmoUp vote any posts that you find helpful, it shows what's working..
Mdi c
Mdi cAuthor
Associate III
March 17, 2020

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
Principal III
March 19, 2020

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
Mdi cAuthor
Associate III
March 22, 2020

thanks! very good application notes :)