-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Description
Board
ESP32
Device Description
DEVKIT
Hardware Configuration
No
Version
latest master (checkout manually)
IDE Name
Arduino IDE
Operating System
Ubuntu 22.04
Flash frequency
Default
PSRAM enabled
yes
Upload speed
115200
Description
I'm trying to configure and use the RTC watchdog on the ESP32 using the Arduino IDE. My goal is to have the RTC watchdog reset the system if it isn't fed within a specified timeout. However, despite my attempts, the RTC watchdog doesn't seem to trigger the reset as expected.
I specifically want to use the RTC watchdog and not the Task Watchdog or any interrupts. My focus is on configuring the RTC watchdog purely via registers to achieve a system reset without involving the FreeRTOS task-level watchdog or handling interrupts.
Steps I've Taken
I've enabled the RTC watchdog using the following register configurations:
WRITE_PERI_REG(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_EN | RTC_CNTL_WDT_FLASHBOOT_MOD_EN); WRITE_PERI_REG(RTC_CNTL_WDTCONFIG1_REG, (3 << RTC_CNTL_WDT_STG0_S)); // Stage 0: Reset system WRITE_PERI_REG(RTC_CNTL_WDTCONFIG2_REG, 8000); // Timeout of ~53 ms WRITE_PERI_REG(RTC_CNTL_WDTFEED_REG, 1); // Feed watchdog
I attempted to stop feeding the watchdog after a few loops in my loop() function to let it expire:
if (count > 5) { while (true) { /* Simulating a crash */ } } else { WRITE_PERI_REG(RTC_CNTL_WDTFEED_REG, 1); // Feed watchdog }
Despite this, the system never resets.
Sketch
#include "soc/rtc_cntl_reg.h"
#include "soc/soc.h"
void setup() {
Serial.begin(115200);
WRITE_PERI_REG(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_EN | RTC_CNTL_WDT_FLASHBOOT_MOD_EN);
WRITE_PERI_REG(RTC_CNTL_WDTCONFIG1_REG, (3 << RTC_CNTL_WDT_STG0_S));
WRITE_PERI_REG(RTC_CNTL_WDTCONFIG2_REG, 8000);
WRITE_PERI_REG(RTC_CNTL_WDTFEED_REG, 1);
Serial.println("RTC Watchdog initialized!");
}
void loop() {
static int count = 0;
count++;
if (count > 5) {
Serial.println("Leaving RTC Watchdog to expire...");
while (true) { /* Simulate system hang */ }
} else {
Serial.println("Feeding RTC Watchdog...");
WRITE_PERI_REG(RTC_CNTL_WDTFEED_REG, 1);
}
delay(1000);
}
Debug Message
-
Other Steps to Reproduce
I also tried using functions like rtc_wdt_enable()
and similar ones (wdt_enable(WDTO_2S)
), but the code does not compile.
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.