2025-04-23 3:11 AM
Hi everybody,
I am currently working on an STM32F446RE
I need to save some bytes like 10 for example. I need to save some bytes like 10 for example, in flash memory to save my HMI configuration.
I have read articles and done research but I don't understand everything.
The memory is divided into sectors. I think I have to write my data to the end of the memory. However, the last sector is 128kB. Do I have to erase 128kB each time?
Isn't there a simpler and less resource-intensive method? Can't we just delete a 2KB page?
I really need to save only a few variables
Thank you to reading me
Solved! Go to Solution.
2025-04-23 9:56 AM
It doesn't need to be, it can be a vector table, or just have Initial SP/PC
The linker(s) typically can be directed to output things at different addresses, but they are generally not terribly efficient at handling holes in an optimal manner.
One can also write data for configuration/settings in available slack spaces. Voids after the vectors could be used to journal data structures. You can also technically erase too, but it just creates a window for failure where you erase critical data before you get the chance to re-write it. Say an error or power failure. It can be done in the lab, or situations where potentially bricking the device can be readily recovered. Generally not desirable for consumer products, but could work for a flight controller, or Arduino, where a loader can be pushed in via DFU and a Reset/Boot button.
2025-04-23 10:07 AM
@Tesla DeLorean wrote:The linker(s) typically can be directed to output things at different addresses, but they are generally not terribly efficient at handling holes in an optimal manner.
Hmmm - yes.
From the previous links (and a bit more googling), it doesn't look like the Linker can "just do it" - it looks like you have to carve it out manually
2025-04-23 10:15 AM
@JJoao.1 does it have to be STM32F446RE ?
Maybe look at other parts which have more "friendly" flash layouts?
I think the only STM32s with true EEPROM are some L0s (Cortex-M0+) and L1s (M3).
2025-04-23 11:27 AM
does it have to be STM32F446RE ?
Yes, I have already ordered it, and place on my PCB .
I need the fast 40Mhz SPI module to communicate with a screen so 80Mhz clock.
I think it's to dangerous for me to try t owrite at the begin of Flash.
I will stay at the end , It doesn't matter for the 128kB. I will erase it every time. Or If i need to modify my PCB maybe Iwill implemente an extern memory.
I thought it was going to be easier, it's my fault
Thank you so much for your help/
See you later
2025-04-23 12:20 PM
If that's resolved it for, please mark that as the solution:
https://community.st.com/t5/community-guidelines/help-others-to-solve-their-issues/ta-p/575256