-
Notifications
You must be signed in to change notification settings - Fork 3k
Add framework for configuring boot stack size #8039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,22 @@ | |
"config": { | ||
"present": 1 | ||
}, | ||
"macros": ["_RTE_"] | ||
"macros": ["_RTE_"], | ||
"target_overrides": { | ||
"*": { | ||
"target.boot-stack-size": "0x400" | ||
}, | ||
"MCU_NRF51": { | ||
"target.boot-stack-size": "0x800" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will it be good to move these overrides in targets.json instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The size in targets.json is the size for mbed 2 - |
||
}, | ||
"MCU_NRF52840": { | ||
"target.boot-stack-size": "0x800" | ||
}, | ||
"MCU_NRF52832": { | ||
"target.boot-stack-size": "0x800" | ||
}, | ||
"MCU_NRF51_UNIFIED": { | ||
"target.boot-stack-size": "0x800" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,12 +53,6 @@ ENTRY(Reset_Handler) | |
|
||
__ram_vector_table__ = 1; | ||
|
||
/* With the RTOS in use, this does not affect the main stack size. The size of | ||
* the stack where main runs is determined via the RTOS. */ | ||
__stack_size__ = 0x400; | ||
|
||
__heap_size__ = 0x6000; | ||
|
||
#if !defined(MBED_APP_START) | ||
#define MBED_APP_START 0 | ||
#endif | ||
|
@@ -67,6 +61,16 @@ __heap_size__ = 0x6000; | |
#define MBED_APP_SIZE 0x100000 | ||
#endif | ||
|
||
#if !defined(MBED_BOOT_STACK_SIZE) | ||
#define MBED_BOOT_STACK_SIZE 0x400 | ||
#endif | ||
|
||
/* With the RTOS in use, this does not affect the main stack size. The size of | ||
* the stack where main runs is determined via the RTOS. */ | ||
__stack_size__ = MBED_BOOT_STACK_SIZE; | ||
|
||
__heap_size__ = 0x6000; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like |
||
|
||
HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x0400; | ||
STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x0400; | ||
M_VECTOR_RAM_SIZE = DEFINED(__ram_vector_table__) ? 0x0400 : 0x0; | ||
|
@@ -259,7 +263,7 @@ SECTIONS | |
__end__ = .; | ||
PROVIDE(end = .); | ||
__HeapBase = .; | ||
. += HEAP_SIZE; | ||
. = ORIGIN(m_data_2) + LENGTH(m_data_2) - STACK_SIZE; | ||
__HeapLimit = .; | ||
__heap_limit = .; /* Add for _sbrk */ | ||
} > m_data_2 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,10 +49,6 @@ | |
*/ | ||
define symbol __ram_vector_table__ = 1; | ||
|
||
/* Heap 1/4 of ram and stack 1/8 */ | ||
define symbol __stack_size__=0x8000; | ||
define symbol __heap_size__=0x10000; | ||
|
||
if (!isdefinedsymbol(MBED_APP_START)) { | ||
define symbol MBED_APP_START = 0; | ||
} | ||
|
@@ -61,6 +57,13 @@ if (!isdefinedsymbol(MBED_APP_SIZE)) { | |
define symbol MBED_APP_SIZE = 0x100000; | ||
} | ||
|
||
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) { | ||
define symbol MBED_BOOT_STACK_SIZE = 0x400; | ||
} | ||
|
||
define symbol __stack_size__=MBED_BOOT_STACK_SIZE; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @theotherjimmy does the name MBED_BOOT_STACK_SIZE seems reasonable to you? Alternatively I could set this to the target define that is set - MBED_CONF_TARGET_BOOT_STACK_SIZE. Let me know what you think. |
||
define symbol __heap_size__=0x10000; | ||
|
||
define symbol __ram_vector_table_size__ = isdefinedsymbol(__ram_vector_table__) ? 0x00000400 : 0; | ||
define symbol __ram_vector_table_offset__ = isdefinedsymbol(__ram_vector_table__) ? 0x000003FF : 0; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -742,12 +742,22 @@ def add_regions(self): | |
except ConfigException: | ||
pass | ||
|
||
def add_linker_defines(self): | ||
stack_param = "target.boot-stack-size" | ||
params, _ = self.config_data | ||
|
||
if stack_param in params: | ||
define_string = self.make_ld_define("MBED_BOOT_STACK_SIZE", int(params[stack_param].value, 0)) | ||
self.ld.append(define_string) | ||
self.flags["ld"].append(define_string) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @theotherjimmy this is how the target define is getting passed to the linker script. Is this the right way to do it or would you like any changes made here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That looks fine. |
||
|
||
# Set the configuration data | ||
def set_config_data(self, config_data): | ||
self.config_data = config_data | ||
# new configuration data can change labels, so clear the cache | ||
self.labels = None | ||
self.add_regions() | ||
self.add_linker_defines() | ||
|
||
# Creates the configuration header if needed: | ||
# - if there is no configuration data, "mbed_config.h" is not create (or deleted if it exists). | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In
targets/targets.json
fileboot-stack-size
is set to 4kB and here is modified and set to 1kB with some exceptions (like for NRF boards).Is this done to distinguish stack size for builds with and without RTOS (4kB for non RTOS and typically 1kB for builds with RTOS)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, by default stack sizes are 4K and they are overridden to 1K when the RTOS is present. Targets with special requirements on stack size, such as the nrf51, can further override for both the RTOS and non-RTOS configuration.