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