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 = 0x18000000, LENGTH = 0x00041000
42  m_interrupts          (RX)  : ORIGIN = 0x10080000, LENGTH = 0x00000130
43  m_text                (RX)  : ORIGIN = 0x10080130, LENGTH = 0x0003FCD0
44  m_veneer_table        (RX)  : ORIGIN = 0x100BFE00, LENGTH = 0x00000200
45  m_data                (RW)  : ORIGIN = 0x30140000, LENGTH = 0x00040000
46  m_usb_sram            (RW)  : ORIGIN = 0x50140000, LENGTH = 0x00004000
47}
48
49/* Define output sections */
50SECTIONS
51{
52  .flash_config :
53  {
54    FILL(0x00)
55    __FLASH_BASE = .;
56    . = 0x400 ;
57    KEEP(* (.flash_conf))     /* flash config section */
58    . = 0x1000 ;
59  } > m_flash
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 AT> m_flash
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 AT> m_flash
86
87
88  .ARM.extab :
89  {
90    *(.ARM.extab* .gnu.linkonce.armextab.*)
91  } > m_text AT> m_flash
92
93  .ARM :
94  {
95    __exidx_start = .;
96    *(.ARM.exidx*)
97    __exidx_end = .;
98  } > m_text AT> m_flash
99
100 .ctors :
101  {
102    __CTOR_LIST__ = .;
103    /* gcc uses crtbegin.o to find the start of
104       the constructors, so we make sure it is
105       first.  Because this is a wildcard, it
106       doesn't matter if the user does not
107       actually link against crtbegin.o; the
108       linker won't look for a file to match a
109       wildcard.  The wildcard also means that it
110       doesn't matter which directory crtbegin.o
111       is in.  */
112    KEEP (*crtbegin.o(.ctors))
113    KEEP (*crtbegin?.o(.ctors))
114    /* We don't want to include the .ctor section from
115       from the crtend.o file until after the sorted ctors.
116       The .ctor section from the crtend file contains the
117       end of ctors marker and it must be last */
118    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
119    KEEP (*(SORT(.ctors.*)))
120    KEEP (*(.ctors))
121    __CTOR_END__ = .;
122  } > m_text AT> m_flash
123
124  .dtors :
125  {
126    __DTOR_LIST__ = .;
127    KEEP (*crtbegin.o(.dtors))
128    KEEP (*crtbegin?.o(.dtors))
129    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
130    KEEP (*(SORT(.dtors.*)))
131    KEEP (*(.dtors))
132    __DTOR_END__ = .;
133  } > m_text AT> m_flash
134
135  .preinit_array :
136  {
137    PROVIDE_HIDDEN (__preinit_array_start = .);
138    KEEP (*(.preinit_array*))
139    PROVIDE_HIDDEN (__preinit_array_end = .);
140  } > m_text AT> m_flash
141
142  .init_array :
143  {
144    PROVIDE_HIDDEN (__init_array_start = .);
145    KEEP (*(SORT(.init_array.*)))
146    KEEP (*(.init_array*))
147    PROVIDE_HIDDEN (__init_array_end = .);
148  } > m_text AT> m_flash
149
150  .fini_array :
151  {
152    PROVIDE_HIDDEN (__fini_array_start = .);
153    KEEP (*(SORT(.fini_array.*)))
154    KEEP (*(.fini_array*))
155    PROVIDE_HIDDEN (__fini_array_end = .);
156  } > m_text AT> m_flash
157
158  __etext = .;    /* define a global symbol at end of code */
159  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
160
161  __VECTOR_RAM = ORIGIN(m_interrupts);
162  __RAM_VECTOR_TABLE_SIZE_BYTES = 0x0;
163
164  .data :
165  {
166    . = ALIGN(4);
167    __DATA_RAM = .;
168    __data_start__ = .;      /* create a global symbol at data start */
169    *(CodeQuickAccess)       /* CodeQuickAccess sections */
170    *(DataQuickAccess)       /* DataQuickAccess sections */
171    *(.data)                 /* .data sections */
172    *(.data*)                /* .data* sections */
173    KEEP(*(.jcr*))
174    . = ALIGN(4);
175    __data_end__ = .;        /* define a global symbol at data end */
176  } > m_data AT> m_flash
177
178  /* section for veneer table */
179  .gnu.sgstubs : AT(ORIGIN(m_flash) + 0x1000 + ORIGIN(m_veneer_table) - ORIGIN(m_interrupts))
180  {
181     . = ALIGN(32);
182     _start_sg = .;
183    *(.gnu.sgstubs*)
184     . = ALIGN(32);
185     _end_sg = .;
186  } > m_veneer_table
187
188  __DATA_END = __DATA_ROM + (__data_end__ - __data_start__);
189  _image_size = __DATA_END - __VECTOR_TABLE;
190  ASSERT(_image_size <= LENGTH(m_flash), "region m_flash overflowed with text and data")
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