cancel
Showing results for 
Search instead for 
Did you mean: 

RAM duration : erased at reset ?

Posted on April 04, 2013 at 15:51

Hello ST lovers,

I have a very simple yet critical to my project question : is the RAM in the STM32F405 erased upon reset ? If yes, then is there any EEPROM I can use to store 32 bits of data that'll survive through reset ?

#ram-reset-erase
7 REPLIES 7
Posted on April 04, 2013 at 16:00

The SRAM is not erased by a reset, although regions might be moved, or cleared by the C Run Time's start up code as it runs.

The SRAM at power up has undefined content.

Certain STM32 parts have registers or RAM areas backed up by the battery in the VBAT power domain.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Posted on April 04, 2013 at 16:13

All I'm doing right now - I'm at the very start of this project - is thinking about how and where to boot. And my boot module might use a temporary boot address (to test a new firmware) that it could store in the SRAM. So if the SRAM survives a reset then I'm good, and after booting I don't need that variable anymore so my CRT will be free to do whatever it wants.

And if power lacks, the SRAM is scrambled, but my booter has a main boot address in Flash (pointing to a firmware I know to be working), so I'm also good. But what you say is interesting : what do you mean, Vbat power domain backup ? How can it backup anything if there's no power anyway ?

Posted on April 04, 2013 at 16:29

With no power you'll need to use FLASH. If you have a battery or supercap, use that to preserve across a cycle in the primary supply.

0690X000006054vQAA.png
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
emalund
Associate III
Posted on April 04, 2013 at 16:51

most? compilers (I know Keil and IAR does) clear RAM at startup. this can be avoided by modifying the startup code (compiler dependent)

Erik
Posted on April 04, 2013 at 17:18

most? compilers (I know Keil and IAR does) clear RAM at startup. this can be avoided by modifying the startup code (compiler dependent)

The out of the box Keil experience with STM32F4 (ARM) is that it only initializes the statics (scatterload_copy), and clears up through the stack (scatterload_zeroinit), which sits atop the heap. It does NOT clear the entire SRAM memory arena.

Data parked outside the SRAM foot print of the application will be left alone across a chip reset.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Evangelist
Posted on April 04, 2013 at 18:02

''most? compilers (I know Keil and IAR does) clear RAM at startup''

The 'C' language definition requires that statics & globals are initialised at startup; either to the explicit initialisation given in the definition, or to zero if no initialiser is given.

I don't think compilers usually waste time in clearing any other regions of memory?

''this can be avoided by modifying the startup code (compiler dependent)''

There may other options; eg, assigning ''no-init'' regions...

Andrew Neil
Evangelist
Posted on April 04, 2013 at 18:03

''I don't think compilers usually waste time in clearing any other regions of memory?''

In fact, this is one common cause of code ''working'' (sic) in a simulator - but not in real hardware...