-
Notifications
You must be signed in to change notification settings - Fork 0
/
STM32F767ZITX_FLASH.ld
316 lines (262 loc) · 8.38 KB
/
STM32F767ZITX_FLASH.ld
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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
/*
******************************************************************************
**
** @file : LinkerScript.ld
**
** @author : Auto-generated by STM32CubeIDE - modified by Douglas P. Fields, Jr.
**
** Abstract : Linker script for NUCLEO-F767ZI Board embedding STM32F767ZITx Device from stm32f7 series
** 2048KBytes FLASH
** 512KBytes RAM
**
** Set heap size, stack size and stack location according
** to application requirements.
**
** Set memory bank area and size if external memory is used
**
** Target : STMicroelectronics STM32
**
** Distribution: The file is distributed as is, without any warranty
** of any kind.
**
******************************************************************************
** @attention
**
** Copyright (c) 2024 STMicroelectronics.
** All rights reserved.
**
** This software is licensed under terms that can be found in the LICENSE file
** in the root directory of this software component.
** If no LICENSE file comes with this software, it is provided AS-IS.
**
******************************************************************************
*/
/*
* Updated on: 2024-09-08
* Author: Douglas P. Fields, Jr.
* Copyright: 2024, Douglas P. Fields, Jr.
* License: Apache 2.0
*/
/*
I am splitting things into multiple memory regions.
DTCM: Very fast memory: Use for stack and specific variables.
SRAM1: Regular RAM: Use for most stuff by default.
SRAM2: Slower RAM than SRAM1: Use only for things that need
DMA not to conflict with SRAM1.
I created a special end of heap symbol, and implemented my own
_sbrk using it. That symbol is _heap_end. We no longer place the
stack to be growing down toward the heap.
So, memory usage:
DTCM
Stack starts somewhere and grows toward the beginning
Initialized Variables
BSS Variables
<empty>
SRAM1
.data
.bss
Heap
SRAM2
Nothing for now
*/
/* Entry Point */
ENTRY(Reset_Handler)
_Min_Heap_Size = 0x200; /* required amount of heap */
_Min_Stack_Size = 0x400; /* required amount of stack */
_DTCM_Stack_Size = 0x4000; /* 16 KB */
/* Highest address of the user mode stack */
_estack = ORIGIN(STACK) + LENGTH(STACK); /* Part of DTCM */
/* Heap End */
_heap_end = ORIGIN(RAM) + LENGTH(RAM);
/* RAM details:
RM0410 Rev 5 p77
DTCM: 0x2000 0000 - 0x2001 FFFF (128KB) Data Tightly Coupled Memory
SRAM1 0x2002 0000 - 0x2007 BFFF (368KB)
SRAM2 0x2007 C000 - 0x2007 FFFF ( 16KB)
ITCM: 0x0000 0000 - 0x0000 3FFF ( 16KB)
Let's see if it runs faster if I define all RAM to use the DTCM
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
LPT: 85 (all memory in DTCM)
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 512K
LPT: 79 (stack not in DTCM)
Later, I split it up so Stack is all in DTCM and it runs faster.
Then, I made the Stack & "fast BSS" and "fast RAM" to contain the
I/O queues, and now it runs at 85 too.
*/
/*
The Mamory map below 0x2000 0000 is Reserved 0x1FFF 0020 - 0x1FFF FFFF.
I wonder if it's fine to let the stack over-grow down to there?
We'll make the stack grow down AWAY from anything it can overwrite.
*/
/* Memories definition */
MEMORY
{
/* Used RAM sections */
RAM (xrw) : ORIGIN = 0x20020000, LENGTH = 368K /* SRAM1 */
STACK (xrw) : ORIGIN = 0x20000000, LENGTH = _DTCM_Stack_Size /* DTCM bottom */
FASTRAM (xrw) : ORIGIN = 0x20000000 + _DTCM_Stack_Size, LENGTH = 128K - _DTCM_Stack_Size /* DTCM TOP */
/* Memory mapped flash default addresses */
FLASH (xr ) : ORIGIN = 0x08000000, LENGTH = 2048K
/* Three actual SRAMs */
DTCM (xrw) : ORIGIN = 0x20000000 LENGTH = 128K
SRAM1 (xrw) : ORIGIN = 0x20020000, LENGTH = 368K
SRAM2 (xrw) : ORIGIN = 0x2007C000, LENGTH = 16k
}
/* Sections */
SECTIONS
{
/* The startup code into "FLASH" Rom type memory */
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector)) /* Startup code */
. = ALIGN(4);
} >FLASH
/* The program code and other data into "FLASH" Rom type memory */
.text :
{
. = ALIGN(4);
*(.text) /* .text sections (code) */
*(.text*) /* .text* sections (code) */
*(.glue_7) /* glue arm to thumb code */
*(.glue_7t) /* glue thumb to arm code */
*(.eh_frame)
KEEP (*(.init))
KEEP (*(.fini))
. = ALIGN(4);
_etext = .; /* define a global symbols at end of code */
} >FLASH
/* Constant data into "FLASH" Rom type memory */
.rodata :
{
. = ALIGN(4);
*(.rodata) /* .rodata sections (constants, strings, etc.) */
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
. = ALIGN(4);
} >FLASH
.ARM.extab (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
{
. = ALIGN(4);
*(.ARM.extab* .gnu.linkonce.armextab.*)
. = ALIGN(4);
} >FLASH
.ARM (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
{
. = ALIGN(4);
__exidx_start = .;
*(.ARM.exidx*)
__exidx_end = .;
. = ALIGN(4);
} >FLASH
.preinit_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
{
. = ALIGN(4);
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array*))
PROVIDE_HIDDEN (__preinit_array_end = .);
. = ALIGN(4);
} >FLASH
.init_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
{
. = ALIGN(4);
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array*))
PROVIDE_HIDDEN (__init_array_end = .);
. = ALIGN(4);
} >FLASH
.fini_array (READONLY) : /* The "READONLY" keyword is only supported in GCC11 and later, remove it if using GCC10 or earlier. */
{
. = ALIGN(4);
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT(.fini_array.*)))
KEEP (*(.fini_array*))
PROVIDE_HIDDEN (__fini_array_end = .);
. = ALIGN(4);
} >FLASH
/* Used by the startup to initialize data & fast_data */
_sidata = LOADADDR(.data);
_sifastdata = LOADADDR(.fast_data);
/* Initialized data sections into "RAM" Ram type memory */
.data :
{
. = ALIGN(4);
_sdata = .; /* create a global symbol at data start */
*(.data) /* .data sections */
*(.data*) /* .data* sections */
*(.RamFunc) /* .RamFunc sections */
*(.RamFunc*) /* .RamFunc* sections */
. = ALIGN(4);
_edata = .; /* define a global symbol at data end */
} >RAM AT> FLASH
/* Uninitialized data section into "RAM" Ram type memory */
. = ALIGN(4);
.bss :
{
/* This is used by the startup in order to initialize the .bss section */
_sbss = .; /* define a global symbol at bss start */
__bss_start__ = _sbss;
*(.bss)
*(.bss*)
*(COMMON)
. = ALIGN(4);
_ebss = .; /* define a global symbol at bss end */
__bss_end__ = _ebss;
} >RAM
/* User_heap section, used to check that there is enough "RAM" Ram type memory left */
._user_heap :
{
. = ALIGN(8);
PROVIDE ( end = . );
PROVIDE ( _end = . );
. = . + _Min_Heap_Size;
. = ALIGN(8);
} >RAM
/* *************************************************** */
/* Initialized data sections into "RAM" Ram type memory */
.fast_data :
{
. = ALIGN(4);
_sfastdata = .; /* create a global symbol at data start */
*(.fast_data) /* .fast_data sections */
*(.fast_data*) /* .fast_data* sections */
. = ALIGN(4);
_efastdata = .; /* define a global symbol at data end */
} >FASTRAM AT> FLASH
/* Fast data section */
._fast_bss :
{
_sfbss = .;
. = ALIGN(4);
*(.fast_bss)
*(.fast_bss*)
. = ALIGN(4);
_efbss = .;
} >FASTRAM
/* Fast noinit section - not used */
/*
._fast_noinit (NOLOAD) :
{
_sfnoinit = .;
. = ALIGN(4);
KEEP(*(*.noinit*))
. = ALIGN(4);
_efnoinit = .;
} >FASTRAM
*/
._user_stack :
{
. = ALIGN(8);
. = . + _Min_Stack_Size;
. = ALIGN(8);
} >STACK
/* Stack (grows toward fast data section) */
/* Remove information from the compiler libraries */
/DISCARD/ :
{
libc.a ( * )
libm.a ( * )
libgcc.a ( * )
}
.ARM.attributes 0 : { *(.ARM.attributes) }
}