5454{
5555#ifdef CONFIG_BOOTLOADER_MCUBOOT
5656 mcuboot_hdr (R) : org = 0x0 , len = 0x20
57- metadata (R) : org = 0x20 , len = 0x20
58- FLASH (R) : org = 0x40 , len = FLASH_SIZE - 0x40
57+ metadata (R) : org = 0x20 , len = 0x60
58+ FLASH (R) : org = 0x80 , len = FLASH_SIZE - 0x80
5959#else
6060 /* Make safety margin in the FLASH memory size so the
6161 * (esp_img_header + (n*esp_seg_headers)) would fit */
@@ -69,7 +69,19 @@ MEMORY
6969 drom0_0_seg (R) : org = DROM_SEG_ORG, len = DROM_SEG_LEN
7070
7171 rtc_iram_seg (RWX) : org = 0x400c0000 , len = 0x2000
72- rtc_slow_seg (RW) : org = 0x50000000 , len = 0x1000
72+ rtc_slow_seg (RW) : org = 0x50000000 , len = 0x2000 - CONFIG_RESERVE_RTC_MEM
73+ rtc_data_seg (RW) : org = 0x3ff80000 , len = 0x2000
74+
75+ /* We reduced the size of rtc_slow_seg by CONFIG_RESERVE_RTC_MEM value.
76+ It reserves the amount of RTC slow memory that we use for this memory segment.
77+ This segment is intended for keeping rtc timer data (s_rtc_timer_retain_mem, see esp_clk.c files).
78+ The aim of this is to keep data that will not be moved around and have a fixed address.
79+ org = 0x50000000 + 0x2000 - CONFIG_RESERVE_RTC_MEM
80+ */
81+ #if (CONFIG_RESERVE_RTC_MEM > 0)
82+ rtc_slow_reserved_seg (RW) : org = 0x50000000 + 0x2000 - CONFIG_RESERVE_RTC_MEM,
83+ len = CONFIG_RESERVE_RTC_MEM
84+ #endif
7385
7486#ifdef CONFIG_ESP_SPIRAM
7587 ext_ram_seg (RW) : org = 0x3f800000 , len = CONFIG_ESP_SPIRAM_SIZE
@@ -126,6 +138,25 @@ SECTIONS
126138 LONG (ADDR (.dram0 .data ))
127139 LONG (LOADADDR (.dram0 .data ))
128140 LONG (LOADADDR (.dram0 .end ) + SIZEOF (.dram0 .end ) - LOADADDR (.dram0 .data ))
141+
142+ /* RTC_TEXT metadata:
143+ * 8. Destination address (VMA) for RTC_TEXT region
144+ * 9. Flash offset (LMA) for start of RTC_TEXT region
145+ * 10. Size of RTC region
146+ */
147+ LONG (ADDR (.rtc .text ))
148+ LONG (LOADADDR (.rtc .text ))
149+ LONG (SIZEOF (.rtc .text ))
150+
151+ /* RTC_DATA metadata:
152+ * 11. Destination address (VMA) for RTC_DATA region
153+ * 12. Flash offset (LMA) for start of RTC_DATA region
154+ * 13. Size of RTC region
155+ */
156+ LONG (ADDR (.rtc .data ))
157+ LONG (LOADADDR (.rtc .data ))
158+ LONG (SIZEOF (.rtc .data ))
159+
129160 } > metadata
130161#endif /* CONFIG_BOOTLOADER_MCUBOOT */
131162
@@ -137,54 +168,90 @@ SECTIONS
137168
138169 /* --- RTC BEGIN --- */
139170
140- /* RTC fast memory holds RTC wake stub code,
141- * including from any source file named rtc_wake_stub*.c
142- */
143171 .rtc.text :
144172 {
145173 . = ALIGN (4 );
146- *(.rtc .literal .rtc .text )
147- *rtc_wake_stub*.o (.literal .text .literal .* .text .*)
174+ *(.rtc .literal .rtc .literal .*)
175+ *(.rtc .text .rtc .text .*)
176+ . = ALIGN (4 );
148177 } GROUP_DATA_LINK_IN (rtc_iram_seg, ROMABLE_REGION)
149178
150- /* RTC slow memory holds RTC wake stub
151- * data/rodata, including from any source file
152- * named rtc_wake_stub*.c
153- */
179+ /*
180+ This section is required to skip rtc.text area because rtc_iram_seg and
181+ rtc_data_seg reflect the same address space on different buses.
182+ */
183+ .rtc.dummy :
184+ {
185+ . = SIZEOF (.rtc .text );
186+ } GROUP_DATA_LINK_IN (rtc_data_seg, ROMABLE_REGION)
187+
188+ /* This section located in RTC FAST Memory area.
189+ It holds data marked with RTC_FAST_ATTR attribute.
190+ See the file "esp_attr.h" for more information.
191+ */
192+ .rtc.force_fast :
193+ {
194+ . = ALIGN (4 );
195+ *(.rtc .force_fast .rtc .force_fast .*)
196+ . = ALIGN (4 );
197+ } GROUP_DATA_LINK_IN (rtc_data_seg, ROMABLE_REGION)
198+
199+ /* RTC data section holds RTC wake stub
200+ data/rodata, including from any source file
201+ named rtc_wake_stub*.c and the data marked with
202+ RTC_DATA_ATTR, RTC_RODATA_ATTR attributes.
203+ */
154204 .rtc.data :
155205 {
206+ . = ALIGN (4 );
156207 _rtc_data_start = ABSOLUTE (.);
157- *(.rtc .data )
158- *(.rtc .rodata )
159- *rtc_wake_stub*.o (.data .rodata .data .* .rodata .* .bss .bss .*)
160- _rtc_data_end = ABSOLUTE (.);
208+ *(.rtc .data .rtc .data .*)
209+ *(.rtc .rodata .rtc .rodata .*)
210+ . = ALIGN (4 );
161211 } GROUP_DATA_LINK_IN (rtc_slow_seg, ROMABLE_REGION)
162212
163- /* RTC bss, from any source file named rtc_wake_stub*.c */
164213 .rtc .bss (NOLOAD) :
165214 {
166215 _rtc_bss_start = ABSOLUTE (.);
167- *rtc_wake_stub*.o (.bss .bss .*)
168- *rtc_wake_stub*.o (COMMON)
216+ *(.rtc .bss .rtc .bss .*)
169217 _rtc_bss_end = ABSOLUTE (.);
170218 } GROUP_LINK_IN (rtc_slow_seg)
171219
220+ .rtc_noinit (NOLOAD) :
221+ {
222+ . = ALIGN (4 );
223+ *(.rtc_noinit .rtc_noinit .*)
224+ . = ALIGN (4 ) ;
225+ } GROUP_LINK_IN (rtc_slow_seg)
226+
172227 /* This section located in RTC SLOW Memory area.
173228 * It holds data marked with RTC_SLOW_ATTR attribute.
174229 * See the file "esp_attr.h" for more information.
175230 */
176231 .rtc.force_slow :
177232 {
178233 . = ALIGN (4 );
179- _rtc_force_slow_start = ABSOLUTE (.);
180234 *(.rtc .force_slow .rtc .force_slow .*)
181235 . = ALIGN (4 ) ;
182236 _rtc_force_slow_end = ABSOLUTE (.);
183- } > rtc_slow_seg
237+ } GROUP_DATA_LINK_IN ( rtc_slow_seg, ROMABLE_REGION)
184238
185- /* Get size of rtc slow data */
186239 _rtc_slow_length = (_rtc_force_slow_end - _rtc_data_start);
187240
241+ /* *
242+ * This section holds RTC SLOW data that should have fixed addresses.
243+ * The data are not initialized at power-up and are retained during deep sleep.
244+ */
245+ #if (CONFIG_RESERVE_RTC_MEM > 0)
246+ .rtc_slow_reserved (NOLOAD) :
247+ {
248+ . = ALIGN (4 );
249+ _rtc_slow_reserved_start = ABSOLUTE (.);
250+ *(.rtc_timer_data_in_rtc_mem .rtc_timer_data_in_rtc_mem .*)
251+ _rtc_slow_reserved_end = ABSOLUTE (.);
252+ } GROUP_LINK_IN (rtc_slow_reserved_seg)
253+ #endif
254+
188255 /* --- RTC END --- */
189256
190257 /* --- IRAM BEGIN --- */
0 commit comments