Skip to content

Use boot stack size from config system #13452

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

Merged
merged 3 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -90,16 +90,16 @@ Phase 2:
Note: Heap split support across multiple RAM banks, can also be achieved post this change.

# Detailed Design
1. Update tools to set define `MBED_BOOT_STACK_SIZE` from target config option `target.boot-stack-size`
1. Linker Scripts - Update linker scripts for ARM, IAR and GCC toolchain to use MBED_BOOT_STACK_SIZE define for standardizing size of ISR stack.
1. Update tools to set define `MBED_CONF_TARGET_BOOT_STACK_SIZE` from target config option `target.boot-stack-size`
1. Linker Scripts - Update linker scripts for ARM, IAR and GCC toolchain to use MBED_CONF_TARGET_BOOT_STACK_SIZE define for standardizing size of ISR stack.
1. Update __user_setup_stackheap() implementation to adopt 2-region RAM memory model.
__user_setup_stackheap() works with systems where the application starts with a value of sp (r13) that is already correct. To make use of sp(stack base), implement __user_setup_stackheap() to set up r0 (heap base), r2 (heap limit), and r3 (stack limit) (for a two-region model) and return.
Reference http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.kui0099a/armlib_cjagaaha.htm http://www.keil.com/support/man/docs/armlib/armlib_chr1359122863069.htm
1. Modify _sbrk() implementation for GCC to use 2-region memory model

# Tools and configuration changes

1. Target config option "target.boot-stack-size" which is passed to the linker as the define "MBED_BOOT_STACK_SIZE" so the linker can adjust the stack accordingly.
1. Target config option "target.boot-stack-size" which is passed to the linker as the define "MBED_CONF_TARGET_BOOT_STACK_SIZE" so the linker can adjust the stack accordingly.
Boot stack size - the size of ISR and main stack will be 4K as default in targets.json for bare metal (non-RTOS) builds.
Boot stack size - the size of ISR stack will be over-written as 1K in `rtos/mbed_lib.json` for RTOS builds.

2 changes: 1 addition & 1 deletion hal/tests/TESTS/mbed_hal/stack_size_unification/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern uint32_t mbed_stack_isr_size;

#define EXPECTED_USER_THREAD_DEFAULT_STACK_SIZE (MBED_CONF_RTOS_THREAD_STACK_SIZE)

#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= (EXPECTED_MAIN_THREAD_STACK_SIZE + EXPECTED_ISR_STACK_SIZE))
#if ((MBED_RAM_SIZE - MBED_CONF_TARGET_BOOT_STACK_SIZE) <= (EXPECTED_MAIN_THREAD_STACK_SIZE + EXPECTED_ISR_STACK_SIZE))
#error [NOT_SUPPORTED] Insufficient stack for staci_size_unification tests
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ using namespace utest::v1;
#define TEST_BLOCK_COUNT 10
#define TEST_ERROR_MASK 16

#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= TEST_BLOCK_DEVICE_SIZE)
#if ((MBED_RAM_SIZE - MBED_CONF_TARGET_BOOT_STACK_SIZE) <= TEST_BLOCK_DEVICE_SIZE)
#error [NOT_SUPPORTED] Insufficient heap for heap block device tests
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ using namespace utest::v1;
#define BLOCK_COUNT 16
#define BLOCK_SIZE 512

#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= (BLOCK_COUNT * BLOCK_SIZE))
#if ((MBED_RAM_SIZE - MBED_CONF_TARGET_BOOT_STACK_SIZE) <= (BLOCK_COUNT * BLOCK_SIZE))
#error [NOT_SUPPORTED] Insufficient heap for mbr block device tests
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ using namespace utest::v1;
#define BLOCK_COUNT 16
#define BLOCK_SIZE 512

#if ((MBED_RAM_SIZE - MBED_BOOT_STACK_SIZE) <= (BLOCK_COUNT * BLOCK_SIZE))
#if ((MBED_RAM_SIZE - MBED_CONF_TARGET_BOOT_STACK_SIZE) <= (BLOCK_COUNT * BLOCK_SIZE))
#error [NOT_SUPPORTED] Insufficient heap for util block device tests
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
# if defined(MBED_BOOT_STACK_SIZE)
# define MBED_CONF_TARGET_BOOT_STACK_SIZE MBED_BOOT_STACK_SIZE
# else
# define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
# endif
#endif

#if (defined(__stack_size__))
#define STACK_SIZE __stack_size__
#else
#define STACK_SIZE MBED_BOOT_STACK_SIZE
#define STACK_SIZE MBED_CONF_TARGET_BOOT_STACK_SIZE
#endif

; The vector table is loaded at address 0x00000000 in Flash memory region.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
#define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
#endif

MEMORY
Expand Down Expand Up @@ -69,7 +69,7 @@ MEMORY
*/
ENTRY(Reset_Handler)

STACK_SIZE = MBED_BOOT_STACK_SIZE;
STACK_SIZE = MBED_CONF_TARGET_BOOT_STACK_SIZE;

/* Size of the vector table in SRAM */
M_VECTOR_RAM_SIZE = NVIC_VECTORS_SIZE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ define symbol __ICFEDIT_region_RAM_end__ = ZBT_SRAM2_START + ZBT_SRAM2_SIZE

/*-Sizes-*/
/* Heap and Stack size */
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
define symbol MBED_BOOT_STACK_SIZE = 0x400;
if (!isdefinedsymbol(MBED_CONF_TARGET_BOOT_STACK_SIZE)) {
define symbol MBED_CONF_TARGET_BOOT_STACK_SIZE = 0x400;
}
define symbol __ICFEDIT_size_heap__ = 0x200000;
define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE;
define symbol __ICFEDIT_size_cstack__ = MBED_CONF_TARGET_BOOT_STACK_SIZE;
/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
# if defined(MBED_BOOT_STACK_SIZE)
# define MBED_CONF_TARGET_BOOT_STACK_SIZE MBED_BOOT_STACK_SIZE
# else
# define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
# endif
#endif

#if (defined(__stack_size__))
#define STACK_SIZE __stack_size__
#else
#define STACK_SIZE MBED_BOOT_STACK_SIZE
#define STACK_SIZE MBED_CONF_TARGET_BOOT_STACK_SIZE
#endif

; The vector table is loaded at address 0x00000000 in Flash memory region.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
#define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
#endif

MEMORY
Expand Down Expand Up @@ -69,7 +69,7 @@ MEMORY
*/
ENTRY(Reset_Handler)

STACK_SIZE = MBED_BOOT_STACK_SIZE;
STACK_SIZE = MBED_CONF_TARGET_BOOT_STACK_SIZE;

/* Size of the vector table in SRAM */
M_VECTOR_RAM_SIZE = NVIC_VECTORS_SIZE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ define symbol __ICFEDIT_region_RAM_end__ = ZBT_SRAM2_START + ZBT_SRAM2_SIZE

/*-Sizes-*/
/* Heap and Stack size */
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
define symbol MBED_BOOT_STACK_SIZE = 0x400;
if (!isdefinedsymbol(MBED_CONF_TARGET_BOOT_STACK_SIZE)) {
define symbol MBED_CONF_TARGET_BOOT_STACK_SIZE = 0x400;
}
define symbol __ICFEDIT_size_heap__ = 0x200000;
define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE;
define symbol __ICFEDIT_size_cstack__ = MBED_CONF_TARGET_BOOT_STACK_SIZE;
/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
# if defined(MBED_BOOT_STACK_SIZE)
# define MBED_CONF_TARGET_BOOT_STACK_SIZE MBED_BOOT_STACK_SIZE
# else
# define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
# endif
#endif

#if (defined(__stack_size__))
#define STACK_SIZE __stack_size__
#else
#define STACK_SIZE MBED_BOOT_STACK_SIZE
#define STACK_SIZE MBED_CONF_TARGET_BOOT_STACK_SIZE
#endif

; The vector table is loaded at address 0x00000000 in Flash memory region.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
#define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
#endif

MEMORY
Expand Down Expand Up @@ -69,7 +69,7 @@ MEMORY
*/
ENTRY(Reset_Handler)

STACK_SIZE = MBED_BOOT_STACK_SIZE;
STACK_SIZE = MBED_CONF_TARGET_BOOT_STACK_SIZE;

/* Size of the vector table in SRAM */
M_VECTOR_RAM_SIZE = NVIC_VECTORS_SIZE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ define symbol __ICFEDIT_region_RAM_end__ = ZBT_SRAM2_START + ZBT_SRAM2_SIZE

/*-Sizes-*/
/* Heap and Stack size */
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
define symbol MBED_BOOT_STACK_SIZE = 0x400;
if (!isdefinedsymbol(MBED_CONF_TARGET_BOOT_STACK_SIZE)) {
define symbol MBED_CONF_TARGET_BOOT_STACK_SIZE = 0x400;
}
define symbol __ICFEDIT_size_heap__ = 0x200000;
define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE;
define symbol __ICFEDIT_size_cstack__ = MBED_CONF_TARGET_BOOT_STACK_SIZE;
/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
# if defined(MBED_BOOT_STACK_SIZE)
# define MBED_CONF_TARGET_BOOT_STACK_SIZE MBED_BOOT_STACK_SIZE
# else
# define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
# endif
#endif

#if (defined(__stack_size__))
#define STACK_SIZE __stack_size__
#else
#define STACK_SIZE MBED_BOOT_STACK_SIZE
#define STACK_SIZE MBED_CONF_TARGET_BOOT_STACK_SIZE
#endif

; The vector table is loaded at address 0x00000000 in Flash memory region.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
#define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
#endif

MEMORY
Expand Down Expand Up @@ -69,7 +69,7 @@ MEMORY
*/
ENTRY(Reset_Handler)

STACK_SIZE = MBED_BOOT_STACK_SIZE;
STACK_SIZE = MBED_CONF_TARGET_BOOT_STACK_SIZE;

/* Size of the vector table in SRAM */
M_VECTOR_RAM_SIZE = NVIC_VECTORS_SIZE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ define symbol __ICFEDIT_region_RAM_end__ = ZBT_SRAM2_START + ZBT_SRAM2_SIZE

/*-Sizes-*/
/* Heap and Stack size */
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
define symbol MBED_BOOT_STACK_SIZE = 0x400;
if (!isdefinedsymbol(MBED_CONF_TARGET_BOOT_STACK_SIZE)) {
define symbol MBED_CONF_TARGET_BOOT_STACK_SIZE = 0x400;
}
define symbol __ICFEDIT_size_heap__ = 0x200000;
define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE;
define symbol __ICFEDIT_size_cstack__ = MBED_CONF_TARGET_BOOT_STACK_SIZE;
/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,18 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
# if defined(MBED_BOOT_STACK_SIZE)
# define MBED_CONF_TARGET_BOOT_STACK_SIZE MBED_BOOT_STACK_SIZE
# else
# define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
# endif
#endif

#if (defined(__stack_size__))
#define STACK_SIZE __stack_size__
#else
#define STACK_SIZE MBED_BOOT_STACK_SIZE
#define STACK_SIZE MBED_CONF_TARGET_BOOT_STACK_SIZE
#endif

; The vector table is loaded at address 0x00000000 in Flash memory region.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
#define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
#endif

MEMORY
Expand Down Expand Up @@ -69,7 +69,7 @@ MEMORY
*/
ENTRY(Reset_Handler)

STACK_SIZE = MBED_BOOT_STACK_SIZE;
STACK_SIZE = MBED_CONF_TARGET_BOOT_STACK_SIZE;

/* Size of the vector table in SRAM */
M_VECTOR_RAM_SIZE = NVIC_VECTORS_SIZE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ define symbol __ICFEDIT_region_RAM_end__ = ZBT_SRAM2_START + ZBT_SRAM2_SIZE

/*-Sizes-*/
/* Heap and Stack size */
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
define symbol MBED_BOOT_STACK_SIZE = 0x400;
if (!isdefinedsymbol(MBED_CONF_TARGET_BOOT_STACK_SIZE)) {
define symbol MBED_CONF_TARGET_BOOT_STACK_SIZE = 0x400;
}
define symbol __ICFEDIT_size_heap__ = 0x200000;
define symbol __ICFEDIT_size_cstack__ = MBED_BOOT_STACK_SIZE;
define symbol __ICFEDIT_size_cstack__ = MBED_CONF_TARGET_BOOT_STACK_SIZE;
/**** End of ICF editor section. ###ICF###*/

define memory mem with size = 4G;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
# if defined(MBED_BOOT_STACK_SIZE)
# define MBED_CONF_TARGET_BOOT_STACK_SIZE MBED_BOOT_STACK_SIZE
# else
# define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
# endif
#endif

#define Stack_Size MBED_BOOT_STACK_SIZE
#define Stack_Size MBED_CONF_TARGET_BOOT_STACK_SIZE

; The vector table is loaded at address 0x00000000 in Flash memory region.
LR_IROM1 FLASH_START FLASH_SIZE {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "../memory_zones.h"
#include "../cmsis_nvic.h"

#if !defined(MBED_BOOT_STACK_SIZE)
#define MBED_BOOT_STACK_SIZE 0x400
#if !defined(MBED_CONF_TARGET_BOOT_STACK_SIZE)
#define MBED_CONF_TARGET_BOOT_STACK_SIZE 0x400
#endif

MEMORY
Expand Down Expand Up @@ -65,7 +65,7 @@ MEMORY
ENTRY(Reset_Handler)

HEAP_SIZE = 0x4000;
STACK_SIZE = MBED_BOOT_STACK_SIZE;
STACK_SIZE = MBED_CONF_TARGET_BOOT_STACK_SIZE;

/* Size of the vector table in SRAM */
M_VECTOR_RAM_SIZE = NVIC_VECTORS_SIZE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ define symbol __ICFEDIT_region_RAM_end__ = ZBT_SSRAM23_START + ZBT_SSRAM23_

/* Sizes */
/* Heap and Stack size */
if (!isdefinedsymbol(MBED_BOOT_STACK_SIZE)) {
define symbol MBED_BOOT_STACK_SIZE = 0x400;
if (!isdefinedsymbol(MBED_CONF_TARGET_BOOT_STACK_SIZE)) {
define symbol MBED_CONF_TARGET_BOOT_STACK_SIZE = 0x400;
}
define symbol __ICFEDIT_size_heap__ = MBED_BOOT_STACK_SIZE;
define symbol __ICFEDIT_size_heap__ = MBED_CONF_TARGET_BOOT_STACK_SIZE;
define symbol __ICFEDIT_size_cstack__ = 0x1000;

define memory mem with size = 4G;
Expand Down
Loading