1/*
2** ###################################################################
3**     Processors:          MIMXRT595SFAWC_cm33
4**                          MIMXRT595SFFOC_cm33
5**
6**     Compiler:            GNU C Compiler
7**     Reference manual:    iMXRT500RM Rev.0, 01/2021
8**     Version:             rev. 5.0, 2021-07-28
9**     Build:               b210730
10**
11**     Abstract:
12**         Linker file for the GNU C Compiler
13**
14**     Copyright 2016 Freescale Semiconductor, Inc.
15**     Copyright 2016-2021 NXP
16**     All rights reserved.
17**
18**     SPDX-License-Identifier: BSD-3-Clause
19**
20**     http:                 www.nxp.com
21**     mail:                 support@nxp.com
22**
23** ###################################################################
24*/
25
26
27
28/* Entry Point */
29ENTRY(Reset_Handler)
30
31HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x0400;
32STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
33
34/* Specify the memory areas */
35/* The SRAM region [0x10000-0x1BFFF] is reserved for ROM code. */
36/* The SRAM region [0x0-0xFFFF], [0x1C000-0x1FFFF] are reserved for app-specific use cases. */
37/* The SRAM region [0x20000-0x7FFFF] is reserved for Non-cached shared memory between M33 and DSP. */
38/* The SRAM region [0x80000-0x27FFFF] is reserved for DSP code and data. */
39MEMORY
40{
41  m_flash               (RX)  : ORIGIN = 0x18000000, LENGTH = 0x00041000
42  m_interrupts          (RX)  : ORIGIN = 0x10280000, LENGTH = 0x00000180
43  m_text                (RX)  : ORIGIN = 0x10280180, LENGTH = 0x0003FC80
44  m_veneer_table        (RX)  : ORIGIN = 0x102BFE00, LENGTH = 0x00000200
45  m_data                (RW)  : ORIGIN = 0x30340000, LENGTH = 0x00040000
46  m_usb_sram            (RW)  : ORIGIN = 0x50140000, LENGTH = 0x00004000
47}
48
49/* Define output sections */
50SECTIONS
51{
52  .flash_config :
53  {
54    __FLASH_BASE = .;
55    FILL(0x00)
56    . = 0x400;
57    KEEP(* (.flash_conf))     /* flash config section */
58    . = 0x1000;
59  } > m_flash
60
61  /* The startup code goes first into internal ram */
62  .interrupts :
63  {
64    . = ALIGN(4);
65    __VECTOR_TABLE = .;
66    __Vectors = .;
67    KEEP(*(.isr_vector))     /* Startup code */
68    FILL(0x00)
69    . = 0x180;
70  } > m_interrupts AT > m_flash
71
72  /* The program code and other data goes into internal ram */
73  .text :
74  {
75    . = ALIGN(4);
76    *(.text)                 /* .text sections (code) */
77    *(.text*)                /* .text* sections (code) */
78    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
79    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
80    *(.glue_7)               /* glue arm to thumb code */
81    *(.glue_7t)              /* glue thumb to arm code */
82    *(.eh_frame)
83    KEEP (*(.init))
84    KEEP (*(.fini))
85    . = ALIGN(4);
86  } > m_text AT > m_flash
87
88  .ARM.extab :
89  {
90    *(.ARM.extab* .gnu.linkonce.armextab.*)
91  } > m_text AT > m_flash
92
93  .ARM :
94  {
95    __exidx_start = .;
96    *(.ARM.exidx*)
97    __exidx_end = .;
98  } > m_text AT > m_flash
99
100 .ctors :
101  {
102    __CTOR_LIST__ = .;
103    /* gcc uses crtbegin.o to find the start of
104       the constructors, so we make sure it is
105       first.  Because this is a wildcard, it
106       doesn't matter if the user does not
107       actually link against crtbegin.o; the
108       linker won't look for a file to match a
109       wildcard.  The wildcard also means that it
110       doesn't matter which directory crtbegin.o
111       is in.  */
112    KEEP (*crtbegin.o(.ctors))
113    KEEP (*crtbegin?.o(.ctors))
114    /* We don't want to include the .ctor section from
115       from the crtend.o file until after the sorted ctors.
116       The .ctor section from the crtend file contains the
117       end of ctors marker and it must be last */
118    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
119    KEEP (*(SORT(.ctors.*)))
120    KEEP (*(.ctors))
121    __CTOR_END__ = .;
122  } > m_text AT > m_flash
123
124  .dtors :
125  {
126    __DTOR_LIST__ = .;
127    KEEP (*crtbegin.o(.dtors))
128    KEEP (*crtbegin?.o(.dtors))
129    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
130    KEEP (*(SORT(.dtors.*)))
131    KEEP (*(.dtors))
132    __DTOR_END__ = .;
133  } > m_text AT > m_flash
134
135  .preinit_array :
136  {
137    PROVIDE_HIDDEN (__preinit_array_start = .);
138    KEEP (*(.preinit_array*))
139    PROVIDE_HIDDEN (__preinit_array_end = .);
140  } > m_text AT > m_flash
141
142  .init_array :
143  {
144    PROVIDE_HIDDEN (__init_array_start = .);
145    KEEP (*(SORT(.init_array.*)))
146    KEEP (*(.init_array*))
147    PROVIDE_HIDDEN (__init_array_end = .);
148  } > m_text AT > m_flash
149
150  .fini_array :
151  {
152    PROVIDE_HIDDEN (__fini_array_start = .);
153    KEEP (*(SORT(.fini_array.*)))
154    KEEP (*(.fini_array*))
155    PROVIDE_HIDDEN (__fini_array_end = .);
156  } > m_text AT > m_flash
157
158  __etext = .;    /* define a global symbol at end of code */
159  __DATA_ROM =  ORIGIN(m_flash) + 0x1000 +  __etext - __VECTOR_TABLE;
160
161  __VECTOR_RAM = ORIGIN(m_interrupts);
162  __RAM_VECTOR_TABLE_SIZE_BYTES = 0x0;
163
164  .data : AT(__DATA_ROM)
165  {
166    . = ALIGN(4);
167    __DATA_RAM = .;
168    __data_start__ = .;      /* create a global symbol at data start */
169    *(CodeQuickAccess)       /* CodeQuickAccess sections */
170    *(DataQuickAccess)       /* DataQuickAccess sections */
171    *(.data)                 /* .data sections */
172    *(.data*)                /* .data* sections */
173    KEEP(*(.jcr*))
174    . = ALIGN(4);
175    __data_end__ = .;        /* define a global symbol at data end */
176  } > m_data
177
178  /* section for veneer table */
179  .gnu.sgstubs : AT(ORIGIN(m_flash) + 0x1000 + ORIGIN(m_veneer_table) - ORIGIN(m_interrupts))
180  {
181     . = ALIGN(32);
182     _start_sg = .;
183    *(.gnu.sgstubs*)
184     . = ALIGN(32);
185     _end_sg = .;
186  } > m_veneer_table
187
188  __DATA_END = __etext + (__data_end__ - __data_start__);
189  _image_size = __DATA_END - __VECTOR_TABLE;
190  ASSERT(_image_size <= LENGTH(m_flash), "region m_flash overflowed with text and data")
191
192  /* Uninitialized data section */
193  .bss :
194  {
195    /* This is used by the startup in order to initialize the .bss section */
196    . = ALIGN(4);
197    __START_BSS = .;
198    __bss_start__ = .;
199    *(.bss)
200    *(.bss*)
201    *(COMMON)
202    . = ALIGN(4);
203    __bss_end__ = .;
204    __END_BSS = .;
205  } > m_data
206
207  .heap :
208  {
209    . = ALIGN(8);
210    __end__ = .;
211    PROVIDE(end = .);
212    __HeapBase = .;
213    . += HEAP_SIZE;
214    __HeapLimit = .;
215    __heap_limit = .; /* Add for _sbrk */
216  } > m_data
217
218  .stack :
219  {
220    . = ALIGN(8);
221    . += STACK_SIZE;
222  } > m_data
223
224  m_usb_bdt (NOLOAD) :
225  {
226    . = ALIGN(512);
227    *(m_usb_bdt)
228  } > m_usb_sram
229
230  m_usb_global (NOLOAD) :
231  {
232    *(m_usb_global)
233  } > m_usb_sram
234
235  /* Initializes stack on the end of block */
236  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
237  __StackLimit = __StackTop - STACK_SIZE;
238  PROVIDE(__stack = __StackTop);
239
240  .ARM.attributes 0 : { *(.ARM.attributes) }
241
242  ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
243}
244
245