mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-10-31 22:02:17 +01:00
fix: don't boot-loop on a corrupted coredump
setup() prints the stored coredump summary on every boot and trusted its backtrace depth. A half-written dump reads back as the 0xa5 stack fill, so depth was 0xa5a5a5a5: the loop read past bt[16], snprintf ran past its 256-byte buffer once the size went negative, and the interrupt watchdog reset the board. The dump stays in flash, so every boot hit it again (seen 2026-10-21: 162 TG1WDT resets in a row, each stopping after "Cause:"). formatBacktrace() in Utils reads at most bt[]'s 16 frames and stops when the buffer is full, and the line notes IDF's corrupted flag. The task name is printed at most 16 chars, since exc_task isn't always terminated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b74f382650
commit
54641af039
4 changed files with 53 additions and 7 deletions
|
|
@ -78,16 +78,15 @@ void setup() {
|
|||
#define CRASH_LOG(fmt, ...) do { if(newCrash) ESP_LOGW(TAG, fmt, ##__VA_ARGS__); else ESP_LOGI(TAG, fmt, ##__VA_ARGS__); } while(0)
|
||||
if(newCrash) ESP_LOGW(TAG, "*** Crash coredump from the last boot ***");
|
||||
else ESP_LOGI(TAG, "Stored coredump from an earlier crash");
|
||||
CRASH_LOG(" Task: %s", summary.exc_task);
|
||||
// exc_task isn't always terminated.
|
||||
CRASH_LOG(" Task: %.*s", (int)sizeof(summary.exc_task), summary.exc_task);
|
||||
CRASH_LOG(" PC: 0x%08x", summary.exc_pc);
|
||||
#ifdef CONFIG_IDF_TARGET_ARCH_XTENSA
|
||||
CRASH_LOG(" Cause: %d", summary.ex_info.exc_cause);
|
||||
char bt_buf[256] = {0};
|
||||
int pos = 0;
|
||||
for (int i = 0; i < summary.exc_bt_info.depth; i++) {
|
||||
pos += snprintf(bt_buf + pos, sizeof(bt_buf) - pos, " 0x%08x", summary.exc_bt_info.bt[i]);
|
||||
}
|
||||
CRASH_LOG(" Backtrace:%s", bt_buf);
|
||||
char bt_buf[256];
|
||||
formatBacktrace(bt_buf, sizeof(bt_buf), summary.exc_bt_info.bt,
|
||||
sizeof(summary.exc_bt_info.bt) / sizeof(summary.exc_bt_info.bt[0]), summary.exc_bt_info.depth);
|
||||
CRASH_LOG(" Backtrace:%s%s", bt_buf, summary.exc_bt_info.corrupted ? " (corrupted)" : "");
|
||||
#elif CONFIG_IDF_TARGET_ARCH_RISCV
|
||||
CRASH_LOG(" Cause: %d", summary.ex_info.mcause);
|
||||
CRASH_LOG(" MTVAL: 0x%08x RA: 0x%08x SP: 0x%08x",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue