diff --git a/components/esp_system/panic.c b/components/esp_system/panic.c index 23cb2abfc2..38044b70d9 100644 --- a/components/esp_system/panic.c +++ b/components/esp_system/panic.c @@ -262,6 +262,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(); + ESP_INFINITE_LOOP(); +} + /********************** Panic handler functions **********************/ /* This function is called from the panic handler entry point to increment the panic entry count */ @@ -455,10 +463,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(); - ESP_INFINITE_LOOP(); + 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 */ }