Без опису
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * Based on Pico SDK memmap_default.ld
  3. * https://community.element14.com/products/raspberry-pi/b/blog/posts/raspberry-pico-c-sdk-reserve-a-flash-memory-block-for-persistent-storage
  4. */
  5. /*
  6. * TODO hard-coded
  7. */
  8. __PERSISTENT_STORAGE_LEN = 4k;
  9. MEMORY
  10. {
  11. FLASH(rx) : ORIGIN = 0x10000000, LENGTH = 2048k - __PERSISTENT_STORAGE_LEN
  12. FLASH_PERSISTENT(r) : ORIGIN = 0x10000000 + (2048k - __PERSISTENT_STORAGE_LEN) , LENGTH = __PERSISTENT_STORAGE_LEN
  13. RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 256k
  14. SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
  15. SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
  16. }
  17. ENTRY(_entry_point)
  18. SECTIONS
  19. {
  20. /* Second stage bootloader is prepended to the image. It must be 256 bytes big
  21. and checksummed. It is usually built by the boot_stage2 target
  22. in the Raspberry Pi Pico SDK
  23. */
  24. .flash_begin : {
  25. __flash_binary_start = .;
  26. } > FLASH
  27. .boot2 : {
  28. __boot2_start__ = .;
  29. KEEP (*(.boot2))
  30. __boot2_end__ = .;
  31. } > FLASH
  32. ASSERT(__boot2_end__ - __boot2_start__ == 256,
  33. "ERROR: Pico second stage bootloader must be 256 bytes in size")
  34. /* The second stage will always enter the image at the start of .text.
  35. The debugger will use the ELF entry point, which is the _entry_point
  36. symbol if present, otherwise defaults to start of .text.
  37. This can be used to transfer control back to the bootrom on debugger
  38. launches only, to perform proper flash setup.
  39. */
  40. .text : {
  41. __logical_binary_start = .;
  42. KEEP (*(.vectors))
  43. KEEP (*(.binary_info_header))
  44. __binary_info_header_end = .;
  45. KEEP (*(.reset))
  46. /* TODO revisit this now memset/memcpy/float in ROM */
  47. /* bit of a hack right now to exclude all floating point and time critical (e.g. memset, memcpy) code from
  48. * FLASH ... we will include any thing excluded here in .data below by default */
  49. *(.init)
  50. *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .text*)
  51. *(.fini)
  52. /* Pull all c'tors into .text */
  53. *crtbegin.o(.ctors)
  54. *crtbegin?.o(.ctors)
  55. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  56. *(SORT(.ctors.*))
  57. *(.ctors)
  58. /* Followed by destructors */
  59. *crtbegin.o(.dtors)
  60. *crtbegin?.o(.dtors)
  61. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  62. *(SORT(.dtors.*))
  63. *(.dtors)
  64. *(.eh_frame*)
  65. . = ALIGN(4);
  66. } > FLASH
  67. .rodata : {
  68. *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .rodata*)
  69. . = ALIGN(4);
  70. *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*)))
  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. /* Machine inspectable binary information */
  84. . = ALIGN(4);
  85. __binary_info_start = .;
  86. .binary_info :
  87. {
  88. KEEP(*(.binary_info.keep.*))
  89. *(.binary_info.*)
  90. } > FLASH
  91. __binary_info_end = .;
  92. . = ALIGN(4);
  93. .ram_vector_table (NOLOAD): {
  94. *(.ram_vector_table)
  95. } > RAM
  96. .data : {
  97. __data_start__ = .;
  98. *(vtable)
  99. *(.time_critical*)
  100. /* remaining .text and .rodata; i.e. stuff we exclude above because we want it in RAM */
  101. *(.text*)
  102. . = ALIGN(4);
  103. *(.rodata*)
  104. . = ALIGN(4);
  105. *(.data*)
  106. . = ALIGN(4);
  107. *(.after_data.*)
  108. . = ALIGN(4);
  109. /* preinit data */
  110. PROVIDE_HIDDEN (__mutex_array_start = .);
  111. KEEP(*(SORT(.mutex_array.*)))
  112. KEEP(*(.mutex_array))
  113. PROVIDE_HIDDEN (__mutex_array_end = .);
  114. . = ALIGN(4);
  115. /* preinit data */
  116. PROVIDE_HIDDEN (__preinit_array_start = .);
  117. KEEP(*(SORT(.preinit_array.*)))
  118. KEEP(*(.preinit_array))
  119. PROVIDE_HIDDEN (__preinit_array_end = .);
  120. . = ALIGN(4);
  121. /* init data */
  122. PROVIDE_HIDDEN (__init_array_start = .);
  123. KEEP(*(SORT(.init_array.*)))
  124. KEEP(*(.init_array))
  125. PROVIDE_HIDDEN (__init_array_end = .);
  126. . = ALIGN(4);
  127. /* finit data */
  128. PROVIDE_HIDDEN (__fini_array_start = .);
  129. *(SORT(.fini_array.*))
  130. *(.fini_array)
  131. PROVIDE_HIDDEN (__fini_array_end = .);
  132. *(.jcr)
  133. . = ALIGN(4);
  134. /* All data end */
  135. __data_end__ = .;
  136. } > RAM AT> FLASH
  137. /* __etext is (for backwards compatibility) the name of the .data init source pointer (...) */
  138. __etext = LOADADDR(.data);
  139. .uninitialized_data (NOLOAD): {
  140. . = ALIGN(4);
  141. *(.uninitialized_data*)
  142. } > RAM
  143. /* Start and end symbols must be word-aligned */
  144. .scratch_x : {
  145. __scratch_x_start__ = .;
  146. *(.scratch_x.*)
  147. . = ALIGN(4);
  148. __scratch_x_end__ = .;
  149. } > SCRATCH_X AT > FLASH
  150. __scratch_x_source__ = LOADADDR(.scratch_x);
  151. .scratch_y : {
  152. __scratch_y_start__ = .;
  153. *(.scratch_y.*)
  154. . = ALIGN(4);
  155. __scratch_y_end__ = .;
  156. } > SCRATCH_Y AT > FLASH
  157. __scratch_y_source__ = LOADADDR(.scratch_y);
  158. .bss : {
  159. . = ALIGN(4);
  160. __bss_start__ = .;
  161. *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
  162. *(COMMON)
  163. . = ALIGN(4);
  164. __bss_end__ = .;
  165. } > RAM
  166. .heap (NOLOAD):
  167. {
  168. __end__ = .;
  169. end = __end__;
  170. KEEP(*(.heap*))
  171. __HeapLimit = .;
  172. } > RAM
  173. /* .stack*_dummy section doesn't contains any symbols. It is only
  174. * used for linker to calculate size of stack sections, and assign
  175. * values to stack symbols later
  176. *
  177. * stack1 section may be empty/missing if platform_launch_core1 is not used */
  178. /* by default we put core 0 stack at the end of scratch Y, so that if core 1
  179. * stack is not used then all of SCRATCH_X is free.
  180. */
  181. .stack1_dummy (NOLOAD):
  182. {
  183. *(.stack1*)
  184. } > SCRATCH_X
  185. .stack_dummy (NOLOAD):
  186. {
  187. KEEP(*(.stack*))
  188. } > SCRATCH_Y
  189. .flash_end : {
  190. PROVIDE(__flash_binary_end = .);
  191. } > FLASH
  192. /* stack limit is poorly named, but historically is maximum heap ptr */
  193. __StackLimit = ORIGIN(RAM) + LENGTH(RAM);
  194. __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X);
  195. __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y);
  196. __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy);
  197. __StackBottom = __StackTop - SIZEOF(.stack_dummy);
  198. PROVIDE(__stack = __StackTop);
  199. /* Check if data + heap + stack exceeds RAM limit */
  200. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed")
  201. ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary")
  202. /* todo assert on extra code */
  203. }