forked from mciantyre/teensy4-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
t4link.x
219 lines (189 loc) · 7.04 KB
/
t4link.x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
INCLUDE device.x
MEMORY
{
ITCM (rwx): ORIGIN = 0x00000000, LENGTH = 512K
DTCM (rwx): ORIGIN = 0x20000000, LENGTH = 512K
RAM (rwx): ORIGIN = 0x20200000, LENGTH = 512K
FLASH (rwx): ORIGIN = 0x60000000, LENGTH = 1984K
}
EXTERN(__start);
/* This might get stripped out in dependent crates, but it's important to keep around. */
/* It's put into the FCB block below. */
EXTERN(FLEXSPI_CONFIGURATION_BLOCK);
EXTERN(__EXCEPTIONS);
EXTERN(__INTERRUPTS);
EXTERN(DefaultHandler);
PROVIDE(NonMaskableInt = DefaultHandler);
EXTERN(HardFaultTrampoline);
PROVIDE(MemoryManagement = DefaultHandler);
PROVIDE(BusFault = DefaultHandler);
PROVIDE(UsageFault = DefaultHandler);
PROVIDE(SecureFault = DefaultHandler);
PROVIDE(SVCall = DefaultHandler);
PROVIDE(DebugMonitor = DefaultHandler);
PROVIDE(PendSV = DefaultHandler);
PROVIDE(SysTick = DefaultHandler);
PROVIDE(HardFault = HardFault_);
PROVIDE(DefaultHandler = DefaultHandler_);
PROVIDE(__pre_init = DefaultPreInit);
SECTIONS
{
/* If you add more sections to FLASH, you must add this section here */
__lflash = SIZEOF(.boot) + SIZEOF(.vector_table) + SIZEOF(.text) + SIZEOF(.data) + SIZEOF(.gnu.sgstubs);
/* The boot section contains all the special things that allow the IMXRT1062 to boot */
.boot ORIGIN(FLASH) :
{
/* Firmware Configuration Block (FCB) */
KEEP(*(.fcb));
FILL(0xFFFFFFFF);
. = ORIGIN(FLASH) + 0x1000;
__ivt = .;
/* ------------------
* Image Vector Table
* ------------------
*/
LONG(0x402000D1); /* Header, magic number */
LONG(__sivectors); /* Address of the vectors table */
LONG(0x00000000); /* RESERVED */
LONG(0x00000000); /* Device Configuration Data (unused) */
LONG(__boot_data); /* Address to boot data */
LONG(__ivt); /* Self reference, required by boot ROM */
LONG(0x00000000); /* Command Sequence File (unused) */
LONG(0x00000000); /* RESERVED */
/* ---------
* Boot data
* ---------
*/
__boot_data = .;
LONG(ORIGIN(FLASH)); /* Start of image (origin of flash) */
LONG(__lflash); /* Length of flash */
LONG(0x00000000); /* Plugin flag (unused) */
/* --------- */
KEEP(*(.boot.start)) /* Shim reset handler for TCM init */
*(.flashmem); /* Compatibility with USB stack */
*(.progmem); /* Compat with USB stack */
} > FLASH
/* The following are used to compute the FlexRAM banks for ITCM / DTCM */
__itcm_block_count = (SIZEOF(.text) + 0x7FFF) >> 15;
__flexram_bank_config = 0xAAAAAAAA | ((1 << (__itcm_block_count * 2)) - 1);
PROVIDE(__stack_start = ORIGIN(DTCM) + ((16 - __itcm_block_count) << 15));
/* ## Sections in FLASH */
/* ### Vector table */
.vector_table : ALIGN(1024)
{
__sivectors = .;
/* Initial Stack Pointer (SP) value */
LONG(__stack_start);
/* Reset vector */
LONG(__start);
__reset_vector = .;
/* Exceptions */
KEEP(*(.vector_table.exceptions)); /* this is the `__EXCEPTIONS` symbol */
__eexceptions = .;
/* Device specific interrupts */
KEEP(*(.vector_table.interrupts)); /* this is the `__INTERRUPTS` symbol */
} > FLASH
/* ### .text */
.text :
{
__stext = .;
/* place these 2 close to each other or the `b` instruction will fail to link */
*(.PreResetTrampoline);
*(.Reset);
*(.text .text.*);
*(.HardFaultTrampoline);
*(.HardFault.*);
. = ALIGN(4); /* Pad .text to the alignment to workaround overlapping load section bug in old lld */
} > ITCM AT> FLASH
. = ALIGN(4); /* Ensure __etext is aligned if something unaligned is inserted after .text */
__etext = .; /* Define outside of .text to allow using INSERT AFTER .text */
__sitext = LOADADDR(.text);
/* ### .gnu.sgstubs
This section contains the TrustZone-M veneers put there by the Arm GNU linker. */
. = ALIGN(32); /* Security Attribution Unit blocks must be 32 bytes aligned. */
__veneer_base = ALIGN(4);
.gnu.sgstubs : ALIGN(4)
{
*(.gnu.sgstubs*)
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
} > FLASH
. = ALIGN(4); /* Ensure __veneer_limit is aligned if something unaligned is inserted after .gnu.sgstubs */
__veneer_limit = .;
/* ## Sections in RAM */
/* ### .data */
.data : ALIGN(4)
{
. = ALIGN(4);
__sdata = .;
*(.data .data.*);
*(.rodata .rodata.*);
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
__edata = .;
/* Keep outside of the [__sdata, __edata] range so that it's not overwritten */
KEEP(*(.vector_table.ram));
} > DTCM AT>FLASH
/* LMA of .data */
__sidata = LOADADDR(.data);
/* ### .bss */
. = ALIGN(4);
__sbss = .; /* Define outside of section to include INSERT BEFORE/AFTER symbols */
.bss (NOLOAD) : ALIGN(4)
{
*(.bss .bss.*);
*(COMMON); /* Uninitialized C statics */
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
} > DTCM
. = ALIGN(4); /* Ensure __ebss is aligned if something unaligned is inserted after .bss */
__ebss = .;
/* ### .uninit */
.uninit (NOLOAD) : ALIGN(4)
{
. = ALIGN(4);
*(.uninit .uninit.*);
. = ALIGN(4);
} > DTCM
. = ALIGN(4); /* Ensure alignment in case of INSERT AFTER */
__sheap_dtcm = .;
.dma (NOLOAD) :
{
*(.dmabuffers); /* Compat with USB */
. = ALIGN(16);
} > RAM
.heap (NOLOAD) : ALIGN(4)
{
. = ALIGN(4);
__sheap = .;
. = ORIGIN(RAM) + LENGTH(RAM);
__eheap = .;
} > RAM
/* ## .got */
/* Dynamic relocations are unsupported. This section is only used to detect relocatable code in
the input files and raise an error if relocatable code is found */
.got (NOLOAD) :
{
KEEP(*(.got .got.*));
}
/* ## Discarded sections */
/DISCARD/ :
{
/* Unused exception related info that only wastes space */
*(.ARM.exidx);
*(.ARM.exidx.*);
*(.ARM.extab.*);
}
}
/* Asserts that check some Rust requirements */
ASSERT(ORIGIN(FLASH) % 4 == 0, "
ERROR(cortex-m-rt): the start of the FLASH region must be 4-byte aligned");
ASSERT(ORIGIN(RAM) % 4 == 0, "
ERROR(cortex-m-rt): the start of the RAM region must be 4-byte aligned");
ASSERT(__sdata % 4 == 0 && __edata % 4 == 0, "
ERROR(cortex-m-rt): .data is not 4-byte aligned");
ASSERT(__sidata % 4 == 0, "
ERROR(cortex-m-rt): the LMA of .data is not 4-byte aligned");
ASSERT(__sbss % 4 == 0 && __ebss % 4 == 0, "
ERROR(cortex-m-rt): .bss is not 4-byte aligned");
ASSERT(__stext % 4 == 0 && __etext % 4 == 0, "
ERROR(cortex-m-rt): .text is not 4-byte aligned");
ASSERT(__sheap % 4 == 0, "
ERROR(cortex-m-rt): start of heap is not 4-byte aligned");