cy8c6xx7_cm4_dual.ld 13 KB

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