From 99dbfb353948a610828f0c6ee892a0d2123b07af Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Tue, 11 Jul 2017 21:08:52 +0800 Subject: [PATCH] Merge branch 'bugfix/minimal_stack_size' into 'master' freertos: Bump idle stack size to 1KB, min stack to 768 bytes, make configurable See merge request !979 --- components/freertos/Kconfig | 9 +++++++++ components/freertos/include/freertos/FreeRTOSConfig.h | 6 +++++- components/freertos/tasks.c | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/components/freertos/Kconfig b/components/freertos/Kconfig index dd9a95b06..d38f104ab 100644 --- a/components/freertos/Kconfig +++ b/components/freertos/Kconfig @@ -149,6 +149,15 @@ menuconfig ENABLE_MEMORY_DEBUG help Enable this option to show malloc heap block and memory crash detect +config FREERTOS_IDLE_TASK_STACKSIZE + int "Idle Task stack size" + range 768 32768 + default 1024 + help + The idle task has its own stack, sized in bytes. The default size is enough for most uses. Size can be reduced + to 768 bytes if no (or simple) FreeRTOS idle hooks are used. The stack size may need to be increased above the + default if the app installs idle hooks that use a lot of stack memory. + config FREERTOS_ISR_STACKSIZE int "ISR stack size" range 1536 32768 diff --git a/components/freertos/include/freertos/FreeRTOSConfig.h b/components/freertos/include/freertos/FreeRTOSConfig.h index a50655256..1dcc1d7be 100644 --- a/components/freertos/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/include/freertos/FreeRTOSConfig.h @@ -164,12 +164,16 @@ #endif #ifndef CONFIG_ESP32_APPTRACE_ENABLE -#define configMINIMAL_STACK_SIZE 512 +#define configMINIMAL_STACK_SIZE 768 #else /* apptrace module requires at least 2KB of stack per task */ #define configMINIMAL_STACK_SIZE 2048 #endif +#ifndef configIDLE_TASK_STACK_SIZE +#define configIDLE_TASK_STACK_SIZE CONFIG_FREERTOS_IDLE_TASK_STACKSIZE +#endif + /* The Xtensa port uses a separate interrupt stack. Adjust the stack size */ /* to suit the needs of your specific application. */ #ifndef configISR_STACK_SIZE diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index a28e1031a..980221252 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -112,9 +112,9 @@ functions but without including stdio.h here. */ #endif /* configUSE_TICKLESS_IDLE */ /* - * Defines the size, in words, of the stack allocated to the idle task. + * Defines the size, in bytes, of the stack allocated to the idle task. */ -#define tskIDLE_STACK_SIZE configMINIMAL_STACK_SIZE +#define tskIDLE_STACK_SIZE configIDLE_TASK_STACK_SIZE #if( configUSE_PREEMPTION == 0 ) /* If the cooperative scheduler is being used then a yield should not be