27
27
#include "user_interface.h"
28
28
#include "esp8266_peri.h"
29
29
#include "cont.h"
30
+ #include "pgmspace.h"
30
31
31
32
extern void __real_system_restart_local ();
32
33
extern void gdb_do_break ();
33
34
34
35
extern cont_t g_cont ;
35
36
37
+ // These will be pointers to PROGMEM const strings
36
38
static const char * s_panic_file = 0 ;
37
39
static int s_panic_line = 0 ;
38
40
static const char * s_panic_func = 0 ;
@@ -55,6 +57,14 @@ extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack,
55
57
56
58
extern void custom_crash_callback ( struct rst_info * rst_info , uint32_t stack , uint32_t stack_end ) __attribute__ ((weak , alias ("__custom_crash_callback" )));
57
59
60
+ static void ets_puts_P (const char * romString ) {
61
+ char c = pgm_read_byte (romString ++ );
62
+ while (c ) {
63
+ ets_putc (c );
64
+ c = pgm_read_byte (romString ++ );
65
+ }
66
+ }
67
+
58
68
void __wrap_system_restart_local () {
59
69
if (crash_for_gdb ) * ((int * )0 ) = 0 ;
60
70
register uint32_t sp asm("a1" );
@@ -71,17 +81,21 @@ void __wrap_system_restart_local() {
71
81
ets_install_putc1 (& uart_write_char_d );
72
82
73
83
if (s_panic_line ) {
74
- ets_printf ("\nPanic %s:%d %s\n" , s_panic_file , s_panic_line , s_panic_func );
84
+ ets_puts_P (PSTR ("\nPanic " ));
85
+ ets_puts_P (s_panic_file );
86
+ ets_printf (":%d " , s_panic_line );
87
+ ets_puts_P (s_panic_func );
88
+ ets_puts_P (PSTR ("\n" ));
75
89
}
76
90
else if (s_abort_called ) {
77
- ets_printf ( "Abort called\n" );
91
+ ets_puts_P ( PSTR ( "Abort called\n" ) );
78
92
}
79
93
else if (rst_info .reason == REASON_EXCEPTION_RST ) {
80
94
ets_printf ("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n" ,
81
95
rst_info .exccause , rst_info .epc1 , rst_info .epc2 , rst_info .epc3 , rst_info .excvaddr , rst_info .depc );
82
96
}
83
97
else if (rst_info .reason == REASON_SOFT_WDT_RST ) {
84
- ets_printf ( "\nSoft WDT reset\n" );
98
+ ets_puts_P ( PSTR ( "\nSoft WDT reset\n" ) );
85
99
}
86
100
87
101
uint32_t cont_stack_start = (uint32_t ) & (g_cont .stack );
@@ -103,11 +117,11 @@ void __wrap_system_restart_local() {
103
117
}
104
118
105
119
if (sp > cont_stack_start && sp < cont_stack_end ) {
106
- ets_printf ( "\nctx: cont \n" );
120
+ ets_puts_P ( PSTR ( "\nctx: cont \n" ) );
107
121
stack_end = cont_stack_end ;
108
122
}
109
123
else {
110
- ets_printf ( "\nctx: sys \n" );
124
+ ets_puts_P (( "\nctx: sys \n" ) );
111
125
stack_end = 0x3fffffb0 ;
112
126
// it's actually 0x3ffffff0, but the stuff below ets_run
113
127
// is likely not really relevant to the crash
@@ -126,7 +140,7 @@ void __wrap_system_restart_local() {
126
140
127
141
128
142
static void print_stack (uint32_t start , uint32_t end ) {
129
- ets_printf ( "\n>>>stack>>>\n" );
143
+ ets_puts_P ( PSTR ( "\n>>>stack>>>\n" ) );
130
144
for (uint32_t pos = start ; pos < end ; pos += 0x10 ) {
131
145
uint32_t * values = (uint32_t * )(pos );
132
146
@@ -136,7 +150,7 @@ static void print_stack(uint32_t start, uint32_t end) {
136
150
ets_printf ("%08x: %08x %08x %08x %08x %c\n" ,
137
151
pos , values [0 ], values [1 ], values [2 ], values [3 ], (looksLikeStackFrame )?'<' :' ' );
138
152
}
139
- ets_printf ( "<<<stack<<<\n" );
153
+ ets_puts_P ( PSTR ( "<<<stack<<<\n" ) );
140
154
}
141
155
142
156
/*
0 commit comments