bootloader.ld 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * SPDX-FileCopyrightText: 2021 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_esp8684.*(.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. *libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
  52. *libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
  53. *libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
  54. *libefuse.a:*.*(.literal .text .literal.* .text.*)
  55. *(.fini.literal)
  56. *(.fini)
  57. *(.gnu.version)
  58. _loader_text_end = ABSOLUTE(.);
  59. } > iram_loader_seg
  60. .iram.text :
  61. {
  62. . = ALIGN (16);
  63. *(.entry.text)
  64. *(.init.literal)
  65. *(.init)
  66. } > iram_seg
  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. .dram0.data :
  90. {
  91. _data_start = ABSOLUTE(.);
  92. *(.data)
  93. *(.data.*)
  94. *(.gnu.linkonce.d.*)
  95. *(.data1)
  96. *(.sdata)
  97. *(.sdata.*)
  98. *(.gnu.linkonce.s.*)
  99. *(.sdata2)
  100. *(.sdata2.*)
  101. *(.gnu.linkonce.s2.*)
  102. *(.jcr)
  103. _data_end = ABSOLUTE(.);
  104. } > dram_seg
  105. .dram0.rodata :
  106. {
  107. _rodata_start = ABSOLUTE(.);
  108. *(.rodata)
  109. *(.rodata.*)
  110. *(.gnu.linkonce.r.*)
  111. *(.rodata1)
  112. __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
  113. *(.xt_except_table)
  114. *(.gcc_except_table)
  115. *(.gnu.linkonce.e.*)
  116. *(.gnu.version_r)
  117. *(.eh_frame)
  118. . = (. + 3) & ~ 3;
  119. /* C++ constructor and destructor tables, properly ordered: */
  120. __init_array_start = ABSOLUTE(.);
  121. KEEP (*crtbegin.*(.ctors))
  122. KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
  123. KEEP (*(SORT(.ctors.*)))
  124. KEEP (*(.ctors))
  125. __init_array_end = ABSOLUTE(.);
  126. KEEP (*crtbegin.*(.dtors))
  127. KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
  128. KEEP (*(SORT(.dtors.*)))
  129. KEEP (*(.dtors))
  130. /* C++ exception handlers table: */
  131. __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
  132. *(.xt_except_desc)
  133. *(.gnu.linkonce.h.*)
  134. __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
  135. *(.xt_except_desc_end)
  136. *(.dynamic)
  137. *(.gnu.version_d)
  138. _rodata_end = ABSOLUTE(.);
  139. /* Literals are also RO data. */
  140. _lit4_start = ABSOLUTE(.);
  141. *(*.lit4)
  142. *(.lit4.*)
  143. *(.gnu.linkonce.lit4.*)
  144. _lit4_end = ABSOLUTE(.);
  145. . = ALIGN(4);
  146. _dram_end = ABSOLUTE(.);
  147. } > dram_seg
  148. .iram.text :
  149. {
  150. _stext = .;
  151. _text_start = ABSOLUTE(.);
  152. *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  153. *(.iram .iram.*) /* catch stray IRAM_ATTR */
  154. *(.fini.literal)
  155. *(.fini)
  156. *(.gnu.version)
  157. /** CPU will try to prefetch up to 16 bytes of
  158. * of instructions. This means that any configuration (e.g. MMU, PMS) must allow
  159. * safe access to up to 16 bytes after the last real instruction, add
  160. * dummy bytes to ensure this
  161. */
  162. . += 16;
  163. _text_end = ABSOLUTE(.);
  164. _etext = .;
  165. } > iram_seg
  166. }
  167. /**
  168. * Appendix: Memory Usage of ROM bootloader
  169. *
  170. * +--------+--------------+------+ 0x3FCC_B0B0
  171. * | ^ |
  172. * | | |
  173. * | | data/bss |
  174. * | | |
  175. * | v |
  176. * +------------------------------+ 0x3FCD_C9C0
  177. * | ^ |
  178. * | | |
  179. * | | stack |
  180. * | | |
  181. * | v |
  182. * +------------------------------+ 0x3FCD_E9C0
  183. */