Skip to content

Commit 0d83f21

Browse files
committed
Update linker script templates to include stack
Update the linker script templates to include the ability to adjust the boot stack stack size.
1 parent a03ce45 commit 0d83f21

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

docs/reference/contributing/target/bootstrap.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ Arm linker script template:
4949
#define MBED_APP_SIZE ROM_SIZE
5050
#endif
5151
52+
#if !defined(MBED_BOOT_STACK_SIZE)
53+
#define MBED_BOOT_STACK_SIZE 0x1000
54+
#endif
55+
5256
/* Round up VECTORS_SIZE to 8 bytes */
53-
#define VECTORS_SIZE (((VECTORS * 4) + 7) & ~7)
57+
#define VECTORS_SIZE (((VECTORS * 4) + 7) AND ~7)
5458
5559
LR_IROM1 MBED_APP_START MBED_APP_SIZE {
5660
@@ -60,9 +64,11 @@ LR_IROM1 MBED_APP_START MBED_APP_SIZE {
6064
.ANY (+RO)
6165
}
6266
63-
RW_IRAM1 (RAM_START + VECTORS_SIZE) (RAM_SIZE - VECTORS_SIZE) { ; RW data
67+
RW_IRAM1 (RAM_START + VECTORS_SIZE) (RAM_SIZE - VECTORS_SIZE - MBED_BOOT_STACK_SIZE) { ; RW data
6468
.ANY (+RW +ZI)
6569
}
70+
ARM_LIB_STACK (RAM_START + RAM_SIZE) EMPTY -MBED_BOOT_STACK_SIZE { ; Stack region growing down
71+
}
6672
}
6773
```
6874

@@ -88,17 +94,20 @@ if (!isdefinedsymbol(MBED_APP_SIZE)) {
8894
define symbol MBED_APP_SIZE = ROM_SIZE;
8995
}
9096
97+
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
98+
define symbol MBED_BOOT_STACK_SIZE = 0x1000;
99+
}
100+
91101
/* Round up VECTORS_SIZE to 8 bytes */
92102
define symbol VECTORS_SIZE = ((VECTORS * 4) + 7) & ~7;
93103
define symbol RAM_REGION_START = RAM_START + VECTORS_SIZE;
94104
define symbol RAM_REGION_SIZE = RAM_SIZE - VECTORS_SIZE;
95-
define symbol ISR_STACK_SIZE = 0x400;
96105
97106
define memory mem with size = 4G;
98107
define region ROM_region = mem:[from MBED_APP_START size MBED_APP_SIZE];
99108
define region RAM_region = mem:[from RAM_REGION_START size RAM_REGION_SIZE];
100109
101-
define block CSTACK with alignment = 8, size = ISR_STACK_SIZE { };
110+
define block CSTACK with alignment = 8, size = MBED_BOOT_STACK_SIZE { };
102111
define block HEAP with alignment = 8, size = HEAP_SIZE { };
103112
104113
initialize by copy { readwrite };
@@ -133,6 +142,10 @@ GCC linker script template:
133142
#define MBED_APP_SIZE ROM_SIZE
134143
#endif
135144
145+
#if !defined(MBED_BOOT_STACK_SIZE)
146+
#define MBED_BOOT_STACK_SIZE 0x1000
147+
#endif
148+
136149
/* Round up VECTORS_SIZE to 8 bytes */
137150
#define VECTORS_SIZE (((VECTORS * 4) + 7) & 0xFFFFFFF8)
138151
@@ -265,6 +278,7 @@ SECTIONS
265278
__end__ = .;
266279
PROVIDE(end = .);
267280
*(.heap*)
281+
. = ORIGIN(RAM) + LENGTH(RAM) - MBED_BOOT_STACK_SIZE;
268282
__HeapLimit = .;
269283
} > RAM
270284
@@ -279,7 +293,7 @@ SECTIONS
279293
/* Set stack top to end of RAM, and stack limit move down by
280294
* size of stack_dummy section */
281295
__StackTop = ORIGIN(RAM) + LENGTH(RAM);
282-
__StackLimit = __StackTop - SIZEOF(.stack_dummy);
296+
__StackLimit = __StackTop - MBED_BOOT_STACK_SIZE;
283297
PROVIDE(__stack = __StackTop);
284298
285299
/* Check if data + heap + stack exceeds RAM limit */

0 commit comments

Comments
 (0)