Page 1 of 1

RTCWDT_RTC_RESET on light sleep

Posted: Sat Sep 21, 2024 4:04 pm
by CamargoF
Hi folks,

I have developed a product that runs on the ESP32-S3 very well and is stable. However, when I attempted to save energy by replacing `delay()` with light sleep at the end of my `loop()`, the ESP32-S3 started rebooting, reporting an RTCWDT_RTC_RESET error.

From my research, it seems that the WDT_RTC generates a timeout to prevent the system from sleeping indefinitely due to bad programming, which is helpful. However, I haven’t been able to find a way to adjust the RTC timeout interval or reset the RTC timer.

I've noticed that people have been reporting this issue in forums since 2021, but no solution has been provided.

I would greatly appreciate any assistance.

The code I am using is:

Code: Untitled.c Select all


    // Sleeps 20ms on loop(), instead of delay()
esp_sleep_enable_timer_wakeup(20 * 1000);

// Keep domains active
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_SLOW_MEM, ESP_PD_OPTION_ON);
esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_FAST_MEM, ESP_PD_OPTION_ON);

// Get a nap (20ms light sleep)
esp_light_sleep_start();
Best regards

Fernando

Re: RTCWDT_RTC_RESET on light sleep

Posted: Sun Sep 22, 2024 9:13 am
by aliarifat794
Please review the power domain settings to check if the system's memory and peripherals are correctly powered during light sleep.

Re: RTCWDT_RTC_RESET on light sleep

Posted: Sun Sep 22, 2024 5:27 pm
by CamargoF
As I mentioned before, the product was running without any problem, until I tried to activate the light sleep.
The power supply looks fine.
I was not able to detect any glitch.

Re: RTCWDT_RTC_RESET on light sleep

Posted: Mon Sep 23, 2024 1:09 am
by CamargoF
I tried to add the call for light sleep, from ESP-IDF, but also fails.

Code: Untitled.c Select all


#include <esp_sleep.h>

#ifndef RTC_WDT_STG_SEL_OFF
# define RTC_WDT_STG_SEL_OFF 0
#endif

#ifndef RTC_WDT_STG_SEL_INT
# define RTC_WDT_STG_SEL_INT 1
#endif

#ifndef RTC_WDT_STG_SEL_RESET_CPU
# define RTC_WDT_STG_SEL_RESET_CPU 2
#endif

#ifndef RTC_WDT_STG_SEL_RESET_SYSTEM
# define RTC_WDT_STG_SEL_RESET_SYSTEM 3
#endif

#ifndef RTC_WDT_STG_SEL_RESET_RTC
# define RTC_WDT_STG_SEL_RESET_RTC 4
#endif

#include "rtc_wdt.h" // from ..\Arduino15\packages\esp32\hardware\esp32\2.0.16\tools\sdk\esp32s3\include\esp_hw_support\include\soc



void watchdogResetRTCWDT() {
// rtc_wdt_feed() = linha 130 de C:\Users\Projetos\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.16\tools\sdk\esp32s3\include\esp_hw_support\include\soc\rtc_wdt.h
// rtc_wdt_feed(); // FAILED

// Trying to access the register directly
// Extract from C:\ESP\esp-idf\components\esp_hw_support\rtc_wdt.c
REG_SET_BIT(RTC_CNTL_WDTFEED_REG, RTC_CNTL_WDT_FEED);
// FAILED}

/*
* @brief Disable the RTC watchdog (RTCWDG).
*/
void watchdogEndRTCWDT() {
// rtc_wdt_disable() = line 123 of ...\Arduino15\packages\esp32\hardware\esp32\2.0.16\tools\sdk\esp32s3\include\esp_hw_support\include\soc\rtc_wdt.h
// rtc_wdt_disable(); // FAILED

// WRITE_PERI_REG(RTC_CNTL_RTC_WDTCONFIG0_REG, 0);

// Trying to access the register directly
// Extract from C:\ESP\esp-idf\components\esp_hw_support\rtc_wdt.c
REG_SET_BIT(RTC_CNTL_WDTFEED_REG, RTC_CNTL_WDT_FEED);
myRtc_wdt_set_stage(RTC_WDT_STAGE0, RTC_WDT_STAGE_ACTION_OFF);
myRtc_wdt_set_stage(RTC_WDT_STAGE1, RTC_WDT_STAGE_ACTION_OFF);
myRtc_wdt_set_stage(RTC_WDT_STAGE2, RTC_WDT_STAGE_ACTION_OFF);
myRtc_wdt_set_stage(RTC_WDT_STAGE3, RTC_WDT_STAGE_ACTION_OFF);
REG_CLR_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_FLASHBOOT_MOD_EN);
REG_CLR_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_EN);
}

/**
* @brief Copied rtc_wdt_set_stage() from C:\ESP\esp-idf\components\esp_hw_support\rtc_wdt.c
*/
esp_err_t myRtc_wdt_set_stage(rtc_wdt_stage_t stage, rtc_wdt_stage_action_t stage_sel)
{
if (stage > 3 || stage_sel > 4) {
return ESP_ERR_INVALID_ARG;
}
if (stage == RTC_WDT_STAGE0) {
REG_SET_FIELD(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_STG0, stage_sel);
} else if (stage == RTC_WDT_STAGE1) {
REG_SET_FIELD(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_STG1, stage_sel);
} else if (stage == RTC_WDT_STAGE2) {
REG_SET_FIELD(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_STG2, stage_sel);
} else {
REG_SET_FIELD(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_STG3, stage_sel);
}

return ESP_OK;
}
Even calling watchdogResetRTCWDT() or watchdogEndRTCWDT() before esp_light_sleep_start(), the RTCWDT_RESET continues.

I have no other idea about what to do. I appreciate any help.

Best regards,

Fernando

Re: RTCWDT_RTC_RESET on light sleep

Posted: Mon Sep 23, 2024 4:02 am
by boarchuz
Can you increase the sleep time (eg. 5s) to determine if it's having issues while asleep or upon wakeup?

Can you share more of your code, especially immediately after esp_light_sleep_start?

Can you add some tracing on the very next line after esp_light_sleep_start? Ideally simple like toggling a GPIO but serial output might work.

Are you certain there's no other serial output? Even if you increase logging level?