ESP32 Stack configuration (reloaded)

As for the ESP32, a FreeRTOS task is created that runs setup() and loop(). That task has a certain stack size.

The CONFIG_ARDUINO_LOOP_STACK_SIZE comes from the preconfigured ESP-IDF base

So unfortunately you can’t override it with build_flags = -D CONFIG_ARDUINO_LOOP_STACK_SIZE=16384 in the platformio.ini because this define hardcodes it without checking if it’s previously defined.

So you should first try and edit it C:\Users\<user>\.platformio\packages\framework-arduinoespressif32\tools\sdk\include\config\sdkconfig.h, recompile the application and see if it still fails. If it works, you can manage it more cleanly with a on-the-fly patch and a tiny bit of scripting.

2 Likes