I am programming a micro in C++. I need a static variable to survive across a reset.
The object is used to hold more detailed information about the reason for the reset. I can't be guaranteed that I can log it to flash at time of reset, so I need to log it after the reset.
I can use pointer constants and manually allocate a block of ram that is not given to the linker in the segments file.... and do in place initialisation.
But I was wondering is there a way of using attributes or something similar in gcc that will allow me to avoid static initialisation of a static variable. This makes it slightly more portable between the different micros I am using as I don't have to fiddle with the memory map manually.
I need the standard object constructors to work when the object is assigned explicitly.
.dataor.bss, which would not be touched by the start-up code. What micro is it? Some of them have persistent scratchpad registers that survive a reset..datasection into RAM. I did that on a recent STM32 project, it woks fine.