STM32N6: Retain RAM contents across resets for OTA firmware updates
Dear all,
I'm implementing Over-the-air firmware updates for a board using the STM32N657 MCU.
In the Appli, I download the new firmware binary over Wifi and store it to RAM at a fixed location in AXISRAM5 and 6. In order to flash the new binary to the OctoSPI Flash I prepend a "magic" header to the new firmware binary (still in RAM) and then restart the MCU using `HAL_NVIC_SystemReset`. Then, after this reset the FSBL checks the fixed location in RAM for the "magic" header. If present, it should flash the OctoSPI Flash with the new firmware binary using the ExtMem Manager (I cannot just flash directly from Appli because I use XIP and hence the Appli is running from OctoSPI in memory-mapped mode, preventing writes). I've done similar things with other MCUs and it worked perfectly fine.
However, it looks like on the STM32N6, the contents of AXISRAM5 and 6 are not preserved across software resets. At least, checking the "magic" header in FSBL always produces randomly looking results that are also different each time I try. Is there a way to preserve contents of AXISRAM5/6 across resets? Do I need to configure something for this to happen (e.g. is there some security feature that resets RAM contents, or the BootROM doing stuff, etc)?
I have disabled the D-Cache and MPU to rule this out as a source of issues, and am also very sure that this is not the usual problem of the C-runtime initialization overwriting the values (since they are different each time, and also because the memory buffer isn't even present in the Linker script - I just access it directly by address).
Thanks a lot, Michael
