1
- /*
1
+ /*
2
2
postmortem.c - output of debug info on sketch crash
3
3
Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
4
4
This file is part of the esp8266 core for Arduino environment.
5
-
5
+
6
6
This library is free software; you can redistribute it and/or
7
7
modify it under the terms of the GNU Lesser General Public
8
8
License as published by the Free Software Foundation; either
@@ -42,25 +42,28 @@ void __wrap_system_restart_local() {
42
42
43
43
struct rst_info rst_info = {0 };
44
44
system_rtc_mem_read (0 , & rst_info , sizeof (rst_info ));
45
- if (rst_info .reason != REASON_SOFT_WDT_RST &&
45
+ if (rst_info .reason != REASON_SOFT_WDT_RST &&
46
46
rst_info .reason != REASON_EXCEPTION_RST &&
47
- rst_info .reason != REASON_WDT_RST )
47
+ rst_info .reason != REASON_WDT_RST )
48
48
{
49
49
return ;
50
50
}
51
51
52
52
ets_install_putc1 (& uart_write_char_d );
53
53
54
54
if (rst_info .reason == REASON_EXCEPTION_RST ) {
55
- ets_printf ("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n" ,
55
+ ets_printf ("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n" ,
56
56
rst_info .exccause , rst_info .epc1 , rst_info .epc2 , rst_info .epc3 , rst_info .excvaddr , rst_info .depc );
57
57
}
58
+ else if (rst_info .reason == REASON_SOFT_WDT_RST ) {
59
+ ets_printf ("\nSoft WDT reset\n" );
60
+ }
58
61
59
62
uint32_t cont_stack_start = (uint32_t ) & (g_cont .stack );
60
63
uint32_t cont_stack_end = (uint32_t ) g_cont .stack_end ;
61
64
uint32_t stack_end ;
62
65
63
- // amount of stack taken by interrupt or exception handler
66
+ // amount of stack taken by interrupt or exception handler
64
67
// and everything up to __wrap_system_restart_local
65
68
// (determined empirically, might break)
66
69
uint32_t offset = 0 ;
@@ -80,13 +83,13 @@ void __wrap_system_restart_local() {
80
83
}
81
84
else {
82
85
ets_printf ("\nctx: sys \n" );
83
- stack_end = 0x3fffffb0 ;
84
- // it's actually 0x3ffffff0, but the stuff below ets_run
86
+ stack_end = 0x3fffffb0 ;
87
+ // it's actually 0x3ffffff0, but the stuff below ets_run
85
88
// is likely not really relevant to the crash
86
89
}
87
-
90
+
88
91
ets_printf ("sp: %08x end: %08x offset: %04x\n" , sp , stack_end , offset );
89
-
92
+
90
93
// print_pcs(sp + offset, stack_end);
91
94
print_stack (sp + offset , stack_end );
92
95
delayMicroseconds (10000 );
@@ -102,7 +105,7 @@ static void print_stack(uint32_t start, uint32_t end) {
102
105
// rough indicator: stack frames usually have SP saved as the second word
103
106
bool looksLikeStackFrame = (values [2 ] == pos + 0x10 );
104
107
105
- ets_printf ("%08x: %08x %08x %08x %08x %c\n" ,
108
+ ets_printf ("%08x: %08x %08x %08x %08x %c\n" ,
106
109
pos , values [0 ], values [1 ], values [2 ], values [3 ], (looksLikeStackFrame )?'<' :' ' );
107
110
}
108
111
ets_printf ("<<<stack<<<\n" );
0 commit comments