Skip to main content
crackl1ng
Associate III
Mar 7, 2022 10:36 AM UTC
Solved

SRAM2 is only partially retained

Hello dear STM32-Community,

I'm using an STM32L4R and wanted to configure my data retention of SRAM2 for standbymode.

I did the following changes to the linker file:

/* Highest address of the user mode stack */
_estack = 0x10004000; /* end of RAM */
/* Generate a link error if heap and stack don't fit into RAM */
_Min_Heap_Size = 0x800; /* required amount of heap */
_Min_Stack_Size = 0x800; /* required amount of stack */
 
/* Specify the memory areas */
MEMORY
{
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 640K
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 2048K
SRAM2 (rw) : ORIGIN = 0x10000000, LENGTH = 16K
}
 
[........]
 
 .data : 
 {
 . = ALIGN(8);
 _sdata = .; /* create a global symbol at data start */
 *(.data) /* .data sections */
 *(.data*) /* .data* sections */
 
 . = ALIGN(8);
 _edata = .; /* define a global symbol at data end */
 } >SRAM2

As seen on the screenshot the data is acutally saved in SRAM2 (0x10000000) 0693W00000KbduWQAR.pngbut except for counter, which is specifically initalized with

volatile uint32_t Counter __attribute__((section(".sram2")));

everything else is reset after restarting the programm. What am I doing wrong? Or do i have to manually enter every variable to sram2 myself?

Kind regards and thank you in advance

crackl1ng

This topic has been closed for replies.
TDK
TDKBest answer
Mar 7, 2022 2:06 PM UTC

> but except for counter, which is specifically initalized with

> volatile uint32_t Counter __attribute__((section(".sram2")));

> everything else is reset after restarting the programm.

How are other SRAM2 variables initialized.

Is SRAM2 marked as NOLOAD?

"If you feel a post has answered your question, please click ""Accept as Solution""."

4 replies

TDK
TDKBest answer
Mar 7, 2022 2:06 PM UTC

> but except for counter, which is specifically initalized with

> volatile uint32_t Counter __attribute__((section(".sram2")));

> everything else is reset after restarting the programm.

How are other SRAM2 variables initialized.

Is SRAM2 marked as NOLOAD?

"If you feel a post has answered your question, please click ""Accept as Solution""."
crackl1ng
crackl1ngAuthor
Associate III
Mar 7, 2022 3:46 PM UTC

The others are just initialized like usual:

float temp = 0.0f; and so on. As stated in the linker file, they are saved in 0x1000000.

And what does NOLOAD mean and where do I find that?

Thank you for your reply.

​

Kind regards

Tesla DeLorean
Guru
Mar 7, 2022 3:51 PM UTC

Google?

Similar to NOINIT (don't initialize)

So that code in startup.s doesn't zero or copy in statics you don't want initialized.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..