rp2040.ld 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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. .text : {
  22. __logical_binary_start = .;
  23. KEEP (*(.vectors))
  24. KEEP (*(.binary_info_header))
  25. __binary_info_header_end = .;
  26. KEEP (*(.reset))
  27. KEEP (*(.init))
  28. *(.fini)
  29. *crtbegin.o(.ctors)
  30. *crtbegin?.o(.ctors)
  31. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  32. *(SORT(.ctors.*))
  33. *(.ctors)
  34. *crtbegin.o(.dtors)
  35. *crtbegin?.o(.dtors)
  36. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  37. *(SORT(.dtors.*))
  38. *(.dtors)
  39. *(.eh_frame*)
  40. . = ALIGN(4);
  41. *(.text)
  42. *(.text*)
  43. } > FLASH
  44. .rodata : {
  45. . = ALIGN(4);
  46. *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*)))
  47. *(.rodata)
  48. *(.rodata*)
  49. . = ALIGN(4);
  50. } > FLASH
  51. .ARM.extab :
  52. {
  53. *(.ARM.extab* .gnu.linkonce.armextab.*)
  54. } > FLASH
  55. __exidx_start = .;
  56. .ARM.exidx :
  57. {
  58. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  59. } > FLASH
  60. __exidx_end = .;
  61. . = ALIGN(4);
  62. __binary_info_start = .;
  63. .binary_info :
  64. {
  65. KEEP(*(.binary_info.keep.*))
  66. *(.binary_info.*)
  67. } > FLASH
  68. __binary_info_end = .;
  69. . = ALIGN(4);
  70. __etext = .;
  71. .ram_vector_table (COPY): {
  72. *(.ram_vector_table)
  73. } > RAM
  74. .data : {
  75. __data_start__ = .;
  76. *(vtable)
  77. *(.time_critical*)
  78. . = ALIGN(4);
  79. *(.data*)
  80. . = ALIGN(4);
  81. *(.after_data.*)
  82. . = ALIGN(4);
  83. PROVIDE_HIDDEN (__mutex_array_start = .);
  84. KEEP(*(SORT(.mutex_array.*)))
  85. KEEP(*(.mutex_array))
  86. PROVIDE_HIDDEN (__mutex_array_end = .);
  87. . = ALIGN(4);
  88. PROVIDE_HIDDEN (__preinit_array_start = .);
  89. KEEP(*(SORT(.preinit_array.*)))
  90. KEEP(*(.preinit_array))
  91. PROVIDE_HIDDEN (__preinit_array_end = .);
  92. . = ALIGN(4);
  93. PROVIDE_HIDDEN (__init_array_start = .);
  94. KEEP(*(SORT(.init_array.*)))
  95. KEEP(*(.init_array))
  96. PROVIDE_HIDDEN (__init_array_end = .);
  97. . = ALIGN(4);
  98. PROVIDE_HIDDEN (__fini_array_start = .);
  99. *(SORT(.fini_array.*))
  100. *(.fini_array)
  101. PROVIDE_HIDDEN (__fini_array_end = .);
  102. *(.jcr)
  103. . = ALIGN(4);
  104. __data_end__ = .;
  105. } > RAM AT> FLASH
  106. .uninitialized_data (COPY): {
  107. . = ALIGN(4);
  108. *(.uninitialized_data*)
  109. } > RAM
  110. .scratch_x : {
  111. __scratch_x_start__ = .;
  112. *(.scratch_x.*)
  113. . = ALIGN(4);
  114. __scratch_x_end__ = .;
  115. } > SCRATCH_X AT > FLASH
  116. __scratch_x_source__ = LOADADDR(.scratch_x);
  117. .scratch_y : {
  118. __scratch_y_start__ = .;
  119. *(.scratch_y.*)
  120. . = ALIGN(4);
  121. __scratch_y_end__ = .;
  122. } > SCRATCH_Y AT > FLASH
  123. __scratch_y_source__ = LOADADDR(.scratch_y);
  124. .bss : {
  125. . = ALIGN(4);
  126. __bss_start__ = .;
  127. *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
  128. *(COMMON)
  129. . = ALIGN(4);
  130. __bss_end__ = .;
  131. } > RAM
  132. .heap (COPY):
  133. {
  134. __end__ = .;
  135. PROVIDE(end = .);
  136. *(.heap*)
  137. . = ORIGIN(RAM) + LENGTH(RAM) - 0x400;
  138. __HeapLimit = .;
  139. } > RAM
  140. .stack1_dummy (COPY):
  141. {
  142. *(.stack1*)
  143. } > SCRATCH_X
  144. .stack_dummy (COPY):
  145. {
  146. *(.stack*)
  147. } > RAM
  148. .flash_end : {
  149. __flash_binary_end = .;
  150. } > FLASH
  151. __StackTop = ORIGIN(RAM) + LENGTH(RAM);
  152. __StackLimit = __StackTop - 0x400;
  153. __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X);
  154. __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy);
  155. __StackBottom = __StackTop - SIZEOF(.stack_dummy);
  156. PROVIDE(__stack = __StackTop);
  157. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed")
  158. ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary")
  159. }