-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Hardware:
Board: ?ESP32 Dev Module?
Core Installation/update date: ?11/jul/2017?
IDE name: ?Arduino IDE?
Flash Frequency: ?40Mhz?
PSRAM enabled: ?no?
Upload Speed: ?115200?
Computer OS: ?Mac OSX?
Description:
I am using an ESP32 NodeMCU development board and using esp32-arduino using platformio. ESP32 hangs/freezes and watchdog doesn't restart the system in a peculiar case. Most of the times it restarts but in some peculiar case it freezes. What i have figured out is if the system restarts either in a timer or an interrupt while WiFi.begin is being called.
Sketch:
//Change the code below by your sketch
#include <Arduino.h>
#include "WiFi.h"
#include "esp_task_wdt.h"
#include "esp_int_wdt.h"
#include "esp32-hal.h"
static volatile long lastACMainsTimestamp = 0;
static volatile int current_count_ac[] = {0,0,0,0};
void IRAM_ATTR recordACInterrupt0() {
ESP.restart();
current_count_ac[0]++;
}
void setup() {
enableLoopWDT();
enableCore0WDT();
enableCore1WDT();
Serial.begin(115200);
Serial.setDebugOutput(true);
pinMode(23, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(23), recordACInterrupt0, CHANGE);
// Comment the below lines and it will never get stuck
WiFi.mode(WIFI_STA);
WiFi.disconnect(true);
WiFi.begin("ssid-test", "password-test");
}
void loop() {
}
Why am I calling ESP.restart() in an interrupt?
I have an esp32 in production used for SMART HOME usecase which stops responding and doesn't reset in a customer environment and i have to ask my customers to reset this by powering off the mains to their house and then powering it on which is almost an annoyance when it happens.
I have looked at all the related issues below and none solve it
- esp_restart() intermittently won't reset, causing stuck esp32 (IDFGH-258) esp-idf#2101
- DEEPSLEEP_RESET gets stuck after a few resets #796
So I did some monkey testing with restarts and tried to get the device into a state which doesn't reset automatically even when WDT is setup and I arrived at the following way where I restart in an interrupt simultaneously when WiFi.begin or WiFi.mode is being called.
How often does it happen?
It happens per customer every once in 2 weeks to a month. If not for this issue its completely stable
StackTrace
For the pin 23 I give a signal of 5Hz DC square wave so that it gets triggered every 200ms and after a few restarts in a some peculiar case it throws the below stacktrace and freezes completely
[E][esp32-hal-misc.c:87] enableCore0WDT(): Failed to add Core 0 IDLE task to WDT
Guru Meditation Error: Core 1 panic'ed (Cache disabled but cached memory region accessed)
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalInstruction). Exception was unhandled.
Memory dump at 0x4013b004: bad00bad bad00bad bad00bad
Guru Meditation Error: Core 1 panic'ed (IllegalGuru Meditation Error: Core 1 panic'ed (Unhandled debug exc
eption)
Debug exception reason: Stack canary watchpoint triggered (�@␜␛�?)
Guru Meditation Error: Core 1 panic'ed (Double exception)
Guru Meditation Error: Core 1 panic'ed (Double exception)
Guru Meditation Error: Core 1 panic'ed (Guru Meditation Error: Core 1 panic'ed (