Julien-Bernard

First attempt store at 1MB Link at 192KB into RAM

Mar 23rd, 2022
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.06 KB | None | 0 0
  1. /* Based on GCC ARM embedded samples.
  2. Defines the following symbols for use by code:
  3. __exidx_start
  4. __exidx_end
  5. __etext
  6. __data_start__
  7. __preinit_array_start
  8. __preinit_array_end
  9. __init_array_start
  10. __init_array_end
  11. __fini_array_start
  12. __fini_array_end
  13. __data_end__
  14. __bss_start__
  15. __bss_end__
  16. __end__
  17. end
  18. __HeapLimit
  19. __StackLimit
  20. __StackTop
  21. __stack (== StackTop)
  22. */
  23.  
  24. MEMORY
  25. {
  26. FLASH(rx) : ORIGIN = 0x10100000, LENGTH = 64k
  27. RAM(rwx) : ORIGIN = 0x20000000, LENGTH = 192k
  28. TARGET(rx) : ORIGIN = 0x20030000, LENGTH = 64k
  29. SCRATCH_X(rwx) : ORIGIN = 0x20040000, LENGTH = 4k
  30. SCRATCH_Y(rwx) : ORIGIN = 0x20041000, LENGTH = 4k
  31. }
  32.  
  33. ENTRY(_entry_point)
  34.  
  35. SECTIONS
  36. {
  37. /* Second stage bootloader is prepended to the image. It must be 256 bytes big
  38. and checksummed. It is usually built by the boot_stage2 target
  39. in the Raspberry Pi Pico SDK
  40. */
  41.  
  42. .flash_begin : {
  43. __flash_binary_start = .;
  44. } > TARGET AT > FLASH
  45.  
  46. .boot2 : {
  47. __boot2_start__ = .;
  48. KEEP (*(.boot2))
  49. __boot2_end__ = .;
  50. } > TARGET AT > FLASH
  51.  
  52. ASSERT(__boot2_end__ - __boot2_start__ == 256,
  53. "ERROR: Pico second stage bootloader must be 256 bytes in size")
  54.  
  55.  
  56. /* The second stage will always enter the image at the start of .text.
  57. The debugger will use the ELF entry point, which is the _entry_point
  58. symbol if present, otherwise defaults to start of .text.
  59. This can be used to transfer control back to the bootrom on debugger
  60. launches only, to perform proper flash setup.
  61. */
  62.  
  63. .text : {
  64. __logical_binary_start = .;
  65. KEEP (*(.vectors))
  66. KEEP (*(.binary_info_header))
  67. __binary_info_header_end = .;
  68. KEEP (*(.reset))
  69. /* TODO revisit this now memset/memcpy/float in ROM */
  70. /* bit of a hack right now to exclude all floating point and time critical (e.g. memset, memcpy) code from
  71. * FLASH ... we will include any thing excluded here in .data below by default */
  72. *(.init)
  73. *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .text*)
  74. *(.fini)
  75. /* Pull all c'tors into .text */
  76. *crtbegin.o(.ctors)
  77. *crtbegin?.o(.ctors)
  78. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  79. *(SORT(.ctors.*))
  80. *(.ctors)
  81. /* Followed by destructors */
  82. *crtbegin.o(.dtors)
  83. *crtbegin?.o(.dtors)
  84. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  85. *(SORT(.dtors.*))
  86. *(.dtors)
  87.  
  88. *(.eh_frame*)
  89. . = ALIGN(4);
  90. } > TARGET AT > FLASH
  91.  
  92. .rodata : {
  93. *(EXCLUDE_FILE(*libgcc.a: *libc.a:*lib_a-mem*.o *libm.a:) .rodata*)
  94. . = ALIGN(4);
  95. *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.flashdata*)))
  96. . = ALIGN(4);
  97. } > TARGET AT > FLASH
  98.  
  99. .ARM.extab :
  100. {
  101. *(.ARM.extab* .gnu.linkonce.armextab.*)
  102. } > TARGET AT > FLASH
  103.  
  104. __exidx_start = .;
  105. .ARM.exidx :
  106. {
  107. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  108. } > TARGET AT > FLASH
  109. __exidx_end = .;
  110.  
  111. /* Machine inspectable binary information */
  112. . = ALIGN(4);
  113. __binary_info_start = .;
  114. .binary_info :
  115. {
  116. KEEP(*(.binary_info.keep.*))
  117. *(.binary_info.*)
  118. } > TARGET AT > FLASH
  119. __binary_info_end = .;
  120. . = ALIGN(4);
  121.  
  122. /* End of .text-like segments */
  123. __etext = .;
  124.  
  125. .ram_vector_table (COPY): {
  126. *(.ram_vector_table)
  127. } > RAM
  128.  
  129. .data : {
  130. __data_start__ = .;
  131. *(vtable)
  132.  
  133. *(.time_critical*)
  134.  
  135. /* remaining .text and .rodata; i.e. stuff we exclude above because we want it in RAM */
  136. *(.text*)
  137. . = ALIGN(4);
  138. *(.rodata*)
  139. . = ALIGN(4);
  140.  
  141. *(.data*)
  142.  
  143. . = ALIGN(4);
  144. *(.after_data.*)
  145. . = ALIGN(4);
  146. /* preinit data */
  147. PROVIDE_HIDDEN (__mutex_array_start = .);
  148. KEEP(*(SORT(.mutex_array.*)))
  149. KEEP(*(.mutex_array))
  150. PROVIDE_HIDDEN (__mutex_array_end = .);
  151.  
  152. . = ALIGN(4);
  153. /* preinit data */
  154. PROVIDE_HIDDEN (__preinit_array_start = .);
  155. KEEP(*(SORT(.preinit_array.*)))
  156. KEEP(*(.preinit_array))
  157. PROVIDE_HIDDEN (__preinit_array_end = .);
  158.  
  159. . = ALIGN(4);
  160. /* init data */
  161. PROVIDE_HIDDEN (__init_array_start = .);
  162. KEEP(*(SORT(.init_array.*)))
  163. KEEP(*(.init_array))
  164. PROVIDE_HIDDEN (__init_array_end = .);
  165.  
  166. . = ALIGN(4);
  167. /* finit data */
  168. PROVIDE_HIDDEN (__fini_array_start = .);
  169. *(SORT(.fini_array.*))
  170. *(.fini_array)
  171. PROVIDE_HIDDEN (__fini_array_end = .);
  172.  
  173. *(.jcr)
  174. . = ALIGN(4);
  175. /* All data end */
  176. __data_end__ = .;
  177. } > RAM AT> FLASH
  178.  
  179. .uninitialized_data (COPY): {
  180. . = ALIGN(4);
  181. *(.uninitialized_data*)
  182. } > RAM
  183.  
  184. /* Start and end symbols must be word-aligned */
  185. .scratch_x : {
  186. __scratch_x_start__ = .;
  187. *(.scratch_x.*)
  188. . = ALIGN(4);
  189. __scratch_x_end__ = .;
  190. } > SCRATCH_X AT > FLASH
  191. __scratch_x_source__ = LOADADDR(.scratch_x);
  192.  
  193. .scratch_y : {
  194. __scratch_y_start__ = .;
  195. *(.scratch_y.*)
  196. . = ALIGN(4);
  197. __scratch_y_end__ = .;
  198. } > SCRATCH_Y AT > FLASH
  199. __scratch_y_source__ = LOADADDR(.scratch_y);
  200.  
  201. .bss : {
  202. . = ALIGN(4);
  203. __bss_start__ = .;
  204. *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*)))
  205. *(COMMON)
  206. . = ALIGN(4);
  207. __bss_end__ = .;
  208. } > RAM
  209.  
  210. .heap (COPY):
  211. {
  212. __end__ = .;
  213. end = __end__;
  214. *(.heap*)
  215. __HeapLimit = .;
  216. } > RAM
  217.  
  218. /* .stack*_dummy section doesn't contains any symbols. It is only
  219. * used for linker to calculate size of stack sections, and assign
  220. * values to stack symbols later
  221. *
  222. * stack1 section may be empty/missing if platform_launch_core1 is not used */
  223.  
  224. /* by default we put core 0 stack at the end of scratch Y, so that if core 1
  225. * stack is not used then all of SCRATCH_X is free.
  226. */
  227. .stack1_dummy (COPY):
  228. {
  229. *(.stack1*)
  230. } > SCRATCH_X
  231. .stack_dummy (COPY):
  232. {
  233. *(.stack*)
  234. } > SCRATCH_Y
  235.  
  236. .flash_end : {
  237. __flash_binary_end = .;
  238. } > TARGET AT > FLASH
  239.  
  240. /* stack limit is poorly named, but historically is maximum heap ptr */
  241. __StackLimit = ORIGIN(RAM) + LENGTH(RAM);
  242. __StackOneTop = ORIGIN(SCRATCH_X) + LENGTH(SCRATCH_X);
  243. __StackTop = ORIGIN(SCRATCH_Y) + LENGTH(SCRATCH_Y);
  244. __StackOneBottom = __StackOneTop - SIZEOF(.stack1_dummy);
  245. __StackBottom = __StackTop - SIZEOF(.stack_dummy);
  246. PROVIDE(__stack = __StackTop);
  247.  
  248. /* Check if data + heap + stack exceeds RAM limit */
  249. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed")
  250.  
  251. ASSERT( __binary_info_header_end - __logical_binary_start <= 256, "Binary info must be in first 256 bytes of the binary")
  252. /* todo assert on extra code */
  253. }
  254.  
  255.  
Advertisement
Add Comment
Please, Sign In to add comment