bootloader.ld 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. /* Simplified memory map for the bootloader.
  7. * Make sure the bootloader can load into main memory without overwriting itself.
  8. */
  9. MEMORY
  10. {
  11. iram_seg (RWX) : org = 0x4004c000, len = 0x4000 /* SRAM Block 13 */
  12. iram_loader_seg (RWX) : org = 0x40050000, len = 0x6000 /* SRAM Block 14 & part of 15 */
  13. dram_seg (RW) : org = 0x3FFE6000, len = 0x4B00 /* Part SRAM Blocks 15 & 16, ROM static buffer starts at end of this region (reclaimed after app runs) */
  14. }
  15. /* Default entry point: */
  16. ENTRY(call_start_cpu0);
  17. SECTIONS
  18. {
  19. .iram_loader.text :
  20. {
  21. . = ALIGN (16);
  22. _loader_text_start = ABSOLUTE(.);
  23. *(.stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  24. *(.iram1 .iram1.*) /* catch stray IRAM_ATTR */
  25. *liblog.a:(.literal .text .literal.* .text.*)
  26. *libgcc.a:(.literal .text .literal.* .text.*)
  27. *libbootloader_support.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
  28. *libbootloader_support.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
  29. *libbootloader_support.a:bootloader_flash.*(.literal .text .literal.* .text.*)
  30. *libbootloader_support.a:bootloader_random.*(.literal .text .literal.* .text.*)
  31. *libbootloader_support.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
  32. *libesp_common.a:fpga_overrides.*(.literal.bootloader_fill_random .text.bootloader_fill_random)
  33. *libbootloader_support.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
  34. *libbootloader_support.a:bootloader_utility.*(.literal .text .literal.* .text.*)
  35. *libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
  36. *libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
  37. *libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
  38. *libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*)
  39. *libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
  40. *libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
  41. *libbootloader_support.a:flash_encryption_secure_features.*(.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_secure_features.*(.literal .text .literal.* .text.*)
  45. *libbootloader_support.a:secure_boot_signatures_bootloader.*(.literal .text .literal.* .text.*)
  46. *libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
  47. *libspi_flash.a:*.*(.literal .text .literal.* .text.*)
  48. *libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
  49. *libhal.a:mmu_hal.*(.literal .text .literal.* .text.*)
  50. *libhal.a:cache_hal.*(.literal .text .literal.* .text.*)
  51. *libhal.a:efuse_hal.*(.literal .text .literal.* .text.*)
  52. *libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
  53. *libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
  54. *libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
  55. *libefuse.a:*.*(.literal .text .literal.* .text.*)
  56. *libesp_rom.a:esp_rom_regi2c.*(.literal .text .literal.* .text.*)
  57. *(.fini.literal)
  58. *(.fini)
  59. *(.gnu.version)
  60. _loader_text_end = ABSOLUTE(.);
  61. } > iram_loader_seg
  62. .iram.text :
  63. {
  64. . = ALIGN (16);
  65. *(.entry.text)
  66. *(.init.literal)
  67. *(.init)
  68. } > iram_seg
  69. /* Shared RAM */
  70. .dram0.bss (NOLOAD) :
  71. {
  72. . = ALIGN (8);
  73. _dram_start = ABSOLUTE(.);
  74. _bss_start = ABSOLUTE(.);
  75. *(.dynsbss)
  76. *(.sbss)
  77. *(.sbss.*)
  78. *(.gnu.linkonce.sb.*)
  79. *(.scommon)
  80. *(.sbss2)
  81. *(.sbss2.*)
  82. *(.gnu.linkonce.sb2.*)
  83. *(.dynbss)
  84. *(.bss)
  85. *(.bss.*)
  86. *(.gnu.linkonce.b.*)
  87. *(COMMON)
  88. . = ALIGN (8);
  89. _bss_end = ABSOLUTE(.);
  90. } >dram_seg
  91. .dram0.data :
  92. {
  93. _data_start = ABSOLUTE(.);
  94. *(.data)
  95. *(.data.*)
  96. *(.gnu.linkonce.d.*)
  97. *(.data1)
  98. *(.sdata)
  99. *(.sdata.*)
  100. *(.gnu.linkonce.s.*)
  101. *(.sdata2)
  102. *(.sdata2.*)
  103. *(.gnu.linkonce.s2.*)
  104. *(.jcr)
  105. _data_end = ABSOLUTE(.);
  106. } >dram_seg
  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. .iram.text :
  151. {
  152. _stext = .;
  153. _text_start = ABSOLUTE(.);
  154. *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  155. *(.iram .iram.*) /* catch stray IRAM_ATTR */
  156. *(.fini.literal)
  157. *(.fini)
  158. *(.gnu.version)
  159. /** CPU will try to prefetch up to 16 bytes of
  160. * of instructions. This means that any configuration (e.g. MMU, PMS) must allow
  161. * safe access to up to 16 bytes after the last real instruction, add
  162. * dummy bytes to ensure this
  163. */
  164. . += 16;
  165. _text_end = ABSOLUTE(.);
  166. _etext = .;
  167. } > iram_seg
  168. }