Skip to content

Commit 1ead033

Browse files
committed
Add framework for configuring boot stack size
Add the target config option "boot-stack-size" which is passed to the linker as the define "MBED_BOOT_STACK_SIZE" so the linker can adjust the stack accordingly. On mbed 2 the boot stack becomes the main stack after boot. On mbed 5 the boot stack becomes the ISR stack after boot. Because of these different uses the stack size for mbed 2 is set to 4K by default while on mbed 5 it is set to 1k. Additionally, the NRF5X family requires a larger interrupt stack size due to the softdevice so the size is increased to 2k on mbed 5 builds.
1 parent 4c996f0 commit 1ead033

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

rtos/mbed_lib.json

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,22 @@
33
"config": {
44
"present": 1
55
},
6-
"macros": ["_RTE_"]
6+
"macros": ["_RTE_"],
7+
"target_overrides": {
8+
"*": {
9+
"target.boot-stack-size": "0x400"
10+
},
11+
"MCU_NRF51": {
12+
"target.boot-stack-size": "0x800"
13+
},
14+
"MCU_NRF52840": {
15+
"target.boot-stack-size": "0x800"
16+
},
17+
"MCU_NRF52832": {
18+
"target.boot-stack-size": "0x800"
19+
},
20+
"MCU_NRF51_UNIFIED": {
21+
"target.boot-stack-size": "0x800"
22+
}
23+
}
724
}

targets/targets.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
"network-default-interface-type": {
2121
"help": "Default network interface type. Typical options: null, ETHERNET, WIFI, CELLULAR, MESH",
2222
"value": null
23+
},
24+
"boot-stack-size": {
25+
"help": "Define the boot stack size in bytes. This value must be a multiple of 8",
26+
"value": "0x1000"
2327
}
2428
}
2529
},

tools/toolchains/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,12 +742,22 @@ def add_regions(self):
742742
except ConfigException:
743743
pass
744744

745+
def add_linker_defines(self):
746+
stack_param = "target.boot-stack-size"
747+
params, _ = self.config_data
748+
749+
if stack_param in params:
750+
define_string = self.make_ld_define("MBED_BOOT_STACK_SIZE", int(params[stack_param].value, 0))
751+
self.ld.append(define_string)
752+
self.flags["ld"].append(define_string)
753+
745754
# Set the configuration data
746755
def set_config_data(self, config_data):
747756
self.config_data = config_data
748757
# new configuration data can change labels, so clear the cache
749758
self.labels = None
750759
self.add_regions()
760+
self.add_linker_defines()
751761

752762
# Creates the configuration header if needed:
753763
# - if there is no configuration data, "mbed_config.h" is not create (or deleted if it exists).

0 commit comments

Comments
 (0)