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:               b210810
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;
33M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x00000180 : 0;
34
35/* Specify the memory areas */
36/* The SRAM region [0x10000-0x1BFFF] is reserved for ROM code. */
37/* The SRAM region [0x0-0xFFFF], [0x1C000-0x1FFFF] are reserved for app-specific use cases. */
38/* The SRAM region [0x20000-0x7FFFF] is reserved for Non-cached shared memory between M33 and DSP. */
39/* The SRAM region [0x80000-0x27FFFF] is reserved for DSP code and data. */
40MEMORY
41{
42  m_flash_config        (RX)  : ORIGIN = 0x18000400, LENGTH = 0x00000200
43  m_interrupts          (RX)  : ORIGIN = 0x18001000, LENGTH = 0x00000180
44  m_text                (RX)  : ORIGIN = 0x18001180, LENGTH = 0x000FEC80
45  m_veneer_table        (RX)  : ORIGIN = 0x180FFE00, LENGTH = 0x00000200
46  /* Use the same SRAM partition with ram_s linker to share the same SAU configuration. */
47  m_data                (RW)  : ORIGIN = 0x30340000, LENGTH = 0x00040000
48  m_usb_sram            (RW)  : ORIGIN = 0x50140000, LENGTH = 0x00004000
49}
50
51/* Define output sections */
52SECTIONS
53{
54  .flash_config :
55  {
56    . = ALIGN(4);
57    __FLASH_BASE = .;
58    KEEP(* (.flash_conf))     /* flash config section */
59    . = ALIGN(4);
60  } > m_flash_config
61
62  /* The startup code goes first into internal ram */
63  .interrupts :
64  {
65    . = ALIGN(4);
66    __VECTOR_TABLE = .;
67    __Vectors = .;
68    KEEP(*(.isr_vector))     /* Startup code */
69    . = ALIGN(4);
70  } > m_interrupts
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
87
88  /* section for veneer table */
89  .gnu.sgstubs :
90  {
91     . = ALIGN(32);
92     _start_sg = .;
93    *(.gnu.sgstubs*)
94     . = ALIGN(32);
95     _end_sg = .;
96  } > m_veneer_table
97
98  .ARM.extab :
99  {
100    *(.ARM.extab* .gnu.linkonce.armextab.*)
101  } > m_text
102
103  .ARM :
104  {
105    __exidx_start = .;
106    *(.ARM.exidx*)
107    __exidx_end = .;
108  } > m_text
109
110 .ctors :
111  {
112    __CTOR_LIST__ = .;
113    /* gcc uses crtbegin.o to find the start of
114       the constructors, so we make sure it is
115       first.  Because this is a wildcard, it
116       doesn't matter if the user does not
117       actually link against crtbegin.o; the
118       linker won't look for a file to match a
119       wildcard.  The wildcard also means that it
120       doesn't matter which directory crtbegin.o
121       is in.  */
122    KEEP (*crtbegin.o(.ctors))
123    KEEP (*crtbegin?.o(.ctors))
124    /* We don't want to include the .ctor section from
125       from the crtend.o file until after the sorted ctors.
126       The .ctor section from the crtend file contains the
127       end of ctors marker and it must be last */
128    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
129    KEEP (*(SORT(.ctors.*)))
130    KEEP (*(.ctors))
131    __CTOR_END__ = .;
132  } > m_text
133
134  .dtors :
135  {
136    __DTOR_LIST__ = .;
137    KEEP (*crtbegin.o(.dtors))
138    KEEP (*crtbegin?.o(.dtors))
139    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
140    KEEP (*(SORT(.dtors.*)))
141    KEEP (*(.dtors))
142    __DTOR_END__ = .;
143  } > m_text
144
145  .preinit_array :
146  {
147    PROVIDE_HIDDEN (__preinit_array_start = .);
148    KEEP (*(.preinit_array*))
149    PROVIDE_HIDDEN (__preinit_array_end = .);
150  } > m_text
151
152  .init_array :
153  {
154    PROVIDE_HIDDEN (__init_array_start = .);
155    KEEP (*(SORT(.init_array.*)))
156    KEEP (*(.init_array*))
157    PROVIDE_HIDDEN (__init_array_end = .);
158  } > m_text
159
160  .fini_array :
161  {
162    PROVIDE_HIDDEN (__fini_array_start = .);
163    KEEP (*(SORT(.fini_array.*)))
164    KEEP (*(.fini_array*))
165    PROVIDE_HIDDEN (__fini_array_end = .);
166  } > m_text
167
168  __etext = .;    /* define a global symbol at end of code */
169  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
170
171  .interrupts_ram :
172  {
173    . = ALIGN(4);
174    __VECTOR_RAM__ = .;
175    __interrupts_ram_start__ = .; /* Create a global symbol at data start */
176    *(.m_interrupts_ram)     /* This is a user defined section */
177    . += M_VECTOR_RAM_SIZE;
178    . = ALIGN(4);
179    __interrupts_ram_end__ = .; /* Define a global symbol at data end */
180  } > m_data
181
182  __VECTOR_RAM = DEFINED(__ram_vector_table__) ? __VECTOR_RAM__ : ORIGIN(m_interrupts);
183  __RAM_VECTOR_TABLE_SIZE_BYTES = DEFINED(__ram_vector_table__) ? (__interrupts_ram_end__ - __interrupts_ram_start__) : 0x0;
184
185  .data : AT(__DATA_ROM)
186  {
187    . = ALIGN(4);
188    __DATA_RAM = .;
189    __data_start__ = .;      /* create a global symbol at data start */
190    *(CodeQuickAccess)       /* CodeQuickAccess sections */
191    *(DataQuickAccess)       /* DataQuickAccess sections */
192    *(.data)                 /* .data sections */
193    *(.data*)                /* .data* sections */
194    KEEP(*(.jcr*))
195    . = ALIGN(4);
196    __data_end__ = .;        /* define a global symbol at data end */
197  } > m_data
198
199  __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
200  text_end = ORIGIN(m_text) + LENGTH(m_text);
201  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
202  _image_size = __DATA_END - __VECTOR_TABLE;
203
204  /* Uninitialized data section */
205  .bss :
206  {
207    /* This is used by the startup in order to initialize the .bss section */
208    . = ALIGN(4);
209    __START_BSS = .;
210    __bss_start__ = .;
211    *(.bss)
212    *(.bss*)
213    *(COMMON)
214    . = ALIGN(4);
215    __bss_end__ = .;
216    __END_BSS = .;
217  } > m_data
218
219  .heap :
220  {
221    . = ALIGN(8);
222    __end__ = .;
223    PROVIDE(end = .);
224    __HeapBase = .;
225    . += HEAP_SIZE;
226    __HeapLimit = .;
227    __heap_limit = .; /* Add for _sbrk */
228  } > m_data
229
230  .stack :
231  {
232    . = ALIGN(8);
233    . += STACK_SIZE;
234  } > m_data
235
236  m_usb_bdt (NOLOAD) :
237  {
238    . = ALIGN(512);
239    *(m_usb_bdt)
240  } > m_usb_sram
241
242  m_usb_global (NOLOAD) :
243  {
244    *(m_usb_global)
245  } > m_usb_sram
246
247  /* Initializes stack on the end of block */
248  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
249  __StackLimit = __StackTop - STACK_SIZE;
250  PROVIDE(__stack = __StackTop);
251
252  .ARM.attributes 0 : { *(.ARM.attributes) }
253
254  ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
255}
256
257