1- /*
1+ /*
22 postmortem.c - output of debug info on sketch crash
33 Copyright (c) 2015 Ivan Grokhotkov. All rights reserved.
44 This file is part of the esp8266 core for Arduino environment.
5-
5+
66 This library is free software; you can redistribute it and/or
77 modify it under the terms of the GNU Lesser General Public
88 License as published by the Free Software Foundation; either
@@ -42,25 +42,28 @@ void __wrap_system_restart_local() {
4242
4343 struct rst_info rst_info = {0 };
4444 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 &&
4646 rst_info .reason != REASON_EXCEPTION_RST &&
47- rst_info .reason != REASON_WDT_RST )
47+ rst_info .reason != REASON_WDT_RST )
4848 {
4949 return ;
5050 }
5151
5252 ets_install_putc1 (& uart_write_char_d );
5353
5454 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" ,
5656 rst_info .exccause , rst_info .epc1 , rst_info .epc2 , rst_info .epc3 , rst_info .excvaddr , rst_info .depc );
5757 }
58+ else if (rst_info .reason == REASON_SOFT_WDT_RST ) {
59+ ets_printf ("\nSoft WDT reset\n" );
60+ }
5861
5962 uint32_t cont_stack_start = (uint32_t ) & (g_cont .stack );
6063 uint32_t cont_stack_end = (uint32_t ) g_cont .stack_end ;
6164 uint32_t stack_end ;
6265
63- // amount of stack taken by interrupt or exception handler
66+ // amount of stack taken by interrupt or exception handler
6467 // and everything up to __wrap_system_restart_local
6568 // (determined empirically, might break)
6669 uint32_t offset = 0 ;
@@ -80,13 +83,13 @@ void __wrap_system_restart_local() {
8083 }
8184 else {
8285 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
8588 // is likely not really relevant to the crash
8689 }
87-
90+
8891 ets_printf ("sp: %08x end: %08x offset: %04x\n" , sp , stack_end , offset );
89-
92+
9093 // print_pcs(sp + offset, stack_end);
9194 print_stack (sp + offset , stack_end );
9295 delayMicroseconds (10000 );
@@ -102,7 +105,7 @@ static void print_stack(uint32_t start, uint32_t end) {
102105 // rough indicator: stack frames usually have SP saved as the second word
103106 bool looksLikeStackFrame = (values [2 ] == pos + 0x10 );
104107
105- ets_printf ("%08x: %08x %08x %08x %08x %c\n" ,
108+ ets_printf ("%08x: %08x %08x %08x %08x %c\n" ,
106109 pos , values [0 ], values [1 ], values [2 ], values [3 ], (looksLikeStackFrame )?'<' :' ' );
107110 }
108111 ets_printf ("<<<stack<<<\n" );
0 commit comments