From 8a656f006e8c22dfc047d1de7a6a27e17a78fb41 Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Thu, 10 Jan 2019 20:17:04 +0800 Subject: [PATCH] esp32: Fix wdt settings in esp_restart_noos Fixed compatibility the new apps with the old bootloaders. Closes: https://github.com/espressif/esp-idf/issues/2927 --- components/esp32/system_api.c | 3 +-- components/soc/esp32/rtc_wdt.c | 5 +++++ components/soc/include/soc/rtc_wdt.h | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/components/esp32/system_api.c b/components/esp32/system_api.c index 02993afa7d..d9b49183a3 100644 --- a/components/esp32/system_api.c +++ b/components/esp32/system_api.c @@ -279,8 +279,7 @@ void IRAM_ATTR esp_restart_noos() rtc_wdt_set_length_of_reset_signal(RTC_WDT_SYS_RESET_SIG, RTC_WDT_LENGTH_200ns); rtc_wdt_set_length_of_reset_signal(RTC_WDT_CPU_RESET_SIG, RTC_WDT_LENGTH_200ns); rtc_wdt_set_time(RTC_WDT_STAGE0, 1000); - rtc_wdt_enable(); - rtc_wdt_protect_on(); + rtc_wdt_flashboot_mode_enable(); // Reset and stall the other CPU. // CPU must be reset before stalling, in case it was running a s32c1i diff --git a/components/soc/esp32/rtc_wdt.c b/components/soc/esp32/rtc_wdt.c index 67770709bc..1b01ce3046 100644 --- a/components/soc/esp32/rtc_wdt.c +++ b/components/soc/esp32/rtc_wdt.c @@ -38,6 +38,11 @@ void rtc_wdt_enable() SET_PERI_REG_MASK(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_EN | RTC_CNTL_WDT_PAUSE_IN_SLP); } +void rtc_wdt_flashboot_mode_enable() +{ + REG_SET_BIT(RTC_CNTL_WDTCONFIG0_REG, RTC_CNTL_WDT_FLASHBOOT_MOD_EN); +} + void rtc_wdt_disable() { bool protect = rtc_wdt_get_protect_status(); diff --git a/components/soc/include/soc/rtc_wdt.h b/components/soc/include/soc/rtc_wdt.h index ec7175a002..bdaea942b4 100644 --- a/components/soc/include/soc/rtc_wdt.h +++ b/components/soc/include/soc/rtc_wdt.h @@ -118,6 +118,15 @@ void rtc_wdt_protect_off(); */ void rtc_wdt_enable(); +/** + * @brief Enable the flash boot protection procedure for WDT. + * + * Do not recommend to use it in the app. + * This function was added to be compatibility with the old bootloaders. + * This mode is disabled in bootloader or using rtc_wdt_disable() function. + */ +void rtc_wdt_flashboot_mode_enable(); + /** * @brief Disable rtc_wdt. */