mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-21 21:22:31 +03:00
Make soft wdt reset more obvious
This commit is contained in:
@ -1,8 +1,8 @@
|
|||||||
/*
|
/*
|
||||||
postmortem.c - output of debug info on sketch crash
|
postmortem.c - output of debug info on sketch crash
|
||||||
Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
|
Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
|
||||||
This file is part of the esp8266 core for Arduino environment.
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
This library is free software; you can redistribute it and/or
|
This library is free software; you can redistribute it and/or
|
||||||
modify it under the terms of the GNU Lesser General Public
|
modify it under the terms of the GNU Lesser General Public
|
||||||
License as published by the Free Software Foundation; either
|
License as published by the Free Software Foundation; either
|
||||||
@ -42,9 +42,9 @@ void __wrap_system_restart_local() {
|
|||||||
|
|
||||||
struct rst_info rst_info = {0};
|
struct rst_info rst_info = {0};
|
||||||
system_rtc_mem_read(0, &rst_info, sizeof(rst_info));
|
system_rtc_mem_read(0, &rst_info, sizeof(rst_info));
|
||||||
if (rst_info.reason != REASON_SOFT_WDT_RST &&
|
if (rst_info.reason != REASON_SOFT_WDT_RST &&
|
||||||
rst_info.reason != REASON_EXCEPTION_RST &&
|
rst_info.reason != REASON_EXCEPTION_RST &&
|
||||||
rst_info.reason != REASON_WDT_RST)
|
rst_info.reason != REASON_WDT_RST)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -52,15 +52,18 @@ void __wrap_system_restart_local() {
|
|||||||
ets_install_putc1(&uart_write_char_d);
|
ets_install_putc1(&uart_write_char_d);
|
||||||
|
|
||||||
if (rst_info.reason == REASON_EXCEPTION_RST) {
|
if (rst_info.reason == REASON_EXCEPTION_RST) {
|
||||||
ets_printf("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n",
|
ets_printf("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n",
|
||||||
rst_info.exccause, rst_info.epc1, rst_info.epc2, rst_info.epc3, rst_info.excvaddr, rst_info.depc);
|
rst_info.exccause, rst_info.epc1, rst_info.epc2, rst_info.epc3, rst_info.excvaddr, rst_info.depc);
|
||||||
}
|
}
|
||||||
|
else if (rst_info.reason == REASON_SOFT_WDT_RST) {
|
||||||
|
ets_printf("\nSoft WDT reset\n");
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t cont_stack_start = (uint32_t) &(g_cont.stack);
|
uint32_t cont_stack_start = (uint32_t) &(g_cont.stack);
|
||||||
uint32_t cont_stack_end = (uint32_t) g_cont.stack_end;
|
uint32_t cont_stack_end = (uint32_t) g_cont.stack_end;
|
||||||
uint32_t stack_end;
|
uint32_t stack_end;
|
||||||
|
|
||||||
// amount of stack taken by interrupt or exception handler
|
// amount of stack taken by interrupt or exception handler
|
||||||
// and everything up to __wrap_system_restart_local
|
// and everything up to __wrap_system_restart_local
|
||||||
// (determined empirically, might break)
|
// (determined empirically, might break)
|
||||||
uint32_t offset = 0;
|
uint32_t offset = 0;
|
||||||
@ -80,13 +83,13 @@ void __wrap_system_restart_local() {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ets_printf("\nctx: sys \n");
|
ets_printf("\nctx: sys \n");
|
||||||
stack_end = 0x3fffffb0;
|
stack_end = 0x3fffffb0;
|
||||||
// it's actually 0x3ffffff0, but the stuff below ets_run
|
// it's actually 0x3ffffff0, but the stuff below ets_run
|
||||||
// is likely not really relevant to the crash
|
// is likely not really relevant to the crash
|
||||||
}
|
}
|
||||||
|
|
||||||
ets_printf("sp: %08x end: %08x offset: %04x\n", sp, stack_end, offset);
|
ets_printf("sp: %08x end: %08x offset: %04x\n", sp, stack_end, offset);
|
||||||
|
|
||||||
// print_pcs(sp + offset, stack_end);
|
// print_pcs(sp + offset, stack_end);
|
||||||
print_stack(sp + offset, stack_end);
|
print_stack(sp + offset, stack_end);
|
||||||
delayMicroseconds(10000);
|
delayMicroseconds(10000);
|
||||||
@ -102,7 +105,7 @@ static void print_stack(uint32_t start, uint32_t end) {
|
|||||||
// rough indicator: stack frames usually have SP saved as the second word
|
// rough indicator: stack frames usually have SP saved as the second word
|
||||||
bool looksLikeStackFrame = (values[2] == pos + 0x10);
|
bool looksLikeStackFrame = (values[2] == pos + 0x10);
|
||||||
|
|
||||||
ets_printf("%08x: %08x %08x %08x %08x %c\n",
|
ets_printf("%08x: %08x %08x %08x %08x %c\n",
|
||||||
pos, values[0], values[1], values[2], values[3], (looksLikeStackFrame)?'<':' ');
|
pos, values[0], values[1], values[2], values[3], (looksLikeStackFrame)?'<':' ');
|
||||||
}
|
}
|
||||||
ets_printf("<<<stack<<<\n");
|
ets_printf("<<<stack<<<\n");
|
||||||
|
Reference in New Issue
Block a user