1/** Simplified memory map for the bootloader. 2 * Make sure the bootloader can load into main memory without overwriting itself. 3 * We put 2nd bootloader in the high address space (before ROM stack/data/bss). 4 * See memory usage for ROM bootloader at the end of this file. 5 */ 6 7MEMORY 8{ 9 iram_seg (RWX) : org = 0x403CE000, len = 0x2000 10 iram_loader_seg (RWX) : org = 0x403D0000, len = 0x6000 11 dram_seg (RW) : org = 0x3FCD6000, len = 0x4000 12} 13 14/* Default entry point: */ 15ENTRY(call_start_cpu0); 16 17SECTIONS 18{ 19 20 .iram_loader.text : 21 { 22 . = ALIGN (16); 23 _loader_text_start = ABSOLUTE(.); 24 *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) 25 *(.iram1 .iram1.*) /* catch stray IRAM_ATTR */ 26 *liblog.a:(.literal .text .literal.* .text.*) 27 *libgcc.a:(.literal .text .literal.* .text.*) 28 *libbootloader_support.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*) 29 *libbootloader_support.a:bootloader_common_loader.*(.literal .text .literal.* .text.*) 30 *libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*) 31 *libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*) 32 *libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable) 33 *libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable) 34 *libbootloader_support.a:bootloader_efuse_esp32h2.*(.literal .text .literal.* .text.*) 35 *libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*) 36 *libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*) 37 *libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*) 38 *libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*) 39 *libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*) 40 *libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*) 41 *libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*) 42 *libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*) 43 *libbootloader_support.a:secure_boot.*(.literal .text .literal.* .text.*) 44 *libbootloader_support.a:secure_boot_signatures_bootloader.*(.literal .text .literal.* .text.*) 45 *libmicro-ecc.a:*.*(.literal .text .literal.* .text.*) 46 *libspi_flash.a:*.*(.literal .text .literal.* .text.*) 47 *libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*) 48 *libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*) 49 *libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*) 50 *libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*) 51 *libefuse.a:*.*(.literal .text .literal.* .text.*) 52 *(.fini.literal) 53 *(.fini) 54 *(.gnu.version) 55 _loader_text_end = ABSOLUTE(.); 56 } > iram_loader_seg 57 58 .iram.text : 59 { 60 . = ALIGN (16); 61 *(.entry.text) 62 *(.init.literal) 63 *(.init) 64 } > iram_seg 65 66 67 /* Shared RAM */ 68 .dram0.bss (NOLOAD) : 69 { 70 . = ALIGN (8); 71 _dram_start = ABSOLUTE(.); 72 _bss_start = ABSOLUTE(.); 73 *(.dynsbss) 74 *(.sbss) 75 *(.sbss.*) 76 *(.gnu.linkonce.sb.*) 77 *(.scommon) 78 *(.sbss2) 79 *(.sbss2.*) 80 *(.gnu.linkonce.sb2.*) 81 *(.dynbss) 82 *(.bss) 83 *(.bss.*) 84 *(.gnu.linkonce.b.*) 85 *(COMMON) 86 . = ALIGN (8); 87 _bss_end = ABSOLUTE(.); 88 } > dram_seg 89 90 .dram0.data : 91 { 92 _data_start = ABSOLUTE(.); 93 *(.data) 94 *(.data.*) 95 *(.gnu.linkonce.d.*) 96 *(.data1) 97 *(.sdata) 98 *(.sdata.*) 99 *(.gnu.linkonce.s.*) 100 *(.sdata2) 101 *(.sdata2.*) 102 *(.gnu.linkonce.s2.*) 103 *(.jcr) 104 _data_end = ABSOLUTE(.); 105 } > dram_seg 106 107 .dram0.rodata : 108 { 109 _rodata_start = ABSOLUTE(.); 110 *(.rodata) 111 *(.rodata.*) 112 *(.gnu.linkonce.r.*) 113 *(.rodata1) 114 __XT_EXCEPTION_TABLE_ = ABSOLUTE(.); 115 *(.xt_except_table) 116 *(.gcc_except_table) 117 *(.gnu.linkonce.e.*) 118 *(.gnu.version_r) 119 *(.eh_frame) 120 . = (. + 3) & ~ 3; 121 /* C++ constructor and destructor tables, properly ordered: */ 122 __init_array_start = ABSOLUTE(.); 123 KEEP (*crtbegin.*(.ctors)) 124 KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors)) 125 KEEP (*(SORT(.ctors.*))) 126 KEEP (*(.ctors)) 127 __init_array_end = ABSOLUTE(.); 128 KEEP (*crtbegin.*(.dtors)) 129 KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors)) 130 KEEP (*(SORT(.dtors.*))) 131 KEEP (*(.dtors)) 132 /* C++ exception handlers table: */ 133 __XT_EXCEPTION_DESCS_ = ABSOLUTE(.); 134 *(.xt_except_desc) 135 *(.gnu.linkonce.h.*) 136 __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.); 137 *(.xt_except_desc_end) 138 *(.dynamic) 139 *(.gnu.version_d) 140 _rodata_end = ABSOLUTE(.); 141 /* Literals are also RO data. */ 142 _lit4_start = ABSOLUTE(.); 143 *(*.lit4) 144 *(.lit4.*) 145 *(.gnu.linkonce.lit4.*) 146 _lit4_end = ABSOLUTE(.); 147 . = ALIGN(4); 148 _dram_end = ABSOLUTE(.); 149 } > dram_seg 150 151 .iram.text : 152 { 153 _stext = .; 154 _text_start = ABSOLUTE(.); 155 *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*) 156 *(.iram .iram.*) /* catch stray IRAM_ATTR */ 157 *(.fini.literal) 158 *(.fini) 159 *(.gnu.version) 160 161 /** CPU will try to prefetch up to 16 bytes of 162 * of instructions. This means that any configuration (e.g. MMU, PMS) must allow 163 * safe access to up to 16 bytes after the last real instruction, add 164 * dummy bytes to ensure this 165 */ 166 . += 16; 167 168 _text_end = ABSOLUTE(.); 169 _etext = .; 170 } > iram_seg 171 172} 173 174/** 175 * Appendix: Memory Usage of ROM bootloader 176 * 177 * +--------+--------------+------+ 0x3FCC_B900 178 * | ^ | 179 * | | | 180 * | | data/bss | 181 * | | | 182 * | v | 183 * +------------------------------+ 0x3FCD_D210 184 * | ^ | 185 * | | | 186 * | | stack | 187 * | | | 188 * | v | 189 * +------------------------------+ 0x3FCD_F210 190 */ 191