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(libc.a libm.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        /* new GCC version uses .init_array */
227        PROVIDE(__ctors_start__ = .);
228        KEEP (*(SORT(.init_array.*)))
229        KEEP (*(.init_array))
230        PROVIDE(__ctors_end__ = .);
231
232        . = ALIGN(4);
233
234        __ROM_End = .;
235    } > FLASH = 0xFF
236
237    __Vectors_Size = __Vectors_End - __Vectors;
238
239    .ARM.extab :
240    {
241        *(.ARM.extab* .gnu.linkonce.armextab.*)
242    } > FLASH
243
244    __exidx_start = .;
245    .ARM.exidx :
246    {
247        *(.ARM.exidx* .gnu.linkonce.armexidx.*)
248    } > FLASH
249    __exidx_end = .;
250
251    /* To copy multiple ROM to RAM sections,
252     * uncomment .copy.table section and,
253     * define __STARTUP_COPY_MULTIPLE in startup_ARMCMx.S */
254    /*
255    .copy.table :
256    {
257        . = ALIGN(4);
258        __copy_table_start__ = .;
259        LONG (__etext)
260        LONG (__data_start__)
261        LONG (__data_end__ - __data_start__)
262        LONG (__etext2)
263        LONG (__data2_start__)
264        LONG (__data2_end__ - __data2_start__)
265        __copy_table_end__ = .;
266    } > FLASH
267    */
268
269    /* To clear multiple BSS sections,
270     * uncomment .zero.table section and,
271     * define __STARTUP_CLEAR_BSS_MULTIPLE in startup_ARMCMx.S */
272    /*
273    .zero.table :
274    {
275        . = ALIGN(4);
276        __zero_table_start__ = .;
277        LONG (__bss_start__)
278        LONG (__bss_end__ - __bss_start__)
279        LONG (__bss2_start__)
280        LONG (__bss2_end__ - __bss2_start__)
281        __zero_table_end__ = .;
282    } > FLASH
283    */
284
285    __etext = .;
286
287    __tz_RAM_S = ORIGIN(RAM);
288
289    /* If DTC is used, put the DTC vector table at the start of SRAM.
290       This avoids memory holes due to 1K alignment required by it. */
291    .fsp_dtc_vector_table (NOLOAD) :
292    {
293        . = ORIGIN(RAM);
294        *(.fsp_dtc_vector_table)
295    } > RAM
296
297    /* Initialized data section. */
298    .data :
299    {
300        __data_start__ = .;
301        . = ALIGN(4);
302
303        __Code_In_RAM_Start = .;
304
305        KEEP(*(.code_in_ram*))
306        __Code_In_RAM_End = .;
307
308        *(vtable)
309        /* Don't use *(.data*) because it will place data meant for .data_flash in this section. */
310        *(.data.*)
311        *(.data)
312
313        . = ALIGN(4);
314        /* preinit data */
315        PROVIDE_HIDDEN (__preinit_array_start = .);
316        KEEP(*(.preinit_array))
317        PROVIDE_HIDDEN (__preinit_array_end = .);
318
319        . = ALIGN(4);
320        /* init data */
321        PROVIDE_HIDDEN (__init_array_start = .);
322        KEEP(*(SORT(.init_array.*)))
323        KEEP(*(.init_array))
324        PROVIDE_HIDDEN (__init_array_end = .);
325
326
327        . = ALIGN(4);
328        /* finit data */
329        PROVIDE_HIDDEN (__fini_array_start = .);
330        KEEP(*(SORT(.fini_array.*)))
331        KEEP(*(.fini_array))
332        PROVIDE_HIDDEN (__fini_array_end = .);
333
334        KEEP(*(.jcr*))
335
336        . = ALIGN(4);
337
338        /* .data section which is used for initialized data */
339        PROVIDE(__dtors_start__ = .);
340        KEEP(*(SORT(.dtors.*)))
341        KEEP(*(.dtors))
342        PROVIDE(__dtors_end__ = .);
343
344        . = ALIGN(4);
345
346        /* All data end */
347        __data_end__ = .;
348
349    } > RAM AT > FLASH
350
351
352    /* TrustZone Secure Gateway Stubs Section. */
353
354    /* Some arithmetic is needed to eliminate unnecessary FILL for secure projects. */
355    /* 1. Get the address to the next block after the .data section in FLASH. */
356    DATA_END = LOADADDR(.data) + SIZEOF(.data);
357    /* 2. Determine the secure gateway stubs address either by the provided linker variable or the next 1024-byte block after .data */
358    SGSTUBS_LOC = (DEFINED(PROJECT_SECURE) && DEFINED(FLASH_NSC_START)) ? ABSOLUTE(FLASH_NSC_START) : ALIGN(DATA_END, 1024);
359    /* 3. Manually specify the start location for .gnu.sgstubs */
360    .gnu.sgstubs SGSTUBS_LOC : ALIGN(1024)
361    {
362        __tz_FLASH_C = DEFINED(FLASH_NSC_START) ? ABSOLUTE(FLASH_NSC_START) : __RESERVE_NS_RAM ? ABSOLUTE(FLASH_START + FLASH_LENGTH) : ALIGN(1024);
363        _start_sg = .;
364        *(.gnu.sgstubs*)
365        . = ALIGN(32);
366        _end_sg = .;
367    } > FLASH
368
369    __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);
370    FLASH_NS_IMAGE_START = DEFINED(FLASH_NS_IMAGE_START) ? FLASH_NS_IMAGE_START : __tz_FLASH_N;
371
372    /* Note: There are no secure/non-secure boundaries for QSPI.  These symbols are provided for the RA configuration tool. */
373    __tz_QSPI_FLASH_S = ORIGIN(QSPI_FLASH);
374
375    /* QSPI_FLASH section to be downloaded via debugger */
376    .qspi_flash :
377    {
378        __qspi_flash_start__ = .;
379        KEEP(*(.qspi_flash*))
380        KEEP(*(.code_in_qspi*))
381        __qspi_flash_end__ = .;
382    } > QSPI_FLASH
383    __qspi_flash_code_size__ = __qspi_flash_end__ - __qspi_flash_start__;
384
385    /* QSPI_FLASH non-retentive section, creates a copy in internal flash that can be copied to QSPI */
386    __qspi_flash_code_addr__ = __etext + (__data_end__ - __data_start__);
387    .qspi_non_retentive : AT (__qspi_flash_code_addr__)
388    {
389        __qspi_non_retentive_start__ = .;
390        KEEP(*(.qspi_non_retentive*))
391        __qspi_non_retentive_end__ = .;
392    } > QSPI_FLASH
393    __qspi_non_retentive_size__ = __qspi_non_retentive_end__ - __qspi_non_retentive_start__;
394
395    __qspi_region_max_size__ = 0x4000000;   /* Must be the same as defined in MEMORY above */
396    __qspi_region_start_address__ = __qspi_flash_start__;
397    __qspi_region_end_address__ = __qspi_flash_start__ + __qspi_region_max_size__;
398
399    /* Note: There are no secure/non-secure boundaries for QSPI.  These symbols are provided for the RA configuration tool. */
400    __tz_QSPI_FLASH_N = __qspi_non_retentive_end__;
401
402    /* Support for OctaRAM */
403    .OSPI_DEVICE_0_NO_LOAD (NOLOAD):
404    {
405        . = ALIGN(4);
406        __ospi_device_0_start__ = .;
407        *(.ospi_device_0_no_load*)
408        . = ALIGN(4);
409        __ospi_device_0_end__ = .;
410    } > OSPI_DEVICE_0_RAM
411
412    .OSPI_DEVICE_1_NO_LOAD (NOLOAD):
413    {
414        . = ALIGN(4);
415        __ospi_device_1_start__ = .;
416        *(.ospi_device_1_no_load*)
417        . = ALIGN(4);
418        __ospi_device_1_end__ = .;
419    } > OSPI_DEVICE_1_RAM
420
421    /* Note: There are no secure/non-secure boundaries for QSPI.  These symbols are provided for the RA configuration tool. */
422    __tz_OSPI_DEVICE_0_S = ORIGIN(OSPI_DEVICE_0);
423
424    /* OSPI_DEVICE_0 section to be downloaded via debugger */
425    .OSPI_DEVICE_0 :
426    {
427        __ospi_device_0_start__ = .;
428        KEEP(*(.ospi_device_0*))
429        KEEP(*(.code_in_ospi_device_0*))
430        __ospi_device_0_end__ = .;
431    } > OSPI_DEVICE_0
432    __ospi_device_0_code_size__ = __ospi_device_0_end__ - __ospi_device_0_start__;
433
434    /* OSPI_DEVICE_0 non-retentive section, creates a copy in internal flash that can be copied to OSPI */
435    __ospi_device_0_code_addr__ = __etext + (__data_end__ - __data_start__);
436    .ospi_device_0_non_retentive : AT (__ospi_device_0_code_addr__)
437    {
438        __ospi_device_0_non_retentive_start__ = .;
439        KEEP(*(.ospi_device_0_non_retentive*))
440        __ospi_device_0_non_retentive_end__ = .;
441    } > OSPI_DEVICE_0
442    __ospi_device_0_non_retentive_size__ = __ospi_device_0_non_retentive_end__ - __ospi_device_0_non_retentive_start__;
443
444    __ospi_device_0_region_max_size__ = 0x8000000;   /* Must be the same as defined in MEMORY above */
445    __ospi_device_0_region_start_address__ = __ospi_device_0_start__;
446    __ospi_device_0_region_end_address__ = __ospi_device_0_start__ + __ospi_device_0_region_max_size__;
447
448    /* Note: There are no secure/non-secure boundaries for OSPI.  These symbols are provided for the RA configuration tool. */
449    __tz_OSPI_DEVICE_0_N = __ospi_device_0_non_retentive_end__;
450
451    /* Note: There are no secure/non-secure boundaries for OSPI.  These symbols are provided for the RA configuration tool. */
452    __tz_OSPI_DEVICE_1_S = ORIGIN(OSPI_DEVICE_1);
453
454    /* OSPI_DEVICE_1 section to be downloaded via debugger */
455    .OSPI_DEVICE_1 :
456    {
457        __ospi_device_1_start__ = .;
458        KEEP(*(.ospi_device_1*))
459        KEEP(*(.code_in_ospi_device_1*))
460        __ospi_device_1_end__ = .;
461    } > OSPI_DEVICE_1
462    __ospi_device_1_code_size__ = __ospi_device_1_end__ - __ospi_device_1_start__;
463
464    /* OSPI_DEVICE_1 non-retentive section, creates a copy in internal flash that can be copied to OSPI */
465    __ospi_device_1_code_addr__ = __etext + (__data_end__ - __data_start__);
466    .ospi_device_1_non_retentive : AT (__ospi_device_1_code_addr__)
467    {
468        __ospi_device_1_non_retentive_start__ = .;
469        KEEP(*(.ospi_device_1_non_retentive*))
470        __ospi_device_1_non_retentive_end__ = .;
471    } > OSPI_DEVICE_1
472    __ospi_device_1_non_retentive_size__ = __ospi_device_1_non_retentive_end__ - __ospi_device_1_non_retentive_start__;
473
474    __ospi_device_1_region_max_size__ = 0x10000000;   /* Must be the same as defined in MEMORY above */
475    __ospi_device_1_region_start_address__ = __ospi_device_1_start__;
476    __ospi_device_1_region_end_address__ = __ospi_device_1_start__ + __ospi_device_1_region_max_size__;
477
478    /* Note: There are no secure/non-secure boundaries for OSPI.  These symbols are provided for the RA configuration tool. */
479    __tz_OSPI_DEVICE_1_N = __ospi_device_1_non_retentive_end__;
480
481    .noinit (NOLOAD):
482    {
483        . = ALIGN(4);
484        __noinit_start = .;
485        KEEP(*(.noinit*))
486        . = ALIGN(8);
487        /* Place the FreeRTOS heap here so that the __HeapLimit calculation does not include the freertos heap. */
488        KEEP(*(.heap.*))
489        __noinit_end = .;
490    } > RAM
491
492    .bss :
493    {
494        . = ALIGN(4);
495        __bss_start__ = .;
496        *(.bss*)
497        *(COMMON)
498        . = ALIGN(4);
499        __bss_end__ = .;
500    } > RAM
501
502    .heap (NOLOAD):
503    {
504        . = ALIGN(8);
505        __HeapBase = .;
506        /* Place the STD heap here. */
507        KEEP(*(.heap))
508        __HeapLimit = .;
509    } > RAM
510
511    /* Stacks are stored in this section. */
512    .stack_dummy (NOLOAD):
513    {
514        . = ALIGN(8);
515        __StackLimit = .;
516        /* Main stack */
517        KEEP(*(.stack))
518        __StackTop = .;
519        /* Thread stacks */
520        KEEP(*(.stack*))
521        __StackTopAll = .;
522    } > RAM
523
524    PROVIDE(__stack = __StackTopAll);
525
526    /* This symbol represents the end of user allocated RAM. The RAM after this symbol can be used
527       at run time for things such as ThreadX memory pool allocations. */
528    __RAM_segment_used_end__ = ALIGN(__StackTopAll , 4);
529
530    /* RAM_NSC_START can be used to set a fixed address for non-secure callable RAM in secure projects.
531     * If it is not specified, the address for NSC RAM is the end of RAM aligned to a 1K boundary.
532     * In flat projects that require non-secure RAM, this variable is set to the start of non-secure RAM. */
533    __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);
534
535    /* RAM_NS_START can be used to set a fixed address for non-secure RAM in secure projects or flat projects.
536     * RAM_NS_BUFFER_BLOCK_LENGTH is used to allocate non-secure buffers in a flat project. If it is not
537     * specified, the address for NSC RAM is the end of RAM aligned to an 8K boundary.
538     * In flat projects that require non-secure RAM, this variable is set to the start of non-secure RAM. */
539    __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);
540
541    /* Non-secure buffers must be in non-secure RAM. This is primarily used for the EDMAC in flat projects.
542     * The EDMAC is a non-secure bus master and can only access non-secure RAM. */
543    .ns_buffer (NOLOAD):
544    {
545        /* Allocate RAM on a 32-byte boundary to help with placement of Ethernet buffers. */
546        . = __RESERVE_NS_RAM ? ABSOLUTE(RAM_NS_BUFFER_START & 0xFFFFFFE0) : .;
547
548        KEEP(*(.ns_buffer*))
549    } > RAM
550
551    /* Data flash. */
552    .data_flash :
553    {
554        . = ORIGIN(DATA_FLASH);
555        __tz_DATA_FLASH_S = .;
556        __Data_Flash_Start = .;
557        KEEP(*(.data_flash*))
558        __Data_Flash_End = .;
559
560        __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);
561    } > DATA_FLASH
562
563    /* Note: There are no secure/non-secure boundaries for SDRAM.  These symbols are provided for the RA configuration tool. */
564    __tz_SDRAM_S = ORIGIN(SDRAM);
565
566    /* SDRAM */
567    .sdram (NOLOAD):
568    {
569        __SDRAM_Start = .;
570        KEEP(*(.sdram*))
571        KEEP(*(.frame*))
572        __SDRAM_End = .;
573    } > SDRAM
574
575    /* Note: There are no secure/non-secure boundaries for SDRAM.  These symbols are provided for the RA configuration tool. */
576    __tz_SDRAM_N = __SDRAM_End;
577
578    /* Note: There are no secure/non-secure boundaries for ID_CODE.  These symbols are provided for the RA configuration tool. */
579    __tz_ID_CODE_S = ORIGIN(ID_CODE);
580
581    .id_code :
582    {
583        __ID_Code_Start = .;
584        KEEP(*(.id_code*))
585        __ID_Code_End = .;
586    } > ID_CODE
587
588    /* Note: There are no secure/non-secure boundaries for ID_CODE.  These symbols are provided for the RA configuration tool. */
589    __tz_ID_CODE_N = __ID_Code_End;
590
591    /* Symbol required for RA Configuration tool. */
592    __tz_OPTION_SETTING_S = ORIGIN(OPTION_SETTING);
593
594    .option_setting :
595    {
596        __OPTION_SETTING_Start = .;
597        KEEP(*(.option_setting_ofs0))
598        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_Start + 0x10 : __OPTION_SETTING_Start;
599        KEEP(*(.option_setting_dualsel))
600        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_Start + 0x34 : __OPTION_SETTING_Start;
601        KEEP(*(.option_setting_sas))
602        __OPTION_SETTING_End = .;
603    } > OPTION_SETTING = 0xFF
604
605    /* Symbol required for RA Configuration tool. */
606    __tz_OPTION_SETTING_N = OPTION_SETTING_START_NS;
607
608    .option_setting_ns :
609    {
610        __OPTION_SETTING_NS_Start = .;
611        KEEP(*(.option_setting_ofs1))
612        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x10 : __OPTION_SETTING_NS_Start;
613        KEEP(*(.option_setting_banksel))
614        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x40 : __OPTION_SETTING_NS_Start;
615        KEEP(*(.option_setting_bps0))
616        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x44 : __OPTION_SETTING_NS_Start;
617        KEEP(*(.option_setting_bps1))
618        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x48 : __OPTION_SETTING_NS_Start;
619        KEEP(*(.option_setting_bps2))
620        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x60 : __OPTION_SETTING_NS_Start;
621        KEEP(*(.option_setting_pbps0))
622        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x64 : __OPTION_SETTING_NS_Start;
623        KEEP(*(.option_setting_pbps1))
624        . = USE_OPTION_SETTING_NS ? __OPTION_SETTING_NS_Start + 0x68 : __OPTION_SETTING_NS_Start;
625        KEEP(*(.option_setting_pbps2))
626        __OPTION_SETTING_NS_End = .;
627    } > OPTION_SETTING = 0xFF
628
629    /* Symbol required for RA Configuration tool. */
630    __tz_OPTION_SETTING_S_S = ORIGIN(OPTION_SETTING_S);
631
632    .option_setting_s :
633    {
634        __OPTION_SETTING_S_Start = .;
635        KEEP(*(.option_setting_ofs1_sec))
636        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x10 : __OPTION_SETTING_S_Start;
637        KEEP(*(.option_setting_banksel_sec))
638        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x40 : __OPTION_SETTING_S_Start;
639        KEEP(*(.option_setting_bps_sec0))
640        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x44 : __OPTION_SETTING_S_Start;
641        KEEP(*(.option_setting_bps_sec1))
642        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x48 : __OPTION_SETTING_S_Start;
643        KEEP(*(.option_setting_bps_sec2))
644        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x60 : __OPTION_SETTING_S_Start;
645        KEEP(*(.option_setting_pbps_sec0))
646        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x64 : __OPTION_SETTING_S_Start;
647        KEEP(*(.option_setting_pbps_sec1))
648        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x68 : __OPTION_SETTING_S_Start;
649        KEEP(*(.option_setting_pbps_sec2))
650        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x80 : __OPTION_SETTING_S_Start;
651        KEEP(*(.option_setting_ofs1_sel))
652        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0x90 : __OPTION_SETTING_S_Start;
653        KEEP(*(.option_setting_banksel_sel))
654        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC0 : __OPTION_SETTING_S_Start;
655        KEEP(*(.option_setting_bps_sel0))
656        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC4 : __OPTION_SETTING_S_Start;
657        KEEP(*(.option_setting_bps_sel1))
658        . = PROJECT_SECURE_OR_FLAT ? __OPTION_SETTING_S_Start + 0xC8 : __OPTION_SETTING_S_Start;
659        KEEP(*(.option_setting_bps_sel2))
660        __OPTION_SETTING_S_End = .;
661    } > OPTION_SETTING_S = 0xFF
662
663    /* Symbol required for RA Configuration tool. */
664    __tz_OPTION_SETTING_S_N = __OPTION_SETTING_S_End;
665}
666