We are trying to retain the state of system after system reset/restart/crash. The plan was to use the last chunk of RAM and explicitly access it via a pointer. So far this seems worked fine, over the course of weeks of test and thousands of restet, we only observed once that section of RAM got corrupted.
We are using STM32F767, there are about 300KB free RAM in the heap, so it is probably safe to assume the last 32KB will never be touched unless explicitly accessed by address. My question is, do we need to do anything else to make sure other parts of code won’t touch that chunk of RAM?
Please advise, thanks.
The best way to do this is to edit the linker script to declare a new section taken from the RAM space, and then use the section attribute to have the compiler link variables into that section.
Here is a simple example from the ST forums: Link
The good thing about this method is you’re not restricted to a position/size, and you have compiler/linker checking for correct sizes and accesses.
Disclaimer; I haven’t actually tried this on an M7, so given the apparent issue also reported in the post, you may need to either disable caching, or configure the MPU to prevent caching the assigned area.
exactly this is used for Mbed crash report, I think. We talk about that in your older topic - How to effectively use watchdog in mbed? - Mbed OS - Arm Mbed OS support forum
I never tried to do something with this, but there seems to be documented how to add region in RAM via linker (correctly sugested by Tom) and so on. You can found how to add your own codes dictly to exiscting system maybe. But as minimum you can use it for inspiration.
Here is probably defined a region for mbed crash for F767 probably
Thanks for your suggestion. This is actually what we did in STM32F4, somehow I completely forgot about it, or probably thought that is not safe also when I asked the question.