@@ -18,7 +18,7 @@ If you are updating your own linker script, you must:
18
18
19
19
- Reserve space for the RAM vector table.
20
20
- Define the heap region:
21
- - Arm - The heap starts immediately after the region ` RW_IRAM1 ` and ends at the start of the ` ARM_LIB_STACK ` region.
21
+ - Arm - The heap is the ` ARM_LIB_HEAP ` region.
22
22
- GCC_ARM - The heap starts at the symbol ` __end__ ` and ends at the ` __HeapLimit ` symbol.
23
23
- IAR - The heap is the ` HEAP ` region.
24
24
- Define the boot stack region:
@@ -38,43 +38,44 @@ Arm linker script template:
38
38
39
39
/* Device specific values */
40
40
41
- #define ROM_START 0x08000000
42
- #define ROM_SIZE 0x200000
43
- #define RAM_START 0x20000000
44
- #define RAM_SIZE 0x30000
45
- #define VECTORS 107 /* This value must match NVIC_NUM_VECTORS */
41
+ /* Tools provide -DMBED_ROM_START=xxx -DMBED_ROM_SIZE=xxx -DMBED_RAM_START=xxx -DMBED_RAM_SIZE=xxx */
42
+
43
+ #define VECTORS xx /* This value must match NVIC_NUM_VECTORS */
46
44
47
45
/* Common - Do not change */
48
46
49
47
#if !defined(MBED_APP_START)
50
- #define MBED_APP_START ROM_START
48
+ #define MBED_APP_START MBED_ROM_START
51
49
#endif
52
50
53
51
#if !defined(MBED_APP_SIZE)
54
- #define MBED_APP_SIZE ROM_SIZE
52
+ #define MBED_APP_SIZE MBED_ROM_SIZE
55
53
#endif
56
54
57
55
#if !defined(MBED_BOOT_STACK_SIZE)
58
- /* This value is normally defined by the tools
59
- to 0x400 for mbed 2 and 0x1000 for mbed 5 */
60
- #define MBED_BOOT_STACK_SIZE 0x1000
56
+ /* This value is normally defined by the tools to 0x1000 for bare metal and 0x400 for RTOS */
57
+ #define MBED_BOOT_STACK_SIZE 0x400
61
58
#endif
62
59
63
60
/* Round up VECTORS_SIZE to 8 bytes */
64
- #define VECTORS_SIZE (((VECTORS * 4) + 7) AND ~7)
61
+ #define VECTORS_SIZE (((VECTORS * 4) + 7) AND ~7)
65
62
66
- LR_IROM1 MBED_APP_START MBED_APP_SIZE {
63
+ LR_IROM1 MBED_APP_START MBED_APP_SIZE {
67
64
68
- ER_IROM1 MBED_APP_START MBED_APP_SIZE {
65
+ ER_IROM1 MBED_APP_START MBED_APP_SIZE {
69
66
*.o (RESET, +First)
70
67
*(InRoot$$Sections)
71
68
.ANY (+RO)
72
69
}
73
70
74
- RW_IRAM1 (RAM_START + VECTORS_SIZE) (RAM_SIZE - VECTORS_SIZE - MBED_BOOT_STACK_SIZE ) { ; RW data
71
+ RW_IRAM1 (RAM_START + VECTORS_SIZE) { ; RW data
75
72
.ANY (+RW +ZI)
76
73
}
77
- ARM_LIB_STACK (RAM_START + RAM_SIZE) EMPTY -MBED_BOOT_STACK_SIZE { ; Stack region growing down
74
+
75
+ ARM_LIB_HEAP AlignExpr(+0, 16) EMPTY (MBED_RAM_START + MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE - AlignExpr(ImageLimit(RW_IRAM1), 16)) { ; Heap growing up
76
+ }
77
+
78
+ ARM_LIB_STACK (RAM_START + RAM_SIZE) EMPTY -MBED_BOOT_STACK_SIZE { ; Stack region growing down
78
79
}
79
80
}
80
81
```
@@ -84,33 +85,31 @@ IAR linker script template:
84
85
```
85
86
/* Device specific values */
86
87
87
- define symbol ROM_START = 0x08000000;
88
- define symbol ROM_SIZE = 0x200000;
89
- define symbol RAM_START = 0x20000000;
90
- define symbol RAM_SIZE = 0x30000;
91
- define symbol VECTORS = 107; /* This value must match NVIC_NUM_VECTORS */
88
+ /* Tools provide -DMBED_ROM_START=xxx -DMBED_ROM_SIZE=xxx -DMBED_RAM_START=xxx -DMBED_RAM_SIZE=xxx */
89
+
90
+ define symbol VECTORS = xx; /* This value must match NVIC_NUM_VECTORS */
92
91
define symbol HEAP_SIZE = 0x10000;
93
92
94
93
/* Common - Do not change */
95
94
96
95
if (!isdefinedsymbol(MBED_APP_START)) {
97
- define symbol MBED_APP_START = ROM_START ;
96
+ define symbol MBED_APP_START = MBED_ROM_START ;
98
97
}
99
98
100
99
if (!isdefinedsymbol(MBED_APP_SIZE)) {
101
- define symbol MBED_APP_SIZE = ROM_SIZE ;
100
+ define symbol MBED_APP_SIZE = MBED_ROM_SIZE ;
102
101
}
103
102
104
103
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
105
104
/* This value is normally defined by the tools
106
- to 0x400 for mbed 2 and 0x1000 for mbed 5 */
107
- define symbol MBED_BOOT_STACK_SIZE = 0x1000 ;
105
+ to 0x1000 for bare metal and 0x400 for RTOS */
106
+ define symbol MBED_BOOT_STACK_SIZE = 0x400 ;
108
107
}
109
108
110
109
/* Round up VECTORS_SIZE to 8 bytes */
111
110
define symbol VECTORS_SIZE = ((VECTORS * 4) + 7) & ~7;
112
- define symbol RAM_REGION_START = RAM_START + VECTORS_SIZE;
113
- define symbol RAM_REGION_SIZE = RAM_SIZE - VECTORS_SIZE;
111
+ define symbol RAM_REGION_START = MBED_RAM_START + VECTORS_SIZE;
112
+ define symbol RAM_REGION_SIZE = MBED_RAM_SIZE - VECTORS_SIZE;
114
113
115
114
define memory mem with size = 4G;
116
115
define region ROM_region = mem:[from MBED_APP_START size MBED_APP_SIZE];
@@ -135,26 +134,24 @@ GCC linker script template:
135
134
```
136
135
/* Device specific values */
137
136
138
- #define ROM_START 0x08000000
139
- #define ROM_SIZE 0x200000
140
- #define RAM_START 0x20000000
141
- #define RAM_SIZE 0x30000
142
- #define VECTORS 107 /* This value must match NVIC_NUM_VECTORS */
137
+ /* Tools provide -DMBED_ROM_START=xxx -DMBED_ROM_SIZE=xxx -DMBED_RAM_START=xxx -DMBED_RAM_SIZE=xxx */
138
+
139
+ #define VECTORS xx /* This value must match NVIC_NUM_VECTORS */
143
140
144
141
/* Common - Do not change */
145
142
146
143
#if !defined(MBED_APP_START)
147
- #define MBED_APP_START ROM_START
144
+ #define MBED_APP_START MBED_ROM_START
148
145
#endif
149
146
150
147
#if !defined(MBED_APP_SIZE)
151
- #define MBED_APP_SIZE ROM_SIZE
148
+ #define MBED_APP_SIZE MBED_ROM_SIZE
152
149
#endif
153
150
154
151
#if !defined(MBED_BOOT_STACK_SIZE)
155
152
/* This value is normally defined by the tools
156
- to 0x400 for mbed 2 and 0x1000 for mbed 5 */
157
- #define MBED_BOOT_STACK_SIZE 0x1000
153
+ to 0x1000 for bare metal and 0x400 for RTOS */
154
+ #define MBED_BOOT_STACK_SIZE 0x400
158
155
#endif
159
156
160
157
/* Round up VECTORS_SIZE to 8 bytes */
@@ -163,7 +160,7 @@ GCC linker script template:
163
160
MEMORY
164
161
{
165
162
FLASH (rx) : ORIGIN = MBED_APP_START, LENGTH = MBED_APP_SIZE
166
- RAM (rwx) : ORIGIN = RAM_START + VECTORS_SIZE, LENGTH = RAM_SIZE - VECTORS_SIZE
163
+ RAM (rwx) : ORIGIN = MBED_RAM_START + VECTORS_SIZE, LENGTH = MBED_RAM_SIZE - VECTORS_SIZE
167
164
}
168
165
169
166
/* Linker script to place sections and symbol values. Should be used together
@@ -237,50 +234,62 @@ SECTIONS
237
234
238
235
/* Location counter can end up 2byte aligned with narrow Thumb code but
239
236
__etext is assumed by startup code to be the LMA of a section in RAM
240
- which must be 4byte aligned */
241
- __etext = ALIGN (4 );
237
+ which must be 8-byte aligned */
238
+ __etext = ALIGN (8 );
242
239
243
240
.data : AT (__etext)
244
241
{
245
242
__data_start__ = .;
246
243
*(vtable)
247
244
*(.data*)
248
245
249
- . = ALIGN(4 );
246
+ . = ALIGN(8 );
250
247
/* preinit data */
251
248
PROVIDE_HIDDEN (__preinit_array_start = .);
252
249
KEEP(*(.preinit_array))
253
250
PROVIDE_HIDDEN (__preinit_array_end = .);
254
251
255
- . = ALIGN(4 );
252
+ . = ALIGN(8 );
256
253
/* init data */
257
254
PROVIDE_HIDDEN (__init_array_start = .);
258
255
KEEP(*(SORT(.init_array.*)))
259
256
KEEP(*(.init_array))
260
257
PROVIDE_HIDDEN (__init_array_end = .);
261
258
262
-
263
- . = ALIGN(4);
259
+ . = ALIGN(8);
264
260
/* finit data */
265
261
PROVIDE_HIDDEN (__fini_array_start = .);
266
262
KEEP(*(SORT(.fini_array.*)))
267
263
KEEP(*(.fini_array))
268
264
PROVIDE_HIDDEN (__fini_array_end = .);
269
265
270
266
KEEP(*(.jcr*))
271
- . = ALIGN(4 );
267
+ . = ALIGN(8 );
272
268
/* All data end */
273
269
__data_end__ = .;
274
270
275
271
} > RAM
276
272
273
+ /* Uninitialized data section
274
+ * This region is not initialized by the C/C++ library and can be used to
275
+ * store state across soft reboots. */
276
+ .uninitialized (NOLOAD):
277
+ {
278
+ . = ALIGN(32);
279
+ __uninitialized_start = .;
280
+ *(.uninitialized)
281
+ KEEP(*(.keep.uninitialized))
282
+ . = ALIGN(32);
283
+ __uninitialized_end = .;
284
+ } > RAM
285
+
277
286
.bss :
278
287
{
279
- . = ALIGN(4 );
288
+ . = ALIGN(8 );
280
289
__bss_start__ = .;
281
290
*(.bss*)
282
291
*(COMMON)
283
- . = ALIGN(4 );
292
+ . = ALIGN(8 );
284
293
__bss_end__ = .;
285
294
} > RAM
286
295
0 commit comments