From a11bcdcd5c2f77a85bb3e17b90bd9feee185ed51 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 16 Mar 2020 23:34:15 +0100 Subject: [PATCH 1/4] cpu/cortexm_common: define BACKUP_RAM attribute --- cpu/cortexm_common/include/cpu_conf_common.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 From b8e18d521fac3d29755c57b518764be0d0000746 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 16 Mar 2020 23:34:36 +0100 Subject: [PATCH 2/4] cpu/esp32: define BACKUP_RAM attribute --- cpu/esp32/include/cpu_conf.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 */ From 69551d4a74c7c38f6b132742cfb350e258c4e588 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 16 Mar 2020 23:34:51 +0100 Subject: [PATCH 3/4] cpu/lpc2387: define BACKUP_RAM attribute --- cpu/lpc2387/include/cpu_conf.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 From aff99b64e9ebf6b2bef56cc31fcc1d5c889aa2b5 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 16 Mar 2020 23:35:11 +0100 Subject: [PATCH 4/4] tests/periph_backup_ram: use BACKUP_RAM attribute --- tests/periph_backup_ram/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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");