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 ffc17317f..56d0e23df 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 2090f0d3c..4e1a0c0e2 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