cancel
Showing results for 
Search instead for 
Did you mean: 

AXI SRAM losing last few writes across reset

CHead
Associate III

it seems that a write to AXI SRAM very shortly before a system reset (via AIRCR) gets lost. I wrote a very short block of code that simply reads a word from 0x24000000, increments it, writes it back, and resets the processor. I can see that the value is not changing. Using a debug tool, I can see that, if I manually modify the contents of memory, the register used for the increment changes accordingly. Also, if I use the debug tool to display that memory location after the code should have written it, it shows the new value. However, if I let the code write back the new value, then reset the processor, the memory reverts to its old value after the reset (as shown both by reading the memory directly or by displaying the register).

I saw this note in the reference manual: “When a half word is written to an internal SRAM and a reset occurs, this half word is not really written to the SRAM after reset. This due to the ECC behavior.�? However, this does not apply: I am doing full-word-size reads and writes. It also can’t be a cache issue because I have the caches turned off. I have set PWR_CR3 appropriately (without which SRAM is apparently read-only), and I have set AXI_TARG7_FN_MOD.READ_ISS_OVERRIDE=1 due to the erratum. I have the necessary DSB before writing to AIRCR. I also tried introducing an ISB as well. I also tried (as recommended in the Cortex-M programming guide to barrier instructions, AN321) adding a dummy read from the AXI SRAM after the write, including with a DSB+ISB both before and after the dummy read. All to no avail.

Everything seems to work just fine during normal operation; it’s only after reset that this problem shows up. This problem doesn’t seem to happen if I use the DTCM or the AHB SRAM, only the AXI SRAM.

Any ideas?

12 REPLIES 12

Yes, not marking a variable as volatile is also a known pitfall. But it is not the case here. We even watched each instruction at assembly level and the content was really written to memory. But still, after a reset, the old value reappeared. I'm convinced this behavior is related to ECC, as Chead noted.

On a H753 rev V, I was storing crash dumps in DTCM and your fix did not work, but after moving the crash dumps to D1 RAM, and doing the doubleword copy just with the address modified to 0x24000000, it seems to be working fine. Also, I discovered then when I used a custom memset that even though it actually copies *bytes*, corruption doesn't occur. But that is probably the compiler turning it into doubleword writes. I haven't looked at the disassembly.

This entire issue is frustrating and should be more explicitly covered in the reference manuals!

I don't know if you all follow also the FAQ section, I've just stumbled upon this interesting FAQ (being linked to from another thread, this time backup-SRAM-related, to which this issue pertains, too):

https://community.st.com/s/article/FAQ-STM32H7-SRAM-Backup-SRAM-content-is-not-preserved-after-reset

JW

@Community member​ , @Pavel A.​ , @Community member​ , @Piranha​ , @CHead​ , @Harrold​ , @ETywo.1​ , @Kilian Nötzold​ , @ZYubi​