@@ -17,12 +17,17 @@ After adding the core files, the next step is to add linker scripts for Mbed OS.
17
17
If you are updating your own linker script, you must:
18
18
19
19
- Reserve space for the RAM vector table.
20
- - Define the start of the heap:
21
- - Arm - The heap starts immediately after the region ` RW_IRAM1 ` .
22
- - GCC_ARM - The heap starts at the symbol ` __end__ ` .
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 .
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
- - Add defines for a relocatable application - ` MBED_APP_START ` and ` MBED_APP_SIZE ` .
25
- - Add preprocessing directive ` #! armcc -E ` (ARM compiler only).
24
+ - Define the boot stack region:
25
+ - Arm - The boot stack is the ` ARM_LIB_STACK ` region.
26
+ - GCC_ARM - The boot stack starts at the symbol ` __StackLimit ` and ends at the symbol ` __StackTop ` .
27
+ - IAR - The boot stack is the ` CSTACK ` region.
28
+ - Add defines for a relocatable application - ` MBED_APP_START ` and ` MBED_APP_SIZE ` .
29
+ - Add the define for boot stack size - ` MBED_BOOT_STACK_SIZE ` .
30
+ - Add preprocessing directive ` #! armcc -E ` (ARM compiler only).
26
31
27
32
If you are using the below linker script, then you need to update all the defines in the ` /* Device specific values */ ` section for your target.
28
33
@@ -49,8 +54,14 @@ Arm linker script template:
49
54
#define MBED_APP_SIZE ROM_SIZE
50
55
#endif
51
56
57
+ #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
61
+ #endif
62
+
52
63
/* Round up VECTORS_SIZE to 8 bytes */
53
- #define VECTORS_SIZE (((VECTORS * 4) + 7) & ~7)
64
+ #define VECTORS_SIZE (((VECTORS * 4) + 7) AND ~7)
54
65
55
66
LR_IROM1 MBED_APP_START MBED_APP_SIZE {
56
67
@@ -60,9 +71,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE {
60
71
.ANY (+RO)
61
72
}
62
73
63
- RW_IRAM1 (RAM_START + VECTORS_SIZE) (RAM_SIZE - VECTORS_SIZE) { ; RW data
74
+ RW_IRAM1 (RAM_START + VECTORS_SIZE) (RAM_SIZE - VECTORS_SIZE - MBED_BOOT_STACK_SIZE ) { ; RW data
64
75
.ANY (+RW +ZI)
65
76
}
77
+ ARM_LIB_STACK (RAM_START + RAM_SIZE) EMPTY -MBED_BOOT_STACK_SIZE { ; Stack region growing down
78
+ }
66
79
}
67
80
```
68
81
@@ -88,17 +101,22 @@ if (!isdefinedsymbol(MBED_APP_SIZE)) {
88
101
define symbol MBED_APP_SIZE = ROM_SIZE;
89
102
}
90
103
104
+ if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
105
+ /* 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;
108
+ }
109
+
91
110
/* Round up VECTORS_SIZE to 8 bytes */
92
111
define symbol VECTORS_SIZE = ((VECTORS * 4) + 7) & ~7;
93
112
define symbol RAM_REGION_START = RAM_START + VECTORS_SIZE;
94
113
define symbol RAM_REGION_SIZE = RAM_SIZE - VECTORS_SIZE;
95
- define symbol ISR_STACK_SIZE = 0x400;
96
114
97
115
define memory mem with size = 4G;
98
116
define region ROM_region = mem:[from MBED_APP_START size MBED_APP_SIZE];
99
117
define region RAM_region = mem:[from RAM_REGION_START size RAM_REGION_SIZE];
100
118
101
- define block CSTACK with alignment = 8, size = ISR_STACK_SIZE { };
119
+ define block CSTACK with alignment = 8, size = MBED_BOOT_STACK_SIZE { };
102
120
define block HEAP with alignment = 8, size = HEAP_SIZE { };
103
121
104
122
initialize by copy { readwrite };
@@ -133,6 +151,12 @@ GCC linker script template:
133
151
#define MBED_APP_SIZE ROM_SIZE
134
152
#endif
135
153
154
+ #if !defined(MBED_BOOT_STACK_SIZE)
155
+ /* 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
158
+ #endif
159
+
136
160
/* Round up VECTORS_SIZE to 8 bytes */
137
161
#define VECTORS_SIZE (((VECTORS * 4) + 7) & 0xFFFFFFF8)
138
162
@@ -265,6 +289,7 @@ SECTIONS
265
289
__end__ = .;
266
290
PROVIDE(end = .);
267
291
*(.heap*)
292
+ . = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE;
268
293
__HeapLimit = .;
269
294
} > RAM
270
295
@@ -279,7 +304,7 @@ SECTIONS
279
304
/* Set stack top to end of RAM, and stack limit move down by
280
305
* size of stack_dummy section */
281
306
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
282
- __StackLimit = __StackTop - SIZEOF(.stack_dummy) ;
307
+ __StackLimit = __StackTop - MBED_BOOT_STACK_SIZE ;
283
308
PROVIDE(__stack = __StackTop);
284
309
285
310
/* Check if data + heap + stack exceeds RAM limit */
0 commit comments