1/*
2** ###################################################################
3**     Processors:          MIMXRT1042DFP6B
4**                          MIMXRT1042XFP5B
5**                          MIMXRT1042XJM5B
6**
7**     Compiler:            GNU C Compiler
8**     Reference manual:    IMXRT1040RM Rev.1, 09/2022
9**     Version:             rev. 0.1, 2021-07-20
10**     Build:               b221011
11**
12**     Abstract:
13**         Linker file for the GNU C Compiler
14**
15**     Copyright 2016 Freescale Semiconductor, Inc.
16**     Copyright 2016-2022 NXP
17**     All rights reserved.
18**
19**     SPDX-License-Identifier: BSD-3-Clause
20**
21**     http:                 www.nxp.com
22**     mail:                 support@nxp.com
23**
24** ###################################################################
25*/
26
27/* Entry Point */
28ENTRY(Reset_Handler)
29
30HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x0400;
31STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
32VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x00000400 : 0;
33
34/* Specify the memory areas */
35MEMORY
36{
37  m_flash_config        (RX)  : ORIGIN = 0x60000000, LENGTH = 0x00001000
38  m_ivt                 (RX)  : ORIGIN = 0x60001000, LENGTH = 0x00001000
39  m_interrupts          (RX)  : ORIGIN = 0x60002000, LENGTH = 0x00000400
40  m_text                (RX)  : ORIGIN = 0x60002400, LENGTH = 0x007FDC00
41  m_qacode              (RX)  : ORIGIN = 0x00000000, LENGTH = 0x00020000
42  m_data                (RW)  : ORIGIN = 0x20000000, LENGTH = 0x00020000
43  m_data2               (RW)  : ORIGIN = 0x20200000, LENGTH = 0x00040000
44}
45
46/* Define output sections */
47SECTIONS
48{
49  __NCACHE_REGION_START = ORIGIN(m_data2);
50  __NCACHE_REGION_SIZE  = 0;
51
52  .flash_config :
53  {
54    . = ALIGN(4);
55    __FLASH_BASE = .;
56    KEEP(* (.boot_hdr.conf))     /* flash config section */
57    . = ALIGN(4);
58  } > m_flash_config
59
60  ivt_begin = ORIGIN(m_flash_config) + LENGTH(m_flash_config);
61
62  .ivt : AT(ivt_begin)
63  {
64    . = ALIGN(4);
65    KEEP(* (.boot_hdr.ivt))           /* ivt section */
66    KEEP(* (.boot_hdr.boot_data))     /* boot section */
67    KEEP(* (.boot_hdr.dcd_data))      /* dcd section */
68    . = ALIGN(4);
69  } > m_ivt
70
71  /* The startup code goes first into internal RAM */
72  .interrupts :
73  {
74    __VECTOR_TABLE = .;
75    __Vectors = .;
76    . = ALIGN(4);
77    KEEP(*(.isr_vector))     /* Startup code */
78    . = ALIGN(4);
79  } > m_interrupts
80
81  /* The program code and other data goes into internal RAM */
82  .text :
83  {
84    . = ALIGN(4);
85    *(.text)                 /* .text sections (code) */
86    *(.text*)                /* .text* sections (code) */
87    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
88    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
89    *(.glue_7)               /* glue arm to thumb code */
90    *(.glue_7t)              /* glue thumb to arm code */
91    *(.eh_frame)
92    KEEP (*(.init))
93    KEEP (*(.fini))
94    . = ALIGN(4);
95  } > m_text
96
97  .ARM.extab :
98  {
99    *(.ARM.extab* .gnu.linkonce.armextab.*)
100  } > m_text
101
102  .ARM :
103  {
104    __exidx_start = .;
105    *(.ARM.exidx*)
106    __exidx_end = .;
107  } > m_text
108
109 .ctors :
110  {
111    __CTOR_LIST__ = .;
112    /* gcc uses crtbegin.o to find the start of
113       the constructors, so we make sure it is
114       first.  Because this is a wildcard, it
115       doesn't matter if the user does not
116       actually link against crtbegin.o; the
117       linker won't look for a file to match a
118       wildcard.  The wildcard also means that it
119       doesn't matter which directory crtbegin.o
120       is in.  */
121    KEEP (*crtbegin.o(.ctors))
122    KEEP (*crtbegin?.o(.ctors))
123    /* We don't want to include the .ctor section from
124       from the crtend.o file until after the sorted ctors.
125       The .ctor section from the crtend file contains the
126       end of ctors marker and it must be last */
127    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
128    KEEP (*(SORT(.ctors.*)))
129    KEEP (*(.ctors))
130    __CTOR_END__ = .;
131  } > m_text
132
133  .dtors :
134  {
135    __DTOR_LIST__ = .;
136    KEEP (*crtbegin.o(.dtors))
137    KEEP (*crtbegin?.o(.dtors))
138    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
139    KEEP (*(SORT(.dtors.*)))
140    KEEP (*(.dtors))
141    __DTOR_END__ = .;
142  } > m_text
143
144  .preinit_array :
145  {
146    PROVIDE_HIDDEN (__preinit_array_start = .);
147    KEEP (*(.preinit_array*))
148    PROVIDE_HIDDEN (__preinit_array_end = .);
149  } > m_text
150
151  .init_array :
152  {
153    PROVIDE_HIDDEN (__init_array_start = .);
154    KEEP (*(SORT(.init_array.*)))
155    KEEP (*(.init_array*))
156    PROVIDE_HIDDEN (__init_array_end = .);
157  } > m_text
158
159  .fini_array :
160  {
161    PROVIDE_HIDDEN (__fini_array_start = .);
162    KEEP (*(SORT(.fini_array.*)))
163    KEEP (*(.fini_array*))
164    PROVIDE_HIDDEN (__fini_array_end = .);
165  } > m_text
166
167  __etext = .;    /* define a global symbol at end of code */
168  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
169
170  .interrupts_ram :
171  {
172    . = ALIGN(4);
173    __VECTOR_RAM__ = .;
174    __interrupts_ram_start__ = .; /* Create a global symbol at data start */
175    *(.m_interrupts_ram)     /* This is a user defined section */
176    . += VECTOR_RAM_SIZE;
177    . = ALIGN(4);
178    __interrupts_ram_end__ = .; /* Define a global symbol at data end */
179  } > m_data
180
181  __VECTOR_RAM = DEFINED(__ram_vector_table__) ? __VECTOR_RAM__ : ORIGIN(m_interrupts);
182  __RAM_VECTOR_TABLE_SIZE_BYTES = DEFINED(__ram_vector_table__) ? (__interrupts_ram_end__ - __interrupts_ram_start__) : 0x0;
183
184  .data : AT(__DATA_ROM)
185  {
186    . = ALIGN(4);
187    __DATA_RAM = .;
188    __data_start__ = .;      /* create a global symbol at data start */
189    *(m_usb_dma_init_data)
190    *(.data)                 /* .data sections */
191    *(.data*)                /* .data* sections */
192    *(DataQuickAccess)       /* quick access data section */
193    KEEP(*(.jcr*))
194    . = ALIGN(4);
195    __data_end__ = .;        /* define a global symbol at data end */
196  } > m_data
197
198  __ram_function_flash_start = __DATA_ROM + (__data_end__ - __data_start__); /* Symbol is used by startup for TCM data initialization */
199
200  .ram_function : AT(__ram_function_flash_start)
201  {
202    . = ALIGN(32);
203    __ram_function_start__ = .;
204    *(CodeQuickAccess)
205    . = ALIGN(128);
206    __ram_function_end__ = .;
207  } > m_qacode
208
209  __NDATA_ROM = __ram_function_flash_start + (__ram_function_end__ - __ram_function_start__);
210  .ncache.init : AT(__NDATA_ROM)
211  {
212    __noncachedata_start__ = .;   /* create a global symbol at ncache data start */
213    *(NonCacheable.init)
214    . = ALIGN(4);
215    __noncachedata_init_end__ = .;   /* create a global symbol at initialized ncache data end */
216  } > m_data
217  . = __noncachedata_init_end__;
218  .ncache :
219  {
220    *(NonCacheable)
221    . = ALIGN(4);
222    __noncachedata_end__ = .;     /* define a global symbol at ncache data end */
223  } > m_data
224
225  __DATA_END = __NDATA_ROM + (__noncachedata_init_end__ - __noncachedata_start__);
226  text_end = ORIGIN(m_text) + LENGTH(m_text);
227  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
228
229  /* Uninitialized data section */
230  .bss :
231  {
232    /* This is used by the startup in order to initialize the .bss section */
233    . = ALIGN(4);
234    __START_BSS = .;
235    __bss_start__ = .;
236    *(m_usb_dma_noninit_data)
237    *(.bss)
238    *(.bss*)
239    *(COMMON)
240    . = ALIGN(4);
241    __bss_end__ = .;
242    __END_BSS = .;
243  } > m_data
244
245  .heap :
246  {
247    . = ALIGN(8);
248    __end__ = .;
249    PROVIDE(end = .);
250    __HeapBase = .;
251    . += HEAP_SIZE;
252    __HeapLimit = .;
253    __heap_limit = .; /* Add for _sbrk */
254  } > m_data
255
256  .stack :
257  {
258    . = ALIGN(8);
259    . += STACK_SIZE;
260  } > m_data
261
262  /* Initializes stack on the end of block */
263  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
264  __StackLimit = __StackTop - STACK_SIZE;
265  PROVIDE(__stack = __StackTop);
266
267  .ARM.attributes 0 : { *(.ARM.attributes) }
268
269  ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
270}
271