link.ld 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. /***************************************************************************//**
  2. * /file xmc7100_x4160_cm7.ld
  3. * /version 1.0.0
  4. *
  5. * Linker file for the GNU C compiler.
  6. *
  7. * The main purpose of the linker script is to describe how the sections in the
  8. * input files should be mapped into the output file, and to control the memory
  9. * layout of the output file.
  10. *
  11. * /note The entry point location is fixed and starts at 0x10000000. The valid
  12. * application image should be placed there.
  13. *
  14. * /note The linker files included with the PDL template projects must be generic
  15. * and handle all common use cases. Your project may not use every section
  16. * defined in the linker files. In that case you may see warnings during the
  17. * build process. In your project, you can simply comment out or remove the
  18. * relevant code in the linker file.
  19. *
  20. ********************************************************************************
  21. * /copyright
  22. * Copyright 2021 Cypress Semiconductor Corporation
  23. * SPDX-License-Identifier: Apache-2.0
  24. *
  25. * Licensed under the Apache License, Version 2.0 (the "License");
  26. * you may not use this file except in compliance with the License.
  27. * You may obtain a copy of the License at
  28. *
  29. * http://www.apache.org/licenses/LICENSE-2.0
  30. *
  31. * Unless required by applicable law or agreed to in writing, software
  32. * distributed under the License is distributed on an "AS IS" BASIS,
  33. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  34. * See the License for the specific language governing permissions and
  35. * limitations under the License.
  36. *******************************************************************************/
  37. OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
  38. GROUP(-lgcc -lc -lnosys )
  39. SEARCH_DIR(.)
  40. GROUP(libgcc.a libc.a libm.a libnosys.a)
  41. ENTRY(Reset_Handler)
  42. /* The size of the stack section at the end of CM7 SRAM */
  43. STACK_SIZE = 0x1000;
  44. RAMVECTORS_ALIGNMENT = 128;
  45. sram_start_reserve = 0;
  46. sram_total_size = 0x000C0000; /* 768K: SRAM0 + SRAM1 */
  47. sram_private_for_srom = 0x00000800; /* Private SRAM for SROM (e.g. API processing) */
  48. sram_used_by_boot = 0x0; /* Used during boot by Cypress firmware (content will be overwritten on reset, so it should not be used for loadable sections in case of RAM build configurations) */
  49. cm0plus_sram_reserve = 0x00004000; /* 16K : cm0 sram size */
  50. cm7_0_sram_reserve = 0x000BC000; /* 752K : cm7_0 sram size */
  51. code_flash_total_size = 0x00410000; /* 4160K: total flash size */
  52. cm0plus_code_flash_reserve = 0x00080000; /* 512K : cm0 flash size */
  53. cm7_0_code_flash_reserve = 0x00390000; /* 3648K: cm7_0 flash size */
  54. code_flash_base_address = 0x10000000;
  55. sram_base_address = 0x28000000;
  56. /* SRAM reservations */
  57. _base_SRAM_CM7_0 = sram_base_address + cm0plus_sram_reserve;
  58. _size_SRAM_CM7_0 = cm7_0_sram_reserve;
  59. /* Code flash reservations */
  60. _base_CODE_FLASH_CM0P = code_flash_base_address;
  61. _size_CODE_FLASH_CM0P = cm0plus_code_flash_reserve;
  62. _base_CODE_FLASH_CM7_0 = code_flash_base_address + cm0plus_code_flash_reserve;
  63. _size_CODE_FLASH_CM7_0 = cm7_0_code_flash_reserve;
  64. /* Fixed Addresses */
  65. _base_WORK_FLASH = 0x14000000;
  66. _size_WORK_FLASH = 0x00040000; /* 256K Work flash */
  67. _base_CM7_0_ITCM = 0x00000000;
  68. _size_CM7_0_ITCM = 0x00004000;
  69. _base_CM7_0_DTCM = 0x20000000;
  70. _size_CM7_0_DTCM = 0x00004000;
  71. /* For the non-dual cm7 device, _CORE_CM7_0_ should be defined and _CORE_CM7_1_ should not be defined */
  72. _base_SRAM = _base_SRAM_CM7_0;
  73. _size_SRAM = _size_SRAM_CM7_0;
  74. _base_CODE_FLASH = _base_CODE_FLASH_CM7_0;
  75. _size_CODE_FLASH = _size_CODE_FLASH_CM7_0;
  76. _base_SFLASH_USER_DATA = 0x17000800;
  77. _size_SFLASH_USER_DATA = 0x00000800;
  78. _base_SFLASH_NAR = 0x17001A00;
  79. _size_SFLASH_NAR = 0x00000200;
  80. _base_SFLASH_PUB_KEY = 0x17006400;
  81. _size_SFLASH_PUB_KEY = 0x00000C00;
  82. _base_SFLASH_APP_PROT = 0x17007600;
  83. _size_SFLASH_APP_PROT = 0x00000200;
  84. _base_SFLASH_TOC2 = 0x17007C00;
  85. _size_SFLASH_TOC2 = 0x00000200;
  86. _base_XIP = 0x60000000;
  87. _size_XIP = 0x08000000;
  88. _base_EFUSE = 0x90700000;
  89. _size_EFUSE = 0x00100000;
  90. _base_ITCM = _base_CM7_0_ITCM;
  91. _size_ITCM = _size_CM7_0_ITCM;
  92. _base_DTCM = _base_CM7_0_DTCM;
  93. _size_DTCM = _size_CM7_0_DTCM;
  94. /* Force symbol to be entered in the output file as an undefined symbol. Doing
  95. * this may, for example, trigger linking of additional modules from standard
  96. * libraries. You may list several symbols for each EXTERN, and you may use
  97. * EXTERN multiple times. This command has the same effect as the -u command-line
  98. * option.
  99. */
  100. EXTERN(Reset_Handler)
  101. /* The MEMORY section below describes the location and size of blocks of memory in the target.
  102. * Use this section to specify the memory regions available for allocation.
  103. */
  104. MEMORY
  105. {
  106. /* The ram and flash regions control RAM and flash memory allocation for the CM7_0/CM7_1 core. */
  107. ram (rxw) : ORIGIN = _base_SRAM, LENGTH = _size_SRAM /* SRAM */
  108. flash_cm0p (rx) : ORIGIN = _base_CODE_FLASH_CM0P, LENGTH = _size_CODE_FLASH_CM0P /* CODE flash CM0+ */
  109. flash (rx) : ORIGIN = _base_CODE_FLASH, LENGTH = _size_CODE_FLASH /* CODE flash CM7_0/1 */
  110. /* This is a 256K flash region used for EEPROM emulation. This region can also be used as the general purpose flash.
  111. * You can assign sections to this memory region for only one of the cores.
  112. */
  113. em_eeprom (rw) : ORIGIN = _base_WORK_FLASH, LENGTH = _size_WORK_FLASH /* WORK flash */
  114. /* The following regions define device specific memory regions and must not be changed. */
  115. sflash_user_data (rx) : ORIGIN = _base_SFLASH_USER_DATA, LENGTH = _size_SFLASH_USER_DATA /* Supervisory flash: User data */
  116. sflash_nar (rx) : ORIGIN = _base_SFLASH_NAR, LENGTH = _size_SFLASH_NAR /* Supervisory flash: Normal Access Restrictions (NAR) */
  117. sflash_public_key (rx) : ORIGIN = _base_SFLASH_PUB_KEY, LENGTH = _size_SFLASH_PUB_KEY /* Supervisory flash: Public Key */
  118. sflash_app_prot (rx) : ORIGIN = _base_SFLASH_APP_PROT, LENGTH = _size_SFLASH_APP_PROT
  119. sflash_toc_2 (rx) : ORIGIN = _base_SFLASH_TOC2, LENGTH = _size_SFLASH_TOC2 /* Supervisory flash: Table of Content # 2 */
  120. xip (rx) : ORIGIN = _base_XIP, LENGTH = _size_XIP /* XIP: 128 MB */
  121. efuse (rx) : ORIGIN = _base_EFUSE, LENGTH = _size_EFUSE /* 1MB */
  122. itcm (rx) : ORIGIN = _base_ITCM, LENGTH = _size_ITCM /* ITCM */
  123. dtcm (rx) : ORIGIN = _base_DTCM, LENGTH = _base_DTCM /* DTCM */
  124. }
  125. /* Library configurations */
  126. GROUP(libgcc.a libc.a libm.a libnosys.a)
  127. SECTIONS
  128. {
  129. /* Cortex-M0+ application flash image area. Comment this section if you don't want to include CM0+ image */
  130. .cy_cm0p_image ORIGIN(flash_cm0p):
  131. {
  132. . = ALIGN(4);
  133. __cy_m0p_code_start = . ;
  134. KEEP(*(.cy_m0p_image))
  135. __cy_m0p_code_end = . ;
  136. } > flash_cm0p
  137. /* Check if .cy_m0p_image size exceeds cm0plus_code_flash_reserve */
  138. ASSERT(__cy_m0p_code_end < ORIGIN(flash), "CM0+ flash image overflows with CM7, increase CM7 base address ")
  139. /* Cortex-M7 application flash area */
  140. .text ORIGIN(flash) :
  141. {
  142. /* Cortex-M7 flash vector table */
  143. . = ALIGN(4);
  144. __Vectors = . ;
  145. KEEP(*(.vectors))
  146. . = ALIGN(4);
  147. __Vectors_End = .;
  148. __Vectors_Size = __Vectors_End - __Vectors;
  149. __end__ = .;
  150. . = ALIGN(4);
  151. *(.text*)
  152. KEEP(*(.init))
  153. KEEP(*(.fini))
  154. /* .ctors */
  155. *crtbegin.o(.ctors)
  156. *crtbegin?.o(.ctors)
  157. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  158. *(SORT(.ctors.*))
  159. *(.ctors)
  160. /* .dtors */
  161. *crtbegin.o(.dtors)
  162. *crtbegin?.o(.dtors)
  163. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  164. *(SORT(.dtors.*))
  165. *(.dtors)
  166. /* Read-only code (constants). */
  167. *(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)
  168. KEEP(*(.eh_frame*))
  169. } > flash
  170. .rtt_const_tables :
  171. {
  172. /* section information for finsh shell */
  173. . = ALIGN(4);
  174. __fsymtab_start = .;
  175. KEEP(*(FSymTab))
  176. __fsymtab_end = .;
  177. . = ALIGN(4);
  178. __vsymtab_start = .;
  179. KEEP(*(VSymTab))
  180. __vsymtab_end = .;
  181. /* section information for utest */
  182. . = ALIGN(4);
  183. __rt_utest_tc_tab_start = .;
  184. KEEP(*(UtestTcTab))
  185. __rt_utest_tc_tab_end = .;
  186. /* section information for initial. */
  187. . = ALIGN(4);
  188. __rt_init_start = .;
  189. KEEP(*(SORT(.rti_fn*)))
  190. __rt_init_end = .;
  191. . = ALIGN(4);
  192. PROVIDE(__ctors_start__ = .);
  193. KEEP (*(SORT(.init_array.*)))
  194. KEEP (*(.init_array))
  195. PROVIDE(__ctors_end__ = .);
  196. } > flash
  197. .ARM.extab :
  198. {
  199. *(.ARM.extab* .gnu.linkonce.armextab.*)
  200. } > flash
  201. __exidx_start = .;
  202. .ARM.exidx :
  203. {
  204. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  205. } > flash
  206. __exidx_end = .;
  207. .copy.table :
  208. {
  209. . = ALIGN(4);
  210. __copy_table_start__ = .;
  211. /* Copy data section to RAM */
  212. LONG (__etext) /* From */
  213. LONG (__data_start__) /* To */
  214. LONG ((__data_end__ - __data_start__)/4) /* Size */
  215. /* Copy code to ITCM */
  216. LONG (__zero_table_end__) /* From */
  217. LONG (__itcm_start__) /* To */
  218. LONG ((__itcm_end__ - __itcm_start__)/4) /* Size */
  219. /* Copy data to DTCM */
  220. LONG (__itcm_flash_end__) /* From */
  221. LONG (__dtcm_start__) /* To */
  222. LONG ((__dtcm_end__ - __dtcm_start__)/4) /* Size */
  223. __copy_table_end__ = .;
  224. } > flash
  225. .zero.table :
  226. {
  227. . = ALIGN(4);
  228. __zero_table_start__ = .;
  229. LONG (__bss_start__)
  230. LONG ((__bss_end__ - __bss_start__)/4)
  231. __zero_table_end__ = .;
  232. } > flash
  233. /* itcm */
  234. .cy_itcm ORIGIN(itcm):
  235. {
  236. __itcm_start__ = .;
  237. KEEP(*(.cy_itcm))
  238. __itcm_end__ = .;
  239. } > itcm AT>flash
  240. __itcm_flash_end__ = __zero_table_end__ + (__itcm_end__ - __itcm_start__);
  241. /* dtcm */
  242. .cy_dtcm ORIGIN(dtcm):
  243. {
  244. __dtcm_start__ = .;
  245. KEEP(*(.cy_dtcm))
  246. __dtcm_end__ = .;
  247. } > dtcm AT>flash
  248. __etext = __itcm_flash_end__ + (__dtcm_end__ - __dtcm_start__) ;
  249. .ramVectors (NOLOAD) :
  250. {
  251. . = ALIGN(RAMVECTORS_ALIGNMENT);
  252. __ram_vectors_start__ = .;
  253. KEEP(*(.ram_vectors))
  254. __ram_vectors_end__ = .;
  255. } > ram
  256. .data __ram_vectors_end__ :
  257. {
  258. . = ALIGN(4);
  259. __data_start__ = .;
  260. *(vtable)
  261. KEEP(*(.data.cybsp_sysclk_pm_callback.1))
  262. *(.data*)
  263. . = ALIGN(4);
  264. /* preinit data */
  265. PROVIDE_HIDDEN (__preinit_array_start = .);
  266. KEEP(*(.preinit_array))
  267. PROVIDE_HIDDEN (__preinit_array_end = .);
  268. . = ALIGN(4);
  269. /* init data */
  270. PROVIDE_HIDDEN (__init_array_start = .);
  271. KEEP(*(SORT(.init_array.*)))
  272. KEEP(*(.init_array))
  273. PROVIDE_HIDDEN (__init_array_end = .);
  274. . = ALIGN(4);
  275. /* finit data */
  276. PROVIDE_HIDDEN (__fini_array_start = .);
  277. KEEP(*(SORT(.fini_array.*)))
  278. KEEP(*(.fini_array))
  279. PROVIDE_HIDDEN (__fini_array_end = .);
  280. KEEP(*(.jcr*))
  281. . = ALIGN(4);
  282. KEEP(*(.cy_ramfunc*))
  283. . = ALIGN(32);
  284. KEEP(*(cy_sharedmem*))
  285. . = ALIGN(4);
  286. __data_end__ = .;
  287. } > ram AT>flash
  288. /* Place variables in the section that should not be initialized during the
  289. * device startup.
  290. */
  291. .noinit (NOLOAD) : ALIGN(8)
  292. {
  293. KEEP(*(.noinit))
  294. } > ram
  295. /* The uninitialized global or static variables are placed in this section.
  296. *
  297. * The NOLOAD attribute tells linker that .bss section does not consume
  298. * any space in the image. The NOLOAD attribute changes the .bss type to
  299. * NOBITS, and that makes linker to A) not allocate section in memory, and
  300. * A) put information to clear the section with all zeros during application
  301. * loading.
  302. *
  303. * Without the NOLOAD attribute, the .bss section might get PROGBITS type.
  304. * This makes linker to A) allocate zeroed section in memory, and B) copy
  305. * this section to RAM during application loading.
  306. */
  307. .bss (NOLOAD):
  308. {
  309. . = ALIGN(4);
  310. __bss_start__ = .;
  311. *(.bss*)
  312. *(COMMON)
  313. . = ALIGN(4);
  314. __bss_end__ = .;
  315. } > ram
  316. .heap (NOLOAD):
  317. {
  318. __HeapBase = .;
  319. __end__ = .;
  320. end = __end__;
  321. KEEP(*(.heap*))
  322. . = ORIGIN(ram) + LENGTH(ram) - STACK_SIZE;
  323. __HeapLimit = .;
  324. } > ram
  325. /* .stack_dummy section doesn't contains any symbols. It is only
  326. * used for linker to calculate size of stack sections, and assign
  327. * values to stack symbols later */
  328. .stack_dummy (NOLOAD):
  329. {
  330. KEEP(*(.stack*))
  331. } > ram
  332. /* Set stack top to end of RAM, and stack limit move down by
  333. * size of stack_dummy section */
  334. __StackTop = ORIGIN(ram) + LENGTH(ram);
  335. __StackLimit = __StackTop - STACK_SIZE;
  336. PROVIDE(__stack = __StackTop);
  337. /* Check if data + heap + stack exceeds RAM limit */
  338. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
  339. /* Emulated EEPROM Flash area */
  340. .cy_em_eeprom :
  341. {
  342. KEEP(*(.cy_em_eeprom))
  343. } > em_eeprom
  344. /* Supervisory Flash: User data */
  345. .cy_sflash_user_data :
  346. {
  347. KEEP(*(.cy_sflash_user_data))
  348. } > sflash_user_data
  349. /* Supervisory Flash: Normal Access Restrictions (NAR) */
  350. .cy_sflash_nar :
  351. {
  352. KEEP(*(.cy_sflash_nar))
  353. } > sflash_nar
  354. /* Supervisory Flash: Public Key */
  355. .cy_sflash_public_key :
  356. {
  357. KEEP(*(.cy_sflash_public_key))
  358. } > sflash_public_key
  359. /* Supervisory Flash: Table of Content # 2 */
  360. .cy_toc_part2 :
  361. {
  362. KEEP(*(.cy_toc_part2))
  363. } > sflash_toc_2
  364. /* Places the code in the Execute in Place (XIP) section. See the smif driver
  365. * documentation for details.
  366. */
  367. cy_xip :
  368. {
  369. __cy_xip_start = .;
  370. KEEP(*(.cy_xip))
  371. __cy_xip_end = .;
  372. } > xip
  373. /* eFuse */
  374. .cy_efuse :
  375. {
  376. KEEP(*(.cy_efuse))
  377. } > efuse
  378. }
  379. /*============================================================
  380. * Symbols for use by application
  381. *============================================================
  382. */
  383. __ecc_init_sram_start_address = ORIGIN(ram);
  384. __ecc_init_sram_end_address = ORIGIN(ram) + LENGTH(ram);
  385. /* EOF */