link.ld 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487
  1. /***************************************************************************//**
  2. * \file cy8c6xxa_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 = 0xFD800
  69. flash (rx) : ORIGIN = 0x10000000, LENGTH = 0x200000
  70. /* This is a 32K flash region used for EEPROM emulation. This region can also be used as the general purpose flash.
  71. * You can assign sections to this memory region for only one of the cores.
  72. * Note some middleware (e.g. BLE, Emulated EEPROM) can place their data into this memory region.
  73. * Therefore, repurposing this memory region will prevent such middleware from operation.
  74. */
  75. em_eeprom (rx) : ORIGIN = 0x14000000, LENGTH = 0x8000 /* 32 KB */
  76. /* The following regions define device specific memory regions and must not be changed. */
  77. sflash_user_data (rx) : ORIGIN = 0x16000800, LENGTH = 0x800 /* Supervisory flash: User data */
  78. sflash_nar (rx) : ORIGIN = 0x16001A00, LENGTH = 0x200 /* Supervisory flash: Normal Access Restrictions (NAR) */
  79. sflash_public_key (rx) : ORIGIN = 0x16005A00, LENGTH = 0xC00 /* Supervisory flash: Public Key */
  80. sflash_toc_2 (rx) : ORIGIN = 0x16007C00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 */
  81. sflash_rtoc_2 (rx) : ORIGIN = 0x16007E00, LENGTH = 0x200 /* Supervisory flash: Table of Content # 2 Copy */
  82. xip (rx) : ORIGIN = 0x18000000, LENGTH = 0x8000000 /* 128 MB */
  83. efuse (r) : ORIGIN = 0x90700000, LENGTH = 0x100000 /* 1 MB */
  84. }
  85. /* Library configurations */
  86. GROUP(libgcc.a libc.a libm.a libnosys.a)
  87. /* Linker script to place sections and symbol values. Should be used together
  88. * with other linker script that defines memory regions FLASH and RAM.
  89. * It references following symbols, which must be defined in code:
  90. * Reset_Handler : Entry of reset handler
  91. *
  92. * It defines following symbols, which code can use without definition:
  93. * __exidx_start
  94. * __exidx_end
  95. * __copy_table_start__
  96. * __copy_table_end__
  97. * __zero_table_start__
  98. * __zero_table_end__
  99. * __etext
  100. * __data_start__
  101. * __preinit_array_start
  102. * __preinit_array_end
  103. * __init_array_start
  104. * __init_array_end
  105. * __fini_array_start
  106. * __fini_array_end
  107. * __data_end__
  108. * __bss_start__
  109. * __bss_end__
  110. * __end__
  111. * end
  112. * __HeapLimit
  113. * __StackLimit
  114. * __StackTop
  115. * __stack
  116. * __Vectors_End
  117. * __Vectors_Size
  118. */
  119. SECTIONS
  120. {
  121. /* Cortex-M0+ application flash image area */
  122. .cy_m0p_image ORIGIN(flash) :
  123. {
  124. . = ALIGN(4);
  125. __cy_m0p_code_start = . ;
  126. KEEP(*(.cy_m0p_image))
  127. __cy_m0p_code_end = . ;
  128. } > flash
  129. /* Check if .cy_m0p_image size exceeds FLASH_CM0P_SIZE */
  130. ASSERT(__cy_m0p_code_end <= ORIGIN(flash) + FLASH_CM0P_SIZE, "CM0+ flash image overflows with CM4, increase FLASH_CM0P_SIZE")
  131. /* Cortex-M4 application flash area */
  132. .text ORIGIN(flash) + FLASH_CM0P_SIZE :
  133. {
  134. . = ALIGN(4);
  135. __Vectors = . ;
  136. KEEP(*(.vectors))
  137. . = ALIGN(4);
  138. __Vectors_End = .;
  139. __Vectors_Size = __Vectors_End - __Vectors;
  140. __end__ = .;
  141. . = ALIGN(4);
  142. *(.text*)
  143. KEEP(*(.init))
  144. KEEP(*(.fini))
  145. /* .ctors */
  146. *crtbegin.o(.ctors)
  147. *crtbegin?.o(.ctors)
  148. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
  149. *(SORT(.ctors.*))
  150. *(.ctors)
  151. /* .dtors */
  152. *crtbegin.o(.dtors)
  153. *crtbegin?.o(.dtors)
  154. *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
  155. *(SORT(.dtors.*))
  156. *(.dtors)
  157. . = ALIGN(4);
  158. /* Read-only code (constants). */
  159. *(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)
  160. KEEP(*(.eh_frame*))
  161. /* section information for utest */
  162. . = ALIGN(4);
  163. __rt_utest_tc_tab_start = .;
  164. KEEP(*(UtestTcTab))
  165. __rt_utest_tc_tab_end = .;
  166. /* section information for finsh shell */
  167. . = ALIGN(4);
  168. __fsymtab_start = .;
  169. KEEP(*(FSymTab))
  170. __fsymtab_end = .;
  171. . = ALIGN(4);
  172. __vsymtab_start = .;
  173. KEEP(*(VSymTab))
  174. __vsymtab_end = .;
  175. . = ALIGN(4);
  176. /* section information for modules */
  177. . = ALIGN(4);
  178. __rtmsymtab_start = .;
  179. KEEP(*(RTMSymTab))
  180. __rtmsymtab_end = .;
  181. /* section information for initialization */
  182. . = ALIGN(4);
  183. __rt_init_start = .;
  184. KEEP(*(SORT(.rti_fn*)))
  185. __rt_init_end = .;
  186. } > flash
  187. .ARM.extab :
  188. {
  189. *(.ARM.extab* .gnu.linkonce.armextab.*)
  190. } > flash
  191. __exidx_start = .;
  192. .ARM.exidx :
  193. {
  194. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  195. } > flash
  196. __exidx_end = .;
  197. /* To copy multiple ROM to RAM sections,
  198. * uncomment .copy.table section and,
  199. * define __STARTUP_COPY_MULTIPLE in startup_psoc6_02_cm4.S */
  200. .copy.table :
  201. {
  202. . = ALIGN(4);
  203. __copy_table_start__ = .;
  204. /* Copy interrupt vectors from flash to RAM */
  205. LONG (__Vectors) /* From */
  206. LONG (__ram_vectors_start__) /* To */
  207. LONG (__Vectors_End - __Vectors) /* Size */
  208. /* Copy data section to RAM */
  209. LONG (__etext) /* From */
  210. LONG (__data_start__) /* To */
  211. LONG (__data_end__ - __data_start__) /* Size */
  212. __copy_table_end__ = .;
  213. } > flash
  214. . = ALIGN(4);
  215. .ctors :
  216. {
  217. PROVIDE(__ctors_start__ = .);
  218. KEEP (*(SORT(.init_array.*)))
  219. KEEP (*(.init_array))
  220. PROVIDE(__ctors_end__ = .);
  221. } > flash
  222. . = ALIGN(4);
  223. .dtors :
  224. {
  225. PROVIDE(__dtors_start__ = .);
  226. KEEP(*(SORT(.dtors.*)))
  227. KEEP(*(.dtors))
  228. PROVIDE(__dtors_end__ = .);
  229. } > flash
  230. /* To clear multiple BSS sections,
  231. * uncomment .zero.table section and,
  232. * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_psoc6_02_cm4.S */
  233. .zero.table :
  234. {
  235. . = ALIGN(4);
  236. __zero_table_start__ = .;
  237. LONG (__bss_start__)
  238. LONG (__bss_end__ - __bss_start__)
  239. __zero_table_end__ = .;
  240. } > flash
  241. __etext = . ;
  242. .ramVectors (NOLOAD) : ALIGN(8)
  243. {
  244. __ram_vectors_start__ = .;
  245. KEEP(*(.ram_vectors))
  246. __ram_vectors_end__ = .;
  247. } > ram
  248. .data __ram_vectors_end__ :
  249. {
  250. . = ALIGN(4);
  251. __data_start__ = .;
  252. *(vtable)
  253. *(.data*)
  254. . = ALIGN(4);
  255. /* preinit data */
  256. PROVIDE_HIDDEN (__preinit_array_start = .);
  257. KEEP(*(.preinit_array))
  258. PROVIDE_HIDDEN (__preinit_array_end = .);
  259. . = ALIGN(4);
  260. /* init data */
  261. PROVIDE_HIDDEN (__init_array_start = .);
  262. KEEP(*(SORT(.init_array.*)))
  263. KEEP(*(.init_array))
  264. PROVIDE_HIDDEN (__init_array_end = .);
  265. . = ALIGN(4);
  266. /* finit data */
  267. PROVIDE_HIDDEN (__fini_array_start = .);
  268. KEEP(*(SORT(.fini_array.*)))
  269. KEEP(*(.fini_array))
  270. PROVIDE_HIDDEN (__fini_array_end = .);
  271. KEEP(*(.jcr*))
  272. . = ALIGN(4);
  273. KEEP(*(.cy_ramfunc*))
  274. . = ALIGN(4);
  275. __data_end__ = .;
  276. } > ram AT>flash
  277. /* Place variables in the section that should not be initialized during the
  278. * device startup.
  279. */
  280. .noinit (NOLOAD) : ALIGN(8)
  281. {
  282. KEEP(*(.noinit))
  283. } > ram
  284. /* The uninitialized global or static variables are placed in this section.
  285. *
  286. * The NOLOAD attribute tells linker that .bss section does not consume
  287. * any space in the image. The NOLOAD attribute changes the .bss type to
  288. * NOBITS, and that makes linker to A) not allocate section in memory, and
  289. * A) put information to clear the section with all zeros during application
  290. * loading.
  291. *
  292. * Without the NOLOAD attribute, the .bss section might get PROGBITS type.
  293. * This makes linker to A) allocate zeroed section in memory, and B) copy
  294. * this section to RAM during application loading.
  295. */
  296. .bss (NOLOAD):
  297. {
  298. . = ALIGN(4);
  299. __bss_start__ = .;
  300. *(.bss*)
  301. *(COMMON)
  302. . = ALIGN(4);
  303. __bss_end__ = .;
  304. } > ram
  305. .heap (NOLOAD):
  306. {
  307. __HeapBase = .;
  308. __end__ = .;
  309. end = __end__;
  310. KEEP(*(.heap*))
  311. . = ORIGIN(ram) + LENGTH(ram) - STACK_SIZE;
  312. __HeapLimit = .;
  313. } > ram
  314. /* .stack_dummy section doesn't contains any symbols. It is only
  315. * used for linker to calculate size of stack sections, and assign
  316. * values to stack symbols later */
  317. .stack_dummy (NOLOAD):
  318. {
  319. KEEP(*(.stack*))
  320. } > ram
  321. /* Set stack top to end of RAM, and stack limit move down by
  322. * size of stack_dummy section */
  323. __StackTop = ORIGIN(ram) + LENGTH(ram);
  324. __StackLimit = __StackTop - SIZEOF(.stack_dummy);
  325. PROVIDE(__stack = __StackTop);
  326. /* Check if data + heap + stack exceeds RAM limit */
  327. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
  328. /* Used for the digital signature of the secure application and the Bootloader SDK application.
  329. * The size of the section depends on the required data size. */
  330. .cy_app_signature ORIGIN(flash) + LENGTH(flash) - 256 :
  331. {
  332. KEEP(*(.cy_app_signature))
  333. } > flash
  334. /* Emulated EEPROM Flash area */
  335. .cy_em_eeprom :
  336. {
  337. KEEP(*(.cy_em_eeprom))
  338. } > em_eeprom
  339. /* Supervisory Flash: User data */
  340. .cy_sflash_user_data :
  341. {
  342. KEEP(*(.cy_sflash_user_data))
  343. } > sflash_user_data
  344. /* Supervisory Flash: Normal Access Restrictions (NAR) */
  345. .cy_sflash_nar :
  346. {
  347. KEEP(*(.cy_sflash_nar))
  348. } > sflash_nar
  349. /* Supervisory Flash: Public Key */
  350. .cy_sflash_public_key :
  351. {
  352. KEEP(*(.cy_sflash_public_key))
  353. } > sflash_public_key
  354. /* Supervisory Flash: Table of Content # 2 */
  355. .cy_toc_part2 :
  356. {
  357. KEEP(*(.cy_toc_part2))
  358. } > sflash_toc_2
  359. /* Supervisory Flash: Table of Content # 2 Copy */
  360. .cy_rtoc_part2 :
  361. {
  362. KEEP(*(.cy_rtoc_part2))
  363. } > sflash_rtoc_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. /* These sections are used for additional metadata (silicon revision,
  379. * Silicon/JTAG ID, etc.) storage.
  380. */
  381. .cymeta 0x90500000 : { KEEP(*(.cymeta)) } :NONE
  382. }
  383. /* The following symbols used by the cymcuelftool. */
  384. /* Flash */
  385. __cy_memory_0_start = 0x10000000;
  386. __cy_memory_0_length = 0x00200000;
  387. __cy_memory_0_row_size = 0x200;
  388. /* Emulated EEPROM Flash area */
  389. __cy_memory_1_start = 0x14000000;
  390. __cy_memory_1_length = 0x8000;
  391. __cy_memory_1_row_size = 0x200;
  392. /* Supervisory Flash */
  393. __cy_memory_2_start = 0x16000000;
  394. __cy_memory_2_length = 0x8000;
  395. __cy_memory_2_row_size = 0x200;
  396. /* XIP */
  397. __cy_memory_3_start = 0x18000000;
  398. __cy_memory_3_length = 0x08000000;
  399. __cy_memory_3_row_size = 0x200;
  400. /* eFuse */
  401. __cy_memory_4_start = 0x90700000;
  402. __cy_memory_4_length = 0x100000;
  403. __cy_memory_4_row_size = 1;
  404. /* EOF */