Skip to content

Watchdog with System Reset #341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
PRosenb opened this issue Apr 30, 2017 · 27 comments
Closed

Watchdog with System Reset #341

PRosenb opened this issue Apr 30, 2017 · 27 comments

Comments

@PRosenb
Copy link

PRosenb commented Apr 30, 2017

According to issue #147, the watchdog functionality of the ESP32 is available to Arduino sketches.

In order to make sure, the sketch is always functional, I want to use the watchdog to reset the chip if it gets stuck somehow. When I call esp_task_wdt_feed() once and then block the loop() thread, nothing happens though.

According to the Task watchdog documentation, the watchdog is supposed to issue a warning but not reset the CPU. For Arduino sketches, I may be better to reset the system instead. Is that possible without manipulating the related watchdog registers directly?

@me-no-dev
Copy link
Member

The reason is that WDT is disabled for the idle task on CPU1 (Arduino setup/loop). If you want to have all options, you might want to look into using Arduino as IDF component.

@PRosenb
Copy link
Author

PRosenb commented May 19, 2017

Thanks @me-no-dev, I'll do that.

@dmody
Copy link

dmody commented Jun 12, 2017

I'm sorry guys, I'm a not familiar with programming the ESP32 without using the Arduino IDE, and I don't understand the solution proposed.

If I understand what you're saying here it is that:

  • watchdogs can not be used for the setup and loop routines in a Arduino. This is because they have been disabled for those two particular tasks.

*I think you're suggesting, but I'm definitely not sure, that you need to switch to programming using Eclipse (the preferred programming environment instead of the Arduino IDE), and use the Arduino code as a component.

Hopefully you can set me straight about watchdogs. What I'm finding is that my ESP32 is 'randomnly' halting, or it's gone into an infinite loop, or it's not restarting from deep sleep, and I would like to use a watchdog to at least eliminate one of those alternatives.

@PRosenb
Copy link
Author

PRosenb commented Jun 12, 2017

Hi @dmody , @me-no-dev refers to building the code as described here:
https://github.com/espressif/arduino-esp32#using-as-esp-idf-component
You don't need Eclipse for it, any text editor will do.

@dmody
Copy link

dmody commented Jun 13, 2017 via email

@inforaudio
Copy link

when install idf, we can compile with diferent options in espressif. But, how can use if in Arduino.?

@me-no-dev
Copy link
Member

@inforaudio you can not set those when using Arduino stand-alone ;) you can if you use it as IDF component (answer is two positions above your question)

@mxwang101
Copy link

To All, Same problem, please give us step by step how to make Watchdogs work as use the Arduino code as a component?

@mxwang101
Copy link

Setup " void esp_int_wdt_init();" OK. But no ideal how to use it in ESP32? a demo prgram code will big help.

#include <CurieBLE.h>
#include <esp_task_wdt.h>
#include <esp_int_wdt.h>

int ctime=1;

void esp_int_wdt_init();

void setup() {
Serial.begin(9600);
while (!Serial);

// initialize the BLE hardware
BLE.begin();

----------Above OK , works

@hcs-svn
Copy link

hcs-svn commented Aug 18, 2017

The reason is that WDT is disabled for the idle task on CPU1 (Arduino setup/loop)

Will we get this for arduino-esp32 or what is the reason why we don't have/get it?

@mxwang101
Copy link

A WDT demo code will fix all problems. ESP team, please release one. Just like 51 , TI430, ,,, all have WDT demo codes. Thanks

@inforaudio
Copy link

We have a bigger project finished with ESP32 and now we find it¡¡¡..
A very bigger problem because without a Watchdog, we can use it in production.

@mxwang101 we have problem with your code. Really run it properly?
@me-no-dev where can i see how use IDF for configure ESP32 Arduino ide with watchdog. (whit details)?
all can i find is for compile espressif proyect.

are there a compilation / libraries / nre version where watchdog is enabled?? So complicated is it? We pass 2 days looking for and we are thinking in use other ESP version

@me-no-dev
Copy link
Member

@inforaudio all you need to do is to install IDF, install Arduino as IDF component and run make menuconfig in your project folder in order to access the build config menu.
Info: https://github.com/espressif/arduino-esp32/blob/master/docs/esp-idf_component.md

@inforaudio
Copy link

how can install Arduino as IDF component?
"make menuconfig in your project folder", in my arduino folder sketch?? .ino? or where? ( here dont run )

after it?? what can we do.?
in the future can we continue compile the proyect with Arduino IDE or with make flash?
do you know some tutorial about it? text, video etc..

@inforaudio
Copy link

Thanks for your help.
So i think that we have some advance.

We create a idf project (copy hello world example) ,
we made components folder, clone git.. and make menuconfig, and activate the arduino options.
Then in main.cpp copy my code (Arduino code).
This time is: (the example).
//file: main.cpp
#include "Arduino.h"

void setup(){
Serial.begin(115200);
}

void loop(){
Serial.println("loop");
delay(1000);
}

try to made a make and have this problem
make[1]: *** No hay ninguna regla para construir el objetivo 'cores/esp32/main', necesario para 'libarduino.a'. Alto.
make: *** [/home/Pablo/esp/esp-idf/make/project.mk:391: component-arduino-build] Error 2

What can i do now? What is the problem?

@usmanshahid001
Copy link

hiii
i am working in automation company and we need fail safe operation we need a wdt which could reset the whole system in case of any crash but i am unable to find any RWDT documentation yet kindly develop library in this regard
thanks

@assegid
Copy link

assegid commented Nov 16, 2017

This issue should not have been closed. It was not properly addressed. None of the explanations given above are complete or seem to work. I think a simple wdt solution in the Arduino IDE environment should be made available. The current solution seems to be if you need the wdt use the IDF. What good is an IOT device that gets deployed and goes dead in 2 days because of some obscure bug. In my opinion if the development team cannot provide a simple wdt solution for the Arduino IDE a very important feature is being ignored.

@usmanshahid001
Copy link

usmanshahid001 commented Nov 16, 2017 via email

@CarlosGS
Copy link

I don't fully understand the implications of this. Does it mean that any Arduino sketch for ESP32 will never be able to automatically reset when stuck?

@unixbigot
Copy link

For those like me who tripped over this thread as a high-ranking hit on search for "arduino esp watchdog", it does now work. Example here: https://github.com/unixbigot/esp-skeleton

@sovereignstack
Copy link

sovereignstack commented Dec 28, 2018

I can confirm that the current Arduino ESP32 SDK does NOTreset the device after watchdog is triggered. This should be reopened.

@me-no-dev
Copy link
Member

please calm down. There are many reasons why WDT reset is disabled for Core1 (it is enabled on Core0). While enabling it will make all of you happy, it will break many other sketches made to run on the Arduino platform (not ESP32 specifically). You have many options on how to detect that your loop is stuck and reset, since you are knowledgeable enough to know what wathdog is. You can spin a task on Core0, wait X ms to take a semaphore from the Arduino loop, and if you do not, then reset. In the loop, first line you give that semaphore. Done. you can detect the problem and reboot. SPIFFS format triggers WDT, so watch out ;)

@me-no-dev
Copy link
Member

how about I add API to enable WDT on the idle task and on the loop task? will that satisfy?

@me-no-dev
Copy link
Member

API added and WDT reboot enabled in #2248

@usmanshahid001
Copy link

usmanshahid001 commented Dec 28, 2018 via email

@Netoperz
Copy link

Netoperz commented Feb 2, 2019

Stupid question, but as far as i understand this will work if called in main loop, and what if the main loop is empty and i'm using tasks ?. In my case when no wifi signal around the test unit for longer time, or interference show up in 2.4ghz that scramble the signal, and that situation persists for a few hours, the task for wifi "hangs" the test unit is not responsive, not communicating with peripheral devices.

Is there a demo example how to properly handle the WDT reset using watchdog, if there is no code in loop (and there cannot be the loop must be empty. Or should i just innit in setup and add the feed in one of the tasks to feed the timer, and it should work ?

Im kind of a not much experienced person when it comes to programming, but i'm trying hard :)
I'm building a home automation/access control system . And my devices are not responsive from time to time, that cannot happen when it comes to access control unit that lets people in or out. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests