System calls

backupRamSync

Since 5.3.1:

The P2 and Photon 2 have limited support for retained memory in Device OS 5.3.1 and later.

Retained memory is preserved on RTL872x devices in the following cases:

Case Saved
When entering sleep modes 5.3.1 and later
OTA firmware updates 5.3.1 and later
System.backupRamSync() 5.3.1 and later
System.reset() Not saved
Reset button or reset pin Not saved
Every 10 seconds 5.3.1 to 5.8.0 only

Calling System.backupRamSync() will manually save the contents of retained memory to a dedicated flash page on the RTL872x processor and will be restored after the device is reset. You should avoid saving the data extremely frequently as it is slower than RAM and will cause flash wear and is relatively slow to execute.

Prior to Device OS 5.3.1, retained memory is not supported on RTL872x devices. The flash file system can be used, or you can use an external chip such as an I2C or SPI FRAM.

Retained memory is 3068 bytes.

// PROTOTYPE
System.backupRamSync();

On all other devices, retained memory is preserved as a special section of battery backed RAM and no special precautions are required.