rp2040.ld 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. MEMORY
  2. {
  3. FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 2048k
  4. RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 240k /* Leave space for pico-debug */
  5. SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
  6. SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
  7. }
  8. ENTRY(_entry_point)
  9. SECTIONS
  10. {
  11. .flash_begin : {
  12. __flash_binary_start = .;
  13. } > FLASH
  14. .boot2 : {
  15. __boot2_start__ = .;
  16. KEEP (*(.boot2))
  17. __boot2_end__ = .;
  18. } > FLASH
  19. ASSERT(__boot2_end__ - __boot2_start__ == 256,
  20. "ERROR: Pico second stage bootloader must be 256 bytes in size")
  21. /* If ZuluSCSI SD card bootloader is included, it goes in first 128 kB */
  22. .text.bootloader : ALIGN(16) SUBALIGN(16)
  23. {
  24. KEEP(*(.text.btldr*))
  25. . = ALIGN(131072);
  26. CHECK_BOOTLOADER_SIZE = 1 / (. <= 131072);
  27. } > FLASH
  28. .text : {
  29. __logical_binary_start = .;
  30. __real_vectors_start = .;
  31. KEEP (*(.vectors))
  32. KEEP (*(.binary_info_header))
  33. __binary_info_header_end = .;
  34. KEEP (*(.reset))
  35. KEEP (*(.init))
  36. *(.fini)
  37. *crtbegin.o(.ctors)
  38. *crtbegin?.o(.ctors)
  39. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  40. *(SORT(.ctors.*))
  41. *(.ctors)
  42. *crtbegin.o(.dtors)
  43. *crtbegin?.o(.dtors)
  44. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  45. *(SORT(.dtors.*))
  46. *(.dtors)
  47. *(.eh_frame*)
  48. . = ALIGN(4);
  49. /* Put only non-timecritical code in flash
  50. * This includes e.g. floating point math routines.
  51. */
  52. *libm*:(.text .text*)
  53. *libc*:(.text .text*)
  54. *libgcc*:*df*(.text .text*)
  55. *USB*(.text .text*)
  56. *SPI*(.text .text*)
  57. *Spi*(.text .text*)
  58. *spi*(.text .text*)
  59. *stdc*:(.text .text*)
  60. *supc*:(.text .text*)
  61. *nosys*:(.text .text*)
  62. *libc*:*printf*(.text .text*)
  63. *libc*:*toa*(.text .text*)
  64. *libminIni.a:(.text .text*)
  65. } > FLASH
  66. .rodata : {
  67. . = ALIGN(4);
  68. *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*)))
  69. *(.rodata)
  70. *(.rodata*)
  71. . = ALIGN(4);
  72. } > FLASH
  73. .ARM.extab :
  74. {
  75. *(.ARM.extab* .gnu.linkonce.armextab.*)
  76. } > FLASH
  77. __exidx_start = .;
  78. .ARM.exidx :
  79. {
  80. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  81. } > FLASH
  82. __exidx_end = .;
  83. . = ALIGN(4);
  84. __binary_info_start = .;
  85. .binary_info :
  86. {
  87. KEEP(*(.binary_info.keep.*))
  88. *(.binary_info.*)
  89. } > FLASH
  90. __binary_info_end = .;
  91. . = ALIGN(4);
  92. __etext = .;
  93. .ram_vector_table (COPY): {
  94. *(.ram_vector_table)
  95. } > RAM
  96. .data : {
  97. __data_start__ = .;
  98. *(vtable)
  99. /* Time critical code will go here to avoid external flash latency */
  100. *(.time_critical*)
  101. . = ALIGN(4);
  102. *(.text)
  103. *(.text*)
  104. . = ALIGN(4);
  105. *(.data*)
  106. . = ALIGN(4);
  107. *(.after_data.*)
  108. . = ALIGN(4);
  109. PROVIDE_HIDDEN (__mutex_array_start = .);
  110. KEEP(*(SORT(.mutex_array.*)))
  111. KEEP(*(.mutex_array))
  112. PROVIDE_HIDDEN (__mutex_array_end = .);
  113. . = ALIGN(4);
  114. PROVIDE_HIDDEN (__preinit_array_start = .);
  115. KEEP(*(SORT(.preinit_array.*)))
  116. KEEP(*(.preinit_array))
  117. PROVIDE_HIDDEN (__preinit_array_end = .);
  118. . = ALIGN(4);
  119. PROVIDE_HIDDEN (__init_array_start = .);
  120. KEEP(*(SORT(.init_array.*)))
  121. KEEP(*(.init_array))
  122. PROVIDE_HIDDEN (__init_array_end = .);
  123. . = ALIGN(4);
  124. PROVIDE_HIDDEN (__fini_array_start = .);
  125. *(SORT(.fini_array.*))
  126. *(.fini_array)
  127. PROVIDE_HIDDEN (__fini_array_end = .);
  128. *(.jcr)
  129. . = ALIGN(4);
  130. __data_end__ = .;
  131. } > RAM AT> FLASH
  132. .uninitialized_data (COPY): {
  133. . = ALIGN(4);
  134. *(.uninitialized_data*)
  135. } > RAM
  136. .scratch_x : {
  137. __scratch_x_start__ = .;
  138. *(.scratch_x.*)
  139. . = ALIGN(4);
  140. __scratch_x_end__ = .;
  141. } > SCRATCH_X AT > FLASH
  142. __scratch_x_source__ = LOADADDR(.scratch_x);
  143. .scratch_y : {
  144. __scratch_y_start__ = .;
  145. *(.scratch_y.*)
  146. . = ALIGN(4);
  147. __scratch_y_end__ = .;
  148. } > SCRATCH_Y AT > FLASH
  149. __scratch_y_source__ = LOADADDR(.scratch_y);
  150. .bss : {
  151. . = ALIGN(4);
  152. __bss_start__ = .;
  153. *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
  154. *(COMMON)
  155. . = ALIGN(4);
  156. __bss_end__ = .;
  157. } > RAM
  158. .heap (COPY):
  159. {
  160. __end__ = .;
  161. PROVIDE(end = .);
  162. *(.heap*)
  163. . = ORIGIN(RAM) + LENGTH(RAM) - 0x400;
  164. __HeapLimit = .;
  165. } > RAM
  166. .stack1_dummy (COPY):
  167. {
  168. *(.stack1*)
  169. } > SCRATCH_X
  170. .stack_dummy (COPY):
  171. {
  172. *(.stack*)
  173. } > RAM
  174. .flash_end : {
  175. __flash_binary_end = .;
  176. } > FLASH
  177. __StackTop = ORIGIN(RAM) + LENGTH(RAM);
  178. __StackLimit = __StackTop - 0x400;
  179. __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X);
  180. __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy);
  181. __StackBottom = __StackTop - SIZEOF(.stack_dummy);
  182. PROVIDE(__stack = __StackTop);
  183. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed")
  184. ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary")
  185. }