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