From f4ea9d4cea6bc707f9cb85c9b350bd3377bfc45f Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 2 Jun 2020 18:51:16 +0200 Subject: [PATCH] freertos: increase configMINIMAL_STACK_SIZE when building with -O0 FreeRTOS scheduler uses additional stack space, as in some functions variables are placed onto the stack instead of registers. This issue resulted in occasional stack overflows in dport task, when compiling at -O0 optimization level. - Increase the configMINIMAL_STACK_SIZE to 1kB. - Enable the watchpoint at the end of stack in CI startup test for this optimization level. --- .../freertos/xtensa/include/freertos/FreeRTOSConfig.h | 9 ++++++--- tools/test_apps/system/startup/sdkconfig.ci.opt_o0 | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/components/freertos/xtensa/include/freertos/FreeRTOSConfig.h b/components/freertos/xtensa/include/freertos/FreeRTOSConfig.h index 51cbcbce2e..128d62190b 100644 --- a/components/freertos/xtensa/include/freertos/FreeRTOSConfig.h +++ b/components/freertos/xtensa/include/freertos/FreeRTOSConfig.h @@ -181,11 +181,14 @@ int xt_clock_freq(void) __attribute__((deprecated)); #define configMAX_PRIORITIES ( 25 ) #endif -#ifndef CONFIG_APPTRACE_ENABLE -#define configMINIMAL_STACK_SIZE 768 -#else +#if defined(CONFIG_APPTRACE_ENABLE) /* apptrace module requires at least 2KB of stack per task */ #define configMINIMAL_STACK_SIZE 2048 +#elif defined(CONFIG_COMPILER_OPTIMIZATION_NONE) +/* with optimizations disabled, scheduler uses additional stack */ +#define configMINIMAL_STACK_SIZE 1024 +#else +#define configMINIMAL_STACK_SIZE 768 #endif #ifndef configIDLE_TASK_STACK_SIZE diff --git a/tools/test_apps/system/startup/sdkconfig.ci.opt_o0 b/tools/test_apps/system/startup/sdkconfig.ci.opt_o0 index 8c66af7708..d9a3a1b05d 100644 --- a/tools/test_apps/system/startup/sdkconfig.ci.opt_o0 +++ b/tools/test_apps/system/startup/sdkconfig.ci.opt_o0 @@ -1 +1,2 @@ CONFIG_COMPILER_OPTIMIZATION_NONE=y +CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y