2020-03-17 05:34 AM
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
2020-03-17 06:10 AM
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.
2020-03-17 06:35 AM
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
2020-03-19 04:11 PM
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.
2020-03-22 07:29 AM
thanks! very good application notes :)