From 57c95909d1ea3ec34f77296fcf20e15c568059ec Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 5 Apr 2026 12:46:40 -1000 Subject: [PATCH] Show exception cause for all crash types WDT resets also populate exccause in rst_info (e.g. Level1Interrupt for stack overflow soft WDT). Show the cause string for all crash reasons, not just REASON_EXCEPTION_RST. Also simplify PC logging to a single line for all crash types. --- esphome/components/esp8266/crash_handler.cpp | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/esphome/components/esp8266/crash_handler.cpp b/esphome/components/esp8266/crash_handler.cpp index 4651291e0a..e8f78e5a69 100644 --- a/esphome/components/esp8266/crash_handler.cpp +++ b/esphome/components/esp8266/crash_handler.cpp @@ -200,19 +200,15 @@ void crash_handler_log() { uint8_t bt_count = read_rtc_backtrace(backtrace, MAX_BACKTRACE); ESP_LOGE(TAG, "*** CRASH DETECTED ON PREVIOUS BOOT ***"); + // Show exception cause for all crash types — WDT resets also populate exccause const LogString *cause = get_exception_cause(resetInfo.exccause); - if (resetInfo.reason == REASON_EXCEPTION_RST && cause != nullptr) { + if (cause != nullptr) { ESP_LOGE(TAG, " Reason: %s - %s (exccause=%" PRIu32 ")", LOG_STR_ARG(get_reset_reason(resetInfo.reason)), LOG_STR_ARG(cause), resetInfo.exccause); } else { ESP_LOGE(TAG, " Reason: %s", LOG_STR_ARG(get_reset_reason(resetInfo.reason))); } - if (resetInfo.reason == REASON_EXCEPTION_RST) { - // Log PC and EXCVADDR together — 0x00000000 IS the diagnostic for null pointer crashes - ESP_LOGE(TAG, " PC: 0x%08" PRIX32 " EXCVADDR: 0x%08" PRIX32, resetInfo.epc1, resetInfo.excvaddr); - } else { - ESP_LOGE(TAG, " PC: 0x%08" PRIX32, resetInfo.epc1); - } + ESP_LOGE(TAG, " PC: 0x%08" PRIX32, resetInfo.epc1); for (uint8_t i = 0; i < bt_count; i++) { ESP_LOGE(TAG, " BT%d: 0x%08" PRIX32, i, backtrace[i]); }