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 = 0x18000400, LENGTH = 0x00000200
43  m_interrupts          (RX)  : ORIGIN = 0x18001000, LENGTH = 0x00000130
44  m_text                (RX)  : ORIGIN = 0x18001130, LENGTH = 0x000FECD0
45  m_veneer_table        (RX)  : ORIGIN = 0x180FFE00, LENGTH = 0x00000200
46  m_data                (RW)  : ORIGIN = 0x30140000, LENGTH = 0x00040000
47  m_usb_sram            (RW)  : ORIGIN = 0x50140000, LENGTH = 0x00004000
48}
49
50/* Define output sections */
51SECTIONS
52{
53  .flash_config :
54  {
55    . = ALIGN(4);
56    __FLASH_BASE = .;
57    KEEP(* (.flash_conf))     /* flash config section */
58    . = ALIGN(4);
59  } > m_flash_config
60
61  /* The startup code goes first into internal ram */
62  .interrupts :
63  {
64    . = ALIGN(4);
65    __VECTOR_TABLE = .;
66    __Vectors = .;
67    KEEP(*(.isr_vector))     /* Startup code */
68    . = ALIGN(4);
69  } > m_interrupts
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
86
87  /* section for veneer table */
88  .gnu.sgstubs :
89  {
90     . = ALIGN(32);
91     _start_sg = .;
92    *(.gnu.sgstubs*)
93     . = ALIGN(32);
94     _end_sg = .;
95  } > m_veneer_table
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    . += M_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    *(CodeQuickAccess)       /* CodeQuickAccess sections */
190    *(DataQuickAccess)       /* DataQuickAccess sections */
191    *(.data)                 /* .data sections */
192    *(.data*)                /* .data* sections */
193    KEEP(*(.jcr*))
194    . = ALIGN(4);
195    __data_end__ = .;        /* define a global symbol at data end */
196  } > m_data
197
198  __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
199  text_end = ORIGIN(m_text) + LENGTH(m_text);
200  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
201  _image_size = __DATA_END - __VECTOR_TABLE;
202
203  /* Uninitialized data section */
204  .bss :
205  {
206    /* This is used by the startup in order to initialize the .bss section */
207    . = ALIGN(4);
208    __START_BSS = .;
209    __bss_start__ = .;
210    *(.bss)
211    *(.bss*)
212    *(COMMON)
213    . = ALIGN(4);
214    __bss_end__ = .;
215    __END_BSS = .;
216  } > m_data
217
218  .heap :
219  {
220    . = ALIGN(8);
221    __end__ = .;
222    PROVIDE(end = .);
223    __HeapBase = .;
224    . += HEAP_SIZE;
225    __HeapLimit = .;
226    __heap_limit = .; /* Add for _sbrk */
227  } > m_data
228
229  .stack :
230  {
231    . = ALIGN(8);
232    . += STACK_SIZE;
233  } > m_data
234
235  m_usb_bdt (NOLOAD) :
236  {
237    . = ALIGN(512);
238    *(m_usb_bdt)
239  } > m_usb_sram
240
241  m_usb_global (NOLOAD) :
242  {
243    *(m_usb_global)
244  } > m_usb_sram
245
246  /* Initializes stack on the end of block */
247  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
248  __StackLimit = __StackTop - STACK_SIZE;
249  PROVIDE(__stack = __StackTop);
250
251  .ARM.attributes 0 : { *(.ARM.attributes) }
252
253  ASSERT(__StackLimit >= __HeapLimit, "region m_data overflowed with stack and heap")
254}
255
256