1/*
2** ###################################################################
3**     Processors:          MIMXRT1165CVM5A_cm4
4**                          MIMXRT1165DVM6A_cm4
5**                          MIMXRT1165XVM5A_cm4
6**
7**     Compiler:            GNU C Compiler
8**     Reference manual:    IMXRT1160RM, Rev 0, 03/2021
9**     Version:             rev. 0.2, 2023-02-27
10**     Build:               b230302
11**
12**     Abstract:
13**         Linker file for the GNU C Compiler
14**
15**     Copyright 2016 Freescale Semiconductor, Inc.
16**     Copyright 2016-2023 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;
32RPMSG_SHMEM_SIZE = DEFINED(__use_shmem__) ? 0x2000 : 0;
33NCACHE_HEAP_START = DEFINED(__heap_noncacheable__) ? 0x20250000 - HEAP_SIZE : 0x20020000 - HEAP_SIZE;
34NCACHE_HEAP_SIZE  = DEFINED(__heap_noncacheable__) ? HEAP_SIZE : 0x0000;
35
36/* Specify the memory areas */
37MEMORY
38{
39  m_interrupts          (RX)  : ORIGIN = 0x1FFE0000, LENGTH = 0x00000400
40  m_text                (RX)  : ORIGIN = 0x1FFE0400, LENGTH = 0x0001FC00
41  m_data                (RW)  : ORIGIN = 0x20000000, LENGTH = DEFINED(__heap_noncacheable__) ? 0x00020000 : 0x00020000 - HEAP_SIZE
42  m_ncache              (RW)  : ORIGIN = 0x20248000, LENGTH = DEFINED(__heap_noncacheable__) ? 0x00008000 - HEAP_SIZE : 0x00008000
43  m_data2               (RW)  : ORIGIN = 0x20240000, LENGTH = 0x00008000
44  m_heap                (RW)  : ORIGIN = NCACHE_HEAP_START, LENGTH = HEAP_SIZE
45  rpmsg_sh_mem          (RW)  : ORIGIN = 0x202C0000, LENGTH = RPMSG_SHMEM_SIZE
46}
47
48/* Define output sections */
49SECTIONS
50{
51  __NCACHE_REGION_START = ORIGIN(m_ncache);
52  __NCACHE_REGION_SIZE  = LENGTH(m_ncache) + NCACHE_HEAP_SIZE;
53
54  __RPMSG_SH_MEM_START = ORIGIN(rpmsg_sh_mem);
55  __RPMSG_SH_MEM_SIZE  = LENGTH(rpmsg_sh_mem);
56
57  /* NOINIT section for rpmsg_sh_mem */
58  .noinit_rpmsg_sh_mem (NOLOAD) : ALIGN(4)
59  {
60     __RPMSG_SH_MEM_START__ = .;
61     *(.noinit.$rpmsg_sh_mem*)
62     . = ALIGN(4) ;
63     __RPMSG_SH_MEM_END__ = .;
64  } > rpmsg_sh_mem
65
66  /* The startup code goes first into internal RAM */
67  .interrupts :
68  {
69    __VECTOR_TABLE = .;
70    __Vectors = .;
71    . = ALIGN(4);
72    KEEP(*(.isr_vector))     /* Startup code */
73    . = ALIGN(4);
74  } > m_interrupts
75
76  /* The program code and other data goes into internal RAM */
77  .text :
78  {
79    . = ALIGN(4);
80    *(.text)                 /* .text sections (code) */
81    *(.text*)                /* .text* sections (code) */
82    *(.rodata)               /* .rodata sections (constants, strings, etc.) */
83    *(.rodata*)              /* .rodata* sections (constants, strings, etc.) */
84    *(CodeQuickAccess)       /* quick access code section */
85    *(.glue_7)               /* glue arm to thumb code */
86    *(.glue_7t)              /* glue thumb to arm code */
87    *(.eh_frame)
88    KEEP (*(.init))
89    KEEP (*(.fini))
90    . = ALIGN(4);
91  } > m_text
92
93  .ARM.extab :
94  {
95    *(.ARM.extab* .gnu.linkonce.armextab.*)
96  } > m_text
97
98  .ARM :
99  {
100    __exidx_start = .;
101    *(.ARM.exidx*)
102    __exidx_end = .;
103  } > m_text
104
105 .ctors :
106  {
107    __CTOR_LIST__ = .;
108    /* gcc uses crtbegin.o to find the start of
109       the constructors, so we make sure it is
110       first.  Because this is a wildcard, it
111       doesn't matter if the user does not
112       actually link against crtbegin.o; the
113       linker won't look for a file to match a
114       wildcard.  The wildcard also means that it
115       doesn't matter which directory crtbegin.o
116       is in.  */
117    KEEP (*crtbegin.o(.ctors))
118    KEEP (*crtbegin?.o(.ctors))
119    /* We don't want to include the .ctor section from
120       from the crtend.o file until after the sorted ctors.
121       The .ctor section from the crtend file contains the
122       end of ctors marker and it must be last */
123    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .ctors))
124    KEEP (*(SORT(.ctors.*)))
125    KEEP (*(.ctors))
126    __CTOR_END__ = .;
127  } > m_text
128
129  .dtors :
130  {
131    __DTOR_LIST__ = .;
132    KEEP (*crtbegin.o(.dtors))
133    KEEP (*crtbegin?.o(.dtors))
134    KEEP (*(EXCLUDE_FILE(*crtend?.o *crtend.o) .dtors))
135    KEEP (*(SORT(.dtors.*)))
136    KEEP (*(.dtors))
137    __DTOR_END__ = .;
138  } > m_text
139
140  .preinit_array :
141  {
142    PROVIDE_HIDDEN (__preinit_array_start = .);
143    KEEP (*(.preinit_array*))
144    PROVIDE_HIDDEN (__preinit_array_end = .);
145  } > m_text
146
147  .init_array :
148  {
149    PROVIDE_HIDDEN (__init_array_start = .);
150    KEEP (*(SORT(.init_array.*)))
151    KEEP (*(.init_array*))
152    PROVIDE_HIDDEN (__init_array_end = .);
153  } > m_text
154
155  .fini_array :
156  {
157    PROVIDE_HIDDEN (__fini_array_start = .);
158    KEEP (*(SORT(.fini_array.*)))
159    KEEP (*(.fini_array*))
160    PROVIDE_HIDDEN (__fini_array_end = .);
161  } > m_text
162
163  __etext = .;    /* define a global symbol at end of code */
164  __DATA_ROM = .; /* Symbol is used by startup for data initialization */
165
166  __VECTOR_RAM = ORIGIN(m_interrupts);
167  __RAM_VECTOR_TABLE_SIZE_BYTES = 0x0;
168
169  .data : AT(__DATA_ROM)
170  {
171    . = ALIGN(4);
172    __DATA_RAM = .;
173    __data_start__ = .;      /* create a global symbol at data start */
174    *(m_usb_dma_init_data)
175    *(.data)                 /* .data sections */
176    *(.data*)                /* .data* sections */
177    *(DataQuickAccess)       /* quick access data section */
178    KEEP(*(.jcr*))
179    . = ALIGN(4);
180    __data_end__ = .;        /* define a global symbol at data end */
181  } > m_data
182
183  __NDATA_ROM = __DATA_ROM + (__data_end__ - __data_start__);
184  .ncache.init : AT(__NDATA_ROM)
185  {
186    __noncachedata_start__ = .;   /* create a global symbol at ncache data start */
187    *(NonCacheable.init)
188    . = ALIGN(4);
189    __noncachedata_init_end__ = .;   /* create a global symbol at initialized ncache data end */
190  } > m_ncache
191  . = __noncachedata_init_end__;
192  .ncache :
193  {
194    *(NonCacheable)
195    . = ALIGN(4);
196    __noncachedata_end__ = .;     /* define a global symbol at ncache data end */
197  } > m_ncache
198
199  __DATA_END = __NDATA_ROM + (__noncachedata_init_end__ - __noncachedata_start__);
200  text_end = ORIGIN(m_text) + LENGTH(m_text);
201  ASSERT(__DATA_END <= text_end, "region m_text overflowed with text and data")
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    *(m_usb_dma_noninit_data)
211    *(.bss)
212    *(.bss*)
213    *(COMMON)
214    . = ALIGN(4);
215    __bss_end__ = .;
216    __END_BSS = .;
217  } > m_data
218
219  .heap :
220  {
221    . = ALIGN(8);
222    __end__ = .;
223    PROVIDE(end = .);
224    __HeapBase = .;
225    . += HEAP_SIZE;
226    __HeapLimit = .;
227    __heap_limit = .; /* Add for _sbrk */
228  } > m_heap
229
230  .stack :
231  {
232    . = ALIGN(8);
233    . += STACK_SIZE;
234    __StackEnd = .;
235  } > m_data
236
237  /* Initializes stack on the end of block */
238  __StackTop   = ORIGIN(m_data) + LENGTH(m_data);
239  __StackLimit = __StackTop - STACK_SIZE;
240  PROVIDE(__stack = __StackTop);
241
242  .ARM.attributes 0 : { *(.ARM.attributes) }
243
244  ASSERT(__StackLimit >= __StackEnd, "region m_data overflowed with stack and heap")
245}
246