Automatic reboot after wdt reset
My boards crash from time to time and I do not know why. After such crash the wd reset shows up (boot mode:(1,6)), but the board does not restart automatically. How can I make the boards reset/restart automatically after a wdt reset?
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
mode:(1,6) means bootloader mode, you need to add resistors like here: https://github.com/esp8266/Arduino/blob/master/doc/boards.md#minimal-hardware-setup-for-bootloading-and-usage
Thank you for this info. I added all these resistors. After knowing that the ESP sits in the "bootloader" I have to rephrase my question: How can I change its behavior that the board restarts the normal "setup()" routine after the watchdog was initiated? I wrote a recovery routine to my sketch which can handle this situation. When I reset it manually, it works. But this will not be possible if I deployed it ;-)
if you have added all the resistors, and you call ESP.restart(); the bord will reboot to the "setup".
keep in mind if you connect other sensors / hardware the GPIO0 need to be HIGH and GPIO15 need to be LOW when you call ESP.restart();
Thank you for your fast reply. I was not clear enough: When my board crashes, it shows the message wdt reset mode:(1,6) and does nothing anymore until I reset it manually. With your explanation, this behavior is clear: The bootloader waits for something to happen. In this situation, my sketch has no control over the board anymore and I cannot issue the command ESP.restart(). Only manual intervention (ground the reset pin) helps to restart the sketch. But I would like to avoid this manual reset and do it automatically after the watchdog showed its message.
ok now i get it, if the wdt reset is triggert the board reboots, when it reboots it is checking the state of GPIO0 and GPIO15 and GPIO2
| GPIO15 | GPIO0 | GPIO2 | Mode |
|---|---|---|---|
| 0V | 0V | 3.3V | Uart Bootloader |
| 0V | 3.3V | 3.3V | Boot sketch |
| 3.3V | x | x | SDIO mode (not used for Arduino) |
you need to make sure that the pins in the right state when a wtd happens or you call ESP.restart()
better you add some delays to prevent the wtd from triggering.
This requires some investigation. I have noticed that sometimes my nodemcu enters bootloader after wdt reset. All the pull up resistors are in place, so not sure what is happening. I'll take a look at this, but not sure when :)
On Sat, Nov 14, 2015, 14:37 Markus [email protected] wrote:
ok now i get it, if the wdt reset is triggert the board reboots, when it reboots it is checking the state of GPIO0 and GPIO15 and GPIO2 GPIO15 GPIO0 GPIO2 Mode 0V 0V 3.3V Uart Bootloader 0V 3.3V 3.3V Boot sketch 3.3V x x SDIO mode (not used for Arduino)
you need to make sure that the pins in the right state when a wtd happens or you call ESP.restart()
better you add some delays to prevent the wtd from triggering.
— Reply to this email directly or view it on GitHub https://github.com/esp8266/Arduino/issues/1017#issuecomment-156689684.
You were absolutely right! The problem is my GPIO0 pin. I pull it up with an Attiny85. I use this method to generate the necessary timing (together with REST). I did a very small sketch to generate a WD reset: void setup() { Serial.begin(115200); Serial.println("Begin"); } void loop() { while (1 == 1); }
Always after I do the uploading, GPIO0 starts to oscillate from 3.1 to around 2 volts (with 26 MHz!). And in this state, the ESP goes into bootloader mode and stays there:
Soft WDT reset ctx: cont sp: 3ffe96c0 end: 3ffe9890 offset: 01b0
stack>>> 3ffe9870: 00000000 00000000 3ffe98b4 4020186a
3ffe9880: 00000000 00000000 3ffe8870 40100114
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(1,7)
ets Jan 8 2013,rst cause:4, boot mode:(1,7)
wdt reset
If I do a (manual) hard reset with everything exactly the same as before, this happens repetedly:
Begin
Soft WDT reset
ctx: cont sp: 3ffe96d0 end: 3ffe9890 offset: 01b0
stack>>> 3ffe9880: 00000000 00000000 3ffe8870 40100114
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1264, room 16 tail 0 chksum 0x42 csum 0x42 ~ld
and GPIO0 does not oscillate at all.
So, I have to invetigate into my uploading logic. Thank you for your help!
With mynodemcu 1.0 esp12e after flash system is blocked and I must cut off power . After this every time I do reset system work perfect
Sent from my iPhone
On 14 nov 2015, at 15:38, SensorsIOT [email protected] wrote:
You were absolutely right! The problem is my GPIO0 pin. I pull it up with an Attiny85. I use this method to generate the necessary timing (together with REST). I did a very small sketch to generate a WD reset: void setup() { Serial.begin(115200); Serial.println("Begin"); } void loop() { while (1 == 1); }
Always after I do the uploading, GPIO0 starts to oscillate from 3.1 to around 2 volts (with 26 MHz!). And in this state, the ESP goes into bootloader mode and stays there:
Soft WDT reset ctx: cont sp: 3ffe96c0 end: 3ffe9890 offset: 01b0
stack>>> 3ffe9870: 00000000 00000000 3ffe98b4 4020186a
3ffe9880: 00000000 00000000 3ffe8870 40100114
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(1,7)
ets Jan 8 2013,rst cause:4, boot mode:(1,7)
wdt reset
If I do a (manual) hard reset with everything exactly the same as before, this happens repetedly:
Begin
Soft WDT reset
ctx: cont sp: 3ffe96d0 end: 3ffe9890 offset: 01b0
stack>>> 3ffe9880: 00000000 00000000 3ffe8870 40100114
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1264, room 16 tail 0 chksum 0x42 csum 0x42 ~ld
and GPIO0 does not oscillate at all.
So, I have to invetigate into my uploading logic. Thank you for your help!
— Reply to this email directly or view it on GitHub.
An additional info: I added a small capacitor to GPIO0 (47nf to GND) and the level of the pin stays now above 3V. The same behavior appears. So, it might have another source. The board is an ESP-7. After the post of asetyde I checked the same coding with my nodemcu ESP12E board. It behaves correctly and resets repedetly. Mybe asetyde can check my sketch on his board. Then we would know more.
At now i can not test , but why use a while(1) in function loop ? It's same
Sent from my iPhone
On 14 nov 2015, at 15:38, SensorsIOT [email protected] wrote:
You were absolutely right! The problem is my GPIO0 pin. I pull it up with an Attiny85. I use this method to generate the necessary timing (together with REST). I did a very small sketch to generate a WD reset: void setup() { Serial.begin(115200); Serial.println("Begin"); } void loop() { while (1 == 1); }
Always after I do the uploading, GPIO0 starts to oscillate from 3.1 to around 2 volts (with 26 MHz!). And in this state, the ESP goes into bootloader mode and stays there:
Soft WDT reset ctx: cont sp: 3ffe96c0 end: 3ffe9890 offset: 01b0
stack>>> 3ffe9870: 00000000 00000000 3ffe98b4 4020186a
3ffe9880: 00000000 00000000 3ffe8870 40100114
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(1,7)
ets Jan 8 2013,rst cause:4, boot mode:(1,7)
wdt reset
If I do a (manual) hard reset with everything exactly the same as before, this happens repetedly:
Begin
Soft WDT reset
ctx: cont sp: 3ffe96d0 end: 3ffe9890 offset: 01b0
stack>>> 3ffe9880: 00000000 00000000 3ffe8870 40100114
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1264, room 16 tail 0 chksum 0x42 csum 0x42 ~ld
and GPIO0 does not oscillate at all.
So, I have to invetigate into my uploading logic. Thank you for your help!
— Reply to this email directly or view it on GitHub.
You can use while (1) . You are right. It is the same.
ok but loop in a loop ?
On 14 nov 2015, at 16:28, SensorsIOT [email protected] wrote:
You can use while (1) . You are right. It is the same.
— Reply to this email directly or view it on GitHub https://github.com/esp8266/Arduino/issues/1017#issuecomment-156712245.
without the while loop the ESP does not crash, at least not in my case. And I wanted to see if the module restarts into the setup() after a crash or if it stays in the bootloader loop (see descriptions above).
I added a small capacitor to GPIO0 (47nf to GND) and the level of the pin stays now above 3V
Since you are trying to keep GPIO0 high, try a 47nf or higher to 3.3v instead. Actually from GPIO0 to chip 3V3 pin.
This will make the pull up look like a short circuit at high freq.
May react differently from cap to GND due to board traces and internal chip tracks.
Linking #793, which is pretty much the same issue.
I have the same issue (ESP.reset() causes wdt reset and hangs). Here are my test findings. I am using nodemcu board. GPIO0,GPIO0 are pulled up, and GPIO15 is pulled down. Test code
void setup() {
Serial.begin(115200);
Serial.println("");
delay(1000);
//wdt_disable(); No difference with this line active or not.
}
void loop() {
Serial.print("Start");
delay(3000);
//ESP.reset();
ESP.restart();//Same results as ESP.reset()
}
First time run:
Start
ets Jan 8 2013,rst cause:2, boot mode:(1,6)
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
And is stuck here.
If I repower the device, then Every run then on shows
Start
ets Jan 8 2013,rst cause:2, boot mode:(3,7)
load 0x4010f000, len 1264, room 16
tail 0
chksum 0x42
csum 0x42
~ld
And resets, reboots successfully. So, something is happening after the first repowering? Because, after that it runs smooth. as expected.
ets Jan 8 2013,rst cause:2, boot mode:(1,6) <-- reboot by reset pin - Mode Uart
ets Jan 8 2013,rst cause:4, boot mode:(1,6) <-- reboot by watchdog - Mode Uart
ets Jan 8 2013,rst cause:2, boot mode:(3,7) <-- reboot by reset pin - Mode Flash (boot the sketch)
more info about the boot messages see here: https://github.com/esp8266/Arduino/blob/master/doc/boards.md#boot-messages-and-modes
the boot mode looks wrong in the first case, check the GPIO0 its is at 0V to get mode 1, you need mode 3 to boot to the sketch.
@Links2004 given GPIO0 is pulled up to 3.3V on my board and the fact that I need to press a button (from GPIO0 to GND) under normal circumstances to program it, any clue why this is happening? I tried with different power supplies, but this behaviour persists.
@Links2004 I did some additional digging with a scope to see what is happening. I have attached pictures. please take a look. @SensorsIot I confirm same findings as you did. Even the simple while loop. Also, same findings as @asetyde after power cycle. resets without any issues then on.
ESP WDT RESET and GPIO0 states on first run.pdf
A sample Serial debug output below.
Soft WDT reset
ctx: cont
sp: 3ffee0a0 end: 3ffee2a0 offset: 01b0
>>>stack>>>
3ffee250: 3ffea958 00000000 0000b7d6 4020e2f8
3ffee260: 00000000 00000000 00000016 3ffee2cc
3ffee270: 3fffdc20 00000000 3ffee2c4 40210af4
3ffee280: 3fffdc20 00000000 3ffee2c4 40201d06
3ffee290: 00000000 00000000 3ffed280 40100398
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(1,6)
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
I use 3K3 pullups, does lower values reduce the sine wave?