machine.WDT does not appear to work [Sorted]

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

machine.WDT does not appear to work [Sorted]

Post by davef » Thu May 19, 2022 9:49 pm

I have been chasing random lock-ups for more than a year on the ESP32-WROOM-32 units. Although I was aware that rev 1 chips had been replaced with rev 3 chips I had to move to the SPIRAM variant as I could not get boards with rev 3 chips off Aliexpress. Random lock-ups seemed to disappear and I was only using a S/W WDT.

Recently, I started getting rev 3 chips in the ESP32-WROOM-32 parts so have had another go at using them. Unfortunately, I made another change and that was using machine.WDT instead of a S/W WDT.

Hardly 12 hours of running the new system and total lock-up. I will go back to a S/W WDT, but if there are any hints out there on how to get machine.WDT to reliably re-boot my board I would really appreciate to hear about it.
Last edited by davef on Fri Jul 29, 2022 10:09 am, edited 1 time in total.

User avatar
karfas
Posts: 193
Joined: Sat Jan 16, 2021 12:53 pm
Location: Vienna, Austria

Re: machine.WDT does not appear to work

Post by karfas » Fri May 20, 2022 9:23 am

Might be a hardware or ESP-IDF issue.
see e.g. https://esp32.com/viewtopic.php?t=18359 or search for "esp_task_wdt_add".
A few hours of debugging might save you from minutes of reading the documentation! :D
My repositories: https://github.com/karfas

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: machine.WDT does not appear to work

Post by davef » Fri May 20, 2022 10:28 am

Thanks for the comments. There was no suggestions to the poster in the first link. I haven't got the skills to try an "esp_task_wdt_add".

I hoped that just using machine.WDT in the ESP32 port would cover my basic requirement. I run these units off a LM317 5V reg (1.5A capability) usually with 1000uF to handle any surges when the WiFi fires-up. Often I put an extra 1000uF on the 3V3 as well ... but not on this unit.

I have gone back to a S/W WDT on this unit.

User avatar
karfas
Posts: 193
Joined: Sat Jan 16, 2021 12:53 pm
Location: Vienna, Austria

Re: machine.WDT does not appear to work

Post by karfas » Fri May 20, 2022 2:49 pm

esp_task_wdt_init and esp_task_wdt_add are the IDF functions called by the WDT module.
You already used them.

For an application with high availability needs I would use both the SW and the WDT watchdog. In the rare cases when the SW Watchdog doesn't catch a lockup, the WDT thing might be able to fix things.
A few hours of debugging might save you from minutes of reading the documentation! :D
My repositories: https://github.com/karfas

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: machine.WDT does not appear to work

Post by davef » Fri May 20, 2022 7:39 pm

When I read through the docs for esp_task_wdt_add it sounded like I would have the opportunity to add in other watchdog tasks and that's when I was overwhelmed!

If and when the S/W WDT fails and will try both ... that never occurred to me. Thanks.

Jibun no kage
Posts: 144
Joined: Mon Jul 25, 2022 9:45 pm

Re: machine.WDT does not appear to work

Post by Jibun no kage » Wed Jul 27, 2022 12:07 am

Odd thing is, I just discovered that machine.WDT is not working right on my Pico W as well. I can set up WDT, but apparently feeding WDT never occurs correctly even when I set WDT timeout 60 seconds, and WDT is in a loop to execute once per second. The WDT still fires. If I disable the WDT from ever starting its count down, my Pico W is fine, otherwise it disconnects/resets.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: machine.WDT does not appear to work

Post by davef » Wed Jul 27, 2022 2:12 am

Something I discovered recently is ... I can only init the system wdt in one file (the file containing your main loop) and only call wdt.feed in that file. So, if I call other files I can not placed any wdt.feed in them.

wdt.feed must be working for me as I am in one second loops 24/7. ESP32-Generic

User avatar
Roberthh
Posts: 3667
Joined: Sat May 09, 2015 4:13 pm
Location: Rhineland, Europe

Re: machine.WDT does not appear to work

Post by Roberthh » Wed Jul 27, 2022 6:27 am

That sounds strange. You should be able to use the wdt object created with the call to WDT() at any place in your code. Obviously you have to take care to make it visible at these places, like making it global.

davef
Posts: 811
Joined: Thu Apr 30, 2020 1:03 am
Location: Christchurch, NZ

Re: machine.WDT does not appear to work

Post by davef » Wed Jul 27, 2022 6:56 am

like making it global
oops! I think you exposed a knowledge-gap. I have used global twice and didn't realise that it was needed in this context.
Thanks

bulletmark
Posts: 59
Joined: Mon Mar 29, 2021 1:36 am
Location: Brisbane Australia

Re: machine.WDT does not appear to work

Post by bulletmark » Thu Jul 28, 2022 12:01 am

@davef, It's likely not needed. I doubt Roberth mean't "global" as a keyword here. I suspect he mean't you need to ensure the wdt() instance is a singleton. I.e. in the function where you have wdt.feed() then the wdt instance does not need to be `global wdt`.

Post Reply