Skip to content

Commit 9dac746

Browse files
committed
samples: boards: espressif: add retained_mem api to deep_sleep sample
Adds retained_mem api to espressif deep_sleep sample and enables it for the following platforms: - esp32_devkitm/esp32/procpu - esp32c3_devkitm - esp32c6_devkitc/esp32c6/hpcore - esp32h2_devkitm - esp32s2_saola - esp32s3_devkitm/esp32s3/procpu Signed-off-by: Marcio Ribeiro <marcio.ribeiro@espressif.com>
1 parent dcb2796 commit 9dac746

File tree

11 files changed

+286
-11
lines changed

11 files changed

+286
-11
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
memory@50001f00 {
9+
compatible = "zephyr,memory-region", "mmio-sram";
10+
reg = <0x50001f00 0x100>;
11+
zephyr,memory-region = "RTC_SLOW_RAM_RETAINED_MEM";
12+
status = "okay";
13+
14+
retainedmem0: retainedmem {
15+
compatible = "zephyr,retained-ram";
16+
status = "okay";
17+
};
18+
};
19+
20+
aliases {
21+
retainedmemdevice = &retainedmem0;
22+
};
23+
};
24+
25+
&rtc_slow_ram {
26+
/* Shrink rtc_slow_ram size to avoid overlap with retained memory region:
27+
* 8KB - 256 = 0x1f00
28+
*/
29+
reg = <0x50000000 0x1f00>;
30+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
memory@50003f00 {
9+
compatible = "zephyr,memory-region", "mmio-sram";
10+
reg = <0x50003f00 0x100>;
11+
zephyr,memory-region = "SRAMLP_RETAINED_MEM";
12+
status = "okay";
13+
14+
retainedmem0: retainedmem {
15+
compatible = "zephyr,retained-ram";
16+
status = "okay";
17+
};
18+
};
19+
20+
aliases {
21+
retainedmemdevice = &retainedmem0;
22+
};
23+
};
24+
25+
/* Delete original shmlp node */
26+
/delete-node/ &shmlp;
27+
28+
&sramlp {
29+
/* Shrink sramlp size to avoid overlap with retained memory region:
30+
* 16KB - 256 = 0x3f00
31+
*/
32+
reg = <0x50000000 0x3f00>;
33+
34+
/* Shift shmlp to keep it inside sramlp memory region:
35+
* 0x50003fe0 - 256 = 0x50003ee0
36+
*/
37+
shmlp: memory@50003ee0 {
38+
reg = <0x50003ee0 0x10>;
39+
};
40+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
memory@50000f00 {
9+
compatible = "zephyr,memory-region", "mmio-sram";
10+
reg = <0x50000f00 0x100>;
11+
zephyr,memory-region = "SRAMLP_RETAINED_MEM";
12+
status = "okay";
13+
14+
retainedmem0: retainedmem {
15+
compatible = "zephyr,retained-ram";
16+
status = "okay";
17+
};
18+
};
19+
20+
aliases {
21+
retainedmemdevice = &retainedmem0;
22+
};
23+
};
24+
25+
&sramlp {
26+
/* Shrink sramlp size to avoid overlap with retained memory region:
27+
* 4KB - 256 = 0xf00
28+
*/
29+
reg = <0x50000000 0xf00>;
30+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
memory@50001f00 {
9+
compatible = "zephyr,memory-region", "mmio-sram";
10+
reg = <0x50001f00 0x100>;
11+
zephyr,memory-region = "RTC_SLOW_RAM_RETAINED_MEM";
12+
status = "okay";
13+
14+
retainedmem0: retainedmem {
15+
compatible = "zephyr,retained-ram";
16+
status = "okay";
17+
};
18+
};
19+
20+
aliases {
21+
retainedmemdevice = &retainedmem0;
22+
};
23+
};
24+
25+
&rtc_slow_ram {
26+
/* Shrink rtc_slow_ram size to avoid overlap with retained memory region:
27+
* 8KB - 256 = 0x1f00
28+
*/
29+
reg = <0x50000000 0x1f00>;
30+
};
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
memory@50001f00 {
9+
compatible = "zephyr,memory-region", "mmio-sram";
10+
reg = <0x50001f00 0x100>;
11+
zephyr,memory-region = "RTC_SLOW_RAM_RETAINED_MEM";
12+
status = "okay";
13+
14+
retainedmem0: retainedmem {
15+
compatible = "zephyr,retained-ram";
16+
status = "okay";
17+
};
18+
};
19+
20+
aliases {
21+
retainedmemdevice = &retainedmem0;
22+
};
23+
};
24+
25+
&rtc_slow_ram {
26+
/* Shrink rtc_slow_ram size to avoid overlap with retained memory region:
27+
* 8KB - 256 = 0x1f00
28+
*/
29+
reg = <0x50000000 0x1f00>;
30+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
CONFIG_POWEROFF=y
2+
CONFIG_RETAINED_MEM=y

samples/boards/espressif/deep_sleep/sample.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ tests:
66
build_only: true
77
platform_allow:
88
- esp32_devkitc/esp32/procpu
9-
- esp32s3_devkitm/esp32s3/procpu
10-
- esp32s2_devkitc
119
- esp32c3_devkitm
1210
- esp32c6_devkitc/esp32c6/hpcore
11+
- esp32s2_saola
12+
- esp32s3_devkitm/esp32s3/procpu
13+
- esp32h2_devkitm
1314
- esp8684_devkitm
1415
sample.esp32.deep_sleep.dut:
1516
extra_args:
@@ -19,10 +20,11 @@ tests:
1920
- CONFIG_ESP32_USE_UNSUPPORTED_REVISION=y
2021
platform_allow:
2122
- esp32_devkitc/esp32/procpu
22-
- esp32s3_devkitm/esp32s3/procpu
23-
- esp32s2_devkitc
2423
- esp32c3_devkitm
2524
- esp32c6_devkitc/esp32c6/hpcore
25+
- esp32s2_saola
26+
- esp32s3_devkitm/esp32s3/procpu
27+
- esp32h2_devkitm
2628
- esp8684_devkitm
2729
tags: esp32
2830
harness: console
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_RETAINED_MEM=n

samples/boards/espressif/deep_sleep/socs/esp32c3.overlay

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Espressif Systems (Shanghai) Co., Ltd.
2+
* Copyright (c) 2022-2025 Espressif Systems (Shanghai) Co., Ltd.
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -10,6 +10,7 @@
1010
* as wake-up sources
1111
*/
1212
wakeup-button = &sample_button;
13+
retainedmemdevice = &retainedmem0;
1314
};
1415

1516
gpio_keys {
@@ -18,4 +19,23 @@
1819
gpios = <&gpio0 0 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
1920
};
2021
};
22+
23+
memory@50001f00 {
24+
compatible = "zephyr,memory-region", "mmio-sram";
25+
reg = <0x50001f00 0x100>;
26+
zephyr,memory-region = "RTC_FAST_RAM_RETAINED_MEM";
27+
status = "okay";
28+
29+
retainedmem0: retainedmem {
30+
compatible = "zephyr,retained-ram";
31+
status = "okay";
32+
};
33+
};
34+
};
35+
36+
&rtc_fast_ram {
37+
/* Shrink rtc_fast_ram size to avoid overlap with retained memory region:
38+
* 8KB - 256 = 0x1f00
39+
*/
40+
reg = <0x50000000 0x1f00>;
2141
};

samples/boards/espressif/deep_sleep/socs/esp32c3_usb.overlay

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* as wake-up sources
1111
*/
1212
wakeup-button = &sample_button;
13+
retainedmemdevice = &retainedmem0;
1314
};
1415

1516
gpio_keys {
@@ -18,4 +19,23 @@
1819
gpios = <&gpio0 0 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>;
1920
};
2021
};
22+
23+
memory@50001f00 {
24+
compatible = "zephyr,memory-region", "mmio-sram";
25+
reg = <0x50001f00 0x100>;
26+
zephyr,memory-region = "RTC_FAST_RAM_RETAINED_MEM";
27+
status = "okay";
28+
29+
retainedmem0: retainedmem {
30+
compatible = "zephyr,retained-ram";
31+
status = "okay";
32+
};
33+
};
34+
};
35+
36+
&rtc_fast_ram {
37+
/* Shrink rtc_fast_ram size to avoid overlap with retained memory region:
38+
* 8KB - 256 = 0x1f00
39+
*/
40+
reg = <0x50000000 0x1f00>;
2141
};

0 commit comments

Comments
 (0)