diff --git a/components/bootloader/Kconfig.projbuild b/components/bootloader/Kconfig.projbuild index be08780f79..f3cb448e25 100644 --- a/components/bootloader/Kconfig.projbuild +++ b/components/bootloader/Kconfig.projbuild @@ -284,6 +284,7 @@ menu "Bootloader config" config BOOTLOADER_WDT_ENABLE bool "Use RTC watchdog in start code" + depends on SOC_RTC_WDT_SUPPORTED default y help Tracks the execution time of startup code. diff --git a/components/bootloader_support/src/bootloader_init.c b/components/bootloader_support/src/bootloader_init.c index 0374001f31..b9c9fc7563 100644 --- a/components/bootloader_support/src/bootloader_init.c +++ b/components/bootloader_support/src/bootloader_init.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,8 +16,11 @@ #include "bootloader_common.h" #include "esp_cpu.h" #include "soc/soc_caps.h" + #include "soc/rtc.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/efuse_hal.h" #include "hal/cache_hal.h" #include "hal/mmu_hal.h" @@ -72,6 +75,7 @@ esp_err_t bootloader_check_bootloader_validity(void) void bootloader_config_wdt(void) { +#if SOC_RTC_WDT_SUPPORTED /* * At this point, the flashboot protection of RWDT and MWDT0 will have been * automatically enabled. We can disable flashboot protection as it's not @@ -95,11 +99,16 @@ void bootloader_config_wdt(void) wdt_hal_write_protect_enable(&rwdt_ctx); #endif - //Disable MWDT0 flashboot protection. But only after we've enabled the RWDT first so that there's not gap in WDT protection. +#endif /* SOC_RTC_WDT_SUPPORTED */ + +#if SOC_WDT_SUPPORTED + //Disable MWDT0 flashboot protection. When RTC WDT is present, run this after RWDT + //setup above so there is no gap in WDT protection during bootloader. wdt_hal_context_t mwdt_ctx = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&mwdt_ctx); wdt_hal_set_flashboot_en(&mwdt_ctx, false); wdt_hal_write_protect_enable(&mwdt_ctx); +#endif /* SOC_WDT_SUPPORTED */ } void bootloader_enable_random(void) diff --git a/components/bootloader_support/src/esp32/bootloader_esp32.c b/components/bootloader_support/src/esp32/bootloader_esp32.c index 879f7c2ece..45bbcde115 100644 --- a/components/bootloader_support/src/esp32/bootloader_esp32.c +++ b/components/bootloader_support/src/esp32/bootloader_esp32.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -24,6 +24,8 @@ #include "soc/gpio_sig_map.h" #include "soc/io_mux_reg.h" #include "soc/rtc.h" +#include "soc/soc_caps.h" + #include "hal/gpio_hal.h" #include "hal/mmu_hal.h" #include "xtensa/config/core.h" @@ -88,6 +90,7 @@ static inline esp_err_t bootloader_check_rated_cpu_clock(void) return ESP_OK; } +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { //We do not reset core1 info here because it didn't work before cpu1 was up. So we put it into call_start_cpu1. @@ -168,6 +171,7 @@ static void bootloader_check_wdt_reset(void) } wdt_reset_cpu0_info_enable(); } +#endif // SOC_RTC_WDT_SUPPORTED esp_err_t bootloader_init(void) { @@ -240,10 +244,14 @@ esp_err_t bootloader_init(void) } #endif // #if !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); return ret; diff --git a/components/bootloader_support/src/esp32c2/bootloader_esp32c2.c b/components/bootloader_support/src/esp32c2/bootloader_esp32c2.c index 3b8f422258..7d4b0496d6 100644 --- a/components/bootloader_support/src/esp32c2/bootloader_esp32c2.c +++ b/components/bootloader_support/src/esp32c2/bootloader_esp32c2.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,8 @@ #include "soc/assist_debug_reg.h" #include "esp_cpu.h" #include "soc/rtc.h" +#include "soc/soc_caps.h" + #include "soc/extmem_reg.h" #include "soc/system_reg.h" #include "esp32c2/rom/ets_sys.h" @@ -39,6 +41,7 @@ ESP_LOG_ATTR_TAG(TAG, "boot.esp32c2"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { REG_SET_BIT(SYSTEM_CPU_PERI_CLK_EN_REG, SYSTEM_CLK_EN_ASSIST_DEBUG); @@ -75,6 +78,7 @@ static void bootloader_super_wdt_auto_feed(void) REG_SET_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_AUTO_FEED_EN); REG_WRITE(RTC_CNTL_SWD_WPROTECT_REG, 0); } +#endif // SOC_RTC_WDT_SUPPORTED static inline void bootloader_ana_reset_config(void) { @@ -89,7 +93,9 @@ esp_err_t bootloader_init(void) esp_err_t ret = ESP_OK; bootloader_ana_reset_config(); +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -135,10 +141,14 @@ esp_err_t bootloader_init(void) } #endif // !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); return ret; diff --git a/components/bootloader_support/src/esp32c3/bootloader_esp32c3.c b/components/bootloader_support/src/esp32c3/bootloader_esp32c3.c index 0b19b71221..c2b51d50a8 100644 --- a/components/bootloader_support/src/esp32c3/bootloader_esp32c3.c +++ b/components/bootloader_support/src/esp32c3/bootloader_esp32c3.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,6 +19,8 @@ #include "esp_cpu.h" #include "soc/rtc.h" #include "soc/rtc_cntl_reg.h" +#include "soc/soc_caps.h" + #include "soc/extmem_reg.h" #include "soc/system_reg.h" #include "soc/chip_revision.h" @@ -44,6 +46,7 @@ ESP_LOG_ATTR_TAG(TAG, "boot.esp32c3"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { REG_SET_BIT(SYSTEM_CPU_PERI_CLK_EN_REG, SYSTEM_CLK_EN_ASSIST_DEBUG); @@ -80,6 +83,7 @@ static void bootloader_super_wdt_auto_feed(void) REG_SET_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_AUTO_FEED_EN); REG_WRITE(RTC_CNTL_SWD_WPROTECT_REG, 0); } +#endif // SOC_RTC_WDT_SUPPORTED static inline void bootloader_hardware_init(void) { @@ -128,7 +132,9 @@ esp_err_t bootloader_init(void) bootloader_hardware_init(); bootloader_ana_reset_config(); +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -179,10 +185,14 @@ esp_err_t bootloader_init(void) } #endif //#if !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); diff --git a/components/bootloader_support/src/esp32c5/bootloader_esp32c5.c b/components/bootloader_support/src/esp32c5/bootloader_esp32c5.c index 8c2f071534..7dd56f8012 100644 --- a/components/bootloader_support/src/esp32c5/bootloader_esp32c5.c +++ b/components/bootloader_support/src/esp32c5/bootloader_esp32c5.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,6 +14,7 @@ #include "esp_rom_sys.h" #include "esp_rom_spiflash.h" #include "soc/soc_caps.h" + #include "soc/gpio_sig_map.h" #include "soc/io_mux_reg.h" #include "soc/assist_debug_reg.h" @@ -45,6 +46,7 @@ ESP_LOG_ATTR_TAG(TAG, "boot.esp32c5"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { REG_SET_BIT(PCR_ASSIST_CONF_REG, PCR_ASSIST_CLK_EN); @@ -81,6 +83,7 @@ static void bootloader_super_wdt_auto_feed(void) REG_SET_BIT(LP_WDT_SWD_CONFIG_REG, LP_WDT_SWD_AUTO_FEED_EN); REG_WRITE(LP_WDT_SWD_WPROTECT_REG, 0); } +#endif // SOC_RTC_WDT_SUPPORTED static inline void bootloader_hardware_init(void) { @@ -113,7 +116,9 @@ esp_err_t bootloader_init(void) bootloader_hardware_init(); bootloader_ana_reset_config(); +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -164,10 +169,14 @@ esp_err_t bootloader_init(void) } #endif // !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); diff --git a/components/bootloader_support/src/esp32c6/bootloader_esp32c6.c b/components/bootloader_support/src/esp32c6/bootloader_esp32c6.c index 32947d8a00..d5ff1e8935 100644 --- a/components/bootloader_support/src/esp32c6/bootloader_esp32c6.c +++ b/components/bootloader_support/src/esp32c6/bootloader_esp32c6.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,8 @@ #include "soc/assist_debug_reg.h" #include "esp_cpu.h" #include "soc/rtc.h" +#include "soc/soc_caps.h" + #include "soc/extmem_reg.h" #include "soc/pcr_reg.h" #include "esp32c6/rom/ets_sys.h" @@ -46,6 +48,7 @@ ESP_LOG_ATTR_TAG(TAG, "boot.esp32c6"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { REG_SET_BIT(PCR_ASSIST_CONF_REG, PCR_ASSIST_CLK_EN); @@ -82,6 +85,7 @@ static void bootloader_super_wdt_auto_feed(void) REG_SET_BIT(LP_WDT_SWD_CONFIG_REG, LP_WDT_SWD_AUTO_FEED_EN); REG_WRITE(LP_WDT_SWD_WPROTECT_REG, 0); } +#endif // SOC_RTC_WDT_SUPPORTED static inline void bootloader_hardware_init(void) { @@ -112,7 +116,9 @@ esp_err_t bootloader_init(void) bootloader_hardware_init(); bootloader_ana_reset_config(); +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -163,10 +169,14 @@ esp_err_t bootloader_init(void) } #endif // !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); diff --git a/components/bootloader_support/src/esp32c61/bootloader_esp32c61.c b/components/bootloader_support/src/esp32c61/bootloader_esp32c61.c index 1e97936b48..6a2c45c04d 100644 --- a/components/bootloader_support/src/esp32c61/bootloader_esp32c61.c +++ b/components/bootloader_support/src/esp32c61/bootloader_esp32c61.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,8 @@ #include "soc/assist_debug_reg.h" #include "esp_cpu.h" #include "soc/rtc.h" +#include "soc/soc_caps.h" + #include "soc/cache_reg.h" #include "soc/pcr_reg.h" #include "esp32c61/rom/ets_sys.h" @@ -46,6 +48,7 @@ ESP_LOG_ATTR_TAG(TAG, "boot.esp32c61"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { REG_SET_BIT(PCR_ASSIST_CONF_REG, PCR_ASSIST_CLK_EN); @@ -82,6 +85,7 @@ static void bootloader_super_wdt_auto_feed(void) REG_SET_BIT(LP_WDT_SWD_CONFIG_REG, LP_WDT_SWD_AUTO_FEED_EN); REG_WRITE(LP_WDT_SWD_WPROTECT_REG, 0); } +#endif // SOC_RTC_WDT_SUPPORTED static inline void bootloader_hardware_init(void) { @@ -104,7 +108,9 @@ esp_err_t bootloader_init(void) esp_err_t ret = ESP_OK; bootloader_hardware_init(); bootloader_ana_reset_config(); +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -155,10 +161,14 @@ esp_err_t bootloader_init(void) } #endif // !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); diff --git a/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c b/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c index 9e0eeab7ba..4b7a057b28 100644 --- a/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c +++ b/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,8 @@ #include "soc/assist_debug_reg.h" #include "esp_cpu.h" #include "soc/rtc.h" +#include "soc/soc_caps.h" + #include "soc/extmem_reg.h" #include "soc/pcr_reg.h" #include "esp32h2/rom/ets_sys.h" @@ -45,6 +47,7 @@ ESP_LOG_ATTR_TAG(TAG, "boot.esp32h2"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { REG_SET_BIT(PCR_ASSIST_CONF_REG, PCR_ASSIST_CLK_EN); @@ -81,6 +84,7 @@ static void bootloader_super_wdt_auto_feed(void) REG_SET_BIT(LP_WDT_SWD_CONFIG_REG, LP_WDT_SWD_AUTO_FEED_EN); REG_WRITE(LP_WDT_SWD_WPROTECT_REG, 0); } +#endif // SOC_RTC_WDT_SUPPORTED static inline void bootloader_hardware_init(void) { @@ -109,7 +113,9 @@ esp_err_t bootloader_init(void) bootloader_hardware_init(); bootloader_ana_reset_config(); +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -161,9 +167,13 @@ esp_err_t bootloader_init(void) #endif // !CONFIG_APP_BUILD_TYPE_RAM // check whether a WDT reset happened +#if SOC_RTC_WDT_SUPPORTED bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); diff --git a/components/bootloader_support/src/esp32h21/bootloader_esp32h21.c b/components/bootloader_support/src/esp32h21/bootloader_esp32h21.c index 483001bae1..e182f90345 100644 --- a/components/bootloader_support/src/esp32h21/bootloader_esp32h21.c +++ b/components/bootloader_support/src/esp32h21/bootloader_esp32h21.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,8 @@ #include "soc/assist_debug_reg.h" #include "esp_cpu.h" #include "soc/rtc.h" +#include "soc/soc_caps.h" + #include "soc/cache_reg.h" #include "soc/pcr_reg.h" #include "rom/ets_sys.h" @@ -44,6 +46,7 @@ ESP_LOG_ATTR_TAG(TAG, "boot.esp32h21"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { REG_SET_BIT(PCR_ASSIST_CONF_REG, PCR_ASSIST_CLK_EN); @@ -80,6 +83,7 @@ static void bootloader_super_wdt_auto_feed(void) REG_SET_BIT(LP_WDT_SWD_CONFIG_REG, LP_WDT_SWD_AUTO_FEED_EN); REG_WRITE(LP_WDT_SWD_WPROTECT_REG, 0); } +#endif // SOC_RTC_WDT_SUPPORTED static inline void bootloader_hardware_init(void) { @@ -106,7 +110,9 @@ esp_err_t bootloader_init(void) bootloader_hardware_init(); bootloader_ana_reset_config(); +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -157,10 +163,14 @@ esp_err_t bootloader_init(void) } #endif // !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); diff --git a/components/bootloader_support/src/esp32h4/bootloader_esp32h4.c b/components/bootloader_support/src/esp32h4/bootloader_esp32h4.c index 5bec41d188..76229966db 100644 --- a/components/bootloader_support/src/esp32h4/bootloader_esp32h4.c +++ b/components/bootloader_support/src/esp32h4/bootloader_esp32h4.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,6 +16,8 @@ #include "soc/gpio_sig_map.h" #include "esp_cpu.h" #include "soc/rtc.h" +#include "soc/soc_caps.h" + #include "soc/cache_reg.h" #include "soc/io_mux_reg.h" #include "soc/pcr_reg.h" @@ -42,6 +44,7 @@ ESP_LOG_ATTR_TAG(TAG, "boot.esp32h4"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { assist_debug_ll_enable_bus_clock(0, true); @@ -77,6 +80,7 @@ static void bootloader_super_wdt_auto_feed(void) REG_SET_BIT(LP_WDT_SWD_CONFIG_REG, LP_WDT_SWD_AUTO_FEED_EN); REG_WRITE(LP_WDT_SWD_WPROTECT_REG, 0); } +#endif // SOC_RTC_WDT_SUPPORTED static inline void bootloader_hardware_init(void) { @@ -120,7 +124,9 @@ esp_err_t bootloader_init(void) bootloader_hardware_init(); bootloader_ana_reset_config(); +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -172,10 +178,14 @@ esp_err_t bootloader_init(void) #endif // !CONFIG_APP_BUILD_TYPE_RAM bootloader_config_dcache(); bootloader_config_icache1(); +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); diff --git a/components/bootloader_support/src/esp32p4/bootloader_esp32p4.c b/components/bootloader_support/src/esp32p4/bootloader_esp32p4.c index 4aff280282..c7a2b3a8f1 100644 --- a/components/bootloader_support/src/esp32p4/bootloader_esp32p4.c +++ b/components/bootloader_support/src/esp32p4/bootloader_esp32p4.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,8 @@ #include "soc/assist_debug_reg.h" #include "esp_cpu.h" #include "soc/rtc.h" +#include "soc/soc_caps.h" + #include "soc/cache_reg.h" #include "esp32p4/rom/ets_sys.h" #include "esp32p4/rom/spi_flash.h" @@ -52,6 +54,7 @@ ESP_LOG_ATTR_TAG(TAG, "boot.esp32p4"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { _assist_debug_ll_enable_bus_clock(0, true); @@ -90,6 +93,7 @@ static void bootloader_super_wdt_auto_feed(void) REG_SET_BIT(LP_WDT_SWD_CONFIG_REG, LP_WDT_SWD_AUTO_FEED_EN); REG_WRITE(LP_WDT_SWD_WPROTECT_REG, 0); } +#endif // SOC_RTC_WDT_SUPPORTED static inline void bootloader_hardware_init(void) { @@ -129,7 +133,9 @@ esp_err_t bootloader_init(void) bootloader_hardware_init(); bootloader_ana_reset_config(); +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -181,10 +187,14 @@ esp_err_t bootloader_init(void) } #endif // !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); diff --git a/components/bootloader_support/src/esp32s2/bootloader_esp32s2.c b/components/bootloader_support/src/esp32s2/bootloader_esp32s2.c index 07f921ce91..b1584b4251 100644 --- a/components/bootloader_support/src/esp32s2/bootloader_esp32s2.c +++ b/components/bootloader_support/src/esp32s2/bootloader_esp32s2.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -33,12 +33,15 @@ #include "soc/extmem_reg.h" #include "soc/rtc.h" #include "soc/rtc_cntl_reg.h" +#include "soc/soc_caps.h" + #include "esp_efuse.h" #include "hal/mmu_hal.h" #include "hal/cache_hal.h" ESP_LOG_ATTR_TAG(TAG, "boot.esp32s2"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { DPORT_REG_SET_BIT(DPORT_PERI_CLK_EN_REG, DPORT_PERI_EN_ASSIST_DEBUG); @@ -100,11 +103,14 @@ static void bootloader_super_wdt_auto_feed(void) { REG_SET_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_AUTO_FEED_EN); } +#endif // SOC_RTC_WDT_SUPPORTED esp_err_t bootloader_init(void) { esp_err_t ret = ESP_OK; +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // protect memory region // In RAM_APP, memory will be initialized in `call_start_cpu0` @@ -163,10 +169,14 @@ esp_err_t bootloader_init(void) } #endif // !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); diff --git a/components/bootloader_support/src/esp32s3/bootloader_esp32s3.c b/components/bootloader_support/src/esp32s3/bootloader_esp32s3.c index d35158725e..2292c2ca33 100644 --- a/components/bootloader_support/src/esp32s3/bootloader_esp32s3.c +++ b/components/bootloader_support/src/esp32s3/bootloader_esp32s3.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,6 +18,8 @@ #include "soc/rtc.h" #include "soc/rtc_cntl_reg.h" #include "soc/extmem_reg.h" +#include "soc/soc_caps.h" + #include "esp_rom_gpio.h" #include "esp_rom_efuse.h" @@ -45,6 +47,7 @@ ESP_LOG_ATTR_TAG(TAG, "boot.esp32s3"); +#if SOC_RTC_WDT_SUPPORTED static void wdt_reset_cpu0_info_enable(void) { REG_SET_BIT(SYSTEM_CPU_PERI_CLK_EN_REG, SYSTEM_CLK_EN_ASSIST_DEBUG); @@ -128,6 +131,7 @@ static void bootloader_super_wdt_auto_feed(void) REG_SET_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_AUTO_FEED_EN); REG_WRITE(RTC_CNTL_SWD_WPROTECT_REG, 0); } +#endif // SOC_RTC_WDT_SUPPORTED static inline void bootloader_ana_reset_config(void) { @@ -147,7 +151,9 @@ esp_err_t bootloader_init(void) #endif // XCHAL_ERRATUM_572 bootloader_ana_reset_config(); +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -202,10 +208,14 @@ esp_err_t bootloader_init(void) } #endif // !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened bootloader_check_wdt_reset(); +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); return ret; diff --git a/components/bootloader_support/src/esp32s31/bootloader_esp32s31.c b/components/bootloader_support/src/esp32s31/bootloader_esp32s31.c index 3908ea48e9..4da433a242 100644 --- a/components/bootloader_support/src/esp32s31/bootloader_esp32s31.c +++ b/components/bootloader_support/src/esp32s31/bootloader_esp32s31.c @@ -11,6 +11,7 @@ #include "flash_qio_mode.h" #include "bootloader_common.h" #include "bootloader_init.h" +#include "soc/soc_caps.h" #include "bootloader_clock.h" #include "bootloader_flash_config.h" #include "bootloader_mem.h" @@ -18,24 +19,30 @@ #include "bootloader_flash_priv.h" #include "bootloader_soc.h" #include "esp_private/bootloader_flash_internal.h" +#if SOC_RTC_WDT_SUPPORTED #include "soc/rtc_wdt_reg.h" #include "hal/rwdt_ll.h" +#endif ESP_LOG_ATTR_TAG(TAG, "boot.esp32s31"); +#if SOC_RTC_WDT_SUPPORTED static void bootloader_super_wdt_auto_feed(void) { REG_WRITE(RTC_WDT_SWD_WPROTECT_REG, RTC_WDT_SWD_WKEY_VALUE); REG_SET_BIT(RTC_WDT_SWD_CONFIG_REG, RTC_WDT_SWD_AUTO_FEED_EN); REG_WRITE(RTC_WDT_SWD_WPROTECT_REG, 0); } +#endif esp_err_t bootloader_init(void) { esp_err_t ret = ESP_OK; // bootloader_hardware_init(); // TODO: IDF-14696 +#if SOC_RTC_WDT_SUPPORTED bootloader_super_wdt_auto_feed(); +#endif // In RAM_APP, memory will be initialized in `call_start_cpu0` #if !CONFIG_APP_BUILD_TYPE_RAM @@ -89,10 +96,14 @@ esp_err_t bootloader_init(void) } #endif // !CONFIG_APP_BUILD_TYPE_RAM +#if SOC_RTC_WDT_SUPPORTED // check whether a WDT reset happened // bootloader_check_wdt_reset(); // TODO: IDF-14678 +#endif +#if SOC_RTC_WDT_SUPPORTED || SOC_WDT_SUPPORTED // config WDT bootloader_config_wdt(); +#endif // enable RNG early entropy source bootloader_enable_random(); diff --git a/components/bootloader_support/src/flash_encryption/flash_encrypt.c b/components/bootloader_support/src/flash_encryption/flash_encrypt.c index a5cb61609d..6fcd898781 100644 --- a/components/bootloader_support/src/flash_encryption/flash_encrypt.c +++ b/components/bootloader_support/src/flash_encryption/flash_encrypt.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,7 +14,9 @@ #include "esp_efuse.h" #include "esp_efuse_table.h" #include "esp_log.h" +#if SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "sdkconfig.h" #include "soc/soc_caps.h" @@ -675,12 +677,16 @@ esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length) return ESP_FAIL; } +#if SOC_RTC_WDT_SUPPORTED wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT(); +#endif for (size_t i = 0; i < data_length; i += FLASH_SECTOR_SIZE) { +#if SOC_RTC_WDT_SUPPORTED wdt_hal_write_protect_disable(&rtc_wdt_ctx); wdt_hal_feed(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif uint32_t sec_start = i + src_addr; err = bootloader_flash_read(sec_start, buf, FLASH_SECTOR_SIZE, false); if (err != ESP_OK) { diff --git a/components/esp_gdbstub/src/gdbstub.c b/components/esp_gdbstub/src/gdbstub.c index fc94d34f9e..e24af43151 100644 --- a/components/esp_gdbstub/src/gdbstub.c +++ b/components/esp_gdbstub/src/gdbstub.c @@ -20,7 +20,9 @@ #include "soc/soc_caps.h" #include "soc/interrupts.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #if GDBSTUB_QXFER_FEATURES_ENABLED #define GDBSTUB_QXFER_SUPPORTED_STR ";qXfer:features:read+" @@ -125,26 +127,35 @@ static uint32_t gdbstub_hton(uint32_t i) return __builtin_bswap32(i); } +#if SOC_RTC_WDT_SUPPORTED static wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT(); static bool rtc_wdt_ctx_enabled = false; +#endif +#if SOC_WDT_SUPPORTED static wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; static bool wdt0_context_enabled = false; #if TIMG_LL_GET(INST_NUM) >= 2 static wdt_hal_context_t wdt1_context = {.inst = WDT_MWDT1, .mwdt_dev = &TIMERG1}; static bool wdt1_context_enabled = false; #endif // TIMG_LL_GET(INST_NUM) +#endif // SOC_WDT_SUPPORTED /** * Disable all enabled WDTs */ static inline void disable_all_wdts(void) { +#if SOC_WDT_SUPPORTED wdt0_context_enabled = wdt_hal_is_enabled(&wdt0_context); #if TIMG_LL_GET(INST_NUM) >= 2 wdt1_context_enabled = wdt_hal_is_enabled(&wdt1_context); #endif +#endif // SOC_WDT_SUPPORTED +#if SOC_RTC_WDT_SUPPORTED rtc_wdt_ctx_enabled = wdt_hal_is_enabled(&rtc_wdt_ctx); +#endif +#if SOC_WDT_SUPPORTED /*Task WDT is the Main Watchdog Timer of Timer Group 0 */ if (true == wdt0_context_enabled) { wdt_hal_write_protect_disable(&wdt0_context); @@ -162,13 +173,16 @@ static inline void disable_all_wdts(void) wdt_hal_write_protect_enable(&wdt1_context); } #endif // TIMG_LL_GET(INST_NUM) >= 2 +#endif // SOC_WDT_SUPPORTED +#if SOC_RTC_WDT_SUPPORTED if (true == rtc_wdt_ctx_enabled) { wdt_hal_write_protect_disable(&rtc_wdt_ctx); wdt_hal_disable(&rtc_wdt_ctx); wdt_hal_feed(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); } +#endif // SOC_RTC_WDT_SUPPORTED } /** @@ -176,6 +190,7 @@ static inline void disable_all_wdts(void) */ static inline void enable_all_wdts(void) { +#if SOC_WDT_SUPPORTED /* Task WDT is the Main Watchdog Timer of Timer Group 0 */ if (false == wdt0_context_enabled) { wdt_hal_write_protect_disable(&wdt0_context); @@ -190,12 +205,15 @@ static inline void enable_all_wdts(void) wdt_hal_write_protect_enable(&wdt1_context); } #endif // TIMG_LL_GET(INST_NUM) >= 2 +#endif // SOC_WDT_SUPPORTED +#if SOC_RTC_WDT_SUPPORTED if (false == rtc_wdt_ctx_enabled) { wdt_hal_write_protect_disable(&rtc_wdt_ctx); wdt_hal_enable(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); } +#endif // SOC_RTC_WDT_SUPPORTED } int getActiveTaskNum(void); diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 5455908037..c98a868b1f 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -68,7 +68,9 @@ #include "hal/cache_ll.h" #include "hal/clk_tree_ll.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED || SOC_SLEEP_TGWDT_STOP_WORKAROUND #include "hal/wdt_hal.h" +#endif #include "hal/uart_hal.h" #if SOC_TOUCH_SENSOR_SUPPORTED #include "hal/touch_sens_hal.h" @@ -367,7 +369,7 @@ void esp_sleep_overhead_out_time_refresh(void) static uint32_t get_power_down_flags(void); static uint32_t get_sleep_flags(uint32_t pd_flags, bool deepsleep); static uint32_t get_sleep_clock_icg_flags(void); -#if CONFIG_ESP_SLEEP_ENABLE_RTC_WDT_IN_SLEEP +#if CONFIG_ESP_SLEEP_ENABLE_RTC_WDT_IN_SLEEP && SOC_RTC_WDT_SUPPORTED static uint32_t get_sleep_rtc_wdt_timeout(uint64_t sleep_duration); static uint32_t calc_sleep_slow_clk_required_cycles(uint32_t timeout, uint32_t rtc_slow_clk_cal_period); #endif @@ -740,7 +742,7 @@ static SLEEP_FN_ATTR void misc_modules_wake_prepare(uint32_t sleep_flags) pvt_func_enable(true); #endif -#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP +#if CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP && SOC_WDT_SUPPORTED if (sleep_flags & PMU_SLEEP_PD_TOP) { // There is no driver to manage the flashboot watchdog, and it is definitely be in off state when // the system is running, after waking up from pd_top sleep, shut it down by software here. @@ -796,6 +798,7 @@ static SLEEP_FN_ATTR void misc_modules_wake_prepare(uint32_t sleep_flags) */ static SLEEP_FN_ATTR void sleep_rtc_wdt_prepare(bool enable) { +#if SOC_RTC_WDT_SUPPORTED wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT(); if (enable) { wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -816,6 +819,9 @@ static SLEEP_FN_ATTR void sleep_rtc_wdt_prepare(bool enable) wdt_hal_disable(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); } +#else + (void)enable; +#endif /* SOC_RTC_WDT_SUPPORTED */ } static SLEEP_FN_ATTR void sleep_low_power_clock_calibration(bool is_dslp) @@ -1288,6 +1294,7 @@ static esp_err_t FORCE_IRAM_ATTR deep_sleep_start(bool allow_sleep_rejection) s_config.sleep_time_adjustment = DEEP_SLEEP_TIME_OVERHEAD_US; // Safety net: enable WDT in case exit from deep sleep fails +#if SOC_RTC_WDT_SUPPORTED wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT(); bool rtc_wdt_was_enabled = wdt_hal_is_enabled(&rtc_wdt_ctx); // If WDT was enabled in the user code, then do not change it here. if (!rtc_wdt_was_enabled) { @@ -1295,6 +1302,7 @@ static esp_err_t FORCE_IRAM_ATTR deep_sleep_start(bool allow_sleep_rejection) } else { ESP_EARLY_LOGW(TAG, "RTC WDT is enabled and will not be reconfigured again!"); } +#endif /* SOC_RTC_WDT_SUPPORTED */ #if SOC_PMU_SUPPORTED uint32_t force_pd_flags = PMU_SLEEP_PD_TOP | PMU_SLEEP_PD_VDDSDIO | PMU_SLEEP_PD_MODEM | PMU_SLEEP_PD_HP_PERIPH \ @@ -1342,9 +1350,11 @@ static esp_err_t FORCE_IRAM_ATTR deep_sleep_start(bool allow_sleep_rejection) ESP_INFINITE_LOOP(); } // Never returns here, except that the sleep is rejected. +#if SOC_RTC_WDT_SUPPORTED if (!rtc_wdt_was_enabled) { sleep_rtc_wdt_prepare(false); } +#endif /* SOC_RTC_WDT_SUPPORTED */ #if CONFIG_ESP_INT_WDT && CONFIG_ESP32_ECO3_CACHE_LOCK_FIX // Configure WDT to use livelock workaround timeout after releasing other CPU @@ -1636,6 +1646,7 @@ esp_err_t esp_light_sleep_start(void) periph_inform_out_light_sleep_overhead(s_config.sleep_time_adjustment - sleep_time_overhead_in); // Safety net: enable WDT in case exit from light sleep fails +#if SOC_RTC_WDT_SUPPORTED wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT(); bool rtc_wdt_was_enabled = wdt_hal_is_enabled(&rtc_wdt_ctx); // If WDT was enabled in the user code, then do not change it here. if (!rtc_wdt_was_enabled) { @@ -1643,6 +1654,7 @@ esp_err_t esp_light_sleep_start(void) } else { ESP_EARLY_LOGW(TAG, "RTC WDT is enabled and will not be reconfigured again!"); } +#endif /* SOC_RTC_WDT_SUPPORTED */ esp_err_t err = ESP_OK; int64_t final_sleep_duration_us = (int64_t)s_config.sleep_duration - (int64_t)s_config.sleep_time_adjustment; @@ -1724,9 +1736,11 @@ esp_err_t esp_light_sleep_start(void) #endif #endif +#if SOC_RTC_WDT_SUPPORTED if (!rtc_wdt_was_enabled) { sleep_rtc_wdt_prepare(false); } +#endif /* SOC_RTC_WDT_SUPPORTED */ #if CONFIG_ESP_TASK_WDT_USE_ESP_TIMER /* Restart the Task Watchdog timer as it was stopped before sleeping. */ @@ -3016,7 +3030,7 @@ static SLEEP_FN_ATTR uint32_t get_sleep_flags(uint32_t sleep_flags, bool deepsle } #endif -#if CONFIG_ESP_SLEEP_ENABLE_RTC_WDT_IN_SLEEP +#if CONFIG_ESP_SLEEP_ENABLE_RTC_WDT_IN_SLEEP && SOC_RTC_WDT_SUPPORTED if (s_config.wakeup_triggers & RTC_TIMER_TRIG_EN) { sleep_flags |= RTC_SLEEP_USE_RTC_WDT; } else { @@ -3075,7 +3089,7 @@ static SLEEP_FN_ATTR uint32_t get_sleep_clock_icg_flags(void) return clk_flags; } -#if CONFIG_ESP_SLEEP_ENABLE_RTC_WDT_IN_SLEEP +#if CONFIG_ESP_SLEEP_ENABLE_RTC_WDT_IN_SLEEP && SOC_RTC_WDT_SUPPORTED /* TODO: PM-609 */ /* Calculate drift cycles of rtc slow clock in long-term working scenarios. */ static SLEEP_FN_ATTR uint32_t calc_sleep_slow_clk_required_cycles(uint32_t timeout, uint32_t rtc_slow_clk_cal_period) diff --git a/components/esp_system/CMakeLists.txt b/components/esp_system/CMakeLists.txt index 5b6238c3ec..fc4f1397f3 100644 --- a/components/esp_system/CMakeLists.txt +++ b/components/esp_system/CMakeLists.txt @@ -37,15 +37,19 @@ else() "esp_ipc.c" "esp_err.c" "freertos_hooks.c" - "int_wdt.c" "panic.c" "esp_system.c" "startup.c" "startup_funcs.c" "system_time.c" "stack_check.c" - "ubsan.c" - "xt_wdt.c") + "ubsan.c") + if(CONFIG_SOC_WDT_SUPPORTED) + list(APPEND srcs "int_wdt.c") + endif() + if(CONFIG_SOC_XT_WDT_SUPPORTED) + list(APPEND srcs "xt_wdt.c") + endif() if(CONFIG_ESP_TASK_WDT_EN) list(APPEND srcs "task_wdt/task_wdt.c") diff --git a/components/esp_system/Kconfig b/components/esp_system/Kconfig index 5288080acc..56165299cd 100644 --- a/components/esp_system/Kconfig +++ b/components/esp_system/Kconfig @@ -269,6 +269,7 @@ menu "ESP System Settings" config ESP_INT_WDT bool "Interrupt watchdog" + depends on SOC_WDT_SUPPORTED default y help This watchdog timer can detect if the FreeRTOS tick interrupt has not been called for a certain time, @@ -294,6 +295,7 @@ menu "ESP System Settings" config ESP_TASK_WDT_EN bool "Enable Task Watchdog Timer" + depends on SOC_WDT_SUPPORTED default y help The Task Watchdog Timer can be used to make sure individual tasks are still diff --git a/components/esp_system/panic.c b/components/esp_system/panic.c index d269dd9c74..ee4639c717 100644 --- a/components/esp_system/panic.c +++ b/components/esp_system/panic.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,8 +16,10 @@ #include "esp_cpu.h" #include "soc/rtc.h" #include "hal/timer_hal.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_types.h" #include "hal/wdt_hal.h" +#endif #include "esp_private/esp_int_wdt.h" #include "esp_private/panic_internal.h" @@ -72,7 +74,9 @@ bool g_panic_abort = false; char *g_panic_abort_details = NULL; +#if SOC_RTC_WDT_SUPPORTED static wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT(); +#endif static uint32_t DRAM_ATTR g_panic_entry_count[CONFIG_FREERTOS_NUMBER_OF_CORES] = {0}; // Number of times panic handler has been entered per core since multiple cores can enter the panic handler simultaneously @@ -177,6 +181,7 @@ static void print_abort_details(const void *f) /********************** Panic handler watchdog timer functions **********************/ +#if SOC_WDT_SUPPORTED /* This function disables the Timer Group WDTs */ void esp_panic_handler_disable_timg_wdts(void) { @@ -192,7 +197,13 @@ void esp_panic_handler_disable_timg_wdts(void) wdt_hal_write_protect_enable(&wdt1_context); #endif /* TIMG_LL_GET(INST_NUM) >= 2 */ } +#else /* SOC_WDT_SUPPORTED */ +void esp_panic_handler_disable_timg_wdts(void) +{ +} +#endif /* SOC_WDT_SUPPORTED */ +#if SOC_RTC_WDT_SUPPORTED /* This function enables the RTC WDT with the given timeout in milliseconds */ void esp_panic_handler_enable_rtc_wdt(uint32_t timeout_ms) { @@ -204,7 +215,14 @@ void esp_panic_handler_enable_rtc_wdt(uint32_t timeout_ms) wdt_hal_enable(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); } +#else /* SOC_RTC_WDT_SUPPORTED */ +void esp_panic_handler_enable_rtc_wdt(uint32_t timeout_ms) +{ + (void)timeout_ms; +} +#endif /* SOC_RTC_WDT_SUPPORTED */ +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED /* Feed the watchdogs if they are enabled and if we are not already in the panic handler */ void esp_panic_handler_feed_wdts(void) { @@ -217,6 +235,7 @@ void esp_panic_handler_feed_wdts(void) return; } +#if SOC_WDT_SUPPORTED // Feed Timer Group 0 WDT wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; if (wdt_hal_is_enabled(&wdt0_context)) { @@ -234,26 +253,43 @@ void esp_panic_handler_feed_wdts(void) wdt_hal_write_protect_enable(&wdt1_context); } #endif /* TIMG_LL_GET(INST_NUM) >= 2 */ +#endif /* SOC_WDT_SUPPORTED */ +#if SOC_RTC_WDT_SUPPORTED // Feed RTC WDT if (wdt_hal_is_enabled(&rtc_wdt_ctx)) { wdt_hal_write_protect_disable(&rtc_wdt_ctx); wdt_hal_feed(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); } +#endif /* SOC_RTC_WDT_SUPPORTED */ } +#else /* SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED */ +void esp_panic_handler_feed_wdts(void) +{ +} +#endif /* SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED */ +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED /* This function disables all the watchdogs */ static inline void disable_all_wdts(void) { +#if SOC_WDT_SUPPORTED //Disable Timer Group WDTs esp_panic_handler_disable_timg_wdts(); - +#endif /* SOC_WDT_SUPPORTED */ +#if SOC_RTC_WDT_SUPPORTED //Disable RTC WDT wdt_hal_write_protect_disable(&rtc_wdt_ctx); wdt_hal_disable(&rtc_wdt_ctx); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ } +#else /* SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED */ +static inline void disable_all_wdts(void) +{ +} +#endif /* SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED */ /* IRAM-only halt stub: reset modules, then loop */ void IRAM_ATTR esp_panic_handler_reset_modules_on_exit_and_halt(void) diff --git a/components/esp_system/port/cpu_start.c b/components/esp_system/port/cpu_start.c index 0ed643d993..48baeacc20 100644 --- a/components/esp_system/port/cpu_start.c +++ b/components/esp_system/port/cpu_start.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -64,8 +64,10 @@ #include "esp_memprot.h" #elif CONFIG_IDF_TARGET_ESP32H4 #include "esp_memprot.h" +#elif CONFIG_IDF_TARGET_ESP32S31 #endif +#include "rom/ets_sys.h" #include "esp_private/cache_utils.h" #include "esp_private/rtc_clk.h" #include "esp_rtc_time.h" @@ -92,7 +94,9 @@ #include "esp_private/crosscore_int.h" #include "esp_private/sleep_gpio.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "soc/rtc.h" #include "hal/cache_hal.h" #include "hal/cache_ll.h" @@ -564,6 +568,7 @@ FORCE_INLINE_ATTR IRAM_ATTR void ext_mem_init(void) MSPI_INIT_ATTR void sys_rtc_init(const soc_reset_reason_t *rst_reas) { +#if SOC_RTC_WDT_SUPPORTED #if CONFIG_IDF_TARGET_ESP32P4 #define RWDT_RESET RESET_REASON_CORE_RWDT #define MWDT_RESET RESET_REASON_CORE_MWDT @@ -585,6 +590,7 @@ MSPI_INIT_ATTR void sys_rtc_init(const soc_reset_reason_t *rst_reas) wdt_hal_write_protect_enable(&rtc_wdt_ctx); } #endif +#endif /* SOC_RTC_WDT_SUPPORTED */ // Configure the power related stuff. After this the MSPI timing tuning can be done. esp_rtc_init(); diff --git a/components/esp_system/port/panic_handler.c b/components/esp_system/port/panic_handler.c index bf7f850802..e59cf50e63 100644 --- a/components/esp_system/port/panic_handler.c +++ b/components/esp_system/port/panic_handler.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -27,8 +27,10 @@ #include "esp_private/panic_internal.h" #include "esp_private/panic_reason.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_types.h" #include "hal/wdt_hal.h" +#endif #if CONFIG_ESP_SYSTEM_HW_STACK_GUARD #include "esp_private/hw_stack_guard.h" @@ -137,9 +139,9 @@ static void panic_handler(void *frame, bool pseudo_excause) * * We do this before we increment the panic handler entry count to ensure that the WDTs are fed. */ -#if CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE +#if (SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED) && CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE esp_panic_handler_feed_wdts(); -#endif // CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE +#endif // (SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED) && CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE /* Increment the panic handler entry count */ esp_panic_handler_increment_entry_count(); @@ -213,18 +215,22 @@ static void panic_handler(void *frame, bool pseudo_excause) * TODO: Make the timeout configurable or more intelligent based on the panic reason and the * config options. */ +#if SOC_RTC_WDT_SUPPORTED #if CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS esp_panic_handler_enable_rtc_wdt((CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS + 10) * 1000); #else esp_panic_handler_enable_rtc_wdt(10000); #endif /* CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS */ +#endif /* SOC_RTC_WDT_SUPPORTED */ +#if SOC_WDT_SUPPORTED /* Before we stall the other CPU, we need to disable all WDTs except the RTC WDT. * This is because the TIMG WDTs cannot reset the RTC subsystem, which stores the CPU stalling * configuration. If the other CPU is stalled and the TIMG WDTs trigger before we can unstall the * CPU then we have a chance of locking up the system without rebooting it. */ esp_panic_handler_disable_timg_wdts(); +#endif /* SOC_WDT_SUPPORTED */ #if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE esp_rom_delay_us(1); diff --git a/components/esp_system/port/soc/esp32/clk.c b/components/esp_system/port/soc/esp32/clk.c index fef77d72e1..0592181219 100644 --- a/components/esp_system/port/soc/esp32/clk.c +++ b/components/esp_system/port/soc/esp32/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -10,7 +10,9 @@ #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" #include "bootloader_clock.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "esp_private/spi_share_hw_ctrl.h" @@ -140,7 +142,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_8m_enable(true, rc_fast_d256_is_enabled); rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (1.6 sec). @@ -165,7 +167,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SLOW_CLK_150K); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32/system_internal.c b/components/esp_system/port/soc/esp32/system_internal.c index b33ce829f1..75bbf3736e 100644 --- a/components/esp_system/port/soc/esp32/system_internal.c +++ b/components/esp_system/port/soc/esp32/system_internal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,6 +12,7 @@ #include "esp_log.h" #include "esp_ipc_isr.h" #include "sdkconfig.h" +#include "soc/soc_caps.h" #include "esp_rom_serial_output.h" #include "soc/dport_reg.h" #include "soc/gpio_reg.h" @@ -19,7 +20,9 @@ #include "esp_cpu.h" #include "soc/rtc.h" #include "esp_private/rtc_clk.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_ll.h" #include "soc/soc_memory_layout.h" #include "esp_private/cache_err_int.h" @@ -72,6 +75,7 @@ void esp_restart_noos(void) // Disable interrupts esp_cpu_intr_disable(0xFFFFFFFF); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -82,6 +86,7 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); +#endif /* SOC_RTC_WDT_SUPPORTED */ // Reset and stall the other CPU. // CPU must be reset before stalling, in case it was running a s32c1i @@ -95,6 +100,7 @@ void esp_restart_noos(void) // Other core is now stalled, can access DPORT registers directly esp_ipc_isr_stall_abort(); +#if SOC_WDT_SUPPORTED //Todo: Refactor to use Interrupt or Task Watchdog API, and a system level WDT context // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; @@ -106,6 +112,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ #ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM if (esp_ptr_external_ram(esp_cpu_get_sp())) { diff --git a/components/esp_system/port/soc/esp32c2/clk.c b/components/esp_system/port/soc/esp32c2/clk.c index 4240ec0bf6..1d915210d0 100644 --- a/components/esp_system/port/soc/esp32c2/clk.c +++ b/components/esp_system/port/soc/esp32c2/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,7 +21,9 @@ #include "soc/soc.h" #include "soc/rtc.h" #include "soc/rtc_periph.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "esp_private/periph_ctrl.h" #include "bootloader_clock.h" #include "soc/syscon_reg.h" @@ -86,7 +88,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (1.6 sec on 40MHz XTAL and 2.5 sec on 26MHz XTAL). @@ -114,7 +116,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SLOW_CLK_RTC); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32c2/system_internal.c b/components/esp_system/port/soc/esp32c2/system_internal.c index 042d5ccadb..ba135ccf5f 100644 --- a/components/esp_system/port/soc/esp32c2/system_internal.c +++ b/components/esp_system/port/soc/esp32c2/system_internal.c @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include #include "sdkconfig.h" +#include "soc/soc_caps.h" #include "esp_macros.h" #include "esp_system.h" #include "esp_private/system_internal.h" @@ -20,7 +21,9 @@ #include "esp_private/rtc_clk.h" #include "soc/syscon_reg.h" #include "soc/system_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_ll.h" #include "esp_private/cache_err_int.h" @@ -59,6 +62,7 @@ void esp_restart_noos(void) { // Disable interrupts rv_utils_intr_global_disable(); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -69,12 +73,15 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); wdt_hal_disable(&wdt0_context); wdt_hal_write_protect_enable(&wdt0_context); +#endif /* SOC_WDT_SUPPORTED */ // Disable cache Cache_Disable_ICache(); diff --git a/components/esp_system/port/soc/esp32c3/clk.c b/components/esp_system/port/soc/esp32c3/clk.c index 161e984289..b3d3ca2857 100644 --- a/components/esp_system/port/soc/esp32c3/clk.c +++ b/components/esp_system/port/soc/esp32c3/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -20,7 +20,9 @@ #include "soc/rtc.h" #include "soc/rtc_periph.h" #include "soc/i2s_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/usb_serial_jtag_ll.h" #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" @@ -81,7 +83,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (1.6 sec). @@ -106,7 +108,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SLOW_CLK_RTC); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32c3/system_internal.c b/components/esp_system/port/soc/esp32c3/system_internal.c index 304018ada3..d6ab41269b 100644 --- a/components/esp_system/port/soc/esp32c3/system_internal.c +++ b/components/esp_system/port/soc/esp32c3/system_internal.c @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include #include "sdkconfig.h" +#include "soc/soc_caps.h" #include "esp_macros.h" #include "esp_system.h" #include "esp_private/system_internal.h" @@ -21,7 +22,9 @@ #include "soc/syscon_reg.h" #include "soc/system_reg.h" #include "soc/uart_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_ll.h" #include "esp_private/cache_err_int.h" @@ -68,6 +71,7 @@ void esp_restart_noos(void) { // Disable interrupts rv_utils_intr_global_disable(); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -78,7 +82,9 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); @@ -89,6 +95,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ // Disable cache Cache_Disable_ICache(); diff --git a/components/esp_system/port/soc/esp32c5/clk.c b/components/esp_system/port/soc/esp32c5/clk.c index d5fe762ccf..73e3f6de3c 100644 --- a/components/esp_system/port/soc/esp32c5/clk.c +++ b/components/esp_system/port/soc/esp32c5/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -22,7 +22,9 @@ #include "soc/chip_revision.h" #include "esp_cpu.h" #include "hal/efuse_hal.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/clk_tree_ll.h" #if SOC_MODEM_CLOCK_SUPPORTED #include "hal/modem_lpcon_ll.h" @@ -74,7 +76,7 @@ __attribute__((weak)) void esp_clk_init(void) #endif #endif //!CONFIG_IDF_ENV_FPGA -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (1.6 sec). @@ -98,7 +100,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC_SLOW); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32c5/system_internal.c b/components/esp_system/port/soc/esp32c5/system_internal.c index bb553fbbcb..8322832756 100644 --- a/components/esp_system/port/soc/esp32c5/system_internal.c +++ b/components/esp_system/port/soc/esp32c5/system_internal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -20,7 +20,9 @@ #include "soc/rtc.h" #include "esp_private/rtc_clk.h" #include "soc/uart_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_ll.h" #if SOC_MODEM_CLOCK_SUPPORTED #include "hal/modem_syscon_ll.h" @@ -107,6 +109,7 @@ void esp_restart_noos(void) { // Disable interrupts rv_utils_intr_global_disable(); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -117,9 +120,11 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ // C5 is a single core SoC, no need to reset and stall the other CPU +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); @@ -130,6 +135,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ // Disable cache Cache_Disable_Cache(); diff --git a/components/esp_system/port/soc/esp32c6/clk.c b/components/esp_system/port/soc/esp32c6/clk.c index 337a2b1d8c..9284daacab 100644 --- a/components/esp_system/port/soc/esp32c6/clk.c +++ b/components/esp_system/port/soc/esp32c6/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,7 +13,9 @@ #include "soc/soc.h" #include "soc/rtc.h" #include "esp_cpu.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/clk_gate_ll.h" #include "hal/pmu_ll.h" #include "esp_private/esp_modem_clock.h" @@ -56,7 +58,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (1.6 sec). @@ -80,7 +82,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC_SLOW); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32c6/system_internal.c b/components/esp_system/port/soc/esp32c6/system_internal.c index 653172ecff..a5391a5c3f 100644 --- a/components/esp_system/port/soc/esp32c6/system_internal.c +++ b/components/esp_system/port/soc/esp32c6/system_internal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,12 +15,15 @@ #include "riscv/rv_utils.h" #include "esp_rom_serial_output.h" #include "soc/gpio_reg.h" +#include "soc/soc_caps.h" #include "esp_cpu.h" #include "soc/rtc.h" #include "esp_private/rtc_clk.h" #include "soc/uart_reg.h" #include "hal/uart_ll.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_ll.h" #include "hal/modem_syscon_ll.h" #include "hal/modem_lpcon_ll.h" @@ -95,6 +98,7 @@ void esp_restart_noos(void) { // Disable interrupts rv_utils_intr_global_disable(); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -105,9 +109,11 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ // C6 is a single core SoC, no need to reset and stall the other CPU +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); @@ -118,6 +124,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ // Disable cache Cache_Disable_ICache(); diff --git a/components/esp_system/port/soc/esp32c61/clk.c b/components/esp_system/port/soc/esp32c61/clk.c index e0fb0de7d9..dd42af7625 100644 --- a/components/esp_system/port/soc/esp32c61/clk.c +++ b/components/esp_system/port/soc/esp32c61/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,7 +18,9 @@ #include "soc/rtc.h" #include "soc/rtc_periph.h" #include "esp_cpu.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "esp_private/esp_modem_clock.h" #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" @@ -54,7 +56,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (1.6 sec). @@ -78,7 +80,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC_SLOW); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32c61/system_internal.c b/components/esp_system/port/soc/esp32c61/system_internal.c index 22f297b3c5..02a3ec8b9b 100644 --- a/components/esp_system/port/soc/esp32c61/system_internal.c +++ b/components/esp_system/port/soc/esp32c61/system_internal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,12 +15,15 @@ #include "riscv/rv_utils.h" #include "esp_rom_serial_output.h" #include "soc/gpio_reg.h" +#include "soc/soc_caps.h" #include "esp_cpu.h" #include "soc/rtc.h" #include "esp_private/rtc_clk.h" #include "soc/uart_reg.h" #include "hal/uart_ll.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_ll.h" #include "esp_private/cache_err_int.h" @@ -107,6 +110,7 @@ void esp_restart_noos(void) { // Disable interrupts rv_utils_intr_global_disable(); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -117,9 +121,11 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ // C61 is a single core SoC, no need to reset and stall the other CPU +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); @@ -130,6 +136,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ // Disable cache Cache_Disable_Cache(); diff --git a/components/esp_system/port/soc/esp32h2/clk.c b/components/esp_system/port/soc/esp32h2/clk.c index c60dd0dcda..e7a8b3cc54 100644 --- a/components/esp_system/port/soc/esp32h2/clk.c +++ b/components/esp_system/port/soc/esp32h2/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -19,7 +19,9 @@ #include "soc/soc.h" #include "soc/rtc.h" #include "soc/rtc_periph.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/clk_gate_ll.h" #include "hal/pmu_ll.h" #include "esp_private/esp_modem_clock.h" @@ -63,7 +65,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (2 sec). @@ -89,7 +91,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC_SLOW); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32h2/system_internal.c b/components/esp_system/port/soc/esp32h2/system_internal.c index e092310411..41140f4422 100644 --- a/components/esp_system/port/soc/esp32h2/system_internal.c +++ b/components/esp_system/port/soc/esp32h2/system_internal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,11 +16,14 @@ #include "riscv/interrupt.h" #include "esp_rom_serial_output.h" #include "soc/gpio_reg.h" +#include "soc/soc_caps.h" #include "esp_cpu.h" #include "soc/rtc.h" #include "esp_private/rtc_clk.h" #include "soc/uart_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_ll.h" #include "hal/spimem_flash_ll.h" #include "hal/uart_ll.h" @@ -93,6 +96,7 @@ void esp_restart_noos(void) { // Disable interrupts rv_utils_intr_global_disable(); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -103,7 +107,9 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); @@ -114,6 +120,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ // Disable cache Cache_Disable_ICache(); diff --git a/components/esp_system/port/soc/esp32h21/clk.c b/components/esp_system/port/soc/esp32h21/clk.c index a00424eaf8..22c56f0500 100644 --- a/components/esp_system/port/soc/esp32h21/clk.c +++ b/components/esp_system/port/soc/esp32h21/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,7 +18,9 @@ #include "soc/soc.h" #include "soc/rtc.h" #include "soc/rtc_periph.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "esp_private/esp_modem_clock.h" #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" @@ -54,7 +56,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (2 sec). @@ -80,7 +82,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC_SLOW_D4); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32h21/system_internal.c b/components/esp_system/port/soc/esp32h21/system_internal.c index 6a3b75d2b6..d39606dbee 100644 --- a/components/esp_system/port/soc/esp32h21/system_internal.c +++ b/components/esp_system/port/soc/esp32h21/system_internal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,8 +21,9 @@ #include "esp_private/rtc_clk.h" #include "soc/uart_reg.h" #include "hal/uart_ll.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" -#include "hal/uart_ll.h" +#endif #include "hal/spimem_flash_ll.h" #include "esp_private/cache_err_int.h" @@ -98,6 +99,7 @@ void esp_restart_noos(void) { // Disable interrupts rv_utils_intr_global_disable(); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -108,7 +110,9 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); @@ -119,6 +123,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ // Disable cache Cache_Disable_ICache(); diff --git a/components/esp_system/port/soc/esp32h4/clk.c b/components/esp_system/port/soc/esp32h4/clk.c index f24d6ce832..b3c3af9966 100644 --- a/components/esp_system/port/soc/esp32h4/clk.c +++ b/components/esp_system/port/soc/esp32h4/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -18,7 +18,9 @@ #include "soc/rtc.h" #include "soc/rtc_periph.h" #include "esp_cpu.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" #include "esp_private/esp_pmu.h" @@ -55,7 +57,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (2 sec). @@ -78,7 +80,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC_SLOW_D4); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32h4/system_internal.c b/components/esp_system/port/soc/esp32h4/system_internal.c index 1c5898c49a..bab0dd5769 100644 --- a/components/esp_system/port/soc/esp32h4/system_internal.c +++ b/components/esp_system/port/soc/esp32h4/system_internal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -20,10 +20,13 @@ #include "soc/rtc.h" #include "esp_private/rtc_clk.h" #include "soc/uart_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_ll.h" #include "esp32h4/rom/cache.h" +#include "esp32h4/rom/ets_sys.h" // TODO: IDF-11911 need refactor void esp_system_reset_modules_on_exit(void) @@ -92,6 +95,7 @@ void esp_restart_noos(void) { // Disable interrupts rv_utils_intr_global_disable(); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -102,6 +106,7 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ const uint32_t core_id = esp_cpu_get_core_id(); #if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE @@ -110,6 +115,7 @@ void esp_restart_noos(void) esp_cpu_stall(other_core_id); #endif +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); @@ -120,6 +126,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ // Disable cache Cache_Disable_Cache(CACHE_MAP_ALL); diff --git a/components/esp_system/port/soc/esp32p4/clk.c b/components/esp_system/port/soc/esp32p4/clk.c index c23e60d477..bc5c51f050 100644 --- a/components/esp_system/port/soc/esp32p4/clk.c +++ b/components/esp_system/port/soc/esp32p4/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,7 +21,9 @@ #include "esp_cpu.h" #include "mspi_timing_tuning_configs.h" #include "hal/clk_gate_ll.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "esp_private/esp_sleep_internal.h" #include "esp_private/esp_clk.h" #include "esp_private/esp_pmu.h" @@ -64,7 +66,7 @@ __attribute__((weak)) void esp_clk_init(void) #error "No RTC fast clock source configured" #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (1.6 sec). @@ -85,7 +87,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC_SLOW); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32p4/system_internal.c b/components/esp_system/port/soc/esp32p4/system_internal.c index a130a7290d..6e9de0ffc6 100644 --- a/components/esp_system/port/soc/esp32p4/system_internal.c +++ b/components/esp_system/port/soc/esp32p4/system_internal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,14 +15,18 @@ #include "riscv/rv_utils.h" #include "esp_rom_serial_output.h" #include "soc/gpio_reg.h" +#include "soc/soc_caps.h" #include "esp_cpu.h" #include "soc/rtc.h" #include "esp_private/rtc_clk.h" #include "soc/uart_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "esp_private/cache_err_int.h" #include "esp32p4/rom/cache.h" +#include "esp32p4/rom/ets_sys.h" #include "esp32p4/rom/rtc.h" #include "soc/hp_sys_clkrst_reg.h" #include "soc/lp_clkrst_reg.h" @@ -157,6 +161,7 @@ void esp_restart_noos(void) { // Disable interrupts rv_utils_intr_global_disable(); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -167,6 +172,7 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ const uint32_t core_id = esp_cpu_get_core_id(); #if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE @@ -175,6 +181,7 @@ void esp_restart_noos(void) esp_cpu_stall(other_core_id); #endif +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); @@ -185,6 +192,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ // Disable cache #if CONFIG_SPIRAM diff --git a/components/esp_system/port/soc/esp32s2/clk.c b/components/esp_system/port/soc/esp32s2/clk.c index 5f9799b203..83b412324e 100644 --- a/components/esp_system/port/soc/esp32s2/clk.c +++ b/components/esp_system/port/soc/esp32s2/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,7 +21,9 @@ #include "soc/rtc.h" #include "soc/rtc_periph.h" #include "soc/i2s_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" #include "bootloader_clock.h" @@ -81,7 +83,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_8m_enable(true, rc_fast_d256_is_enabled); rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 90kHz to 32kHz, then the timeout set for the WDT will increase 2.8 times. // Therefore, for the time of frequency change, set a new lower timeout value (1.6 sec). @@ -106,7 +108,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SLOW_CLK_RTC); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000ULL); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32s2/system_internal.c b/components/esp_system/port/soc/esp32s2/system_internal.c index 7d49c83748..8ff900bf8c 100644 --- a/components/esp_system/port/soc/esp32s2/system_internal.c +++ b/components/esp_system/port/soc/esp32s2/system_internal.c @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include #include "sdkconfig.h" +#include "soc/soc_caps.h" #include "esp_macros.h" #include "esp_system.h" #include "esp_private/system_internal.h" @@ -20,7 +21,9 @@ #include "soc/rtc.h" #include "esp_private/rtc_clk.h" #include "soc/syscon_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_ll.h" #include "soc/soc_memory_layout.h" @@ -69,6 +72,7 @@ void esp_restart_noos(void) // Disable interrupts esp_cpu_intr_disable(0xFFFFFFFF); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -79,7 +83,9 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ +#if SOC_WDT_SUPPORTED //Todo: Refactor to use Interrupt or Task Watchdog API, and a system level WDT context // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; @@ -91,6 +97,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ #ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM if (esp_ptr_external_ram(esp_cpu_get_sp())) { diff --git a/components/esp_system/port/soc/esp32s3/clk.c b/components/esp_system/port/soc/esp32s3/clk.c index ef13acfc0a..acbfa9cc8e 100644 --- a/components/esp_system/port/soc/esp32s3/clk.c +++ b/components/esp_system/port/soc/esp32s3/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -20,7 +20,9 @@ #include "soc/rtc.h" #include "soc/rtc_periph.h" #include "soc/i2s_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/usb_serial_jtag_ll.h" #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" @@ -83,7 +85,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_8m_enable(true, rc_fast_d256_is_enabled); rtc_clk_fast_src_set(SOC_RTC_FAST_CLK_SRC_RC_FAST); -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (1.6 sec). @@ -108,7 +110,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SLOW_CLK_RTC); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000ULL); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32s3/system_internal.c b/components/esp_system/port/soc/esp32s3/system_internal.c index 378c48f34f..31c7a0e64a 100644 --- a/components/esp_system/port/soc/esp32s3/system_internal.c +++ b/components/esp_system/port/soc/esp32s3/system_internal.c @@ -1,6 +1,6 @@ /* - * SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2018-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -21,7 +21,9 @@ #include "soc/rtc.h" #include "esp_private/rtc_clk.h" #include "soc/syscon_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_ll.h" #include "soc/soc_memory_layout.h" @@ -75,6 +77,7 @@ void esp_restart_noos(void) // Disable interrupts esp_cpu_intr_disable(0xFFFFFFFF); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -85,7 +88,9 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); @@ -96,6 +101,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ #ifdef CONFIG_FREERTOS_TASK_CREATE_ALLOW_EXT_MEM if (esp_ptr_external_ram(esp_cpu_get_sp())) { diff --git a/components/esp_system/port/soc/esp32s31/clk.c b/components/esp_system/port/soc/esp32s31/clk.c index 4044067145..ea09bb9733 100644 --- a/components/esp_system/port/soc/esp32s31/clk.c +++ b/components/esp_system/port/soc/esp32s31/clk.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -29,7 +29,9 @@ #include "soc/usb_serial_jtag_reg.h" #include "soc/hp_alive_sys_reg.h" #include "hal/uart_ll.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "esp_private/esp_sleep_internal.h" #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" @@ -63,7 +65,7 @@ __attribute__((weak)) void esp_clk_init(void) rtc_clk_8m_enable(true); -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // WDT uses a SLOW_CLK clock source. After a function select_rtc_slow_clk a frequency of this source can changed. // If the frequency changes from 150kHz to 32kHz, then the timeout set for the WDT will increase 4.6 times. // Therefore, for the time of frequency change, set a new lower timeout value (1.6 sec). @@ -84,7 +86,7 @@ __attribute__((weak)) void esp_clk_init(void) select_rtc_slow_clk(SOC_RTC_SLOW_CLK_SRC_RC_SLOW); #endif -#ifdef CONFIG_BOOTLOADER_WDT_ENABLE +#if defined(CONFIG_BOOTLOADER_WDT_ENABLE) && SOC_RTC_WDT_SUPPORTED // After changing a frequency WDT timeout needs to be set for new frequency. stage_timeout_ticks = (uint32_t)((uint64_t)CONFIG_BOOTLOADER_WDT_TIME_MS * rtc_clk_slow_freq_get_hz() / 1000); wdt_hal_write_protect_disable(&rtc_wdt_ctx); diff --git a/components/esp_system/port/soc/esp32s31/system_internal.c b/components/esp_system/port/soc/esp32s31/system_internal.c index cbc7d5e8a8..bdc656ed63 100644 --- a/components/esp_system/port/soc/esp32s31/system_internal.c +++ b/components/esp_system/port/soc/esp32s31/system_internal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -15,15 +15,19 @@ #include "riscv/rv_utils.h" #include "esp_rom_serial_output.h" #include "soc/gpio_reg.h" +#include "soc/soc_caps.h" #include "esp_cpu.h" #include "soc/rtc.h" #include "esp_private/rtc_clk.h" #include "soc/rtc_periph.h" #include "soc/uart_reg.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "esp_private/cache_err_int.h" #include "hal/uart_ll.h" #include "esp32s31/rom/cache.h" +#include "esp32s31/rom/ets_sys.h" #include "esp32s31/rom/rtc.h" #include "soc/hp_sys_clkrst_reg.h" #include "soc/lp_clkrst_reg.h" @@ -49,6 +53,7 @@ void esp_restart_noos(void) { // Disable interrupts rv_utils_intr_global_disable(); +#if SOC_RTC_WDT_SUPPORTED // Enable RTC watchdog for 1 second wdt_hal_context_t rtc_wdt_ctx; wdt_hal_init(&rtc_wdt_ctx, WDT_RWDT, 0, false); @@ -60,6 +65,7 @@ void esp_restart_noos(void) //Enable flash boot mode so that flash booting after restart is protected by the RTC WDT. wdt_hal_set_flashboot_en(&rtc_wdt_ctx, true); wdt_hal_write_protect_enable(&rtc_wdt_ctx); +#endif /* SOC_RTC_WDT_SUPPORTED */ const uint32_t core_id = esp_cpu_get_core_id(); #if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE @@ -68,6 +74,7 @@ void esp_restart_noos(void) esp_cpu_stall(other_core_id); #endif +#if SOC_WDT_SUPPORTED // Disable TG0/TG1 watchdogs wdt_hal_context_t wdt0_context = {.inst = WDT_MWDT0, .mwdt_dev = &TIMERG0}; wdt_hal_write_protect_disable(&wdt0_context); @@ -78,6 +85,7 @@ void esp_restart_noos(void) wdt_hal_write_protect_disable(&wdt1_context); wdt_hal_disable(&wdt1_context); wdt_hal_write_protect_enable(&wdt1_context); +#endif /* SOC_WDT_SUPPORTED */ // Disable cache #if CONFIG_SPIRAM diff --git a/components/esp_system/startup_funcs.c b/components/esp_system/startup_funcs.c index 3a4da31bd7..6589588b77 100644 --- a/components/esp_system/startup_funcs.c +++ b/components/esp_system/startup_funcs.c @@ -19,7 +19,9 @@ #include "esp_private/startup_internal.h" #include "freertos/FreeRTOS.h" #include "soc/soc_caps.h" +#if SOC_WDT_SUPPORTED || SOC_RTC_WDT_SUPPORTED #include "hal/wdt_hal.h" +#endif #include "hal/uart_types.h" #include "hal/uart_ll.h" @@ -134,7 +136,7 @@ ESP_SYSTEM_INIT_FN(init_bootloader_offset, SECONDARY, BIT(0), 205) } #endif // SOC_RECOVERY_BOOTLOADER_SUPPORTED -#ifndef CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE +#if SOC_RTC_WDT_SUPPORTED && !defined(CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE) ESP_SYSTEM_INIT_FN(init_disable_rtc_wdt, SECONDARY, BIT(0), 999) { wdt_hal_context_t rtc_wdt_ctx = RWDT_HAL_CONTEXT_DEFAULT(); @@ -143,4 +145,4 @@ ESP_SYSTEM_INIT_FN(init_disable_rtc_wdt, SECONDARY, BIT(0), 999) wdt_hal_write_protect_enable(&rtc_wdt_ctx); return ESP_OK; } -#endif // CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE +#endif // SOC_RTC_WDT_SUPPORTED && !CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE diff --git a/components/soc/esp32/include/soc/Kconfig.soc_caps.in b/components/soc/esp32/include/soc/Kconfig.soc_caps.in index b11aaada74..99d7c4a8fe 100644 --- a/components/soc/esp32/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32/include/soc/Kconfig.soc_caps.in @@ -167,6 +167,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index 44964fa3b2..2c1fe8d1f0 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -107,6 +107,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_MPU_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 #define SOC_LIGHT_SLEEP_SUPPORTED 1 diff --git a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in index bd7d6682cb..f2f7ac12c1 100644 --- a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in @@ -115,6 +115,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32c2/include/soc/soc_caps.h b/components/soc/esp32c2/include/soc/soc_caps.h index 47e993f56a..bbba57d35f 100644 --- a/components/soc/esp32c2/include/soc/soc_caps.h +++ b/components/soc/esp32c2/include/soc/soc_caps.h @@ -51,6 +51,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_ASSIST_DEBUG_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 #define SOC_LIGHT_SLEEP_SUPPORTED 1 diff --git a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in index c8e39fbc07..d1c61ef7d7 100644 --- a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in @@ -171,6 +171,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32c3/include/soc/soc_caps.h b/components/soc/esp32c3/include/soc/soc_caps.h index 190b0ffc96..9a087e104a 100644 --- a/components/soc/esp32c3/include/soc/soc_caps.h +++ b/components/soc/esp32c3/include/soc/soc_caps.h @@ -68,6 +68,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_ASSIST_DEBUG_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 #define SOC_LIGHT_SLEEP_SUPPORTED 1 diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index 5e93bf615c..4b4d8b3c5c 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -235,6 +235,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SDIO_SLAVE_SUPPORTED bool default y diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index 0d7799e786..e33942ea98 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -81,6 +81,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_ASSIST_DEBUG_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SDIO_SLAVE_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_ECDSA_SUPPORTED 1 diff --git a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in index 2d88f28cbb..4979ee2d65 100644 --- a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in @@ -227,6 +227,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index e16a298696..bf64a3e76e 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -79,6 +79,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_ASSIST_DEBUG_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 #define SOC_LIGHT_SLEEP_SUPPORTED 1 diff --git a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in index 12ddc4a8a1..3f3598fc79 100644 --- a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in @@ -143,6 +143,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32c61/include/soc/soc_caps.h b/components/soc/esp32c61/include/soc/soc_caps.h index 46f5e8f91b..9e0361519e 100644 --- a/components/soc/esp32c61/include/soc/soc_caps.h +++ b/components/soc/esp32c61/include/soc/soc_caps.h @@ -59,6 +59,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_ASSIST_DEBUG_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_MODEM_CLOCK_SUPPORTED 1 #define SOC_REG_I2C_SUPPORTED 1 diff --git a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in index 936d1e437d..8158f4a83f 100644 --- a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in @@ -223,6 +223,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index 11a9fbc6f8..822a354221 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -94,6 +94,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_ASSIST_DEBUG_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 #define SOC_LIGHT_SLEEP_SUPPORTED 1 diff --git a/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in index 1e57246b0d..67017078ab 100644 --- a/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h21/include/soc/Kconfig.soc_caps.in @@ -135,6 +135,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32h21/include/soc/soc_caps.h b/components/soc/esp32h21/include/soc/soc_caps.h index a251947d5a..295563cda8 100644 --- a/components/soc/esp32h21/include/soc/soc_caps.h +++ b/components/soc/esp32h21/include/soc/soc_caps.h @@ -67,6 +67,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_ASSIST_DEBUG_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 //TODO: [ESP32H21] IDF-11526 // #define SOC_RNG_SUPPORTED 1 //TODO: [ESP32H21] IDF-11503 #define SOC_MODEM_CLOCK_SUPPORTED 1 diff --git a/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in index b2bf42562f..58f6d3306b 100644 --- a/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h4/include/soc/Kconfig.soc_caps.in @@ -167,6 +167,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32h4/include/soc/soc_caps.h b/components/soc/esp32h4/include/soc/soc_caps.h index 1e3f7160eb..296064f395 100644 --- a/components/soc/esp32h4/include/soc/soc_caps.h +++ b/components/soc/esp32h4/include/soc/soc_caps.h @@ -85,6 +85,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_ASSIST_DEBUG_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_SPIRAM_SUPPORTED 1 #define SOC_LIGHT_SLEEP_SUPPORTED 1 diff --git a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in index c30ff9a349..19eabc306a 100644 --- a/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32p4/include/soc/Kconfig.soc_caps.in @@ -335,6 +335,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index 8a150fe99c..547f311b7a 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -106,6 +106,7 @@ #define SOC_ASSIST_DEBUG_SUPPORTED 1 #define SOC_DEBUG_PROBE_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_TOUCH_SENSOR_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 diff --git a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in index 025c969f9b..7025efc9bc 100644 --- a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in @@ -203,6 +203,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32s2/include/soc/soc_caps.h b/components/soc/esp32s2/include/soc/soc_caps.h index c6cf4fade4..721c016e62 100644 --- a/components/soc/esp32s2/include/soc/soc_caps.h +++ b/components/soc/esp32s2/include/soc/soc_caps.h @@ -93,6 +93,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_MPU_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 #define SOC_LIGHT_SLEEP_SUPPORTED 1 diff --git a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in index 7063dbe2d4..6849c35f3a 100644 --- a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in @@ -235,6 +235,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32s3/include/soc/soc_caps.h b/components/soc/esp32s3/include/soc/soc_caps.h index c3ac93303e..24788eb889 100644 --- a/components/soc/esp32s3/include/soc/soc_caps.h +++ b/components/soc/esp32s3/include/soc/soc_caps.h @@ -86,6 +86,7 @@ #define SOC_CLK_TREE_SUPPORTED 1 #define SOC_MPU_SUPPORTED 1 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 #define SOC_RNG_SUPPORTED 1 #define SOC_LIGHT_SLEEP_SUPPORTED 1 diff --git a/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in index 94284fab2d..23ff884724 100644 --- a/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s31/include/soc/Kconfig.soc_caps.in @@ -75,6 +75,10 @@ config SOC_WDT_SUPPORTED bool default y +config SOC_RTC_WDT_SUPPORTED + bool + default y + config SOC_SPI_FLASH_SUPPORTED bool default y diff --git a/components/soc/esp32s31/include/soc/soc_caps.h b/components/soc/esp32s31/include/soc/soc_caps.h index 369b4fa2a2..e09238bd37 100644 --- a/components/soc/esp32s31/include/soc/soc_caps.h +++ b/components/soc/esp32s31/include/soc/soc_caps.h @@ -87,6 +87,7 @@ // #define SOC_ASSIST_DEBUG_SUPPORTED 1 // TODO: [ESP32S31] IDF-14675 // #define SOC_DEBUG_PROBE_SUPPORTED 1 // TODO: [ESP32S31] IDF-14798 #define SOC_WDT_SUPPORTED 1 +#define SOC_RTC_WDT_SUPPORTED 1 #define SOC_SPI_FLASH_SUPPORTED 1 // TODO: [ESP32S31] IDF-14777 // #define SOC_TOUCH_SENSOR_SUPPORTED 1 // TODO: [ESP32S31] IDF-14796 // #define SOC_RNG_SUPPORTED 1 // TODO: [ESP32S31] IDF-14632