Page 1 of 1

How to disable WDT for a task?

Posted: Thu Apr 07, 2022 10:11 am
by tankist
I created a task (the main code is running on core 1)

Code: Select all

xTaskCreatePinnedToCore(showScreen, "showScreen", 2048, NULL, 0, NULL, 0);
and then I got an error during the execution:
E (11583) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (11583) task_wdt: - IDLE0 (CPU 0)
E (11583) task_wdt: Tasks currently running:
E (11583) task_wdt: CPU 0: showScreen
E (11583) task_wdt: CPU 1: loopTask
E (11583) task_wdt: Aborting.
I tried a lot of things to prevent the error, but nothing helped:
esp_task_wdt_feed() in the task loop - it didn't help
esp_task_wdt_reset() in the task loop - it didn't help
esp_task_wdt_deinit() before create the task - it didn't help
esp_task_wdt_delete(th) after create the task - it didn't help

The only thing that helped to stop WDT is delay(1) instruction, but delay for 1 ms is too much for my purpose .

Could anybody tell me the official way (which really works) to stop WDT in a task ?

Re: How to disable WDT for a task?

Posted: Thu Apr 07, 2022 1:33 pm
by rpiloverbd
I found the following blogs and threads and some more only. Nothing official.
https://www.reddit.com/r/esp32/comments ... on_esp_32/
https://bisko.dev/2020/04/29/arduino-es ... -watchdog/

Re: How to disable WDT for a task?

Posted: Thu Apr 07, 2022 1:57 pm
by Maxzillian
Unfortunately the only way to really resolve this one is to either disable the idle watchdog or use a delay (that lets the CPU temporarily return to idle) like you've found.

If you want to disable the idle watchdog you could turn it off in your sdkconfig:
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y

Alternatively you could increase the watchdog timeout, but it's already set to a very hefty 5 seconds:
CONFIG_ESP_TASK_WDT_TIMEOUT_S=5

Personally I don't recommend either of the both and would instead focus on why the task requires so much CPU time; IE can it run slower or optimized better.

Another thing to consider is what is the priority of your task? If it's set to 0 it'll never yield to the idle task and you'll quickly hit the watchdog.