bootloader.ld 6.2 KB

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