blob: c6204799c347794d77c7c5c480b67394a6db3489 [file] [log] [blame]
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +02001/***************************************************************************//**
2* \file cy8c6xxa_cm0plus.ld
3* \version 2.60
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
38OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
39SEARCH_DIR(.)
40GROUP(-lgcc -lc -lnosys)
41ENTRY(Reset_Handler)
42
43/* Size of the stack section at the end of CM0+ SRAM */
44STACK_SIZE = 0x1000;
45
46/* Force symbol to be entered in the output file as an undefined symbol. Doing
47* this may, for example, trigger linking of additional modules from standard
48* libraries. You may list several symbols for each EXTERN, and you may use
49* EXTERN multiple times. This command has the same effect as the -u command-line
50* option.
51*/
52EXTERN(Reset_Handler)
53
54/* The MEMORY section below describes the location and size of blocks of memory in the target.
55* Use this section to specify the memory regions available for allocation.
56*/
57MEMORY
58{
59 /* The ram and flash regions control RAM and flash memory allocation for the CM0+ core.
60 * You can change the memory allocation by editing the 'ram' and 'flash' regions.
61 * Note that 2 KB of RAM (at the end of the SRAM) are reserved for system use.
62 * Using this memory region for other purposes will lead to unexpected behavior.
63 * Your changes must be aligned with the corresponding memory regions for the CM4 core in 'xx_cm4_dual.ld',
64 * where 'xx' is the device group; for example, 'cy8c6xx7_cm4_dual.ld'.
65 */
Bohdan Kovalchuk0324f1b2020-05-26 08:04:24 -050066 ram (rwx) : ORIGIN = 0x08020000, LENGTH = 0x20000
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020067 flash (rx) : ORIGIN = 0x10000000, LENGTH = 0x18000
68
69 /* This is a 32K flash region used for EEPROM emulation. This region can also be used as the general purpose flash.
70 * You can assign sections to this memory region for only one of the cores.
71 * Note some middleware (e.g. BLE, Emulated EEPROM) can place their data into this memory region.
72 * Therefore, repurposing this memory region will prevent such middleware from operation.
73 */
74 em_eeprom (rx) : ORIGIN = 0x14000000, LENGTH = 0x8000 /* 32 KB */
75
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
86/* Library configurations */
87GROUP(libgcc.a libc.a libm.a libnosys.a)
88
89/* Linker script to place sections and symbol values. Should be used together
90 * with other linker script that defines memory regions FLASH and RAM.
91 * It references following symbols, which must be defined in code:
92 * Reset_Handler : Entry of reset handler
93 *
94 * It defines following symbols, which code can use without definition:
95 * __exidx_start
96 * __exidx_end
97 * __copy_table_start__
98 * __copy_table_end__
99 * __zero_table_start__
100 * __zero_table_end__
101 * __etext
102 * __data_start__
103 * __preinit_array_start
104 * __preinit_array_end
105 * __init_array_start
106 * __init_array_end
107 * __fini_array_start
108 * __fini_array_end
109 * __data_end__
110 * __bss_start__
111 * __bss_end__
112 * __end__
113 * end
114 * __HeapLimit
115 * __StackLimit
116 * __StackTop
117 * __stack
118 * __Vectors_End
119 * __Vectors_Size
120 */
121
122
123SECTIONS
124{
125 .cy_app_header :
126 {
127 KEEP(*(.cy_app_header))
128 } > flash
129
130 /* Cortex-M0+ application flash area */
131 .text :
132 {
133 . = ALIGN(4);
134 __Vectors = . ;
135 KEEP(*(.vectors))
136 . = ALIGN(4);
137 __Vectors_End = .;
138 __Vectors_Size = __Vectors_End - __Vectors;
139 __end__ = .;
140
141 . = ALIGN(4);
142 *(.text*)
143
144 KEEP(*(.init))
145 KEEP(*(.fini))
146
147 /* .ctors */
148 *crtbegin.o(.ctors)
149 *crtbegin?.o(.ctors)
150 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
151 *(SORT(.ctors.*))
152 *(.ctors)
153
154 /* .dtors */
155 *crtbegin.o(.dtors)
156 *crtbegin?.o(.dtors)
157 *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
158 *(SORT(.dtors.*))
159 *(.dtors)
160
161 /* Read-only code (constants). */
162 *(.rodata .rodata.* .constdata .constdata.* .conststring .conststring.*)
163
164 KEEP(*(.eh_frame*))
165 } > flash
166
167
168 .ARM.extab :
169 {
170 *(.ARM.extab* .gnu.linkonce.armextab.*)
171 } > flash
172
173 __exidx_start = .;
174
175 .ARM.exidx :
176 {
177 *(.ARM.exidx* .gnu.linkonce.armexidx.*)
178 } > flash
179 __exidx_end = .;
180
181
182 /* To copy multiple ROM to RAM sections,
183 * uncomment .copy.table section and,
184 * define __STARTUP_COPY_MULTIPLE in startup_psoc6_02_cm0plus.S */
185 .copy.table :
186 {
187 . = ALIGN(4);
188 __copy_table_start__ = .;
189
190 /* Copy interrupt vectors from flash to RAM */
191 LONG (__Vectors) /* From */
192 LONG (__ram_vectors_start__) /* To */
193 LONG (__Vectors_End - __Vectors) /* Size */
194
195 /* Copy data section to RAM */
196 LONG (__etext) /* From */
197 LONG (__data_start__) /* To */
198 LONG (__data_end__ - __data_start__) /* Size */
199
200 __copy_table_end__ = .;
201 } > flash
202
203
204 /* To clear multiple BSS sections,
205 * uncomment .zero.table section and,
206 * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_psoc6_02_cm0plus.S */
207 .zero.table :
208 {
209 . = ALIGN(4);
210 __zero_table_start__ = .;
211 LONG (__bss_start__)
212 LONG (__bss_end__ - __bss_start__)
213 __zero_table_end__ = .;
214 } > flash
215
216 __etext = . ;
217
218 /* Set stack top to end of RAM, and stack limit move down by
219 * size of stack_dummy section */
220 __StackTop = ORIGIN(ram) + LENGTH(ram);
221 __StackLimit = __StackTop - STACK_SIZE ;
222 PROVIDE(__stack = __StackTop);
223
224 .stackSpace (NOLOAD) : ALIGN(8)
225 {
226 . = . + STACK_SIZE ;
227 } > ram
228
229 .ramVectors (NOLOAD) : ALIGN(8)
230 {
231 __ram_vectors_start__ = .;
232 KEEP(*(.ram_vectors))
233 __ram_vectors_end__ = .;
234 } > ram
235
236
237 .data __ram_vectors_end__ : AT (__etext)
238 {
239 __data_start__ = .;
240
241 *(vtable)
242 *(.data*)
243
244 . = ALIGN(4);
245 /* preinit data */
246 PROVIDE_HIDDEN (__preinit_array_start = .);
247 KEEP(*(.preinit_array))
248 PROVIDE_HIDDEN (__preinit_array_end = .);
249
250 . = ALIGN(4);
251 /* init data */
252 PROVIDE_HIDDEN (__init_array_start = .);
253 KEEP(*(SORT(.init_array.*)))
254 KEEP(*(.init_array))
255 PROVIDE_HIDDEN (__init_array_end = .);
256
257 . = ALIGN(4);
258 /* finit data */
259 PROVIDE_HIDDEN (__fini_array_start = .);
260 KEEP(*(SORT(.fini_array.*)))
261 KEEP(*(.fini_array))
262 PROVIDE_HIDDEN (__fini_array_end = .);
263
264 KEEP(*(.jcr*))
265 . = ALIGN(4);
266
267 KEEP(*(.cy_ramfunc*))
268 . = ALIGN(4);
269
270 __data_end__ = .;
271
272 } > ram
273
274
275 /* Place variables in the section that should not be initialized during the
276 * device startup.
277 */
278 .noinit (NOLOAD) : ALIGN(8)
279 {
280 KEEP(*(.noinit))
281 } > ram
282
283
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
306 .heap (NOLOAD):
307 {
308 __HeapBase = .;
309 __end__ = .;
310 end = __end__;
311 KEEP(*(.heap*))
312 . = ORIGIN(ram) + LENGTH(ram);
313 __HeapLimit = .;
314 } > ram
315
316
317 /* Emulated EEPROM Flash area */
318 .cy_em_eeprom :
319 {
320 KEEP(*(.cy_em_eeprom))
321 } > em_eeprom
322
323
324 /* Supervisory Flash: User data */
325 .cy_sflash_user_data :
326 {
327 KEEP(*(.cy_sflash_user_data))
328 } > sflash_user_data
329
330
331 /* Supervisory Flash: Normal Access Restrictions (NAR) */
332 .cy_sflash_nar :
333 {
334 KEEP(*(.cy_sflash_nar))
335 } > sflash_nar
336
337
338 /* Supervisory Flash: Public Key */
339 .cy_sflash_public_key :
340 {
341 KEEP(*(.cy_sflash_public_key))
342 } > sflash_public_key
343
344
345 /* Supervisory Flash: Table of Content # 2 */
346 .cy_toc_part2 :
347 {
348 KEEP(*(.cy_toc_part2))
349 } > sflash_toc_2
350
351
352 /* Supervisory Flash: Table of Content # 2 Copy */
353 .cy_rtoc_part2 :
354 {
355 KEEP(*(.cy_rtoc_part2))
356 } > sflash_rtoc_2
357
358
359 /* Places the code in the Execute in Place (XIP) section. See the smif driver
360 * documentation for details.
361 */
362 .cy_xip :
363 {
364 KEEP(*(.cy_xip))
365 } > xip
366
367
368 /* eFuse */
369 .cy_efuse :
370 {
371 KEEP(*(.cy_efuse))
372 } > efuse
373
374
375 /* These sections are used for additional metadata (silicon revision,
376 * Silicon/JTAG ID, etc.) storage.
377 */
378 .cymeta 0x90500000 : { KEEP(*(.cymeta)) } :NONE
379}
380
381
382/* The following symbols used by the cymcuelftool. */
383/* Flash */
384__cy_memory_0_start = 0x10000000;
385__cy_memory_0_length = 0x00200000;
386__cy_memory_0_row_size = 0x200;
387
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
393/* Supervisory Flash */
394__cy_memory_2_start = 0x16000000;
395__cy_memory_2_length = 0x8000;
396__cy_memory_2_row_size = 0x200;
397
398/* XIP */
399__cy_memory_3_start = 0x18000000;
400__cy_memory_3_length = 0x08000000;
401__cy_memory_3_row_size = 0x200;
402
403/* eFuse */
404__cy_memory_4_start = 0x90700000;
405__cy_memory_4_length = 0x100000;
406__cy_memory_4_row_size = 1;
407
408/* EOF */