1/*
2                  Linker File for Renesas FSP
3*/
4
5INCLUDE memory_regions.ld
6
7/* Uncomment and set XIP_SECONDARY_SLOT_IMAGE to 1 below for the secondary XIP application image.*/
8/*
9 XIP_SECONDARY_SLOT_IMAGE = 1;
10*/
11
12QSPI_FLASH_PRV_LENGTH = DEFINED(QSPI_FLASH_SIZE) ? ABSOLUTE(QSPI_FLASH_SIZE) : ABSOLUTE(QSPI_FLASH_LENGTH);
13OSPI_DEVICE_0_PRV_LENGTH = DEFINED(OSPI_DEVICE_0_SIZE) ? ABSOLUTE(OSPI_DEVICE_0_SIZE) : ABSOLUTE(OSPI_DEVICE_0_LENGTH);
14OSPI_DEVICE_1_PRV_LENGTH = DEFINED(OSPI_DEVICE_1_SIZE) ? ABSOLUTE(OSPI_DEVICE_1_SIZE) : ABSOLUTE(OSPI_DEVICE_1_LENGTH);
15
16/* If a flat (secure) project has DEFINED RAM_NS_BUFFER_LENGTH, then emit IDAU symbols to allocate non-secure RAM. */
17__RESERVE_NS_RAM = !DEFINED(PROJECT_NONSECURE) && DEFINED(RAM_NS_BUFFER_LENGTH) && (OPTION_SETTING_S_LENGTH != 0);
18
19RAM_NS_BUFFER_BLOCK_LENGTH = DEFINED(RAM_NS_BUFFER_LENGTH) ? ALIGN(RAM_NS_BUFFER_LENGTH, 8192) : 0;
20RAM_NS_BUFFER_LENGTH = DEFINED(RAM_NS_BUFFER_LENGTH) ? RAM_NS_BUFFER_LENGTH : 0;
21RAM_NS_BUFFER_START = RAM_START + RAM_LENGTH - RAM_NS_BUFFER_LENGTH;
22RAM_NS_BUFFER_BLOCK_START = RAM_START + RAM_LENGTH - RAM_NS_BUFFER_BLOCK_LENGTH;
23
24OPTION_SETTING_START_NS = 0x0100A180;
25
26/* This definition is used to avoid moving the counter in OPTION_SETTING regions for projects that should not configure option settings.
27 * Bootloader images do not configure option settings because they are owned by the bootloader.
28 * FSP_BOOTABLE_IMAGE is only defined in bootloader images. */
29__bl_FSP_BOOTABLE_IMAGE = 1;
30__bln_FSP_BOOTABLE_IMAGE = 1;
31PROJECT_SECURE_OR_FLAT = !DEFINED(PROJECT_NONSECURE) && OPTION_SETTING_LENGTH && !DEFINED(FSP_BOOTABLE_IMAGE);
32USE_OPTION_SETTING_NS = DEFINED(PROJECT_NONSECURE) && !DEFINED(FSP_BOOTABLE_IMAGE);
33
34__bl_FLASH_IMAGE_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
35                         FLASH_APPLICATION_IMAGE_NUMBER == 1 ? FLASH_BOOTLOADER_LENGTH + FLASH_BOOTLOADER_HEADER_LENGTH :
36                         FLASH_BOOTLOADER_LENGTH + FLASH_BOOTLOADER_SCRATCH_LENGTH + FLASH_APPLICATION_S_LENGTH + FLASH_BOOTLOADER_HEADER_LENGTH;
37__bl_FLASH_IMAGE_LENGTH = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
38                          FLASH_APPLICATION_S_LENGTH - FLASH_BOOTLOADER_HEADER_LENGTH;
39__bl_FLASH_IMAGE_END    = __bl_FLASH_IMAGE_START + __bl_FLASH_IMAGE_LENGTH;
40__bl_XIP_SECONDARY_FLASH_IMAGE_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
41                         FLASH_BOOTLOADER_LENGTH + FLASH_APPLICATION_S_LENGTH + FLASH_BOOTLOADER_HEADER_LENGTH;
42__bl_XIP_SECONDARY_FLASH_IMAGE_END = __bl_XIP_SECONDARY_FLASH_IMAGE_START + __bl_FLASH_IMAGE_LENGTH;
43__bl_FLASH_NS_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
44                        FLASH_APPLICATION_NS_LENGTH == 0 ? __bl_FLASH_IMAGE_END :
45                        __bl_FLASH_IMAGE_START - FLASH_BOOTLOADER_HEADER_LENGTH + FLASH_APPLICATION_S_LENGTH;
46__bl_FLASH_NSC_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
47                        FLASH_APPLICATION_NS_LENGTH == 0 ? __bl_FLASH_IMAGE_END :
48                        __bl_FLASH_NS_START - FLASH_APPLICATION_NSC_LENGTH;
49__bl_RAM_NS_START    = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
50                       FLASH_APPLICATION_NS_LENGTH == 0 ? RAM_START + RAM_LENGTH :
51                       RAM_START + RAM_LENGTH - RAM_APPLICATION_NS_LENGTH;
52__bl_RAM_NSC_START   = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
53                       FLASH_APPLICATION_NS_LENGTH == 0 ? RAM_START + RAM_LENGTH :
54                       __bl_RAM_NS_START - RAM_APPLICATION_NSC_LENGTH;
55__bl_FLASH_NS_IMAGE_START = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
56                            FLASH_APPLICATION_NS_LENGTH == 0 ? __bl_FLASH_IMAGE_END :
57                            __bl_FLASH_NS_START + FLASH_BOOTLOADER_HEADER_LENGTH_2;
58__bln_FLASH_IMAGE_START = __bl_FLASH_NS_IMAGE_START;
59__bln_FLASH_IMAGE_LENGTH = !DEFINED(FLASH_BOOTLOADER_LENGTH) ? 0 :
60                           FLASH_APPLICATION_NS_LENGTH == 0 ? __bl_FLASH_IMAGE_END :
61                           FLASH_APPLICATION_NS_LENGTH - FLASH_BOOTLOADER_HEADER_LENGTH_2;
62
63XIP_SECONDARY_SLOT_IMAGE = DEFINED(XIP_SECONDARY_SLOT_IMAGE) ? XIP_SECONDARY_SLOT_IMAGE : 0;
64FLASH_ORIGIN = !DEFINED(FLASH_IMAGE_START) ? FLASH_START :
65                XIP_SECONDARY_SLOT_IMAGE == 1 ? XIP_SECONDARY_FLASH_IMAGE_START :
66                FLASH_IMAGE_START;
67LIMITED_FLASH_LENGTH = DEFINED(FLASH_IMAGE_LENGTH) ? FLASH_IMAGE_LENGTH :
68                       DEFINED(FLASH_BOOTLOADER_LENGTH) ? FLASH_BOOTLOADER_LENGTH :
69                       FLASH_LENGTH;
70
71/* Define memory regions. */
72MEMORY
73{
74  FLASH (rx)      : ORIGIN = FLASH_ORIGIN, LENGTH = LIMITED_FLASH_LENGTH
75  RAM (rwx)       : ORIGIN = RAM_START, LENGTH = RAM_LENGTH
76  DATA_FLASH (rx) : ORIGIN = DATA_FLASH_START, LENGTH = DATA_FLASH_LENGTH
77  QSPI_FLASH (rx) : ORIGIN = QSPI_FLASH_START, LENGTH = QSPI_FLASH_PRV_LENGTH
78  OSPI_DEVICE_0 (rx) : ORIGIN = OSPI_DEVICE_0_START, LENGTH = OSPI_DEVICE_0_PRV_LENGTH
79  OSPI_DEVICE_1 (rx) : ORIGIN = OSPI_DEVICE_1_START, LENGTH = OSPI_DEVICE_1_PRV_LENGTH
80  OSPI_DEVICE_0_RAM (rwx) : ORIGIN = OSPI_DEVICE_0_START, LENGTH = OSPI_DEVICE_0_PRV_LENGTH
81  OSPI_DEVICE_1_RAM (rwx) : ORIGIN = OSPI_DEVICE_1_START, LENGTH = OSPI_DEVICE_1_PRV_LENGTH
82  SDRAM (rwx)     : ORIGIN = SDRAM_START, LENGTH = SDRAM_LENGTH
83  OPTION_SETTING (r): ORIGIN = OPTION_SETTING_START, LENGTH = OPTION_SETTING_LENGTH
84  OPTION_SETTING_S (r): ORIGIN = OPTION_SETTING_S_START, LENGTH = OPTION_SETTING_S_LENGTH
85  ID_CODE (rx)    : ORIGIN = ID_CODE_START, LENGTH = ID_CODE_LENGTH
86}
87
88/* Library configurations */
89GROUP(libgcc.a libc.a libm.a libnosys.a)
90
91/* Linker script to place sections and symbol values. Should be used together
92 * with other linker script that defines memory regions FLASH and RAM.
93 * It references following symbols, which must be DEFINED in code:
94 *   Reset_Handler : Entry of reset handler
95 *
96 * It defines following symbols, which code can use without definition:
97 *   __exidx_start
98 *   __exidx_end
99 *   __copy_table_start__
100 *   __copy_table_end__
101 *   __zero_table_start__
102 *   __zero_table_end__
103 *   __etext
104 *   __data_start__
105 *   __preinit_array_start
106 *   __preinit_array_end
107 *   __init_array_start
108 *   __init_array_end
109 *   __fini_array_start
110 *   __fini_array_end
111 *   __data_end__
112 *   __bss_start__
113 *   __bss_end__
114 *   __HeapLimit
115 *   __StackLimit
116 *   __StackTop
117 *   __stack
118 *   __Vectors_End
119 *   __Vectors_Size
120 *   __qspi_flash_start__
121 *   __qspi_flash_end__
122 *   __qspi_flash_code_size__
123 *   __qspi_region_max_size__
124 *   __qspi_region_start_address__
125 *   __qspi_region_end_address__
126 *   __ospi_device_0_start__
127 *   __ospi_device_0_end__
128 *   __ospi_device_0_code_size__
129 *   __ospi_device_0_region_max_size__
130 *   __ospi_device_0_region_start_address__
131 *   __ospi_device_0_region_end_address__
132 *   __ospi_device_1_start__
133 *   __ospi_device_1_end__
134 *   __ospi_device_1_code_size__
135 *   __ospi_device_1_region_max_size__
136 *   __ospi_device_1_region_start_address__
137 *   __ospi_device_1_region_end_address__
138 */
139ENTRY(Reset_Handler)
140
141SECTIONS
142{
143    .text :
144    {
145        __tz_FLASH_S = ABSOLUTE(FLASH_START);
146        __ROM_Start = .;
147
148        /* Even though the vector table is not 256 entries (1KB) long, we still allocate that much
149         * space because ROM registers are at address 0x400 and there is very little space
150         * in between. */
151        KEEP(*(.fixed_vectors*))
152        KEEP(*(.application_vectors*))
153        __Vectors_End = .;
154
155        /* ROM Registers start at address 0x00000400 for devices that do not have the OPTION_SETTING region. */
156        . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x400;
157        KEEP(*(.rom_registers*))
158
159        /* Reserving 0x100 bytes of space for ROM registers. */
160        . = OPTION_SETTING_LENGTH > 0 ? . : __ROM_Start + 0x500;
161
162        /* Allocate flash write-boundary-aligned
163         * space for sce9 wrapped public keys for mcuboot if the module is used.
164         */
165		. = ALIGN(128);
166        KEEP(*(.mcuboot_sce9_key*))
167
168        *(.text*)
169
170        KEEP(*(.version))
171        KEEP(*(.init))
172        KEEP(*(.fini))
173
174        /* section information for finsh shell */
175        . = ALIGN(4);
176        __fsymtab_start = .;
177        KEEP(*(FSymTab))
178        __fsymtab_end = .;
179
180        . = ALIGN(4);
181        __vsymtab_start = .;
182        KEEP(*(VSymTab))
183        __vsymtab_end = .;
184
185        /* section information for initial. */
186        . = ALIGN(4);
187        __rt_init_start = .;
188        KEEP(*(SORT(.rti_fn*)))
189        __rt_init_end = .;
190
191        . = ALIGN(4);
192        KEEP(*(FalPartTable))
193
194        /* .ctors */
195        *crtbegin.o(.ctors)
196        *crtbegin?.o(.ctors)
197        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors)
198        *(SORT(.ctors.*))
199        *(.ctors)
200
201        /* .dtors */
202        *crtbegin.o(.dtors)
203        *crtbegin?.o(.dtors)
204        *(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors)
205        *(SORT(.dtors.*))
206        *(.dtors)
207
208        *(.rodata*)
209        __usb_dev_descriptor_start_fs = .;
210        KEEP(*(.usb_device_desc_fs*))
211        __usb_cfg_descriptor_start_fs = .;
212        KEEP(*(.usb_config_desc_fs*))
213        __usb_interface_descriptor_start_fs = .;
214        KEEP(*(.usb_interface_desc_fs*))
215        __usb_descriptor_end_fs = .;
216        __usb_dev_descriptor_start_hs = .;
217        KEEP(*(.usb_device_desc_hs*))
218        __usb_cfg_descriptor_start_hs = .;
219        KEEP(*(.usb_config_desc_hs*))
220        __usb_interface_descriptor_start_hs = .;
221        KEEP(*(.usb_interface_desc_hs*))
222        __usb_descriptor_end_hs = .;
223
224        KEEP(*(.eh_frame*))
225
226        __ROM_End = .;
227    } > FLASH = 0xFF
228
229    __Vectors_Size = __Vectors_End - __Vectors;
230
231    .ARM.extab :
232    {
233        *(.ARM.extab* .gnu.linkonce.armextab.*)
234    } > FLASH
235
236    __exidx_start = .;
237    .ARM.exidx :
238    {
239        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
240    } > FLASH
241    __exidx_end = .;
242
243    /* To copy multiple ROM to RAM sections,
244     * uncomment .copy.table section and,
245     * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
246    /*
247    .copy.table :
248    {
249        . = ALIGN(4);
250        __copy_table_start__ = .;
251        LONG (__etext)
252        LONG (__data_start__)
253        LONG (__data_end__ - __data_start__)
254        LONG (__etext2)
255        LONG (__data2_start__)
256        LONG (__data2_end__ - __data2_start__)
257        __copy_table_end__ = .;
258    } > FLASH
259    */
260
261    /* To clear multiple BSS sections,
262     * uncomment .zero.table section and,
263     * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
264    /*
265    .zero.table :
266    {
267        . = ALIGN(4);
268        __zero_table_start__ = .;
269        LONG (__bss_start__)
270        LONG (__bss_end__ - __bss_start__)
271        LONG (__bss2_start__)
272        LONG (__bss2_end__ - __bss2_start__)
273        __zero_table_end__ = .;
274    } > FLASH
275    */
276
277    __etext = .;
278
279    __tz_RAM_S = ORIGIN(RAM);
280
281    /* If DTC is used, put the DTC vector table at the start of SRAM.
282       This avoids memory holes due to 1K alignment required by it. */
283    .fsp_dtc_vector_table (NOLOAD) :
284    {
285        . = ORIGIN(RAM);
286        *(.fsp_dtc_vector_table)
287    } > RAM
288
289    /* Initialized data section. */
290    .data :
291    {
292        __data_start__ = .;
293        . = ALIGN(4);
294
295        __Code_In_RAM_Start = .;
296
297        KEEP(*(.code_in_ram*))
298        __Code_In_RAM_End = .;
299
300        *(vtable)
301        /* Don't use *(.data*) because it will place data meant for .data_flash in this section. */
302        *(.data.*)
303        *(.data)
304
305        . = ALIGN(4);
306        /* preinit data */
307        PROVIDE_HIDDEN (__preinit_array_start = .);
308        KEEP(*(.preinit_array))
309        PROVIDE_HIDDEN (__preinit_array_end = .);
310
311        . = ALIGN(4);
312        /* init data */
313        PROVIDE_HIDDEN (__init_array_start = .);
314        KEEP(*(SORT(.init_array.*)))
315        KEEP(*(.init_array))
316        PROVIDE_HIDDEN (__init_array_end = .);
317
318
319        . = ALIGN(4);
320        /* finit data */
321        PROVIDE_HIDDEN (__fini_array_start = .);
322        KEEP(*(SORT(.fini_array.*)))
323        KEEP(*(.fini_array))
324        PROVIDE_HIDDEN (__fini_array_end = .);
325
326        KEEP(*(.jcr*))
327
328        . = ALIGN(4);
329
330        /* All data end */
331        __data_end__ = .;
332
333    } > RAM AT > FLASH
334
335
336    /* TrustZone Secure Gateway Stubs Section. */
337
338    /* Some arithmetic is needed to eliminate unnecessary FILL for secure projects. */
339    /* 1. Get the address to the next block after the .data section in FLASH. */
340    DATA_END = LOADADDR(.data) + SIZEOF(.data);
341    /* 2. Determine the secure gateway stubs address either by the provided linker variable or the next 1024-byte block after .data */
342    SGSTUBS_LOC = (DEFINED(PROJECT_SECURE) && DEFINED(FLASH_NSC_START)) ? ABSOLUTE(FLASH_NSC_START) : ALIGN(DATA_END, 1024);
343    /* 3. Manually specify the start location for .gnu.sgstubs */
344    .gnu.sgstubs SGSTUBS_LOC : ALIGN(1024)
345    {
346        __tz_FLASH_C = DEFINED(FLASH_NSC_START) ? ABSOLUTE(FLASH_NSC_START) : __RESERVE_NS_RAM ? ABSOLUTE(FLASH_START + FLASH_LENGTH) : ALIGN(1024);
347        _start_sg = .;
348        *(.gnu.sgstubs*)
349        . = ALIGN(32);
350        _end_sg = .;
351    } > FLASH
352
353    __tz_FLASH_N = DEFINED(FLASH_NS_START) ? ABSOLUTE(FLASH_NS_START) : __RESERVE_NS_RAM ? ABSOLUTE(FLASH_START + FLASH_LENGTH) : FLASH_LENGTH < 32768 ? FLASH_LENGTH : ALIGN(32768);
354    FLASH_NS_IMAGE_START = DEFINED(FLASH_NS_IMAGE_START) ? FLASH_NS_IMAGE_START : __tz_FLASH_N;
355
356    /* Note: There are no secure/non-secure boundaries for QSPI.  These symbols are provided for the RA configuration tool. */
357    __tz_QSPI_FLASH_S = ORIGIN(QSPI_FLASH);
358
359    /* QSPI_FLASH section to be downloaded via debugger */
360    .qspi_flash :
361    {
362        __qspi_flash_start__ = .;
363        KEEP(*(.qspi_flash*))
364        KEEP(*(.code_in_qspi*))
365        __qspi_flash_end__ = .;
366    } > QSPI_FLASH
367    __qspi_flash_code_size__ = __qspi_flash_end__ - __qspi_flash_start__;
368
369    /* QSPI_FLASH non-retentive section, creates a copy in internal flash that can be copied to QSPI */
370    __qspi_flash_code_addr__ = __etext + (__data_end__ - __data_start__);
371    .qspi_non_retentive : AT (__qspi_flash_code_addr__)
372    {
373        __qspi_non_retentive_start__ = .;
374        KEEP(*(.qspi_non_retentive*))
375        __qspi_non_retentive_end__ = .;
376    } > QSPI_FLASH
377    __qspi_non_retentive_size__ = __qspi_non_retentive_end__ - __qspi_non_retentive_start__;
378
379    __qspi_region_max_size__ = 0x4000000;   /* Must be the same as defined in MEMORY above */
380    __qspi_region_start_address__ = __qspi_flash_start__;
381    __qspi_region_end_address__ = __qspi_flash_start__ + __qspi_region_max_size__;
382
383    /* Note: There are no secure/non-secure boundaries for QSPI.  These symbols are provided for the RA configuration tool. */
384    __tz_QSPI_FLASH_N = __qspi_non_retentive_end__;
385
386    /* Support for OctaRAM */
387    .OSPI_DEVICE_0_NO_LOAD (NOLOAD):
388    {
389        . = ALIGN(4);
390        __ospi_device_0_start__ = .;
391        *(.ospi_device_0_no_load*)
392        . = ALIGN(4);
393        __ospi_device_0_end__ = .;
394    } > OSPI_DEVICE_0_RAM
395
396    .OSPI_DEVICE_1_NO_LOAD (NOLOAD):
397    {
398        . = ALIGN(4);
399        __ospi_device_1_start__ = .;
400        *(.ospi_device_1_no_load*)
401        . = ALIGN(4);
402        __ospi_device_1_end__ = .;
403    } > OSPI_DEVICE_1_RAM
404
405    /* Note: There are no secure/non-secure boundaries for QSPI.  These symbols are provided for the RA configuration tool. */
406    __tz_OSPI_DEVICE_0_S = ORIGIN(OSPI_DEVICE_0);
407
408    /* OSPI_DEVICE_0 section to be downloaded via debugger */
409    .OSPI_DEVICE_0 :
410    {
411        __ospi_device_0_start__ = .;
412        KEEP(*(.ospi_device_0*))
413        KEEP(*(.code_in_ospi_device_0*))
414        __ospi_device_0_end__ = .;
415    } > OSPI_DEVICE_0
416    __ospi_device_0_code_size__ = __ospi_device_0_end__ - __ospi_device_0_start__;
417
418    /* OSPI_DEVICE_0 non-retentive section, creates a copy in internal flash that can be copied to OSPI */
419    __ospi_device_0_code_addr__ = __etext + (__data_end__ - __data_start__);
420    .ospi_device_0_non_retentive : AT (__ospi_device_0_code_addr__)
421    {
422        __ospi_device_0_non_retentive_start__ = .;
423        KEEP(*(.ospi_device_0_non_retentive*))
424        __ospi_device_0_non_retentive_end__ = .;
425    } > OSPI_DEVICE_0
426    __ospi_device_0_non_retentive_size__ = __ospi_device_0_non_retentive_end__ - __ospi_device_0_non_retentive_start__;
427
428    __ospi_device_0_region_max_size__ = 0x8000000;   /* Must be the same as defined in MEMORY above */
429    __ospi_device_0_region_start_address__ = __ospi_device_0_start__;
430    __ospi_device_0_region_end_address__ = __ospi_device_0_start__ + __ospi_device_0_region_max_size__;
431
432    /* Note: There are no secure/non-secure boundaries for OSPI.  These symbols are provided for the RA configuration tool. */
433    __tz_OSPI_DEVICE_0_N = __ospi_device_0_non_retentive_end__;
434
435    /* Note: There are no secure/non-secure boundaries for OSPI.  These symbols are provided for the RA configuration tool. */
436    __tz_OSPI_DEVICE_1_S = ORIGIN(OSPI_DEVICE_1);
437
438    /* OSPI_DEVICE_1 section to be downloaded via debugger */
439    .OSPI_DEVICE_1 :
440    {
441        __ospi_device_1_start__ = .;
442        KEEP(*(.ospi_device_1*))
443        KEEP(*(.code_in_ospi_device_1*))
444        __ospi_device_1_end__ = .;
445    } > OSPI_DEVICE_1
446    __ospi_device_1_code_size__ = __ospi_device_1_end__ - __ospi_device_1_start__;
447
448    /* OSPI_DEVICE_1 non-retentive section, creates a copy in internal flash that can be copied to OSPI */
449    __ospi_device_1_code_addr__ = __etext + (__data_end__ - __data_start__);
450    .ospi_device_1_non_retentive : AT (__ospi_device_1_code_addr__)
451    {
452        __ospi_device_1_non_retentive_start__ = .;
453        KEEP(*(.ospi_device_1_non_retentive*))
454        __ospi_device_1_non_retentive_end__ = .;
455    } > OSPI_DEVICE_1
456    __ospi_device_1_non_retentive_size__ = __ospi_device_1_non_retentive_end__ - __ospi_device_1_non_retentive_start__;
457
458    __ospi_device_1_region_max_size__ = 0x10000000;   /* Must be the same as defined in MEMORY above */
459    __ospi_device_1_region_start_address__ = __ospi_device_1_start__;
460    __ospi_device_1_region_end_address__ = __ospi_device_1_start__ + __ospi_device_1_region_max_size__;
461
462    /* Note: There are no secure/non-secure boundaries for OSPI.  These symbols are provided for the RA configuration tool. */
463    __tz_OSPI_DEVICE_1_N = __ospi_device_1_non_retentive_end__;
464
465    .noinit (NOLOAD):
466    {
467        . = ALIGN(4);
468        __noinit_start = .;
469        KEEP(*(.noinit*))
470        . = ALIGN(8);
471        /* Place the FreeRTOS heap here so that the __HeapLimit calculation does not include the freertos heap. */
472        KEEP(*(.heap.*))
473        __noinit_end = .;
474    } > RAM
475
476    .bss :
477    {
478        . = ALIGN(4);
479        __bss_start__ = .;
480        *(.bss*)
481        *(COMMON)
482        . = ALIGN(4);
483        __bss_end__ = .;
484    } > RAM
485
486    .heap (NOLOAD):
487    {
488        . = ALIGN(8);
489        __HeapBase = .;
490        /* Place the STD heap here. */
491        KEEP(*(.heap))
492        __HeapLimit = .;
493    } > RAM
494
495    /* Stacks are stored in this section. */
496    .stack_dummy (NOLOAD):
497    {
498        . = ALIGN(8);
499        __StackLimit = .;
500        /* Main stack */
501        KEEP(*(.stack))
502        __StackTop = .;
503        /* Thread stacks */
504        KEEP(*(.stack*))
505        __StackTopAll = .;
506    } > RAM
507
508    PROVIDE(__stack = __StackTopAll);
509
510    /* This symbol represents the end of user allocated RAM. The RAM after this symbol can be used
511       at run time for things such as ThreadX memory pool allocations. */
512    __RAM_segment_used_end__ = ALIGN(__StackTopAll , 4);
513
514    /* RAM_NSC_START can be used to set a fixed address for non-secure callable RAM in secure projects.
515     * If it is not specified, the address for NSC RAM is the end of RAM aligned to a 1K boundary.
516     * In flat projects that require non-secure RAM, this variable is set to the start of non-secure RAM. */
517    __tz_RAM_C = DEFINED(RAM_NSC_START) ? ABSOLUTE(RAM_NSC_START) : __RESERVE_NS_RAM ? ABSOLUTE(RAM_NS_BUFFER_BLOCK_START) : ALIGN(__RAM_segment_used_end__, 1024);
518
519    /* RAM_NS_START can be used to set a fixed address for non-secure RAM in secure projects or flat projects.
520     * RAM_NS_BUFFER_BLOCK_LENGTH is used to allocate non-secure buffers in a flat project. If it is not
521     * specified, the address for NSC RAM is the end of RAM aligned to an 8K boundary.
522     * In flat projects that require non-secure RAM, this variable is set to the start of non-secure RAM. */
523    __tz_RAM_N = DEFINED(RAM_NS_START) ? ABSOLUTE(RAM_NS_START) : __RESERVE_NS_RAM ? ABSOLUTE(RAM_NS_BUFFER_BLOCK_START) : ALIGN(__tz_RAM_C, 8192);
524
525    /* Non-secure buffers must be in non-secure RAM. This is primarily used for the EDMAC in flat projects.
526     * The EDMAC is a non-secure bus master and can only access non-secure RAM. */
527    .ns_buffer (NOLOAD):
528    {
529        /* Allocate RAM on a 32-byte boundary to help with placement of Ethernet buffers. */
530        . = __RESERVE_NS_RAM ? ABSOLUTE(RAM_NS_BUFFER_START & 0xFFFFFFE0) : .;
531
532        KEEP(*(.ns_buffer*))
533    } > RAM
534
535    /* Data flash. */
536    .data_flash :
537    {
538        . = ORIGIN(DATA_FLASH);
539        __tz_DATA_FLASH_S = .;
540        __Data_Flash_Start = .;
541        KEEP(*(.data_flash*))
542        __Data_Flash_End = .;
543
544        __tz_DATA_FLASH_N = DEFINED(DATA_FLASH_NS_START) ? ABSOLUTE(DATA_FLASH_NS_START) : __RESERVE_NS_RAM ? ABSOLUTE(DATA_FLASH_START + DATA_FLASH_LENGTH) : ALIGN(1024);
545    } > DATA_FLASH
546
547    /* Note: There are no secure/non-secure boundaries for SDRAM.  These symbols are provided for the RA configuration tool. */
548    __tz_SDRAM_S = ORIGIN(SDRAM);
549
550    /* SDRAM */
551    .sdram (NOLOAD):
552    {
553        __SDRAM_Start = .;
554        KEEP(*(.sdram*))
555        KEEP(*(.frame*))
556        __SDRAM_End = .;
557    } > SDRAM
558
559    /* Note: There are no secure/non-secure boundaries for SDRAM.  These symbols are provided for the RA configuration tool. */
560    __tz_SDRAM_N = __SDRAM_End;
561
562    /* Note: There are no secure/non-secure boundaries for ID_CODE.  These symbols are provided for the RA configuration tool. */
563    __tz_ID_CODE_S = ORIGIN(ID_CODE);
564
565    .id_code :
566    {
567        __ID_Code_Start = .;
568        KEEP(*(.id_code*))
569        __ID_Code_End = .;
570    } > ID_CODE
571
572    /* Note: There are no secure/non-secure boundaries for ID_CODE.  These symbols are provided for the RA configuration tool. */
573    __tz_ID_CODE_N = __ID_Code_End;
574
575    /* Symbol required for RA Configuration tool. */
576    __tz_OPTION_SETTING_S = ORIGIN(OPTION_SETTING);
577
578    .option_setting :
579    {
580        __OPTION_SETTING_Start = .;
581        KEEP(*(.option_setting_ofs0))
582        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_Start + 0x10 : __OPTION_SETTING_Start;
583        KEEP(*(.option_setting_dualsel))
584        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_Start + 0x34 : __OPTION_SETTING_Start;
585        KEEP(*(.option_setting_sas))
586        __OPTION_SETTING_End = .;
587    } > OPTION_SETTING = 0xFF
588
589    /* Symbol required for RA Configuration tool. */
590    __tz_OPTION_SETTING_N = OPTION_SETTING_START_NS;
591
592    .option_setting_ns :
593    {
594        __OPTION_SETTING_NS_Start = .;
595        KEEP(*(.option_setting_ofs1))
596        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x10 : __OPTION_SETTING_NS_Start;
597        KEEP(*(.option_setting_banksel))
598        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x40 : __OPTION_SETTING_NS_Start;
599        KEEP(*(.option_setting_bps0))
600        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x44 : __OPTION_SETTING_NS_Start;
601        KEEP(*(.option_setting_bps1))
602        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x48 : __OPTION_SETTING_NS_Start;
603        KEEP(*(.option_setting_bps2))
604        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x60 : __OPTION_SETTING_NS_Start;
605        KEEP(*(.option_setting_pbps0))
606        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x64 : __OPTION_SETTING_NS_Start;
607        KEEP(*(.option_setting_pbps1))
608        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x68 : __OPTION_SETTING_NS_Start;
609        KEEP(*(.option_setting_pbps2))
610        __OPTION_SETTING_NS_End = .;
611    } > OPTION_SETTING = 0xFF
612
613    /* Symbol required for RA Configuration tool. */
614    __tz_OPTION_SETTING_S_S = ORIGIN(OPTION_SETTING_S);
615
616    .option_setting_s :
617    {
618        __OPTION_SETTING_S_Start = .;
619        KEEP(*(.option_setting_ofs1_sec))
620        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x10 : __OPTION_SETTING_S_Start;
621        KEEP(*(.option_setting_banksel_sec))
622        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x40 : __OPTION_SETTING_S_Start;
623        KEEP(*(.option_setting_bps_sec0))
624        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x44 : __OPTION_SETTING_S_Start;
625        KEEP(*(.option_setting_bps_sec1))
626        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x48 : __OPTION_SETTING_S_Start;
627        KEEP(*(.option_setting_bps_sec2))
628        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x60 : __OPTION_SETTING_S_Start;
629        KEEP(*(.option_setting_pbps_sec0))
630        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x64 : __OPTION_SETTING_S_Start;
631        KEEP(*(.option_setting_pbps_sec1))
632        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x68 : __OPTION_SETTING_S_Start;
633        KEEP(*(.option_setting_pbps_sec2))
634        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x80 : __OPTION_SETTING_S_Start;
635        KEEP(*(.option_setting_ofs1_sel))
636        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x90 : __OPTION_SETTING_S_Start;
637        KEEP(*(.option_setting_banksel_sel))
638        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC0 : __OPTION_SETTING_S_Start;
639        KEEP(*(.option_setting_bps_sel0))
640        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC4 : __OPTION_SETTING_S_Start;
641        KEEP(*(.option_setting_bps_sel1))
642        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC8 : __OPTION_SETTING_S_Start;
643        KEEP(*(.option_setting_bps_sel2))
644        __OPTION_SETTING_S_End = .;
645    } > OPTION_SETTING_S = 0xFF
646
647    /* Symbol required for RA Configuration tool. */
648    __tz_OPTION_SETTING_S_N = __OPTION_SETTING_S_End;
649}
650