diff --git a/cpu/cortexm_common/include/cpu_conf_common.h b/cpu/cortexm_common/include/cpu_conf_common.h index ea6ffa4429a2..7e9efe21a835 100644 --- a/cpu/cortexm_common/include/cpu_conf_common.h +++ b/cpu/cortexm_common/include/cpu_conf_common.h @@ -73,6 +73,20 @@ extern "C" { */ #define PUF_SRAM_ATTRIBUTES __attribute__((used, section(".puf"))) +#if CPU_HAS_BACKUP_RAM || DOXYGEN +/** + * @brief Memory marked with this attribute is retained during deep sleep + * and initialized with 0 on cold boot. + */ +#define BACKUP_RAM __attribute__((section(".backup.bss"))) + +/** + * @brief Memory marked with this attribute is retained during deep sleep + * and initialized with user provided data on cold boot. + */ +#define BACKUP_RAM_DATA __attribute__((section(".backup.data"))) +#endif /* CPU_HAS_BACKUP_RAM */ + #ifdef __cplusplus } #endif diff --git a/cpu/esp32/include/cpu_conf.h b/cpu/esp32/include/cpu_conf.h index 58f24ba7f8d3..3f36b9dc4348 100644 --- a/cpu/esp32/include/cpu_conf.h +++ b/cpu/esp32/include/cpu_conf.h @@ -51,6 +51,18 @@ extern "C" { */ #define PRINTF_BUFSIZ 256 +/** + * @brief Memory marked with this attribute is retained during deep sleep + * and initialized with 0 on cold boot. + */ +#define BACKUP_RAM __attribute__((section(".rtc.bss"))) + +/** + * @brief Memory marked with this attribute is retained during deep sleep + * and initialized with user provided data on cold boot. + */ +#define BACKUP_RAM_DATA __attribute__((section(".rtc.data"))) + #ifdef __cplusplus } #endif /* CPU_CONF_H */ diff --git a/cpu/lpc2387/include/cpu_conf.h b/cpu/lpc2387/include/cpu_conf.h index 2a214834d387..b0e46d287e8a 100644 --- a/cpu/lpc2387/include/cpu_conf.h +++ b/cpu/lpc2387/include/cpu_conf.h @@ -6,7 +6,6 @@ * directory for more details. */ - #ifndef CPU_CONF_H #define CPU_CONF_H @@ -127,6 +126,18 @@ extern "C" { */ #define NUM_HEAPS (4) +/** + * @brief Memory marked with this attribute is retained during deep sleep + * and initialized with 0 on cold boot. + */ +#define BACKUP_RAM __attribute__((section(".backup.bss"))) + +/** + * @brief Memory marked with this attribute is retained during deep sleep + * and initialized with user provided data on cold boot. + */ +#define BACKUP_RAM_DATA __attribute__((section(".backup.data"))) + #ifdef __cplusplus } #endif diff --git a/tests/periph_backup_ram/main.c b/tests/periph_backup_ram/main.c index f76cb0e05942..bdb88aa72e66 100644 --- a/tests/periph_backup_ram/main.c +++ b/tests/periph_backup_ram/main.c @@ -39,7 +39,7 @@ int main(void) * counter anyway after wakeup, we did not sleep properly. */ static int counter_noinit __attribute__((section(".noinit"))); - static int counter __attribute__((section(".backup.bss"))); + static int counter BACKUP_RAM; if (counter == 0) { puts("\nBackup RAM test\n");