The looptask-Size setting has changed away from main.cpp, but where is it now?

I need a larger stack size for the looptask, which in the past was easily achieved in main.cpp:

Excerpt from main.cpp:

#ifndef CONFIG_ARDUINO_LOOP_STACK_SIZE
// default next line:
//#define CONFIG_ARDUINO_LOOP_STACK_SIZE 8192
// changed to:
#define CONFIG_ARDUINO_LOOP_STACK_SIZE 24576
#endif

...

extern "C" void app_main()
{
    loopTaskWDTEnabled = false;
    initArduino();
    //xTaskCreateUniversal(loopTask, "loopTask", CONFIG_ARDUINO_LOOP_STACK_SIZE, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
    xTaskCreateUniversal(loopTask, "loopTask", 24576, NULL, 1, &loopTaskHandle, CONFIG_ARDUINO_RUNNING_CORE);
}

However, changing CONFIG_ARDUINO_LOOP_STACK_SIZE is no longer sufficient. I had to use an explicit number in xTaskCreateUniversal.

This is now the first thing I print out in setup:

15:34:37.639 -> Setup: CONFIG_ARDUINO_LOOP_STACK_SIZE: 8192 
15:34:37.639 -> Setup: HWM: 23832 

Looks like CONFIG_ARDUINO_LOOP_STACK_SIZE is now being defined somewhere else, and before main.cpp is called. But where?

Which board is this for?

ESP32-Dev

Which version of the ESP32 Boards platform are you using?

Which version were you using when you were able to configure it via your previous approach?

If you have use the Git installation method, rather than Boards Manager, then we'll need to know the commit hashes.

Anyway, this looks relevant:

I am now using ESP-Core-1.0.6. Before I was using 1.0.4, all installed only via Arduino.

I can't tell with certainty when this change happened, as I am struggling with several other issues, which did not require the bigger task stack.

Certainly, a way to set loop size which survives any updates would be very welcome.

OK, that rules out Make LOOP_STACK_SIZE user configurable at compile-time. by everslick · Pull Request #5173 · espressif/arduino-esp32 · GitHub then, because that change was made after the 1.0.6 release, so it's only available when using the beta test version of the platform.

Unfortunately, I don't have much knowledge about the ESP32, and nothing at this depth. I didn't even recognize it's main.cpp, though I could see that it wasn't from any of the cores I'm more familiar with.

I do have a trick I use when I want to track down the location of a macro definition. I set it to a value I know is different from the original in order to trigger a warning, which shows the location of the previous definition:

C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\main.cpp:6:0: warning: "CONFIG_ARDUINO_LOOP_STACK_SIZE" redefined
 #define CONFIG_ARDUINO_LOOP_STACK_SIZE asdf
 ^
In file included from C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/include/spi_flash/esp_spi_flash.h:22:0,
                 from C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/include/spi_flash/esp_partition.h:22,
                 from C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\Esp.h:24,
                 from C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\Arduino.h:155,
                 from C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6\cores\esp32\main.cpp:4:
C:\Users\per\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.6/tools/sdk/include/config/sdkconfig.h:175:0: note: this is the location of the previous definition
 #define CONFIG_ARDUINO_LOOP_STACK_SIZE 8192

Maybe that will answer your question.

Yes, that is the location I needed, thanks! And changing the stack size there works.

It certainly makes sense to have all config settings in one place, but now I have to remember always to change this file when an update comes through. I hope there will come an option to make such changes specific to a certain sketch.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.