flash_rtt.ld 7.5 KB

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