1/*
2** ###################################################################
3**     Processors:          MIMXRT685SFAWBR_cm33
4**                          MIMXRT685SFFOB_cm33
5**                          MIMXRT685SFVKB_cm33
6**
7**     Compiler:            GNU C Compiler
8**     Reference manual:    MIMXRT685 User manual Rev. 0.95 11 November 2019
9**     Version:             rev. 1.0, 2018-06-19
10**     Build:               b210303
11**
12**     Abstract:
13**         Linker file for the GNU C Compiler
14**
15**     Copyright 2016 Freescale Semiconductor, Inc.
16**     Copyright 2016-2021 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
28
29/* Entry Point */
30ENTRY(Reset_Handler)
31
32HEAP_SIZE  = DEFINED(__heap_size__)  ? __heap_size__  : 0x0400;
33STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400;
34M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x00000130 : 0;
35
36/* Specify the memory areas */
37/* The SRAM region [0x10000-0x1BFFF] is reserved for ROM code. */
38/* The SRAM region [0x0-0xFFFF], [0x1C000-0x1FFFF] is reserved for app-specific use cases. */
39/* The SRAM region [0x20000-0x7FFFF] is reserved for Non-cached shared memory between M33 and DSP. */
40MEMORY
41{
42  m_flash_config        (RX)  : ORIGIN = 0x08000400, LENGTH = 0x00000200
43  m_interrupts          (RX)  : ORIGIN = 0x08001000, LENGTH = 0x00000130
44  m_text                (RX)  : ORIGIN = 0x08001130, LENGTH = 0x001FEED0
45  m_data                (RW)  : ORIGIN = 0x20080000, LENGTH = 0x00180000
46  m_usb_sram            (RW)  : ORIGIN = 0x40140000, LENGTH = 0x00004000
47}
48
49/* Define output sections */
50SECTIONS
51{
52  .flash_config :
53  {
54    . = ALIGN(4);
55    __FLASH_BASE = .;
56    KEEP(* (.flash_conf))     /* flash config section */
57    . = ALIGN(4);
58  } > m_flash_config
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    . = ALIGN(4);
68  } > m_interrupts
69
70  /* The program code and other data goes into internal ram */
71  .text :
72  {
73    . = ALIGN(4);
74    *(.text)                 /* .text sections (code) */
75    *(.text*)                /* .text* sections (code) */
76    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
77    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
78    *(.glue_7)               /* glue arm to thumb code */
79    *(.glue_7t)              /* glue thumb to arm code */
80    *(.eh_frame)
81    KEEP (*(.init))
82    KEEP (*(.fini))
83    . = ALIGN(4);
84  } > m_text
85
86  .ARM.extab :
87  {
88    *(.ARM.extab* .gnu.linkonce.armextab.*)
89  } > m_text
90
91  .ARM :
92  {
93    __exidx_start = .;
94    *(.ARM.exidx*)
95    __exidx_end = .;
96  } > m_text
97
98 .ctors :
99  {
100    __CTOR_LIST__ = .;
101    /* gcc uses crtbegin.o to find the start of
102       the constructors, so we make sure it is
103       first.  Because this is a wildcard, it
104       doesn't matter if the user does not
105       actually link against crtbegin.o; the
106       linker won't look for a file to match a
107       wildcard.  The wildcard also means that it
108       doesn't matter which directory crtbegin.o
109       is in.  */
110    KEEP (*crtbegin.o(.ctors))
111    KEEP (*crtbegin?.o(.ctors))
112    /* We don't want to include the .ctor section from
113       from the crtend.o file until after the sorted ctors.
114       The .ctor section from the crtend file contains the
115       end of ctors marker and it must be last */
116    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
117    KEEP (*(SORT(.ctors.*)))
118    KEEP (*(.ctors))
119    __CTOR_END__ = .;
120  } > m_text
121
122  .dtors :
123  {
124    __DTOR_LIST__ = .;
125    KEEP (*crtbegin.o(.dtors))
126    KEEP (*crtbegin?.o(.dtors))
127    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
128    KEEP (*(SORT(.dtors.*)))
129    KEEP (*(.dtors))
130    __DTOR_END__ = .;
131  } > m_text
132
133  .preinit_array :
134  {
135    PROVIDE_HIDDEN (__preinit_array_start = .);
136    KEEP (*(.preinit_array*))
137    PROVIDE_HIDDEN (__preinit_array_end = .);
138  } > m_text
139
140  .init_array :
141  {
142    PROVIDE_HIDDEN (__init_array_start = .);
143    KEEP (*(SORT(.init_array.*)))
144    KEEP (*(.init_array*))
145    PROVIDE_HIDDEN (__init_array_end = .);
146  } > m_text
147
148  .fini_array :
149  {
150    PROVIDE_HIDDEN (__fini_array_start = .);
151    KEEP (*(SORT(.fini_array.*)))
152    KEEP (*(.fini_array*))
153    PROVIDE_HIDDEN (__fini_array_end = .);
154  } > m_text
155
156  __etext = .;    /* define a global symbol at end of code */
157  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
158
159  .interrupts_ram :
160  {
161    . = ALIGN(4);
162    __VECTOR_RAM__ = .;
163    __interrupts_ram_start__ = .; /* Create a global symbol at data start */
164    *(.m_interrupts_ram)     /* This is a user defined section */
165    . += M_VECTOR_RAM_SIZE;
166    . = ALIGN(4);
167    __interrupts_ram_end__ = .; /* Define a global symbol at data end */
168  } > m_data
169
170  __VECTOR_RAM = DEFINED(__ram_vector_table__) ? __VECTOR_RAM__ : ORIGIN(m_interrupts);
171  __RAM_VECTOR_TABLE_SIZE_BYTES = DEFINED(__ram_vector_table__) ? (__interrupts_ram_end__ - __interrupts_ram_start__) : 0x0;
172
173  .data : AT(__DATA_ROM)
174  {
175    . = ALIGN(4);
176    __DATA_RAM = .;
177    __data_start__ = .;      /* create a global symbol at data start */
178    *(CodeQuickAccess)       /* CodeQuickAccess sections */
179    *(DataQuickAccess)       /* DataQuickAccess sections */
180    *(.data)                 /* .data sections */
181    *(.data*)                /* .data* sections */
182    KEEP(*(.jcr*))
183    . = ALIGN(4);
184    __data_end__ = .;        /* define a global symbol at data end */
185  } > m_data
186
187  __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
188  text_end = ORIGIN(m_text) + LENGTH(m_text);
189  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
190  _image_size = __DATA_END - __VECTOR_TABLE;
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