Merge branch 'fix/panic_handler_reboot_before_halt_v5.3' into 'release/v5.3'

fix(panic_handler): Fixed a issue where the system reboots before halt (v5.3)

See merge request espressif/esp-idf!41268
This commit is contained in:
Jiang Jiang Jian
2025-09-28 17:47:23 +08:00
6 changed files with 40 additions and 2 deletions

View File

@@ -260,6 +260,14 @@ static inline void disable_all_wdts(void)
wdt_hal_write_protect_enable(&rtc_wdt_ctx);
}
/* IRAM-only halt stub: reset modules, then loop */
void IRAM_ATTR esp_panic_handler_reset_modules_on_exit_and_halt(void)
{
// Do not print or call non-IRAM functions beyond this point
esp_system_reset_modules_on_exit();
while (1);
}
/********************** Panic handler functions **********************/
/* This function is called from the panic handler entry point to increment the panic entry count */
@@ -453,10 +461,10 @@ void esp_panic_handler(panic_info_t *info)
panic_print_str("Rebooting...\r\n");
panic_restart();
#else /* CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT */
esp_panic_handler_feed_wdts();
panic_print_str("CPU halted.\r\n");
esp_system_reset_modules_on_exit();
disable_all_wdts();
while (1);
esp_panic_handler_reset_modules_on_exit_and_halt();
#endif /* CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT || CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT */
#endif /* CONFIG_ESP_SYSTEM_PANIC_GDBSTUB */
}