cancel
Showing results for 
Search instead for 
Did you mean: 

how to make keep ram value after software reset?

ikassma
Senior

So i use to stm32cubeide & stm32h743zi. I want to create a variable that the system does not initailize even if the after software reset. just like __no_init in IAR.

i follow this method. but i can't.

https://atadiat.com/en/e-how-to-preserve-a-variable-in-ram-between-software-resets/

1 ACCEPTED SOLUTION

Accepted Solutions
Kamil Duljas
Senior III

Try this:

MEMORY
{
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 319K
  NOINIT(xrw) 	  : ORIGIN = 0x2004FC00, LENGTH = 1K
  FLASH    (rx)    : ORIGIN = 0x8000000,   LENGTH = 1024K
}

Then create section:

  .noinit :
  {
    KEEP(*(.noinitdata))
  } >NOINIT

and create variable:

uint32_t __attribute__(( section(".noinitdata") )) first_run;
 

Dudo

View solution in original post

7 REPLIES 7
Pavel A.
Evangelist III

The default GCC startup code is much simpler than IAR, it initializes only one array of data and one BSS.

The easiest is to use one of SRAM blocks of stm32h743 that are not used for .data, .bss or stack/heap in your linker script. For example if your script uses the AXI SRAM for the "main" data, use SRAM2 or TCM RAM.

Kamil Duljas
Senior III

Try this:

MEMORY
{
  RAM    (xrw)    : ORIGIN = 0x20000000,   LENGTH = 319K
  NOINIT(xrw) 	  : ORIGIN = 0x2004FC00, LENGTH = 1K
  FLASH    (rx)    : ORIGIN = 0x8000000,   LENGTH = 1024K
}

Then create section:

  .noinit :
  {
    KEEP(*(.noinitdata))
  } >NOINIT

and create variable:

uint32_t __attribute__(( section(".noinitdata") )) first_run;
 

Dudo

it is not working.

Couriously, depending on the location of the function that puts a value in the variable, it either keeps or does not retain the value after the reset.​

Kamil Duljas
Senior III

Someone had simillar problem here:

https://stackoverflow.com/questions/65577391/stm32-create-ram-section

Try use this instruction.

Dudo

i had set up to use I Cache and D Cache. It didn't work normally at this time. Each cahe is diabled, so it works normally. but i don't know why.

Kamil Duljas
Senior III

@ikassma​ Do You resolve your problem?

Dudo

yes! I Cache and D Cache Disable. it is works.

Thanks to your advice.