arduinoesp32arduino-esp32platformio

How to use WatchDog on esp32-s3-devkitc-1


On my esp32dev board i was using the watchdog as follows and it was working perfectly.

// 1) include

#include <Arduino.h>
#include "soc/soc.h"
#include "soc/rtc_cntl_reg.h"
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <esp_task_wdt.h>
#include <esp_log.h>
#include <soc/rtc_wdt.h>


// 2) activate the watchdog

watchdogRTC();


// 3) reset timer of the  watchdog
rtc_wdt_feed(); //Alimenta o RTC WDT


// 4) code to test

    if (Serial.available())
    {
     while(1){
     Serial.println("preso");
     delay(1000);
     }
    }


// 5) final functio

void watchdogRTC()
{
   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_RTC);
   rtc_wdt_set_time(RTC_WDT_STAGE0, 9000);
   rtc_wdt_enable();           //Start the RTC WDT timer
   rtc_wdt_protect_on();       //Enable RTC WDT write protection
}

platformio.ini

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200
board_build.f_flash = 80000000L

On my esp32-s3-devkitc-1 using the same approach i get the errors:

‘RTC_WDT_STG_SEL_OFF’ was not declared in this scope, ‘RTC_WDT_STG_SEL_INT’ was not declared in this scope ‘RTC_WDT_STG_SEL_RESET_CPU’ was not declared in this scope ‘RTC_WDT_STG_SEL_RESET_SYSTEM’ was not declared in this scope ‘RTC_WDT_STG_SEL_RESET_RTC’ was not declared in this scope

platformio.ini

[env:esp32-s3-devkitc-1]
platform = espressif32
board = esp32-s3-devkitc-1
framework = arduino
monitor_speed = 115200
board_build.f_flash = 80000000L

Solution

  • answer to this problem by Ivan Grokhotkov (developer at Espressif) from https://github.com/espressif/esp-idf/issues/8038#issuecomment-1091860842

    If you don't need the rtc_wdt.h header specifically, but you need to use RTC watchdog, you can try to use components/hal/include/hal/wdt_hal.h instead (hal/wdt_hal.h). Just like rtc_wdt.h, this is a "private" header, which can change in the future in incompatible ways. But it is supported on all chip targets.

    Unfortunately for now we don't have a stable public API for the RTC watchdog.