diff --git a/rtos/mbed_boot.c b/rtos/mbed_boot.c index ab7200d811..efe6cc39d4 100644 --- a/rtos/mbed_boot.c +++ b/rtos/mbed_boot.c @@ -178,10 +178,12 @@ WEAK void mbed_main(void); void pre_main (void); osThreadAttr_t _main_thread_attr; -/* The main stack size is hardcoded on purpose, so it's less tempting to change it per platform. As usually it's not - * the correct solution to the problem and it makes mbed OS behave differently on different targets. - */ -MBED_ALIGN(8) char _main_stack[4096]; + +/** The main thread's stack size can be configured by the application, if not explicitly specified it'll default to 4K */ +#ifndef MBED_CONF_APP_MAIN_STACK_SIZE +#define MBED_CONF_APP_MAIN_STACK_SIZE 4096 +#endif +MBED_ALIGN(8) char _main_stack[MBED_CONF_APP_MAIN_STACK_SIZE]; mbed_rtos_storage_thread_t _main_obj; osMutexId_t singleton_mutex_id; diff --git a/rtos/rtx2/mbed_rtx_conf.h b/rtos/rtx2/mbed_rtx_conf.h index 04af69df2e..c8a93f97a1 100644 --- a/rtos/rtx2/mbed_rtx_conf.h +++ b/rtos/rtx2/mbed_rtx_conf.h @@ -24,14 +24,13 @@ #include "mbed_rtx.h" -#ifndef OS_STACK_SIZE -#ifndef MBED_SMALL_TARGET -#define OS_STACK_SIZE 4096 -#else -#define OS_STACK_SIZE 2048 -#endif +/** The thread's stack size can be configured by the application, if not explicitly specified it'll default to 4K */ +#ifndef MBED_CONF_APP_THREAD_STACK_SIZE +#define MBED_CONF_APP_THREAD_STACK_SIZE 4096 #endif +#define OS_STACK_SIZE MBED_CONF_APP_THREAD_STACK_SIZE + #define OS_TIMER_THREAD_STACK_SIZE 768 #define OS_IDLE_THREAD_STACK_SIZE 256