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;
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] is reserved for app-specific use cases. */
38/* The SRAM region [0x20000-0x7FFFF] is reserved for Non-cached shared memory between M33 and DSP. */
39MEMORY
40{
41  m_flash               (RX)  : ORIGIN = 0x08000000, LENGTH = 0x00200000
42  m_interrupts          (RX)  : ORIGIN = 0x00080000, LENGTH = 0x00000130
43  m_text                (RX)  : ORIGIN = 0x00080130, LENGTH = 0x000FFED0
44  m_data                (RW)  : ORIGIN = 0x20180000, LENGTH = 0x00080000
45  m_usb_sram            (RW)  : ORIGIN = 0x40140000, LENGTH = 0x00004000
46}
47
48/* Define output sections */
49SECTIONS
50{
51  .flash_config :
52  {
53    FILL(0x00)
54    __FLASH_BASE = .;
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    . = ALIGN(4);
68  } > m_interrupts AT> m_flash
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 AT> m_flash
85
86  .ARM.extab :
87  {
88    *(.ARM.extab* .gnu.linkonce.armextab.*)
89  } > m_text AT> m_flash
90
91  .ARM :
92  {
93    __exidx_start = .;
94    *(.ARM.exidx*)
95    __exidx_end = .;
96  } > m_text AT> m_flash
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 AT> m_flash
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 AT> m_flash
132
133  .preinit_array :
134  {
135    PROVIDE_HIDDEN (__preinit_array_start = .);
136    KEEP (*(.preinit_array*))
137    PROVIDE_HIDDEN (__preinit_array_end = .);
138  } > m_text AT> m_flash
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 AT> m_flash
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 AT> m_flash
155
156  __etext = .;    /* define a global symbol at end of code */
157  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
158
159  __VECTOR_RAM = ORIGIN(m_interrupts);
160  __RAM_VECTOR_TABLE_SIZE_BYTES = 0x0;
161
162  .data :
163  {
164    . = ALIGN(4);
165    __DATA_RAM = .;
166    __data_start__ = .;      /* create a global symbol at data start */
167    *(CodeQuickAccess)       /* CodeQuickAccess sections */
168    *(DataQuickAccess)       /* DataQuickAccess sections */
169    *(.data)                 /* .data sections */
170    *(.data*)                /* .data* sections */
171    KEEP(*(.jcr*))
172    . = ALIGN(4);
173    __data_end__ = .;        /* define a global symbol at data end */
174  } > m_data AT> m_flash
175
176  __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
177  _image_size = __DATA_END - __VECTOR_TABLE;
178  ASSERT(_image_size <= LENGTH(m_flash), "region m_flash overflowed with text and data")
179
180  /* Uninitialized data section */
181  .bss :
182  {
183    /* This is used by the startup in order to initialize the .bss section */
184    . = ALIGN(4);
185    __START_BSS = .;
186    __bss_start__ = .;
187    *(.bss)
188    *(.bss*)
189    *(COMMON)
190    . = ALIGN(4);
191    __bss_end__ = .;
192    __END_BSS = .;
193  } > m_data
194
195  .heap :
196  {
197    . = ALIGN(8);
198    __end__ = .;
199    PROVIDE(end = .);
200    __HeapBase = .;
201    . += HEAP_SIZE;
202    __HeapLimit = .;
203    __heap_limit = .; /* Add for _sbrk */
204  } > m_data
205
206  .stack :
207  {
208    . = ALIGN(8);
209    . += STACK_SIZE;
210  } > m_data
211
212  m_usb_bdt (NOLOAD) :
213  {
214    . = ALIGN(512);
215    *(m_usb_bdt)
216  } > m_usb_sram
217
218  m_usb_global (NOLOAD) :
219  {
220    *(m_usb_global)
221  } > m_usb_sram
222
223  /* Initializes stack on the end of block */
224  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
225  __StackLimit = __StackTop - STACK_SIZE;
226  PROVIDE(__stack = __StackTop);
227
228  .ARM.attributes 0 : { *(.ARM.attributes) }
229
230  ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
231}
232
233