bootloader.ld 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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:esp_image_format.*(.literal .text .literal.* .text.*)
  36. *libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
  37. *libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
  38. *libbootloader_support.a:secure_boot.*(.literal .text .literal.* .text.*)
  39. *libbootloader_support.a:secure_boot_signatures.*(.literal .text .literal.* .text.*)
  40. *libmicro-ecc.a:*.*(.literal .text .literal.* .text.*)
  41. *libspi_flash.a:*.*(.literal .text .literal.* .text.*)
  42. *libhal.a:wdt_hal_iram.*(.literal .text .literal.* .text.*)
  43. *libesp_hw_support.a:rtc_clk.*(.literal .text .literal.* .text.*)
  44. *libesp_hw_support.a:rtc_time.*(.literal .text .literal.* .text.*)
  45. *libesp_hw_support.a:regi2c_ctrl.*(.literal .text .literal.* .text.*)
  46. *libefuse.a:*.*(.literal .text .literal.* .text.*)
  47. *(.fini.literal)
  48. *(.fini)
  49. *(.gnu.version)
  50. _loader_text_end = ABSOLUTE(.);
  51. } > iram_loader_seg
  52. .iram.text :
  53. {
  54. . = ALIGN (16);
  55. *(.entry.text)
  56. *(.init.literal)
  57. *(.init)
  58. } > iram_seg
  59. /* Shared RAM */
  60. .dram0.bss (NOLOAD) :
  61. {
  62. . = ALIGN (8);
  63. _dram_start = ABSOLUTE(.);
  64. _bss_start = ABSOLUTE(.);
  65. *(.dynsbss)
  66. *(.sbss)
  67. *(.sbss.*)
  68. *(.gnu.linkonce.sb.*)
  69. *(.scommon)
  70. *(.sbss2)
  71. *(.sbss2.*)
  72. *(.gnu.linkonce.sb2.*)
  73. *(.dynbss)
  74. *(.bss)
  75. *(.bss.*)
  76. *(.gnu.linkonce.b.*)
  77. *(COMMON)
  78. . = ALIGN (8);
  79. _bss_end = ABSOLUTE(.);
  80. } > dram_seg
  81. .dram0.data :
  82. {
  83. _data_start = ABSOLUTE(.);
  84. *(.data)
  85. *(.data.*)
  86. *(.gnu.linkonce.d.*)
  87. *(.data1)
  88. *(.sdata)
  89. *(.sdata.*)
  90. *(.gnu.linkonce.s.*)
  91. *(.sdata2)
  92. *(.sdata2.*)
  93. *(.gnu.linkonce.s2.*)
  94. *(.jcr)
  95. _data_end = ABSOLUTE(.);
  96. } > dram_seg
  97. .dram0.rodata :
  98. {
  99. _rodata_start = ABSOLUTE(.);
  100. *(.rodata)
  101. *(.rodata.*)
  102. *(.gnu.linkonce.r.*)
  103. *(.rodata1)
  104. __XT_EXCEPTION_TABLE_ = ABSOLUTE(.);
  105. *(.xt_except_table)
  106. *(.gcc_except_table)
  107. *(.gnu.linkonce.e.*)
  108. *(.gnu.version_r)
  109. *(.eh_frame)
  110. . = (. + 3) & ~ 3;
  111. /* C++ constructor and destructor tables, properly ordered: */
  112. __init_array_start = ABSOLUTE(.);
  113. KEEP (*crtbegin.*(.ctors))
  114. KEEP (*(EXCLUDE_FILE (*crtend.*) .ctors))
  115. KEEP (*(SORT(.ctors.*)))
  116. KEEP (*(.ctors))
  117. __init_array_end = ABSOLUTE(.);
  118. KEEP (*crtbegin.*(.dtors))
  119. KEEP (*(EXCLUDE_FILE (*crtend.*) .dtors))
  120. KEEP (*(SORT(.dtors.*)))
  121. KEEP (*(.dtors))
  122. /* C++ exception handlers table: */
  123. __XT_EXCEPTION_DESCS_ = ABSOLUTE(.);
  124. *(.xt_except_desc)
  125. *(.gnu.linkonce.h.*)
  126. __XT_EXCEPTION_DESCS_END__ = ABSOLUTE(.);
  127. *(.xt_except_desc_end)
  128. *(.dynamic)
  129. *(.gnu.version_d)
  130. _rodata_end = ABSOLUTE(.);
  131. /* Literals are also RO data. */
  132. _lit4_start = ABSOLUTE(.);
  133. *(*.lit4)
  134. *(.lit4.*)
  135. *(.gnu.linkonce.lit4.*)
  136. _lit4_end = ABSOLUTE(.);
  137. . = ALIGN(4);
  138. _dram_end = ABSOLUTE(.);
  139. } > dram_seg
  140. .iram.text :
  141. {
  142. _stext = .;
  143. _text_start = ABSOLUTE(.);
  144. *(.literal .text .literal.* .text.* .stub .gnu.warning .gnu.linkonce.literal.* .gnu.linkonce.t.*.literal .gnu.linkonce.t.*)
  145. *(.iram .iram.*) /* catch stray IRAM_ATTR */
  146. *(.fini.literal)
  147. *(.fini)
  148. *(.gnu.version)
  149. _text_end = ABSOLUTE(.);
  150. _etext = .;
  151. } > iram_seg
  152. }
  153. /**
  154. * Appendix: Memory Usage of ROM bootloader
  155. *
  156. * +--------+--------------+------+ 0x3FCC_B000
  157. * | ^ |
  158. * | | |
  159. * | | data/bss |
  160. * | | |
  161. * | v |
  162. * +------------------------------+ 0x3FCD_C910
  163. * | ^ |
  164. * | | |
  165. * | | stack |
  166. * | | |
  167. * | v |
  168. * +------------------------------+ 0x3FCD_E910
  169. */