cancel
Showing results for 
Search instead for 
Did you mean: 

SRAM2 is only partially retained

crackl1ng
Associate III

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

1 ACCEPTED SOLUTION

Accepted Solutions
TDK
Guru

> 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".

View solution in original post

4 REPLIES 4
TDK
Guru

> 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".

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

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
Up vote any posts that you find helpful, it shows what's working..
If you’re initializing them, it would make sense that they would be reset at startup. You need to mark them as no load and initialize only if needed.
If you feel a post has answered your question, please click "Accept as Solution".