15
15
%% endmacro
16
16
17
17
%% macro prefix()
18
+ OUTPUT_FORMAT("elf32-littlearm")
19
+ OUTPUT_ARCH(arm)
20
+ ENTRY(Reset_Handler)
21
+
18
22
MEMORY
19
23
{
20
- %% for memory in ( memories + cont_ram_regions)
24
+ %% for memory in memories
21
25
{{ memory.name | upper }} ({{ memory.access }}) : ORIGIN = {{ "0x%08X" % memory.start }}, LENGTH = {{ memory.size }}
22
- %% endfor
26
+ %% endfor
27
+ %% for memory in cont_ram_regions
28
+ %% if memory.cont_name != memory.name
29
+ {{ memory.cont_name | upper }} ({{ memory.access }}) : ORIGIN = {{ "0x%08X" % memory.start }}, LENGTH = {{ memory.size }}
30
+ %% endif
31
+ %% endfor
32
+ %% if linkerscript_memory
23
33
{{ linkerscript_memory | indent(first=True) }}
34
+ %% endif
24
35
}
25
36
26
- %% for memory in memories
37
+ %% for memory in memories
27
38
__{{memory.name}}_start = ORIGIN({{memory.name|upper}});
28
39
__{{memory.name}}_end = ORIGIN({{memory.name|upper}}) + LENGTH({{memory.name|upper}});
29
- %% endfor
30
-
31
- OUTPUT_FORMAT("elf32-littlearm")
32
- OUTPUT_ARCH(arm)
33
- ENTRY(Reset_Handler)
40
+ %% endfor
41
+ %#
34
42
35
- /* the handler stack is used for main program as well as interrupts */
43
+ /* The handler stack is used for main program as well as interrupts */
36
44
MAIN_STACK_SIZE = {{ options[":platform:cortex-m:main_stack_size"] }};
37
45
PROCESS_STACK_SIZE = {{ process_stack_size }};
38
46
TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
39
47
%% endmacro
40
48
41
49
42
50
%% macro section_vector_rom(memory)
51
+ /* Read-only vector table in {{memory}} */
43
52
.text :
44
53
{
45
54
__vector_table_rom_start = .;
46
55
__vector_table_ram_load = .;
47
- /* Initial stack address, Reset and NMI handler */
48
56
KEEP(*(.vector_rom))
57
+ __vector_table_rom_end = .;
49
58
} >{{memory}}
50
59
%% endmacro
51
60
52
61
53
62
%% macro section_vector_ram(memory, table_copy)
63
+ /* Read-Write vector table in {{memory}} */
54
64
%% do table_copy.append("vector_table_ram")
55
65
.vectors (NOLOAD) :
56
66
{
57
67
__vector_table_ram_start = .;
58
- /* Vector table in RAM, only if remapped */
59
68
KEEP(*(.vector_ram))
60
69
. = ALIGN(4);
61
70
__vector_table_ram_end = .;
@@ -64,10 +73,11 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
64
73
65
74
66
75
%% macro section_stack(memory, start=None)
76
+ /* Main stack in {{memory}} */
67
77
.stack (NOLOAD) :
68
78
{
69
79
%% if start != None
70
- . = {{ start }};
80
+ . + = {{ start }};
71
81
%% endif
72
82
__stack_start = .;
73
83
@@ -85,6 +95,7 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
85
95
86
96
87
97
%% macro section_tables(memory, copy, zero, heap)
98
+ /* Memory layout configuration tables */
88
99
.rodata :
89
100
{
90
101
. = ALIGN(4);
@@ -104,35 +115,27 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
104
115
__table_copy_intern_end = .;
105
116
106
117
__table_zero_extern_start = .;
118
+ %% if linkerscript_extern_zero
107
119
{{ linkerscript_extern_zero | indent(8, first=True) }}
120
+ %% endif
108
121
__table_zero_extern_end = .;
109
122
__table_copy_extern_start = .;
123
+ %% if linkerscript_extern_copy
110
124
{{ linkerscript_extern_copy | indent(8, first=True) }}
125
+ %% endif
111
126
__table_copy_extern_end = .;
112
127
113
- /* SRAM properties bit mask (16-bit):
114
- *
115
- * - 0x0001: accessible via S-Bus
116
- * - 0x0002: accessible via D-Bus
117
- * - 0x0004: accessible via I-Bus
118
- * - 0x0008: accessible via DMA
119
- * - 0x0010: accessible via DMA2D
120
- *
121
- * - 0x1FE0: reserved
122
- *
123
- * - 0x2000: Fast memory (Core- or Tightly-Coupled)
124
- * - 0x4000: non-volatile (or battery backed) memory
125
- * - 0x8000: external memory
126
- */
128
+ /* See `modm:architecture:memory` for bitmask */
127
129
__table_heap_start = .;
128
130
%% for section in heap
129
131
LONG({{ section.prop }})
130
132
LONG(__{{ section.name }}_start)
131
133
LONG(__{{ section.name }}_end)
132
134
%% endfor
135
+ %% if linkerscript_extern_heap
133
136
{{ linkerscript_extern_heap | indent(8, first=True) }}
137
+ %% endif
134
138
__table_heap_end = .;
135
-
136
139
} >{{memory}}
137
140
%% endmacro
138
141
@@ -147,9 +150,9 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
147
150
. = ALIGN(4);
148
151
__{{name}}_end = .;
149
152
} >{{memory}}
150
-
151
153
%% do table_copy.extend(sections)
152
154
%% for section in sections
155
+ %#
153
156
.{{section}} :
154
157
{
155
158
__{{section}}_load = LOADADDR(.{{section}});
@@ -172,8 +175,8 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
172
175
. = ALIGN(4);
173
176
__{{section}}_end = .;
174
177
} >{{ placement if placement else memory }}
178
+ %#
175
179
%% endfor
176
-
177
180
.{{name}} (NOLOAD) :
178
181
{
179
182
. = ALIGN(4);
@@ -187,20 +190,22 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
187
190
%% macro all_heap_sections(table_copy, table_zero, table_heap)
188
191
%% for cont_region in cont_ram_regions
189
192
%% for region in cont_region.contains
193
+ /* Sections in {{ region.name|upper }} */
190
194
%% if region.index
191
- {{ section(cont_region.name |upper + " AT >FLASH", "data_"+region.name, table_copy) }}
195
+ {{ section(cont_region.cont_name |upper + " AT >FLASH", "data_"+region.name, table_copy) }}
192
196
%% do table_zero.append("bss_"+region.name)
193
197
%% endif
194
-
195
- {{ section_heap(region.name|upper, "heap_"+region.name, cont_region.name|upper,
198
+ {{ section_heap(region.name|upper, "heap_"+region.name, cont_region.cont_name|upper,
196
199
sections=(["bss_"+region.name] if region.index else []) + ["noinit_"+region.name]) }}
197
200
%% do table_heap.insert(region.index, {"name": "heap_"+region.name, "prop": "0x2013" if "dtcm" in region.name else "0x001f"})
201
+ %#
198
202
%% endfor
199
203
%% endfor
200
204
%% endmacro
201
205
202
206
203
207
%% macro section_rom(memory)
208
+ /* Read-only sections in {{memory}} */
204
209
.text :
205
210
{
206
211
*(.text .text.* .gnu.linkonce.t.*)
@@ -219,7 +224,6 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
219
224
__init_array_end = .;
220
225
221
226
__hardware_init_start = .;
222
- /* Table symbols are alphabetically sorted! */
223
227
KEEP(*(SORT(.hardware_init.order_*)))
224
228
KEEP(*(SORT(.hardware_init)))
225
229
. = ALIGN(4);
@@ -233,13 +237,15 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
233
237
__build_id = .;
234
238
KEEP(*(.note.gnu.build-id))
235
239
} >{{memory}}
240
+
236
241
/* We do not call static destructors ever */
237
242
/DISCARD/ :
238
243
{
239
244
*(.fini_array .fini_array.*)
240
245
}
241
-
242
246
%% if with_cpp_exceptions
247
+ %#
248
+ /* C++ exception unwind tables */
243
249
.exidx :
244
250
{
245
251
. = ALIGN(4);
@@ -255,9 +261,8 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
255
261
KEEP(*(.eh_frame*))
256
262
} >{{memory}}
257
263
%% else
258
- /* Unwind tables are used to unwind the stack for C++ exceptions. Even
259
- * though we disabled exceptions, pre-compiled libraries such as libstdc++
260
- * still have to raise exceptions. */
264
+ %#
265
+ /* C++ exception unwind tables are discarded */
261
266
/DISCARD/ :
262
267
{
263
268
*(.ARM.extab* .gnu.linkonce.armextab.*)
@@ -266,16 +271,18 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
266
271
}
267
272
%% endif
268
273
%% if not with_heap
274
+ %#
275
+ /* Catch use of dynamic memory without `modm:platform:heap` module. */
269
276
/DISCARD/ :
270
277
{
271
- /* See `modm:platform:heap` module for an explanation! */
272
278
*({{no_heap_section}})
273
279
}
274
280
%% endif
275
281
%% endmacro
276
282
277
283
278
284
%% macro section_ram(memory, rom, table_copy, table_zero, sections_data=[], sections_bss=[])
285
+ /* Read-write sections in {{memory}} */
279
286
%% do table_copy.append("data")
280
287
.data :
281
288
{
@@ -286,9 +293,9 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
286
293
. = ALIGN(4);
287
294
__data_end = .;
288
295
} >{{memory}} AT >{{rom}}
289
-
290
296
%% do table_copy.extend(sections_data)
291
297
%% for section in sections_data
298
+ %#
292
299
.{{section}} :
293
300
{
294
301
__{{section}}_load = LOADADDR(.{{section}});
@@ -298,7 +305,7 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
298
305
__{{section}}_end = .;
299
306
} >{{memory}} AT >{{rom}}
300
307
%% endfor
301
-
308
+ %#
302
309
%% do table_zero.append("bss")
303
310
.bss (NOLOAD) :
304
311
{
@@ -307,9 +314,9 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
307
314
. = ALIGN(4);
308
315
__bss_end = .;
309
316
} >{{memory}}
310
-
311
317
%% do table_zero.extend(sections_bss)
312
318
%% for section in sections_bss
319
+ %#
313
320
.{{section}} (NOLOAD) :
314
321
{
315
322
__{{section}}_start = . ;
@@ -318,7 +325,7 @@ TOTAL_STACK_SIZE = MAIN_STACK_SIZE + PROCESS_STACK_SIZE;
318
325
__{{section}}_end = .;
319
326
} >{{memory}}
320
327
%% endfor
321
-
328
+ %#
322
329
.noinit (NOLOAD) :
323
330
{
324
331
__noinit_start = .;
0 commit comments