bootloader.ld 6.4 KB

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