flash_rtt.ld 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /*
  2. * Copyright 2021-2023 HPMicro
  3. * SPDX-License-Identifier: BSD-3-Clause
  4. */
  5. ENTRY(_start)
  6. STACK_SIZE = DEFINED(_stack_size) ? _stack_size : 0x4000;
  7. HEAP_SIZE = DEFINED(_heap_size) ? _heap_size : 144K;
  8. FLASH_SIZE = DEFINED(_flash_size) ? _flash_size : 16M;
  9. NONCACHEABLE_SIZE = DEFINED(_noncacheable_size) ? _noncacheable_size : 0x4000;
  10. MEMORY
  11. {
  12. XPI0 (rx) : ORIGIN = 0x80000000, LENGTH = FLASH_SIZE
  13. ILM (wx) : ORIGIN = 0, LENGTH = 128K
  14. DLM (w) : ORIGIN = 0x80000, LENGTH = 128K
  15. NONCACHEABLE_RAM (wx) : ORIGIN = 0x01080000, LENGTH = 64K
  16. AXI_SRAM (wx) : ORIGIN = 0x01090000, LENGTH = 176K
  17. SHARE_RAM (w) : ORIGIN = 0x010BC000, LENGTH = 16K
  18. AHB_SRAM (w) : ORIGIN = 0xF0300000, LENGTH = 32k
  19. }
  20. __nor_cfg_option_load_addr__ = ORIGIN(XPI0) + 0x400;
  21. __boot_header_load_addr__ = ORIGIN(XPI0) + 0x1000;
  22. __app_load_addr__ = ORIGIN(XPI0) + 0x3000;
  23. __boot_header_length__ = __boot_header_end__ - __boot_header_start__;
  24. __app_offset__ = __app_load_addr__ - __boot_header_load_addr__;
  25. SECTIONS
  26. {
  27. .nor_cfg_option __nor_cfg_option_load_addr__ : {
  28. KEEP(*(.nor_cfg_option))
  29. } > XPI0
  30. .boot_header __boot_header_load_addr__ : {
  31. __boot_header_start__ = .;
  32. KEEP(*(.boot_header))
  33. KEEP(*(.fw_info_table))
  34. KEEP(*(.dc_info))
  35. __boot_header_end__ = .;
  36. } > XPI0
  37. .start __app_load_addr__ : {
  38. . = ALIGN(8);
  39. KEEP(*(.start))
  40. } > XPI0
  41. __vector_load_addr__ = ADDR(.start) + SIZEOF(.start);
  42. .vectors : AT(__vector_load_addr__) {
  43. . = ALIGN(8);
  44. __vector_ram_start__ = .;
  45. KEEP(*(.vector_table))
  46. KEEP(*(.isr_vector))
  47. . = ALIGN(8);
  48. __vector_ram_end__ = .;
  49. } > ILM
  50. .fast : AT(etext + __data_end__ - __tdata_start__) {
  51. . = ALIGN(8);
  52. __ramfunc_start__ = .;
  53. *(.fast)
  54. /* RT-Thread Core Start */
  55. KEEP(*context_gcc.o(.text* .rodata*))
  56. KEEP(*port*.o (.text .text* .rodata .rodata*))
  57. KEEP(*interrupt_gcc.o (.text .text* .rodata .rodata*))
  58. KEEP(*trap_common.o (.text .text* .rodata .rodata*))
  59. KEEP(*irq.o (.text .text* .rodata .rodata*))
  60. KEEP(*clock.o (.text .text* .rodata .rodata*))
  61. KEEP(*kservice.o (.text .text* .rodata .rodata*))
  62. KEEP(*scheduler.o (.text .text* .rodata .rodata*))
  63. KEEP(*trap*.o (.text .text* .rodata .rodata*))
  64. KEEP(*idle.o (.text .text* .rodata .rodata*))
  65. KEEP(*ipc.o (.text .text* .rodata .rodata*))
  66. KEEP(*thread.o (.text .text* .rodata .rodata*))
  67. KEEP(*object.o (.text .text* .rodata .rodata*))
  68. KEEP(*timer.o (.text .text* .rodata .rodata*))
  69. KEEP(*mem.o (.text .text* .rodata .rodata*))
  70. KEEP(*mempool.o (.text .text* .rodata .rodata*))
  71. /* RT-Thread Core End */
  72. . = ALIGN(8);
  73. __ramfunc_end__ = .;
  74. } > ILM
  75. .text (__vector_load_addr__ + __vector_ram_end__ - __vector_ram_start__) : {
  76. . = ALIGN(8);
  77. *(.text)
  78. *(.text*)
  79. *(.rodata)
  80. *(.rodata*)
  81. *(.srodata)
  82. *(.srodata*)
  83. *(.hash)
  84. *(.dyn*)
  85. *(.gnu*)
  86. *(.pl*)
  87. KEEP(*(.eh_frame))
  88. *(.eh_frame*)
  89. KEEP (*(.init))
  90. KEEP (*(.fini))
  91. . = ALIGN(8);
  92. /*********************************************
  93. *
  94. * RT-Thread related sections - Start
  95. *
  96. *********************************************/
  97. /* section information for finsh shell */
  98. . = ALIGN(4);
  99. __fsymtab_start = .;
  100. KEEP(*(FSymTab))
  101. __fsymtab_end = .;
  102. . = ALIGN(4);
  103. __vsymtab_start = .;
  104. KEEP(*(VSymTab))
  105. __vsymtab_end = .;
  106. . = ALIGN(4);
  107. . = ALIGN(4);
  108. __rt_init_start = .;
  109. KEEP(*(SORT(.rti_fn*)))
  110. __rt_init_end = .;
  111. . = ALIGN(4);
  112. /* section information for modules */
  113. . = ALIGN(4);
  114. __rtmsymtab_start = .;
  115. KEEP(*(RTMSymTab))
  116. __rtmsymtab_end = .;
  117. /* RT-Thread related sections - end */
  118. /* section information for usbh class */
  119. . = ALIGN(8);
  120. __usbh_class_info_start__ = .;
  121. KEEP(*(.usbh_class_info))
  122. __usbh_class_info_end__ = .;
  123. } > XPI0
  124. .rel : {
  125. KEEP(*(.rel*))
  126. } > XPI0
  127. PROVIDE (__etext = .);
  128. PROVIDE (_etext = .);
  129. PROVIDE (etext = .);
  130. .fast_ram (NOLOAD) : {
  131. KEEP(*(.fast_ram))
  132. } > DLM
  133. .bss(NOLOAD) : {
  134. . = ALIGN(8);
  135. __bss_start__ = .;
  136. *(.bss)
  137. *(.bss*)
  138. *(.sbss*)
  139. *(.scommon)
  140. *(.scommon*)
  141. *(.dynsbss*)
  142. *(COMMON)
  143. . = ALIGN(8);
  144. _end = .;
  145. __bss_end__ = .;
  146. } > DLM
  147. /* Note: the .tbss and .tdata section should be adjacent */
  148. .tbss(NOLOAD) : {
  149. . = ALIGN(8);
  150. __tbss_start__ = .;
  151. *(.tbss*)
  152. *(.tcommon*)
  153. _end = .;
  154. __tbss_end__ = .;
  155. } > DLM
  156. .tdata : AT(etext) {
  157. . = ALIGN(8);
  158. __tdata_start__ = .;
  159. __thread_pointer = .;
  160. *(.tdata)
  161. *(.tdata*)
  162. . = ALIGN(8);
  163. __tdata_end__ = .;
  164. } > DLM
  165. .data : AT(etext + __tdata_end__ - __tdata_start__) {
  166. . = ALIGN(8);
  167. __data_start__ = .;
  168. __global_pointer$ = . + 0x800;
  169. *(.data)
  170. *(.data*)
  171. *(.sdata)
  172. *(.sdata*)
  173. KEEP(*(.jcr))
  174. KEEP(*(.dynamic))
  175. KEEP(*(.got*))
  176. KEEP(*(.got))
  177. KEEP(*(.gcc_except_table))
  178. KEEP(*(.gcc_except_table.*))
  179. . = ALIGN(8);
  180. PROVIDE(__preinit_array_start = .);
  181. KEEP(*(.preinit_array))
  182. PROVIDE(__preinit_array_end = .);
  183. . = ALIGN(8);
  184. PROVIDE(__init_array_start = .);
  185. KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*)))
  186. KEEP(*(.init_array))
  187. PROVIDE(__init_array_end = .);
  188. . = ALIGN(8);
  189. PROVIDE(__finit_array_start = .);
  190. KEEP(*(SORT_BY_INIT_PRIORITY(.finit_array.*)))
  191. KEEP(*(.finit_array))
  192. PROVIDE(__finit_array_end = .);
  193. . = ALIGN(8);
  194. PROVIDE(__ctors_start__ = .);
  195. KEEP(*crtbegin*.o(.ctors))
  196. KEEP(*(EXCLUDE_FILE (*crtend*.o) .ctors))
  197. KEEP(*(SORT(.ctors.*)))
  198. KEEP(*(.ctors))
  199. PROVIDE(__ctors_end__ = .);
  200. . = ALIGN(8);
  201. KEEP(*crtbegin*.o(.dtors))
  202. KEEP(*(EXCLUDE_FILE (*crtend*.o) .dtors))
  203. KEEP(*(SORT(.dtors.*)))
  204. KEEP(*(.dtors))
  205. . = ALIGN(8);
  206. __data_end__ = .;
  207. PROVIDE (__edata = .);
  208. PROVIDE (_edata = .);
  209. PROVIDE (edata = .);
  210. } > DLM
  211. __fw_size__ = __data_end__ - __tdata_start__ + etext - __app_load_addr__;
  212. .heap(NOLOAD) : {
  213. . = ALIGN(8);
  214. __heap_start__ = .;
  215. . += HEAP_SIZE;
  216. __heap_end__ = .;
  217. } > AXI_SRAM
  218. .stack(NOLOAD) : {
  219. . = ALIGN(8);
  220. __stack_base__ = .;
  221. . += STACK_SIZE;
  222. . = ALIGN(8);
  223. PROVIDE (_stack = .);
  224. PROVIDE (_stack_in_dlm = .);
  225. PROVIDE( __rt_rvstack = . );
  226. } > DLM
  227. .noncacheable.init : AT(etext + __data_end__ - __tdata_start__ + __ramfunc_end__ - __ramfunc_start__) {
  228. . = ALIGN(8);
  229. __noncacheable_init_start__ = .;
  230. KEEP(*(.noncacheable.init))
  231. __noncacheable_init_end__ = .;
  232. . = ALIGN(8);
  233. } > NONCACHEABLE_RAM
  234. .noncacheable.bss (NOLOAD) : {
  235. . = ALIGN(8);
  236. KEEP(*(.noncacheable))
  237. __noncacheable_bss_start__ = .;
  238. KEEP(*(.noncacheable.bss))
  239. __noncacheable_bss_end__ = .;
  240. . = ALIGN(8);
  241. } > NONCACHEABLE_RAM
  242. .ahb_sram (NOLOAD) : {
  243. KEEP(*(.ahb_sram))
  244. } > AHB_SRAM
  245. __noncacheable_start__ = ORIGIN(NONCACHEABLE_RAM);
  246. __noncacheable_end__ = ORIGIN(NONCACHEABLE_RAM) + LENGTH(NONCACHEABLE_RAM);
  247. __share_mem_start__ = ORIGIN(SHARE_RAM);
  248. __share_mem_end__ = ORIGIN(SHARE_RAM) + LENGTH(SHARE_RAM);
  249. }