2025-05-31 11:09 PM
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
Solved! Go to Solution.
2025-06-09 4:52 AM
I created a minimal project for the N6 Discovery Kit to show the issue, and attached it to this post. It does not even need an Appli and XIP, just the FSBL is enough. All it does is enable AXISRAM5, check whether the magic number is there at a specific location. If it is, it blinks the user LED quickly for 10 seconds, clears the magic number and reboots. If the magic number is not there it blinks slowly for 10 seconds. All the code custom code is in main.c (in particular, I did not touch the linker script which configures AXISRAM2 as main memory).
Note that this has to be run from Flash (i.e. the DK-board switched to Flash-boot mode). Running from the debugger is not possible because of the Software-triggered system restart.
I would be really happy if someone from ST with experience with the N6 (maybe @RomainR. or @B.Montanari ?) could have a look at this. If this really is not possible to do with the N6 then I think this is a pretty severe limitation of the chip.
Thanks a lot!
2025-06-10 5:57 AM
Hello @asdfasdf
I just tried your project on my side.
Indeed, the content of AXISRAM5 is lost after a System Reset.
After internal confirmation, this is due to the default shutdown mode of SRAM3 to SRAM6. This corresponds to bit 20 (SRAM SD) of the RAMCFG_AXISRAMxCR registers (with x = 2 to 6).
In RM0486, the reset value of the RAMCFG_AXISRAM3CR to RAMCFG_AXISRAM6CR registers is 0x0010 0000.
As a result, by default, the internal power supply of the concerned SRAMs is turned off to reduce power consumption on VDDCore. Consequently, their content is not guaranteed after a System Reset.
Therefore, important clarifications need to be made on our side in this reference manual, starting from section 10.3.1 "Internal SRAM features" and especially in Table 33 "Internal SRAM features."
Please note that for SRAM1 and SRAM2, the default value of bit 20 (SRAMSD) is 0x0000 0000. However, their content is erased by a system reset.
For your application, you can use the 80kB of retention RAM (between 0x3400 0000 and 0x3401 4000) or the Backup RAM, which is in the VBAT domain (only 8kB !).
Finally, for to store locally your binary, in my opinion, you only have the following options:
Then reset.
Best regards,
Romain,
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2025-06-10 7:46 PM
You've evidently plenty of RAM.
Could you change your implementation like this?
As it's OTA, the interleaving flash write times aren't likely to problematic.
As the download's written direct to flash, your app's max size would be larger.
Please share what you decide to do.
2025-06-15 9:55 PM
Thanks for the confirmation, Romain!
We decided to change our approach and run the flash writing part of our software stack from RAM instead, so that we don't need to restart the system and rely on ram retention. So far it's working pretty well.
Best regards,
Michael