link.ld 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /******************************************************************************
  2. * Copyright (C) 2022-2025, Xiaohua Semiconductor Co., Ltd. All rights reserved.
  3. *
  4. * This software component is licensed by XHSC under BSD 3-Clause license
  5. * (the "License"); You may not use this file except in compliance with the
  6. * License. You may obtain a copy of the License at:
  7. * opensource.org/licenses/BSD-3-Clause
  8. *
  9. */
  10. /*****************************************************************************/
  11. /* File HC32F4A8xI.ld */
  12. /* Abstract Linker script for HC32F4A8 Device with */
  13. /* 2MByte FLASH, 516KByte RAM */
  14. /* Version V1.0 */
  15. /* Date 2024-09-13 */
  16. /*****************************************************************************/
  17. /* OTP section(data sections are not flash multiplexed region) implementation.
  18. You need to pay attention to the size of the specified OTP block.
  19. Take two OTP blocks for example. */
  20. __OTP_DATA_BASE = 0x03000000;
  21. __OTP_LOCK_BASE = 0x03001800;
  22. /* OTP block 16 */
  23. __OTP_DATA_B16_START = 0x03000000;
  24. __OTP_LOCK_B16_START = 0x03001900;
  25. __OTP_DATA_B16_OFFSET = __OTP_DATA_B16_START - __OTP_DATA_BASE;
  26. __OTP_LOCK_B16_OFFSET = __OTP_LOCK_B16_START - __OTP_LOCK_BASE;
  27. /* OTP block 17 */
  28. __OTP_DATA_B17_START = 0x03000010;
  29. __OTP_LOCK_B17_START = 0x03001910;
  30. __OTP_DATA_B17_OFFSET = __OTP_DATA_B17_START - __OTP_DATA_BASE;
  31. __OTP_LOCK_B17_OFFSET = __OTP_LOCK_B17_START - __OTP_LOCK_BASE;
  32. /* Use contiguous memory regions for simple. */
  33. MEMORY
  34. {
  35. FLASH (rx): ORIGIN = 0x00000000, LENGTH = 2M
  36. OTP_DATA (rx): ORIGIN = 0x03000000, LENGTH = 6K
  37. OTP_LOCK (rx): ORIGIN = 0x03001800, LENGTH = 1904
  38. RAM (rwx): ORIGIN = 0x1FFE0000, LENGTH = 512K
  39. RAMB (rwx): ORIGIN = 0x200F0000, LENGTH = 4K
  40. }
  41. ENTRY(Reset_Handler)
  42. SECTIONS
  43. {
  44. .vectors :
  45. {
  46. . = ALIGN(4);
  47. KEEP(*(.vectors))
  48. . = ALIGN(4);
  49. } >FLASH
  50. .icg_sec 0x00000400 :
  51. {
  52. KEEP(*(.icg_sec))
  53. } >FLASH
  54. .text :
  55. {
  56. . = ALIGN(4);
  57. _stext = .;
  58. KEEP(*(.isr_vector)) /* Startup code */
  59. . = ALIGN(4);
  60. *(.text) /* remaining code */
  61. *(.text.*) /* remaining code */
  62. *(.rodata) /* read-only data (constants) */
  63. *(.rodata*)
  64. *(.glue_7)
  65. *(.glue_7t)
  66. *(.gnu.linkonce.t*)
  67. /* section information for finsh shell */
  68. . = ALIGN(4);
  69. __fsymtab_start = .;
  70. KEEP(*(FSymTab))
  71. __fsymtab_end = .;
  72. . = ALIGN(4);
  73. __vsymtab_start = .;
  74. KEEP(*(VSymTab))
  75. __vsymtab_end = .;
  76. . = ALIGN(4);
  77. /* section information for initial. */
  78. . = ALIGN(4);
  79. __rt_init_start = .;
  80. KEEP(*(SORT(.rti_fn*)))
  81. __rt_init_end = .;
  82. . = ALIGN(4);
  83. /* section for CherryUSB. */
  84. . = ALIGN(4);
  85. __usbh_class_info_start__ = .;
  86. KEEP(*(.usbh_class_info))
  87. __usbh_class_info_end__ = .;
  88. . = ALIGN(4);
  89. _etext = .;
  90. } >FLASH
  91. .rodata :
  92. {
  93. . = ALIGN(4);
  94. *(.rodata)
  95. *(.rodata*)
  96. . = ALIGN(4);
  97. } >FLASH
  98. .ARM.extab :
  99. {
  100. *(.ARM.extab* .gnu.linkonce.armextab.*)
  101. } >FLASH
  102. __exidx_start = .;
  103. .ARM.exidx :
  104. {
  105. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  106. } >FLASH
  107. __exidx_end = .;
  108. .preinit_array :
  109. {
  110. . = ALIGN(4);
  111. /* preinit data */
  112. PROVIDE_HIDDEN (__preinit_array_start = .);
  113. KEEP(*(.preinit_array))
  114. PROVIDE_HIDDEN (__preinit_array_end = .);
  115. . = ALIGN(4);
  116. } >FLASH
  117. .init_array :
  118. {
  119. . = ALIGN(4);
  120. /* init data */
  121. PROVIDE_HIDDEN (__init_array_start = .);
  122. KEEP(*(SORT(.init_array.*)))
  123. KEEP(*(.init_array))
  124. PROVIDE_HIDDEN (__init_array_end = .);
  125. . = ALIGN(4);
  126. } >FLASH
  127. .fini_array :
  128. {
  129. . = ALIGN(4);
  130. /* finit data */
  131. PROVIDE_HIDDEN (__fini_array_start = .);
  132. KEEP(*(SORT(.fini_array.*)))
  133. KEEP(*(.fini_array))
  134. PROVIDE_HIDDEN (__fini_array_end = .);
  135. . = ALIGN(4);
  136. } >FLASH
  137. __etext = ALIGN(4);
  138. .otp_data :
  139. {
  140. . = ALIGN(4);
  141. . = ORIGIN(OTP_DATA) + __OTP_DATA_B16_OFFSET;
  142. KEEP(*(.otp_b16_data*))
  143. . = ORIGIN(OTP_DATA) + __OTP_DATA_B17_OFFSET;
  144. KEEP(*(.otp_b17_data*))
  145. . = ALIGN(4);
  146. } >OTP_DATA
  147. .otp_lock :
  148. {
  149. . = ALIGN(4);
  150. . = ORIGIN(OTP_LOCK) + __OTP_LOCK_B16_OFFSET;
  151. KEEP(*(.otp_b16_lock*))
  152. . = ORIGIN(OTP_LOCK) + __OTP_LOCK_B17_OFFSET;
  153. KEEP(*(.otp_b17_lock*))
  154. . = ALIGN(4);
  155. } >OTP_LOCK
  156. .data : AT (__etext)
  157. {
  158. . = ALIGN(4);
  159. __data_start__ = .;
  160. *(vtable)
  161. *(.data)
  162. *(.data*)
  163. *(.gnu.linkonce.d*)
  164. . = ALIGN(4);
  165. *(.ramfunc)
  166. *(.ramfunc*)
  167. . = ALIGN(4);
  168. __data_end__ = .;
  169. } >RAM
  170. .heap_stack (COPY) :
  171. {
  172. . = ALIGN(8);
  173. __end__ = .;
  174. PROVIDE(end = .);
  175. PROVIDE(_end = .);
  176. *(.heap*)
  177. . = ALIGN(8);
  178. __HeapLimit = .;
  179. __StackLimit = .;
  180. *(.stack*)
  181. . = ALIGN(8);
  182. __StackTop = .;
  183. } >RAM
  184. __etext_ramb = __etext + ALIGN (SIZEOF(.data), 4);
  185. .ramb_data : AT (__etext_ramb)
  186. {
  187. . = ALIGN(4);
  188. __data_start_ramb__ = .;
  189. *(.ramb_data)
  190. *(.ramb_data*)
  191. . = ALIGN(4);
  192. __data_end_ramb__ = .;
  193. } >RAMB
  194. __bss_start = .;
  195. .bss __StackTop (NOLOAD):
  196. {
  197. . = ALIGN(4);
  198. _sbss = .;
  199. __bss_start__ = _sbss;
  200. *(.bss)
  201. *(.bss*)
  202. *(COMMON)
  203. . = ALIGN(4);
  204. _ebss = .;
  205. __bss_end__ = _ebss;
  206. . = ALIGN(4);
  207. *(.noinit*)
  208. . = ALIGN(4);
  209. } >RAM
  210. __bss_end = .;
  211. .ramb_bss :
  212. {
  213. . = ALIGN(4);
  214. __bss_start_ramb__ = .;
  215. *(.ramb_bss)
  216. *(.ramb_bss*)
  217. . = ALIGN(4);
  218. __bss_end_ramb__ = .;
  219. } >RAMB
  220. /DISCARD/ :
  221. {
  222. libc.a (*)
  223. libm.a (*)
  224. libgcc.a (*)
  225. }
  226. .ARM.attributes 0 : { *(.ARM.attributes) }
  227. PROVIDE(_stack = __StackTop);
  228. PROVIDE(_Min_Heap_Size = __HeapLimit - __HeapBase);
  229. PROVIDE(_Min_Stack_Size = __StackTop - __StackLimit);
  230. __RamEnd = ORIGIN(RAM) + LENGTH(RAM);
  231. ASSERT(__StackTop <= __RamEnd, "region RAM overflowed with stack")
  232. /* Stabs debugging sections. */
  233. .stab 0 : { *(.stab) }
  234. .stabstr 0 : { *(.stabstr) }
  235. .stab.excl 0 : { *(.stab.excl) }
  236. .stab.exclstr 0 : { *(.stab.exclstr) }
  237. .stab.index 0 : { *(.stab.index) }
  238. .stab.indexstr 0 : { *(.stab.indexstr) }
  239. .comment 0 : { *(.comment) }
  240. /* DWARF debug sections.
  241. * Symbols in the DWARF debugging sections are relative to the beginning
  242. * of the section so we begin them at 0. */
  243. /* DWARF 1 */
  244. .debug 0 : { *(.debug) }
  245. .line 0 : { *(.line) }
  246. /* GNU DWARF 1 extensions */
  247. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  248. .debug_sfnames 0 : { *(.debug_sfnames) }
  249. /* DWARF 1.1 and DWARF 2 */
  250. .debug_aranges 0 : { *(.debug_aranges) }
  251. .debug_pubnames 0 : { *(.debug_pubnames) }
  252. /* DWARF 2 */
  253. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  254. .debug_abbrev 0 : { *(.debug_abbrev) }
  255. .debug_line 0 : { *(.debug_line) }
  256. .debug_frame 0 : { *(.debug_frame) }
  257. .debug_str 0 : { *(.debug_str) }
  258. .debug_loc 0 : { *(.debug_loc) }
  259. .debug_macinfo 0 : { *(.debug_macinfo) }
  260. /* SGI/MIPS DWARF 2 extensions */
  261. .debug_weaknames 0 : { *(.debug_weaknames) }
  262. .debug_funcnames 0 : { *(.debug_funcnames) }
  263. .debug_typenames 0 : { *(.debug_typenames) }
  264. .debug_varnames 0 : { *(.debug_varnames) }
  265. }