Skip to content

Commit 69f8a6d

Browse files
committed
drivers: retained_mem: enable retained_mem for esp32 paltforms
Enables retained_mem on esp32 platforms using RTCRAM Signed-off-by: Marcio Ribeiro <[email protected]>
1 parent e83d8d9 commit 69f8a6d

File tree

6 files changed

+53
-3
lines changed

6 files changed

+53
-3
lines changed

boards/espressif/esp32s3_devkitc/esp32s3_devkitc_procpu.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ supported:
1717
- pwm
1818
- dma
1919
- input
20+
- retained_mem
2021
vendor: espressif

dts/xtensa/espressif/esp32s3/esp32s3_common.dtsi

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,18 @@
161161
#mbox-cells = <1>;
162162
};
163163

164+
rtcram_slow: memory@50000000 {
165+
compatible = "zephyr,memory-region", "mmio-sram";
166+
reg = <0x50000000 DT_SIZE_K(8)>;
167+
zephyr,memory-region = "RTCRAM_SLOW";
168+
};
169+
170+
rtcram_fast: memory@600fe000 {
171+
compatible = "zephyr,memory-region", "mmio-sram";
172+
reg = <0x600fe000 DT_SIZE_K(8)>;
173+
zephyr,memory-region = "RTCRAM_FAST";
174+
};
175+
164176
intc: interrupt-controller@600c2000 {
165177
#interrupt-cells = <3>;
166178
#address-cells = <0>;

soc/espressif/esp32s3/default.ld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ MEMORY
9595
#endif
9696

9797
/* RTC fast memory (executable). Persists over deep sleep. */
98-
rtc_iram_seg(RWX): org = 0x600fe000, len = 0x2000 - CONFIG_RESERVE_RTC_MEM
98+
rtc_iram_seg(RWX): org = RCTRAM_FAST_START, len = RCTRAM_FAST_SIZE - CONFIG_RESERVE_RTC_MEM
9999

100100
/* We reduced the size of rtc_iram_seg by CONFIG_RESERVE_RTC_MEM value.
101101
* It reserves the amount of RTC fast memory that we use for this memory segment.
@@ -105,12 +105,12 @@ MEMORY
105105
* The aim of this is to keep data that will not be moved around and have a fixed address.
106106
*/
107107
#if (CONFIG_RESERVE_RTC_MEM > 0)
108-
rtc_reserved_seg(RW): org = 0x600fe000 + 0x2000 - CONFIG_RESERVE_RTC_MEM,
108+
rtc_reserved_seg(RW): org = RCTRAM_FAST_START + RCTRAM_FAST_SIZE - CONFIG_RESERVE_RTC_MEM,
109109
len = CONFIG_RESERVE_RTC_MEM
110110
#endif
111111

112112
/* RTC slow memory (data accessible). Persists over deep sleep. */
113-
rtc_slow_seg(RW): org = 0x50000000, len = 0x2000
113+
rtc_slow_seg(RW): org = RCTRAM_SLOW_START, len = RCTRAM_SLOW_SIZE
114114

115115
#ifdef CONFIG_GEN_ISR_TABLES
116116
IDT_LIST(RW): org = 0x3ebfe010, len = 0x2000

soc/espressif/esp32s3/memory.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
#define SRAM2_USER_DRAM_START (SRAM2_DRAM_START + CONFIG_ESP32S3_DATA_CACHE_SIZE)
1919
#define SRAM2_USER_DRAM_SIZE (SRAM2_SIZE - CONFIG_ESP32S3_DATA_CACHE_SIZE)
2020

21+
#define RCTRAM_SLOW_START DT_REG_ADDR(DT_NODELABEL(rtcram_slow))
22+
#define RCTRAM_SLOW_SIZE DT_REG_SIZE(DT_NODELABEL(rtcram_slow))
23+
24+
#define RCTRAM_FAST_START DT_REG_ADDR(DT_NODELABEL(rtcram_fast))
25+
#define RCTRAM_FAST_SIZE DT_REG_SIZE(DT_NODELABEL(rtcram_fast))
26+
2127
/** Simplified memory map for the bootloader.
2228
* Make sure the bootloader can load into main memory without overwriting itself.
2329
*
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@600fff00 {
9+
compatible = "zephyr,memory-region", "mmio-sram";
10+
reg = <0x600fff00 0x100>;
11+
zephyr,memory-region = "RTCRAM_FAST_RETAINEDMEM";
12+
status = "okay";
13+
14+
retainedmem0: retainedmem {
15+
compatible = "zephyr,retained-ram";
16+
status = "okay";
17+
};
18+
};
19+
20+
aliases {
21+
retainedmemtestdevice = &retainedmem0;
22+
};
23+
};
24+
25+
&rtcram_fast {
26+
/* Shrink rtcram_fast size to avoid overlap with retained memory region:
27+
* 8KB - 256 = 0x1f00
28+
*/
29+
reg = <0x600fe000 0x1f00>;
30+
};

tests/drivers/retained_mem/api/testcase.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ tests:
66
- retained_mem
77
drivers.retained_mem.api.ram:
88
platform_allow:
9+
- esp32s3_devkitc/esp32s3/procpu
910
- qemu_cortex_m3
1011
- nrf5340dk/nrf5340/cpuapp
1112
- nrf54h20dk/nrf54h20/cpuapp

0 commit comments

Comments
 (0)