link.ld 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. /***************************************************************************//**
  2. * \file xmc7200_x8384_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 = 0x00100000; /* 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 = 0x000FC000; /* 1008K : cm7_0 sram size */
  51. code_flash_total_size = 0x00830000; /* 8384K: total flash size */
  52. cm0plus_code_flash_reserve = 0x00080000; /* 512K : cm0 flash size */
  53. cm7_0_code_flash_reserve = 0x007B0000; /* 7872K: 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. .ARM.extab :
  171. {
  172. *(.ARM.extab* .gnu.linkonce.armextab.*)
  173. } > flash
  174. __exidx_start = .;
  175. .ARM.exidx :
  176. {
  177. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  178. } > flash
  179. __exidx_end = .;
  180. .copy.table :
  181. {
  182. . = ALIGN(4);
  183. __copy_table_start__ = .;
  184. /* Copy data section to RAM */
  185. LONG (__etext) /* From */
  186. LONG (__data_start__) /* To */
  187. LONG ((__data_end__ - __data_start__)/4) /* Size */
  188. /* Copy code to ITCM */
  189. LONG (__zero_table_end__) /* From */
  190. LONG (__itcm_start__) /* To */
  191. LONG ((__itcm_end__ - __itcm_start__)/4) /* Size */
  192. /* Copy data to DTCM */
  193. LONG (__itcm_flash_end__) /* From */
  194. LONG (__dtcm_start__) /* To */
  195. LONG ((__dtcm_end__ - __dtcm_start__)/4) /* Size */
  196. __copy_table_end__ = .;
  197. } > flash
  198. .zero.table :
  199. {
  200. . = ALIGN(4);
  201. __zero_table_start__ = .;
  202. LONG (__bss_start__)
  203. LONG ((__bss_end__ - __bss_start__)/4)
  204. __zero_table_end__ = .;
  205. } > flash
  206. /* itcm */
  207. .cy_itcm ORIGIN(itcm):
  208. {
  209. __itcm_start__ = .;
  210. KEEP(*(.cy_itcm))
  211. __itcm_end__ = .;
  212. } > itcm AT>flash
  213. __itcm_flash_end__ = __zero_table_end__ + (__itcm_end__ - __itcm_start__);
  214. /* dtcm */
  215. .cy_dtcm ORIGIN(dtcm):
  216. {
  217. __dtcm_start__ = .;
  218. KEEP(*(.cy_dtcm))
  219. __dtcm_end__ = .;
  220. } > dtcm AT>flash
  221. __etext = __itcm_flash_end__ + (__dtcm_end__ - __dtcm_start__) ;
  222. .ramVectors (NOLOAD) :
  223. {
  224. . = ALIGN(RAMVECTORS_ALIGNMENT);
  225. __ram_vectors_start__ = .;
  226. KEEP(*(.ram_vectors))
  227. __ram_vectors_end__ = .;
  228. } > ram
  229. .data __ram_vectors_end__ :
  230. {
  231. . = ALIGN(4);
  232. __data_start__ = .;
  233. *(vtable)
  234. *(.data*)
  235. . = ALIGN(4);
  236. /* preinit data */
  237. PROVIDE_HIDDEN (__preinit_array_start = .);
  238. KEEP(*(.preinit_array))
  239. PROVIDE_HIDDEN (__preinit_array_end = .);
  240. . = ALIGN(4);
  241. /* init data */
  242. PROVIDE_HIDDEN (__init_array_start = .);
  243. KEEP(*(SORT(.init_array.*)))
  244. KEEP(*(.init_array))
  245. PROVIDE_HIDDEN (__init_array_end = .);
  246. . = ALIGN(4);
  247. /* finit data */
  248. PROVIDE_HIDDEN (__fini_array_start = .);
  249. KEEP(*(SORT(.fini_array.*)))
  250. KEEP(*(.fini_array))
  251. PROVIDE_HIDDEN (__fini_array_end = .);
  252. KEEP(*(.jcr*))
  253. . = ALIGN(4);
  254. KEEP(*(.cy_ramfunc*))
  255. . = ALIGN(32);
  256. KEEP(*(cy_sharedmem*))
  257. . = ALIGN(4);
  258. __data_end__ = .;
  259. } > ram AT>flash
  260. /* Place variables in the section that should not be initialized during the
  261. * device startup.
  262. */
  263. .noinit (NOLOAD) : ALIGN(8)
  264. {
  265. KEEP(*(.noinit))
  266. } > ram
  267. /* The uninitialized global or static variables are placed in this section.
  268. *
  269. * The NOLOAD attribute tells linker that .bss section does not consume
  270. * any space in the image. The NOLOAD attribute changes the .bss type to
  271. * NOBITS, and that makes linker to A) not allocate section in memory, and
  272. * A) put information to clear the section with all zeros during application
  273. * loading.
  274. *
  275. * Without the NOLOAD attribute, the .bss section might get PROGBITS type.
  276. * This makes linker to A) allocate zeroed section in memory, and B) copy
  277. * this section to RAM during application loading.
  278. */
  279. .bss (NOLOAD):
  280. {
  281. . = ALIGN(4);
  282. __bss_start__ = .;
  283. *(.bss*)
  284. *(COMMON)
  285. . = ALIGN(4);
  286. __bss_end__ = .;
  287. } > ram
  288. .heap (NOLOAD):
  289. {
  290. __HeapBase = .;
  291. __end__ = .;
  292. end = __end__;
  293. KEEP(*(.heap*))
  294. . = ORIGIN(ram) + LENGTH(ram) - STACK_SIZE;
  295. __HeapLimit = .;
  296. } > ram
  297. /* .stack_dummy section doesn't contains any symbols. It is only
  298. * used for linker to calculate size of stack sections, and assign
  299. * values to stack symbols later */
  300. .stack_dummy (NOLOAD):
  301. {
  302. KEEP(*(.stack*))
  303. } > ram
  304. /* Set stack top to end of RAM, and stack limit move down by
  305. * size of stack_dummy section */
  306. __StackTop = ORIGIN(ram) + LENGTH(ram);
  307. __StackLimit = __StackTop - STACK_SIZE;
  308. PROVIDE(__stack = __StackTop);
  309. /* Check if data + heap + stack exceeds RAM limit */
  310. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
  311. /* Emulated EEPROM Flash area */
  312. .cy_em_eeprom :
  313. {
  314. KEEP(*(.cy_em_eeprom))
  315. } > em_eeprom
  316. /* Supervisory Flash: User data */
  317. .cy_sflash_user_data :
  318. {
  319. KEEP(*(.cy_sflash_user_data))
  320. } > sflash_user_data
  321. /* Supervisory Flash: Normal Access Restrictions (NAR) */
  322. .cy_sflash_nar :
  323. {
  324. KEEP(*(.cy_sflash_nar))
  325. } > sflash_nar
  326. /* Supervisory Flash: Public Key */
  327. .cy_sflash_public_key :
  328. {
  329. KEEP(*(.cy_sflash_public_key))
  330. } > sflash_public_key
  331. /* Supervisory Flash: Table of Content # 2 */
  332. .cy_toc_part2 :
  333. {
  334. KEEP(*(.cy_toc_part2))
  335. } > sflash_toc_2
  336. /* Places the code in the Execute in Place (XIP) section. See the smif driver
  337. * documentation for details.
  338. */
  339. cy_xip :
  340. {
  341. __cy_xip_start = .;
  342. KEEP(*(.cy_xip))
  343. __cy_xip_end = .;
  344. } > xip
  345. /* eFuse */
  346. .cy_efuse :
  347. {
  348. KEEP(*(.cy_efuse))
  349. } > efuse
  350. }
  351. /*============================================================
  352. * Symbols for use by application
  353. *============================================================
  354. */
  355. __ecc_init_sram_start_address = ORIGIN(ram);
  356. __ecc_init_sram_end_address = ORIGIN(ram) + LENGTH(ram);
  357. /* EOF */