bootloader.ld 6.4 KB

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