Make stack sizes configurable by the app

Application can overwrite stack sizes by defining main-stack-size and
thread-stack-size in mbed_app.json
pull/4294/head
Bartek Szatkowski 2017-05-22 16:21:35 +01:00 committed by Martin Kojtal
parent abcae6f01e
commit 535ee8ba25
2 changed files with 11 additions and 10 deletions

View File

@ -178,10 +178,12 @@ WEAK void mbed_main(void);
void pre_main (void); void pre_main (void);
osThreadAttr_t _main_thread_attr; 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. /** 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
MBED_ALIGN(8) char _main_stack[4096]; #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; mbed_rtos_storage_thread_t _main_obj;
osMutexId_t singleton_mutex_id; osMutexId_t singleton_mutex_id;

View File

@ -24,14 +24,13 @@
#include "mbed_rtx.h" #include "mbed_rtx.h"
#ifndef OS_STACK_SIZE /** The thread's stack size can be configured by the application, if not explicitly specified it'll default to 4K */
#ifndef MBED_SMALL_TARGET #ifndef MBED_CONF_APP_THREAD_STACK_SIZE
#define OS_STACK_SIZE 4096 #define MBED_CONF_APP_THREAD_STACK_SIZE 4096
#else
#define OS_STACK_SIZE 2048
#endif
#endif #endif
#define OS_STACK_SIZE MBED_CONF_APP_THREAD_STACK_SIZE
#define OS_TIMER_THREAD_STACK_SIZE 768 #define OS_TIMER_THREAD_STACK_SIZE 768
#define OS_IDLE_THREAD_STACK_SIZE 256 #define OS_IDLE_THREAD_STACK_SIZE 256