Page 1 of 1

Watchdog triggered in CPU1,

Posted: Fri Apr 07, 2023 5:16 am
by yoko911
I have been doing some test code in ESP32, I took an sample code, so I am not using RTOS, I know that main is invoked from a RTOS task underline in esp32-idf.
My main program is now running long at 30k ticks I get a Task watchdog trigger:

Code: Select all

E (30232) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (30232) task_wdt:  - IDLE (CPU 0)
E (30232) task_wdt: Tasks currently running:
E (30232) task_wdt: CPU 0: main
E (30232) task_wdt: CPU 1: IDLE
E (30232) task_wdt: Print CPU 0 (current core) backtrace
I tried adding vTaskDelay(100); on the heavy load loop but then I get this error:

Code: Select all

***ERROR*** A stack overflow in task main has been detected.
So maybe RTOS is not correctly enabled? Any tips?

Re: Watchdog triggered in CPU1,

Posted: Sat Apr 08, 2023 3:09 am
by ESP_Sprite
Hard to say. Can you post your code?

Re: Watchdog triggered in CPU1,

Posted: Sun Apr 09, 2023 8:01 pm
by MicroController
Fact: If your task never vTaskDelays and never blocks the idle task does not get any CPU time, so cannot reset its watchdog.
Speculation: I believe the OS is responsible for actively checking stack limits, unless an MPU is present and configured. This means that the stack overflow may have happened "anywhere" in your code but only gets detected when you yield control to the OS, e.g. via vTaskDelay, and as such the problem is unrelated to the call to vTaskDelay.

The reason for the stack overflow may be that you do a lot of things in the main task and have a lot of local variables and/or arrays in app_main(). If that is the case, you can try and increase the main task's stack size (menuconfig -> Component Config -> ESP system settings). The better option would of course be to restructure your code, and move variables, especially arrays, to the heap, constants to flash &c.