Skip to content

Commit

Permalink
Increase background stack size to fix overflows
Browse files Browse the repository at this point in the history
On platforms using both tickless and the low power ticker wrapper
so much of the background stack is used that it overflows. To
ensure the background thread's stack doesn't overflow increase this
size by 256 bytes when tickless is enabled. Worst case usage
on the NUCLEO_F476RG was recorded at 656 when tickless is
turned on so this increased size should safely prevent overflows.
  • Loading branch information
c1728p9 committed Nov 6, 2018
1 parent b18c819 commit 9613e0f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions rtos/TARGET_CORTEX/mbed_rtx_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@
#define OS_TIMER_THREAD_STACK_SIZE MBED_CONF_RTOS_TIMER_THREAD_STACK_SIZE
#endif

// Increase the idle thread stack size when tickless is enabled
#if defined(MBED_TICKLESS) && defined(LPTICKER_DELAY_TICKS) && (LPTICKER_DELAY_TICKS > 0)
#define EXTRA_IDLE_STACK MBED_CONF_RTOS_IDLE_THREAD_STACK_SIZE_TICKLESS_EXTRA
#else
#define EXTRA_IDLE_STACK 0
#endif
#ifdef MBED_CONF_APP_IDLE_THREAD_STACK_SIZE
#define OS_IDLE_THREAD_STACK_SIZE MBED_CONF_APP_IDLE_THREAD_STACK_SIZE
#define OS_IDLE_THREAD_STACK_SIZE (MBED_CONF_APP_IDLE_THREAD_STACK_SIZE + EXTRA_IDLE_STACK)
#else
#define OS_IDLE_THREAD_STACK_SIZE MBED_CONF_RTOS_IDLE_THREAD_STACK_SIZE
#define OS_IDLE_THREAD_STACK_SIZE (MBED_CONF_RTOS_IDLE_THREAD_STACK_SIZE + EXTRA_IDLE_STACK)
#endif

#define OS_DYNAMIC_MEM_SIZE 0
Expand Down
4 changes: 4 additions & 0 deletions rtos/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@
"thread-stack-size": {
"help": "The default stack size of new threads",
"value": 4096
},
"idle-thread-stack-size-tickless-extra": {
"help": "Additional size to add to the idle thread when tickless is enabled and LPTICKER_DELAY_TICKS is used",
"value": 256
}
},
"macros": ["_RTE_"],
Expand Down

0 comments on commit 9613e0f

Please sign in to comment.