Page 1 of 1

ESP32 watchdog timer triggers constantly

Posted: Tue Feb 15, 2022 5:42 pm
by MJU20
I've had this issue a few times already but always fixes it.

I'm playing with a simple FC project that first initialises a few components:
1- UART
2- WLAN-ESP
3- Network Comms

I've done this before. But this time I get the message via UART that the watchdog timer gets triggered.
The ESP keeps booting.

Code: Select all

[0;31mE (50576) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:[0m
[0;31mE (50576) task_wdt:  - IDLE0 (CPU 0)[0m
[0;31mE (50576) task_wdt: Tasks currently running:[0m
[0;31mE (50576) task_wdt: CPU 0: main[0m
[0;31mE (50576) task_wdt: CPU 1: IDLE1[0m
I have tried the code in this post: https://flowcode.co.uk/forums/viewtopic ... +esp#p4446
But this doesn't work.

If I add a delay of 1 second between every initialisation step (see above), the WDT isn't triggered.
Could it be that during initialisation the watchdog gets tired waiting and resets the lot?

Isn't there a way to add a challenge for the WDT during initialisation of these components so it doesn't get triggered?
Or disable the WDT during this macro call?

Or other ideas?
If I hadn't a UART reading I wouldn't know about this issue. :D

Re: ESP32 watchdog timer triggers constantly

Posted: Wed Feb 16, 2022 2:16 pm
by BenR
Hello,

This post should solve the problem for you.
viewtopic.php?p=3568#p3568

Here's the info you need should the link ever have problems.

Please note that as you are using a tight loop with no significant delays the ESP32 watchdog is kicking in and potentially causing a reset. To avoid the reset simply add this line of C code into your loop to keep the watchdog timer happy.

Code: Select all

TIMERG0.wdt_wprotect=TIMG_WDT_WKEY_VALUE;
TIMERG0.wdt_feed=1;
TIMERG0.wdt_wprotect=0;
You will also need to go into the Project Options -> Supplementary Code and add this line to the definitions.

Code: Select all

#include "soc/rtc_wdt.h"

Re: ESP32 watchdog timer triggers constantly

Posted: Wed Feb 16, 2022 3:07 pm
by stefan.erni
Hi Ben, Hi MJU20

Can I turn off the WDT from the ESP32 with this ?

regards

Stefan
WDT-2022-02-16_16-03-09.jpg
WDT-2022-02-16_16-03-09.jpg (26.44 KiB) Viewed 3780 times

Re: ESP32 watchdog timer triggers constantly

Posted: Wed Feb 16, 2022 5:43 pm
by Steve-Matrix
Looking at the CAL for the ESP32, the watchdog timer is currently unimplemented using that option.

Ben should know if this can be implemented.

Re: ESP32 watchdog timer triggers constantly

Posted: Thu Feb 17, 2022 5:25 pm
by MJU20
Thanks already for the suggested workarounds.
But the issue appears even when there is no loop after an initialisation macro.

So I've done these steps (nothing more, nothing less):
- Calculation: set a variable to a certain value
- Call the macro: "initialise WLAN_ESP32"
- Call the macro: "initialise Network Comms"

No loop or so to check if there is a return value for checking if the macro was successful. I have found this issue in other topics on other fora already.
So this can not be the reason the WDT is triggered.
I have tested further and only by adding a small delay after the Init WLAN_ESP32 the WDT isn't triggered.

So this is what works:
- Calculation: set a variable to a certain value
- Call the macro: "initialise WLAN_ESP32"
- Delay: 5ms (could become less)
- Call the macro: "initialise Network Comms"

My guess is that there is something in the component macro that takes too long for the WDT. So this gets triggered.

Is it possible to look into the component macro to see if there is a reason that the WDT gets bored?