link.ld 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. /***************************************************************************//**
  2. * \file cy8c6xx4_cm4_dual.ld
  3. * \version 2.91
  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 2016-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. SEARCH_DIR(.)
  39. GROUP(-lgcc -lc -lnosys)
  40. ENTRY(Reset_Handler)
  41. /* The size of the stack section at the end of CM4 SRAM */
  42. STACK_SIZE = 0x1000;
  43. /* By default, the COMPONENT_CM0P_SLEEP prebuilt image is used for the CM0p core.
  44. * More about CM0+ prebuilt images, see here:
  45. * https://github.com/cypresssemiconductorco/psoc6cm0p
  46. */
  47. /* The size of the Cortex-M0+ application image at the start of FLASH */
  48. FLASH_CM0P_SIZE = 0x2000;
  49. /* Force symbol to be entered in the output file as an undefined symbol. Doing
  50. * this may, for example, trigger linking of additional modules from standard
  51. * libraries. You may list several symbols for each EXTERN, and you may use
  52. * EXTERN multiple times. This command has the same effect as the -u command-line
  53. * option.
  54. */
  55. EXTERN(Reset_Handler)
  56. /* The MEMORY section below describes the location and size of blocks of memory in the target.
  57. * Use this section to specify the memory regions available for allocation.
  58. */
  59. MEMORY
  60. {
  61. /* The ram and flash regions control RAM and flash memory allocation for the CM4 core.
  62. * You can change the memory allocation by editing the 'ram' and 'flash' regions.
  63. * Note that 2 KB of RAM (at the end of the SRAM) are reserved for system use.
  64. * Using this memory region for other purposes will lead to unexpected behavior.
  65. * Your changes must be aligned with the corresponding memory regions for CM0+ core in 'xx_cm0plus.ld',
  66. * where 'xx' is the device group; for example, 'cy8c6xx7_cm0plus.ld'.
  67. */
  68. ram (rwx) : ORIGIN = 0x08002000, LENGTH = 0x1D800
  69. flash (rx) : ORIGIN = 0x10000000, LENGTH = 0x40000
  70. /* The following regions define device specific memory regions and must not be changed. */
  71. sflash_user_data (rx) : ORIGIN = 0x16000800, LENGTH = 0x800 /* Supervisory flash: User data */
  72. sflash_nar (rx) : ORIGIN = 0x16001A00, LENGTH = 0x200 /* Supervisory flash: Normal Access Restrictions (NAR) */
  73. sflash_public_key (rx) : ORIGIN = 0x16005A00, LENGTH = 0xC00 /* Supervisory flash: Public Key */
  74. sflash_toc_2 (rx) : ORIGIN = 0x16007C00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 */
  75. sflash_rtoc_2 (rx) : ORIGIN = 0x16007E00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 Copy */
  76. xip (rx) : ORIGIN = 0x18000000, LENGTH = 0x8000000 /* 128 MB */
  77. efuse (r) : ORIGIN = 0x90700000, LENGTH = 0x100000 /* 1 MB */
  78. }
  79. /* Library configurations */
  80. GROUP(libgcc.a libc.a libm.a libnosys.a)
  81. /* Linker script to place sections and symbol values. Should be used together
  82. * with other linker script that defines memory regions FLASH and RAM.
  83. * It references following symbols, which must be defined in code:
  84. * Reset_Handler : Entry of reset handler
  85. *
  86. * It defines following symbols, which code can use without definition:
  87. * __exidx_start
  88. * __exidx_end
  89. * __copy_table_start__
  90. * __copy_table_end__
  91. * __zero_table_start__
  92. * __zero_table_end__
  93. * __etext
  94. * __data_start__
  95. * __preinit_array_start
  96. * __preinit_array_end
  97. * __init_array_start
  98. * __init_array_end
  99. * __fini_array_start
  100. * __fini_array_end
  101. * __data_end__
  102. * __bss_start__
  103. * __bss_end__
  104. * __end__
  105. * end
  106. * __HeapLimit
  107. * __StackLimit
  108. * __StackTop
  109. * __stack
  110. * __Vectors_End
  111. * __Vectors_Size
  112. */
  113. SECTIONS
  114. {
  115. /* Cortex-M0+ application flash image area */
  116. .cy_m0p_image ORIGIN(flash) :
  117. {
  118. . = ALIGN(4);
  119. __cy_m0p_code_start = . ;
  120. KEEP(*(.cy_m0p_image))
  121. __cy_m0p_code_end = . ;
  122. } > flash
  123. /* Check if .cy_m0p_image size exceeds FLASH_CM0P_SIZE */
  124. ASSERT(__cy_m0p_code_end <= ORIGIN(flash) + FLASH_CM0P_SIZE, "CM0+ flash image overflows with CM4, increase FLASH_CM0P_SIZE")
  125. /* Cortex-M4 application flash area */
  126. .text ORIGIN(flash) + FLASH_CM0P_SIZE :
  127. {
  128. . = ALIGN(4);
  129. __Vectors = . ;
  130. KEEP(*(.vectors))
  131. . = ALIGN(4);
  132. __Vectors_End = .;
  133. __Vectors_Size = __Vectors_End - __Vectors;
  134. __end__ = .;
  135. . = ALIGN(4);
  136. *(.text*)
  137. KEEP(*(.init))
  138. KEEP(*(.fini))
  139. /* .ctors */
  140. *crtbegin.o(.ctors)
  141. *crtbegin?.o(.ctors)
  142. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  143. *(SORT(.ctors.*))
  144. *(.ctors)
  145. /* .dtors */
  146. *crtbegin.o(.dtors)
  147. *crtbegin?.o(.dtors)
  148. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  149. *(SORT(.dtors.*))
  150. *(.dtors)
  151. /* Read-only code (constants). */
  152. *(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)
  153. KEEP(*(.eh_frame*))
  154. /* section information for utest */
  155. . = ALIGN(4);
  156. __rt_utest_tc_tab_start = .;
  157. KEEP(*(UtestTcTab))
  158. __rt_utest_tc_tab_end = .;
  159. /* section information for finsh shell */
  160. . = ALIGN(4);
  161. __fsymtab_start = .;
  162. KEEP(*(FSymTab))
  163. __fsymtab_end = .;
  164. . = ALIGN(4);
  165. __vsymtab_start = .;
  166. KEEP(*(VSymTab))
  167. __vsymtab_end = .;
  168. . = ALIGN(4);
  169. /* section information for modules */
  170. . = ALIGN(4);
  171. __rtmsymtab_start = .;
  172. KEEP(*(RTMSymTab))
  173. __rtmsymtab_end = .;
  174. /* section information for initialization */
  175. . = ALIGN(4);
  176. __rt_init_start = .;
  177. KEEP(*(SORT(.rti_fn*)))
  178. __rt_init_end = .;
  179. } > flash
  180. .ARM.extab :
  181. {
  182. *(.ARM.extab* .gnu.linkonce.armextab.*)
  183. } > flash
  184. __exidx_start = .;
  185. .ARM.exidx :
  186. {
  187. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  188. } > flash
  189. __exidx_end = .;
  190. /* To copy multiple ROM to RAM sections,
  191. * uncomment .copy.table section and,
  192. * define __STARTUP_COPY_MULTIPLE in startup_psoc6_04_cm4.S */
  193. .copy.table :
  194. {
  195. . = ALIGN(4);
  196. __copy_table_start__ = .;
  197. /* Copy interrupt vectors from flash to RAM */
  198. LONG (__Vectors) /* From */
  199. LONG (__ram_vectors_start__) /* To */
  200. LONG (__Vectors_End - __Vectors) /* Size */
  201. /* Copy data section to RAM */
  202. LONG (__etext) /* From */
  203. LONG (__data_start__) /* To */
  204. LONG (__data_end__ - __data_start__) /* Size */
  205. __copy_table_end__ = .;
  206. } > flash
  207. /* To clear multiple BSS sections,
  208. * uncomment .zero.table section and,
  209. * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_psoc6_04_cm4.S */
  210. .zero.table :
  211. {
  212. . = ALIGN(4);
  213. __zero_table_start__ = .;
  214. LONG (__bss_start__)
  215. LONG (__bss_end__ - __bss_start__)
  216. __zero_table_end__ = .;
  217. } > flash
  218. __etext = . ;
  219. .ramVectors (NOLOAD) : ALIGN(8)
  220. {
  221. __ram_vectors_start__ = .;
  222. KEEP(*(.ram_vectors))
  223. __ram_vectors_end__ = .;
  224. } > ram
  225. .data __ram_vectors_end__ :
  226. {
  227. . = ALIGN(4);
  228. __data_start__ = .;
  229. *(vtable)
  230. *(.data*)
  231. . = ALIGN(4);
  232. /* preinit data */
  233. PROVIDE_HIDDEN (__preinit_array_start = .);
  234. KEEP(*(.preinit_array))
  235. PROVIDE_HIDDEN (__preinit_array_end = .);
  236. . = ALIGN(4);
  237. /* init data */
  238. PROVIDE_HIDDEN (__init_array_start = .);
  239. KEEP(*(SORT(.init_array.*)))
  240. KEEP(*(.init_array))
  241. PROVIDE_HIDDEN (__init_array_end = .);
  242. . = ALIGN(4);
  243. /* finit data */
  244. PROVIDE_HIDDEN (__fini_array_start = .);
  245. KEEP(*(SORT(.fini_array.*)))
  246. KEEP(*(.fini_array))
  247. PROVIDE_HIDDEN (__fini_array_end = .);
  248. KEEP(*(.jcr*))
  249. . = ALIGN(4);
  250. KEEP(*(.cy_ramfunc*))
  251. . = ALIGN(4);
  252. __data_end__ = .;
  253. } > ram AT>flash
  254. /* Place variables in the section that should not be initialized during the
  255. * device startup.
  256. */
  257. .noinit (NOLOAD) : ALIGN(8)
  258. {
  259. KEEP(*(.noinit))
  260. } > ram
  261. /* The uninitialized global or static variables are placed in this section.
  262. *
  263. * The NOLOAD attribute tells linker that .bss section does not consume
  264. * any space in the image. The NOLOAD attribute changes the .bss type to
  265. * NOBITS, and that makes linker to A) not allocate section in memory, and
  266. * A) put information to clear the section with all zeros during application
  267. * loading.
  268. *
  269. * Without the NOLOAD attribute, the .bss section might get PROGBITS type.
  270. * This makes linker to A) allocate zeroed section in memory, and B) copy
  271. * this section to RAM during application loading.
  272. */
  273. .bss (NOLOAD):
  274. {
  275. . = ALIGN(4);
  276. __bss_start__ = .;
  277. *(.bss*)
  278. *(COMMON)
  279. . = ALIGN(4);
  280. __bss_end__ = .;
  281. } > ram
  282. .heap (NOLOAD):
  283. {
  284. __HeapBase = .;
  285. __end__ = .;
  286. end = __end__;
  287. KEEP(*(.heap*))
  288. . = ORIGIN(ram) + LENGTH(ram) - STACK_SIZE;
  289. __HeapLimit = .;
  290. } > ram
  291. /* .stack_dummy section doesn't contains any symbols. It is only
  292. * used for linker to calculate size of stack sections, and assign
  293. * values to stack symbols later */
  294. .stack_dummy (NOLOAD):
  295. {
  296. KEEP(*(.stack*))
  297. } > ram
  298. /* Set stack top to end of RAM, and stack limit move down by
  299. * size of stack_dummy section */
  300. __StackTop = ORIGIN(ram) + LENGTH(ram);
  301. __StackLimit = __StackTop - SIZEOF(.stack_dummy);
  302. PROVIDE(__stack = __StackTop);
  303. /* Check if data + heap + stack exceeds RAM limit */
  304. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
  305. /* Used for the digital signature of the secure application and the Bootloader SDK application.
  306. * The size of the section depends on the required data size. */
  307. .cy_app_signature ORIGIN(flash) + LENGTH(flash) - 256 :
  308. {
  309. KEEP(*(.cy_app_signature))
  310. } > flash
  311. /* Supervisory Flash: User data */
  312. .cy_sflash_user_data :
  313. {
  314. KEEP(*(.cy_sflash_user_data))
  315. } > sflash_user_data
  316. /* Supervisory Flash: Normal Access Restrictions (NAR) */
  317. .cy_sflash_nar :
  318. {
  319. KEEP(*(.cy_sflash_nar))
  320. } > sflash_nar
  321. /* Supervisory Flash: Public Key */
  322. .cy_sflash_public_key :
  323. {
  324. KEEP(*(.cy_sflash_public_key))
  325. } > sflash_public_key
  326. /* Supervisory Flash: Table of Content # 2 */
  327. .cy_toc_part2 :
  328. {
  329. KEEP(*(.cy_toc_part2))
  330. } > sflash_toc_2
  331. /* Supervisory Flash: Table of Content # 2 Copy */
  332. .cy_rtoc_part2 :
  333. {
  334. KEEP(*(.cy_rtoc_part2))
  335. } > sflash_rtoc_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. /* These sections are used for additional metadata (silicon revision,
  351. * Silicon/JTAG ID, etc.) storage.
  352. */
  353. .cymeta 0x90500000 : { KEEP(*(.cymeta)) } :NONE
  354. }
  355. /* The following symbols used by the cymcuelftool. */
  356. /* Flash */
  357. __cy_memory_0_start = 0x10000000;
  358. __cy_memory_0_length = 0x00040000;
  359. __cy_memory_0_row_size = 0x200;
  360. /* Supervisory Flash */
  361. __cy_memory_2_start = 0x16000000;
  362. __cy_memory_2_length = 0x8000;
  363. __cy_memory_2_row_size = 0x200;
  364. /* XIP */
  365. __cy_memory_3_start = 0x18000000;
  366. __cy_memory_3_length = 0x08000000;
  367. __cy_memory_3_row_size = 0x200;
  368. /* eFuse */
  369. __cy_memory_4_start = 0x90700000;
  370. __cy_memory_4_length = 0x100000;
  371. __cy_memory_4_row_size = 1;
  372. /* EOF */