1010
1111#include " memory.h"
1212
13- /* The "user_iram_end" represents the 2nd stage bootloader
14- * "iram_loader_seg" start address (that should not be overlapped).
15- * If no bootloader is used, we can extend it to gain more user ram.
16- */
17- #ifdef CONFIG_ESP_SIMPLE_BOOT
18- user_iram_end = (BOOTLOADER_USER_DRAM_END + IRAM_DRAM_OFFSET);
19- #else
20- user_iram_end = BOOTLOADER_IRAM_LOADER_SEG_START;
21- #endif
22-
2313/* User available SRAM memory segments */
24- user_dram_seg_org = SRAM1_DRAM_START;
25- user_iram_seg_org = SRAM0_IRAM_START + CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE;
26- user_dram_end = BOOTLOADER_IRAM_LOADER_SEG_START - IRAM_DRAM_OFFSET;
27- user_idram_size = user_dram_end - SRAM1_DRAM_START;
28- sram0_iram_size = SRAM0_SIZE - CONFIG_ESP32S3_INSTRUCTION_CACHE_SIZE;
29- user_iram_seg_len = user_idram_size + sram0_iram_size;
30- user_dram_seg_len = user_idram_size;
14+ amp_total_size = APPCPU_SRAM_TOTAL_SIZE;
15+ procpu_iram_end = USER_IRAM_END - APPCPU_SRAM_TOTAL_SIZE;
16+ procpu_dram_end = USER_DRAM_END - APPCPU_SRAM_TOTAL_SIZE;
17+
18+ procpu_iram_org = SRAM_USER_IRAM_START;
19+ procpu_iram_len = procpu_iram_end - procpu_iram_org;
20+
21+ procpu_dram_org = SRAM1_DRAM_START;
22+ procpu_dram_len = procpu_dram_end - procpu_dram_org;
3123
3224/* Aliases */
3325#define FLASH_CODE_REGION irom0_0_seg
@@ -36,6 +28,7 @@ user_dram_seg_len = user_idram_size;
3628#define RAMABLE_REGION dram0_0_seg
3729#define ROMABLE_REGION FLASH
3830
31+ /* Zephyr macro re-definitions */
3932#undef GROUP_DATA_LINK_IN
4033#define GROUP_DATA_LINK_IN (vregion, lregion ) > vregion AT > lregion
4134
@@ -66,14 +59,13 @@ MEMORY
6659 FLASH (R) : org = 0x0 , len = FLASH_SIZE - 0x100
6760#endif /* CONFIG_BOOTLOADER_MCUBOOT */
6861
69- iram0_0_seg (RX) : org = user_iram_seg_org , len = user_iram_seg_len - APPCPU_IRAM_SIZE
70- dram0_0_seg (RW) : org = user_dram_seg_org , len = user_dram_seg_len - APPCPU_DRAM_SIZE
62+ iram0_0_seg (RX) : org = procpu_iram_org , len = procpu_iram_len
63+ dram0_0_seg (RW) : org = procpu_dram_org , len = procpu_dram_len
7164
7265 irom0_0_seg (RX) : org = IROM_SEG_ORG, len = IROM_SEG_LEN
7366 drom0_0_seg (R) : org = DROM_SEG_ORG, len = DROM_SEG_LEN
7467
75- /* *
76- * `ext_ram_seg` and `drom0_0_seg` share the same bus and the address region.
68+ /* The `ext_ram_seg` and `drom0_0_seg` share the same bus and the address region.
7769 * A dummy section is used to avoid overlap. See `.ext_ram.dummy` in `sections.ld.in`
7870 */
7971#if defined(CONFIG_ESP_SPIRAM)
@@ -101,11 +93,15 @@ MEMORY
10193ENTRY (CONFIG_KERNEL_ENTRY)
10294
10395/* Used as a pointer to the heap end */
96+ #ifdef CONFIG_SOC_ENABLE_APPCPU
97+ _heap_sentry = procpu_dram_end;
98+ #else
10499_heap_sentry = DRAM_RESERVED_START;
100+ #endif
105101
106102SECTIONS
107103{
108- _iram_dram_offset = IRAM_DRAM_OFFSET;
104+ _iram_dram_offset = IRAM_DRAM_OFFSET;
109105
110106#ifdef CONFIG_BOOTLOADER_MCUBOOT
111107 /* Reserve space for MCUboot header in the binary */
@@ -116,6 +112,7 @@ SECTIONS
116112 QUAD (0x0 )
117113 QUAD (0x0 )
118114 } > mcuboot_hdr
115+ /* Image load table */
119116 .metadata :
120117 {
121118 /* 0. Magic byte for load header */
@@ -144,7 +141,6 @@ SECTIONS
144141 } > metadata
145142#endif /* CONFIG_BOOTLOADER_MCUBOOT */
146143
147-
148144/* Virtual non-loadable sections */
149145#include < zephyr/linker/rel-sections.ld>
150146
@@ -275,7 +271,9 @@ SECTIONS
275271 *(.entry .text )
276272 *(.init .literal )
277273 *(.init )
274+
278275 _init_end = ABSOLUTE (.);
276+
279277 } GROUP_DATA_LINK_IN (IRAM_REGION, ROMABLE_REGION)
280278
281279 .iram0.text : ALIGN (4 )
@@ -310,6 +308,11 @@ SECTIONS
310308 *libphy.a :(.phyiram .phyiram .*)
311309 *libgcov.a :(.literal .text .literal .* .text .*)
312310
311+ /* APPCPU_ENABLED */
312+ *libzephyr.a :esp32s3-mp.*(.literal .text .literal .* .text .*)
313+ *libzephyr.a :bootloader_flash.*(.literal .text .literal .* .text .*)
314+ *libzephyr.a :flash_mmap.*(.literal .text .literal .* .text .*)
315+
313316 /* [mapping:esp_psram] */
314317 *libzephyr.a :mmu_psram_flash.*(.literal .literal .* .text .text .*)
315318 *libzephyr.a :esp_psram_impl_quad.*(.literal .literal .* .text .text .*)
@@ -550,6 +553,11 @@ SECTIONS
550553 *libzephyr.a :esp_mmu_map.*(.rodata .rodata .*)
551554 *libdrivers__interrupt_controller.a :(.rodata .rodata .*)
552555
556+ /* APPCPU_ENABLE */
557+ *libzephyr.a :esp32s3-mp.*(.rodata .rodata .*)
558+ *libzephyr.a :bootloader_flash.*(.rodata .rodata .* .sdata2 .sdata2 .* .srodata .srodata .*)
559+ *libzephyr.a :flash_mmap.*(.rodata .rodata .* .sdata2 .sdata2 .* .srodata .srodata .*)
560+
553561 /* [mapping:esp_psram] */
554562 *libzephyr.a :mmu_psram_flash.*(.rodata .rodata .*)
555563 *libzephyr.a :esp_psram_impl_octal.*(.rodata .rodata .*)
@@ -798,6 +806,10 @@ SECTIONS
798806
799807 } GROUP_DATA_LINK_IN (FLASH_CODE_REGION, ROMABLE_REGION)
800808
809+ /* --- END OF IROM --- */
810+
811+ /* --- START OF DROM --- */
812+
801813 /* This dummy section represents the .flash.text section but in default_rodata_seg.
802814 * Thus, it must have its alignment and (at least) its size.
803815 */
@@ -879,6 +891,10 @@ SECTIONS
879891 _image_rodata_end = ABSOLUTE (.);
880892 } GROUP_DATA_LINK_IN (RODATA_REGION, ROMABLE_REGION)
881893
894+ /* --- END OF DROM --- */
895+
896+ /* --- START OF SPIRAM --- */
897+
882898 /* *
883899 * This section is required to skip flash rodata sections, because `ext_ram_seg`
884900 * and `drom0_0_seg` are on the same bus
@@ -907,8 +923,9 @@ SECTIONS
907923
908924#endif /* CONFIG_ESP_SPIRAM */
909925
910- /* --- XTENSA GLUE AND DEBUG BEGIN --- */
926+ /* --- END OF SPIRAM --- */
911927
928+ /* --- XTENSA GLUE AND DEBUG BEGIN --- */
912929#ifdef CONFIG_GEN_ISR_TABLES
913930#include < zephyr/linker/intlist.ld>
914931#endif
0 commit comments