cancel
Showing results for 
Search instead for 
Did you mean: 

SRAM data is lost after soft boot

PHolz.1
Associate II

Hi,

I have a problem with the SRAM. I use a stm32f303CCT and Keil. I write  a value in the SRAM memory. (0x20000000 - 0x20000008) However, after a soft reset, the SRAM value will be deleted. How can this be prevented so that the data is preserved?

PHolz1_2-1701849775464.png

The data is stored as shown in the image below.

PHolz1_4-1701849882377.png

After soft reset the SRAM is deleted.

PHolz1_5-1701849964218.png

What do I need to change in the Patter File or the startup File so that the data is not lost?

PHolz1_0-1701849205040.png

Thank you for help

 

7 REPLIES 7
TDK
Guru

Global variables are initialized to 0 by default at the start of the program. You can carve out a ram section and mark it as NOLOAD if you don't want that to take place.

https://mcuoneclipse.com/2014/04/19/gnu-linker-can-you-not-initialize-my-variable/

 

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

Doesn't Keil use NOINIT  not UNINIT

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
PHolz.1
Associate II

 

 In the "Options for Target" there is a box "NoInit" and Keil generates the UNINIT in the scatter file.

PHolz1_0-1701874029372.png

The line with UNINT should actually work, but the RAM memory area is always deleted after the software RESET.

 

PHolz1_2-1701874203316.png

The link https://mcuoneclipse.com/2014/04/19/gnu-linker-can-you-not-initialize-my-variable/  is only suitable, if you use the stm32CubeIDE program. At Keil the scatter file has a different syntax.

 

Pavel A.
Evangelist III

Please set a breakpoint on the reset handler in the asm startup and look at the SRAM at that point. If the data is already lost, it is something hardware (power loss). Else it is software (initialization of this area still runs somehow).

-- Addition--

If the data is lost at this point, it can be also artifact of the debugger. Just because debuggers can do this.

What is "soft reset"? OK I see in screenshot, some HAL function, presumably just calling the standard CMSIS software reset function.

What hardware is tied to NRST pin?

Sorry, this is all nonsense. Just have a look at disasm of the startup code (reset handler) and/or do what Pavel A. suggested above.

JW

The __main called in startup.s is what calls the scatterload function, and subsequently user's main() function.

Would suggest unpacking the initialization tables, might need to review .MAP, and disassemble .AXF via

FROMELF -csd  foo.axf  >foo.lst

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
PHolz.1
Associate II
Thanks for your help. I solved my problem using the following link

https://developer.arm.com/documentation/ka003046/latest

 

I made the declarations like in Compiler 5, but I have Complier 6. So the declaration must look like this:

// Arm Compiler 5

PHolz1_0-1701938955537.png

PHolz1_1-1701938984117.png

// Arm Compiler 6

PHolz1_2-1701939043187.png

PHolz1_3-1701939066088.png