Gen 3 Devices:
A 3068 bytes section of backup RAM is provided for storing values that are maintained across system reset and hibernate sleep mode. Unlike EEPROM emulation, the backup RAM can be accessed at the same speed as regular RAM and does not have any wear limitations.
On Gen 3 devices (Argon, Boron, B Series SoM, Tracker SoM), retained memory is only initialized in Device OS 1.5.0 and later. In prior versions, retained memory would always be uninitialized on first power-up.
Gen 2 Devices:
The STM32F2xx features 4KB of backup RAM (3068 bytes for Device OS version v0.6.0 and later) of which is available to the user. Unlike the regular RAM memory, the backup RAM is retained so long as power is provided to VIN or to VBAT. In particular this means that the data in backup RAM is retained when:
- the device goes into deep sleep mode (SLEEP_MODE_DEEP or HIBERNATE)
- the device is hardware or software reset (while maintaining power)
- power is removed from VIN but retained on VBAT (which will retain both the backup RAM and the RTC)
Note that if neither VIN or VBAT is powered then the contents of the backup RAM will be lost; for data to be retained, the device needs a power source. For persistent storage of data through a total power loss, please use the EEPROM.
Power Conditions and how they relate to Backup RAM initialization and data retention:
|Power Down Method||Power Up Method||When VIN Powered||When VBAT Powered||SRAM Initialized||SRAM Retained|
|Power removed on VIN and VBAT||Power applied on VIN||-||No||Yes||No|
|Power removed on VIN and VBAT||Power applied on VIN||-||Yes||Yes||No|
|Power removed on VIN||Power applied on VIN||-||Yes||No||Yes|
|System.sleep(SLEEP_MODE_DEEP)||Rising edge on WKP pin, or Hard Reset||Yes||Yes/No||No||Yes|
|System.sleep(SLEEP_MODE_DEEP,10)||RTC alarm after 10 seconds||Yes||Yes/No||No||Yes|
|System.reset()||Boot after software reset||Yes||Yes/No||No||Yes|
|Hard reset||Boot after hard reset||Yes||Yes/No||No||Yes|
 Note: If VBAT is floating when powering up for the first time, SRAM remains uninitialized. When using this feature for Backup RAM, it is recommended to have VBAT connected to a 3V3 or a known good power source on system first boot. When using this feature for Extra RAM, it is recommended to jumper VBAT to GND on the Photon, P1, and Electron to ensure it always initializes on system first boot. On the Electron, VBAT is tied to 3V3 and you must not connect it to GND.