flash_rtt.ld 8.4 KB

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