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 = 0x08000000, LENGTH = 0x00300000
42  m_interrupts          (RX)  : ORIGIN = 0x00280000, LENGTH = 0x00000180
43  m_text                (RX)  : ORIGIN = 0x00280180, LENGTH = 0x0013FE80
44  m_data                (RW)  : ORIGIN = 0x203C0000, LENGTH = 0x00140000
45  m_usb_sram            (RW)  : ORIGIN = 0x40140000, LENGTH = 0x00004000
46}
47
48/* Define output sections */
49SECTIONS
50{
51  .flash_config :
52  {
53    __FLASH_BASE = .;
54    FILL(0x00)
55    . = 0x400;
56    KEEP(* (.flash_conf))     /* flash config section */
57    . = 0x1000;
58  } > m_flash
59
60  /* The startup code goes first into internal ram */
61  .interrupts :
62  {
63    . = ALIGN(4);
64    __VECTOR_TABLE = .;
65    __Vectors = .;
66    KEEP(*(.isr_vector))     /* Startup code */
67    FILL(0x00)
68    . = 0x180;
69  } > m_interrupts AT > m_flash
70
71  /* The program code and other data goes into internal ram */
72  .text :
73  {
74    . = ALIGN(4);
75    *(.text)                 /* .text sections (code) */
76    *(.text*)                /* .text* sections (code) */
77    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
78    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
79    *(.glue_7)               /* glue arm to thumb code */
80    *(.glue_7t)              /* glue thumb to arm code */
81    *(.eh_frame)
82    KEEP (*(.init))
83    KEEP (*(.fini))
84    . = ALIGN(4);
85  } > m_text AT > m_flash
86
87  .ARM.extab :
88  {
89    *(.ARM.extab* .gnu.linkonce.armextab.*)
90  } > m_text AT > m_flash
91
92  .ARM :
93  {
94    __exidx_start = .;
95    *(.ARM.exidx*)
96    __exidx_end = .;
97  } > m_text AT > m_flash
98
99 .ctors :
100  {
101    __CTOR_LIST__ = .;
102    /* gcc uses crtbegin.o to find the start of
103       the constructors, so we make sure it is
104       first.  Because this is a wildcard, it
105       doesn't matter if the user does not
106       actually link against crtbegin.o; the
107       linker won't look for a file to match a
108       wildcard.  The wildcard also means that it
109       doesn't matter which directory crtbegin.o
110       is in.  */
111    KEEP (*crtbegin.o(.ctors))
112    KEEP (*crtbegin?.o(.ctors))
113    /* We don't want to include the .ctor section from
114       from the crtend.o file until after the sorted ctors.
115       The .ctor section from the crtend file contains the
116       end of ctors marker and it must be last */
117    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
118    KEEP (*(SORT(.ctors.*)))
119    KEEP (*(.ctors))
120    __CTOR_END__ = .;
121  } > m_text AT > m_flash
122
123  .dtors :
124  {
125    __DTOR_LIST__ = .;
126    KEEP (*crtbegin.o(.dtors))
127    KEEP (*crtbegin?.o(.dtors))
128    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
129    KEEP (*(SORT(.dtors.*)))
130    KEEP (*(.dtors))
131    __DTOR_END__ = .;
132  } > m_text AT > m_flash
133
134  .preinit_array :
135  {
136    PROVIDE_HIDDEN (__preinit_array_start = .);
137    KEEP (*(.preinit_array*))
138    PROVIDE_HIDDEN (__preinit_array_end = .);
139  } > m_text AT > m_flash
140
141  .init_array :
142  {
143    PROVIDE_HIDDEN (__init_array_start = .);
144    KEEP (*(SORT(.init_array.*)))
145    KEEP (*(.init_array*))
146    PROVIDE_HIDDEN (__init_array_end = .);
147  } > m_text AT > m_flash
148
149  .fini_array :
150  {
151    PROVIDE_HIDDEN (__fini_array_start = .);
152    KEEP (*(SORT(.fini_array.*)))
153    KEEP (*(.fini_array*))
154    PROVIDE_HIDDEN (__fini_array_end = .);
155  } > m_text AT > m_flash
156
157  __etext = .;    /* define a global symbol at end of code */
158  __DATA_ROM = ORIGIN(m_flash) + 0x1000 + __etext - __VECTOR_TABLE;
159
160  __VECTOR_RAM = ORIGIN(m_interrupts);
161  __RAM_VECTOR_TABLE_SIZE_BYTES = 0x0;
162
163  .data : AT(__DATA_ROM)
164  {
165    . = ALIGN(4);
166    __DATA_RAM = .;
167    __data_start__ = .;      /* create a global symbol at data start */
168    *(CodeQuickAccess)       /* CodeQuickAccess sections */
169    *(DataQuickAccess)       /* DataQuickAccess sections */
170    *(.data)                 /* .data sections */
171    *(.data*)                /* .data* sections */
172    KEEP(*(.jcr*))
173    . = ALIGN(4);
174    __data_end__ = .;        /* define a global symbol at data end */
175  } > m_data
176
177  __DATA_END = __etext + (__data_end__ - __data_start__);
178  _image_size = __DATA_END - __VECTOR_TABLE;
179  ASSERT(_image_size <= LENGTH(m_flash), "region m_flash overflowed with text and data")
180
181  /* Uninitialized data section */
182  .bss :
183  {
184    /* This is used by the startup in order to initialize the .bss section */
185    . = ALIGN(4);
186    __START_BSS = .;
187    __bss_start__ = .;
188    *(.bss)
189    *(.bss*)
190    *(COMMON)
191    . = ALIGN(4);
192    __bss_end__ = .;
193    __END_BSS = .;
194  } > m_data
195
196  .heap :
197  {
198    . = ALIGN(8);
199    __end__ = .;
200    PROVIDE(end = .);
201    __HeapBase = .;
202    . += HEAP_SIZE;
203    __HeapLimit = .;
204    __heap_limit = .; /* Add for _sbrk */
205  } > m_data
206
207  .stack :
208  {
209    . = ALIGN(8);
210    . += STACK_SIZE;
211  } > m_data
212
213  m_usb_bdt (NOLOAD) :
214  {
215    . = ALIGN(512);
216    *(m_usb_bdt)
217  } > m_usb_sram
218
219  m_usb_global (NOLOAD) :
220  {
221    *(m_usb_global)
222  } > m_usb_sram
223
224  /* Initializes stack on the end of block */
225  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
226  __StackLimit = __StackTop - STACK_SIZE;
227  PROVIDE(__stack = __StackTop);
228
229  .ARM.attributes 0 : { *(.ARM.attributes) }
230
231  ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
232}
233
234