Page 1 of 1

RTC Watchdog Timer

Posted: Thu Mar 12, 2020 8:14 pm
by hydedw
Hello,

I need to force a system reset on the ESP32-PICO-D4 and from my understanding the RTC Watchdog is the only way from software to force the system reset. The register description and discussion of the Main System Watchdog Timer is quite good with a lot of detail about the registers. However, the description of the RTC watchdog is almost nonexistent and the register bits are not discussed. Is there a better description of RTC watchdog available? Has anyone been able to implement a software driven system reset with the RTC watchdog or possibly with a different method?

Thanks!
David

Re: RTC Watchdog Timer

Posted: Fri Mar 13, 2020 12:06 am
by boarchuz
If I understand correctly, this is all you're after:

Code: Select all

#include "esp_system.h"

esp_restart();

Re: RTC Watchdog Timer

Posted: Fri Mar 13, 2020 12:53 pm
by hydedw
I think esp_restart causes a CPU reset, not a system reset. A CPU reset resets either one or both CPU cores but a system reset is similar to a power-on reset where the entire ESP32 is reset (CPUs and peripherals). The documentation states that system resets are only caused by the RTC watchdog timeout or power cycling the device.

Re: RTC Watchdog Timer

Posted: Fri Mar 13, 2020 3:22 pm
by ESP_Dazz
The registers and features of the RTC WDT are almost identical to the Main System Watchdogs. Use the APIs provided in the RTC WDT driver. Example below:
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include "soc/rtc_wdt.h"
  4.  
  5. void app_main()
  6. {
  7.     rtc_wdt_protect_off();      //Disable RTC WDT write protection
  8.     //Set stage 0 to trigger a system reset after 1000ms
  9.     rtc_wdt_set_stage(RTC_WDT_STAGE0, RTC_WDT_STAGE_ACTION_RESET_SYSTEM);
  10.     rtc_wdt_set_time(RTC_WDT_STAGE0, 1000);
  11.     rtc_wdt_enable();           //Start the RTC WDT timer
  12.     rtc_wdt_protect_on();       //Enable RTC WDT write protection
  13. }

Re: RTC Watchdog Timer

Posted: Thu Aug 03, 2023 1:31 pm
by ullixesp
@ESP_Dazz: I tried your code, but failed to get a benefit. I now hope for some further help.

I am using an ESP32 under vscode with platformio, using the Arduino framework. Overall the program works, but fails on WiFi transfer with a Task-WDT fail when a binary file to be transferred is bigger than a very few 10kB. I use the static serve, like:

Code: Select all

server.serveStatic("/cam.data",      *myFS, "/cam.data");
The error message is:

Code: Select all

E (51702) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (51702) task_wdt:  - async_tcp (CPU 0)
E (51702) task_wdt: Tasks currently running:
E (51702) task_wdt: CPU 0: IDLE
E (51702) task_wdt: CPU 1: loopTask
E (51702) task_wdt: Aborting.
I had put your code sample under setup(), and into the loop() task I had put "rtc_wdt_feed();". My guess is it fails because I am "protecting" the looptask, while the watchdog is actually triggering the "async_tcp" task? Unfortunately, I do not see if, how and where a timeout is set in the async_tcp task.

What can I do for a solution?

Re: RTC Watchdog Timer

Posted: Wed Dec 13, 2023 11:39 am
by cwx133
Hi, my code as follow,
ESP32 OK,but ESP32S3 error RTC_WDT_STG_SEL_OFF not define

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <freertos/timers.h>
#include <freertos/queue.h>
#include <driver/gpio.h>
#include "driver/timer.h"
#include "esp_task_wdt.h"
#include "soc/rtc_wdt.h"
#include "sdkconfig.h"
#include "nvs_flash.h"
#include <sys/unistd.h>
#include <sys/stat.h>
#include "esp_vfs_fat.h"
#include "sdmmc_cmd.h"
#include <Arduino.h>
#include <esp_log.h>
void setup()
{
    rtc_wdt_protect_off();      //Disable RTC WDT write protection
    //Set stage 0 to trigger a system reset after 1000ms
    rtc_wdt_set_stage(RTC_WDT_STAGE0, RTC_WDT_STAGE_ACTION_RESET_SYSTEM);
    rtc_wdt_set_time(RTC_WDT_STAGE0, 1000);
    rtc_wdt_enable();           //Start the RTC WDT timer
    rtc_wdt_protect_on();       //Enable RTC WDT write protection
}

platformio.ini
[env:esp32s3box]
board = esp32s3box
platform = espressif32
framework = arduino, espidf
monitor_speed = 115200
upload_speed = 921600
upload_port = COM[3]