mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
refactor(system): guard WDT with SoC capability macros
Wrap MWDT-related code under SOC_WDT_SUPPORTED so targets without a main watchdog can compile. Add SOC_RTC_WDT_SUPPORTED for RTC watchdog usage (bootloader, slow-clock paths) and regenerate Kconfig.soc_caps.in. Bootloader RWDT setup stays under SOC_RTC_WDT_SUPPORTED; MWDT flashboot teardown stays under SOC_WDT_SUPPORTED. ESP_INT_WDT, ESP_TASK_WDT_EN, and BOOTLOADER_WDT_ENABLE depend on SOC_WDT_SUPPORTED where applicable. Build xt_wdt.c only when SOC_XT_WDT_SUPPORTED. Provide no-op panic WDT helpers when SOC_WDT_SUPPORTED is disabled.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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())) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <string.h>
|
||||
#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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <string.h>
|
||||
#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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 <string.h>
|
||||
#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())) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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())) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user