link.ld 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472
  1. /***************************************************************************//**
  2. * \file cy8c6xx7_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 = 0x45800
  69. flash (rx) : ORIGIN = 0x10000000, LENGTH = 0x100000
  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. /* Read-only code (constants). */
  158. *(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)
  159. KEEP(*(.eh_frame*))
  160. /* section information for utest */
  161. . = ALIGN(4);
  162. __rt_utest_tc_tab_start = .;
  163. KEEP(*(UtestTcTab))
  164. __rt_utest_tc_tab_end = .;
  165. /* section information for finsh shell */
  166. . = ALIGN(4);
  167. __fsymtab_start = .;
  168. KEEP(*(FSymTab))
  169. __fsymtab_end = .;
  170. . = ALIGN(4);
  171. __vsymtab_start = .;
  172. KEEP(*(VSymTab))
  173. __vsymtab_end = .;
  174. . = ALIGN(4);
  175. /* section information for modules */
  176. . = ALIGN(4);
  177. __rtmsymtab_start = .;
  178. KEEP(*(RTMSymTab))
  179. __rtmsymtab_end = .;
  180. /* section information for initialization */
  181. . = ALIGN(4);
  182. __rt_init_start = .;
  183. KEEP(*(SORT(.rti_fn*)))
  184. __rt_init_end = .;
  185. } > flash
  186. .ARM.extab :
  187. {
  188. *(.ARM.extab* .gnu.linkonce.armextab.*)
  189. } > flash
  190. __exidx_start = .;
  191. .ARM.exidx :
  192. {
  193. *(.ARM.exidx* .gnu.linkonce.armexidx.*)
  194. } > flash
  195. __exidx_end = .;
  196. /* To copy multiple ROM to RAM sections,
  197. * uncomment .copy.table section and,
  198. * define __STARTUP_COPY_MULTIPLE in startup_psoc6_01_cm4.S */
  199. .copy.table :
  200. {
  201. . = ALIGN(4);
  202. __copy_table_start__ = .;
  203. /* Copy interrupt vectors from flash to RAM */
  204. LONG (__Vectors) /* From */
  205. LONG (__ram_vectors_start__) /* To */
  206. LONG (__Vectors_End - __Vectors) /* Size */
  207. /* Copy data section to RAM */
  208. LONG (__etext) /* From */
  209. LONG (__data_start__) /* To */
  210. LONG (__data_end__ - __data_start__) /* Size */
  211. __copy_table_end__ = .;
  212. } > flash
  213. /* To clear multiple BSS sections,
  214. * uncomment .zero.table section and,
  215. * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_psoc6_01_cm4.S */
  216. .zero.table :
  217. {
  218. . = ALIGN(4);
  219. __zero_table_start__ = .;
  220. LONG (__bss_start__)
  221. LONG (__bss_end__ - __bss_start__)
  222. __zero_table_end__ = .;
  223. } > flash
  224. __etext = . ;
  225. .ramVectors (NOLOAD) : ALIGN(8)
  226. {
  227. __ram_vectors_start__ = .;
  228. KEEP(*(.ram_vectors))
  229. __ram_vectors_end__ = .;
  230. } > ram
  231. .data __ram_vectors_end__ :
  232. {
  233. . = ALIGN(4);
  234. __data_start__ = .;
  235. *(vtable)
  236. *(.data*)
  237. . = ALIGN(4);
  238. /* preinit data */
  239. PROVIDE_HIDDEN (__preinit_array_start = .);
  240. KEEP(*(.preinit_array))
  241. PROVIDE_HIDDEN (__preinit_array_end = .);
  242. . = ALIGN(4);
  243. /* init data */
  244. PROVIDE_HIDDEN (__init_array_start = .);
  245. KEEP(*(SORT(.init_array.*)))
  246. KEEP(*(.init_array))
  247. PROVIDE_HIDDEN (__init_array_end = .);
  248. . = ALIGN(4);
  249. /* finit data */
  250. PROVIDE_HIDDEN (__fini_array_start = .);
  251. KEEP(*(SORT(.fini_array.*)))
  252. KEEP(*(.fini_array))
  253. PROVIDE_HIDDEN (__fini_array_end = .);
  254. KEEP(*(.jcr*))
  255. . = ALIGN(4);
  256. KEEP(*(.cy_ramfunc*))
  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 - SIZEOF(.stack_dummy);
  308. PROVIDE(__stack = __StackTop);
  309. /* Check if data + heap + stack exceeds RAM limit */
  310. ASSERT(__StackLimit >= __HeapLimit, "region RAM overflowed with stack")
  311. /* Used for the digital signature of the secure application and the Bootloader SDK application.
  312. * The size of the section depends on the required data size. */
  313. .cy_app_signature ORIGIN(flash) + LENGTH(flash) - 256 :
  314. {
  315. KEEP(*(.cy_app_signature))
  316. } > flash
  317. /* Emulated EEPROM Flash area */
  318. .cy_em_eeprom :
  319. {
  320. KEEP(*(.cy_em_eeprom))
  321. } > em_eeprom
  322. /* Supervisory Flash: User data */
  323. .cy_sflash_user_data :
  324. {
  325. KEEP(*(.cy_sflash_user_data))
  326. } > sflash_user_data
  327. /* Supervisory Flash: Normal Access Restrictions (NAR) */
  328. .cy_sflash_nar :
  329. {
  330. KEEP(*(.cy_sflash_nar))
  331. } > sflash_nar
  332. /* Supervisory Flash: Public Key */
  333. .cy_sflash_public_key :
  334. {
  335. KEEP(*(.cy_sflash_public_key))
  336. } > sflash_public_key
  337. /* Supervisory Flash: Table of Content # 2 */
  338. .cy_toc_part2 :
  339. {
  340. KEEP(*(.cy_toc_part2))
  341. } > sflash_toc_2
  342. /* Supervisory Flash: Table of Content # 2 Copy */
  343. .cy_rtoc_part2 :
  344. {
  345. KEEP(*(.cy_rtoc_part2))
  346. } > sflash_rtoc_2
  347. /* Places the code in the Execute in Place (XIP) section. See the smif driver
  348. * documentation for details.
  349. */
  350. cy_xip :
  351. {
  352. __cy_xip_start = .;
  353. KEEP(*(.cy_xip))
  354. __cy_xip_end = .;
  355. } > xip
  356. /* eFuse */
  357. .cy_efuse :
  358. {
  359. KEEP(*(.cy_efuse))
  360. } > efuse
  361. /* These sections are used for additional metadata (silicon revision,
  362. * Silicon/JTAG ID, etc.) storage.
  363. */
  364. .cymeta 0x90500000 : { KEEP(*(.cymeta)) } :NONE
  365. }
  366. /* The following symbols used by the cymcuelftool. */
  367. /* Flash */
  368. __cy_memory_0_start = 0x10000000;
  369. __cy_memory_0_length = 0x00100000;
  370. __cy_memory_0_row_size = 0x200;
  371. /* Emulated EEPROM Flash area */
  372. __cy_memory_1_start = 0x14000000;
  373. __cy_memory_1_length = 0x8000;
  374. __cy_memory_1_row_size = 0x200;
  375. /* Supervisory Flash */
  376. __cy_memory_2_start = 0x16000000;
  377. __cy_memory_2_length = 0x8000;
  378. __cy_memory_2_row_size = 0x200;
  379. /* XIP */
  380. __cy_memory_3_start = 0x18000000;
  381. __cy_memory_3_length = 0x08000000;
  382. __cy_memory_3_row_size = 0x200;
  383. /* eFuse */
  384. __cy_memory_4_start = 0x90700000;
  385. __cy_memory_4_length = 0x100000;
  386. __cy_memory_4_row_size = 1;
  387. /* EOF */