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 ;
@@ -53,6 +55,14 @@ extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack,
53
55
54
56
extern void custom_crash_callback ( struct rst_info * rst_info , uint32_t stack , uint32_t stack_end ) __attribute__ ((weak , alias ("__custom_crash_callback" )));
55
57
58
+ static void ets_puts_P (const char * romString ) {
59
+ char c = pgm_read_byte (romString ++ );
60
+ while (c ) {
61
+ ets_putc (c );
62
+ c = pgm_read_byte (romString ++ );
63
+ }
64
+ }
65
+
56
66
void __wrap_system_restart_local () {
57
67
register uint32_t sp asm("a1" );
58
68
@@ -68,17 +78,21 @@ void __wrap_system_restart_local() {
68
78
ets_install_putc1 (& uart_write_char_d );
69
79
70
80
if (s_panic_line ) {
71
- ets_printf ("\nPanic %s:%d %s\n" , s_panic_file , s_panic_line , s_panic_func );
81
+ ets_puts_P (PSTR ("\nPanic " ));
82
+ ets_puts_P (s_panic_file );
83
+ ets_printf (":%d " , s_panic_line );
84
+ ets_puts_P (s_panic_func );
85
+ ets_puts_P (PSTR ("\n" ));
72
86
}
73
87
else if (s_abort_called ) {
74
- ets_printf ( "Abort called\n" );
88
+ ets_puts_P ( PSTR ( "Abort called\n" ) );
75
89
}
76
90
else if (rst_info .reason == REASON_EXCEPTION_RST ) {
77
91
ets_printf ("\nException (%d):\nepc1=0x%08x epc2=0x%08x epc3=0x%08x excvaddr=0x%08x depc=0x%08x\n" ,
78
92
rst_info .exccause , rst_info .epc1 , rst_info .epc2 , rst_info .epc3 , rst_info .excvaddr , rst_info .depc );
79
93
}
80
94
else if (rst_info .reason == REASON_SOFT_WDT_RST ) {
81
- ets_printf ( "\nSoft WDT reset\n" );
95
+ ets_puts_P ( PSTR ( "\nSoft WDT reset\n" ) );
82
96
}
83
97
84
98
uint32_t cont_stack_start = (uint32_t ) & (g_cont .stack );
@@ -100,11 +114,11 @@ void __wrap_system_restart_local() {
100
114
}
101
115
102
116
if (sp > cont_stack_start && sp < cont_stack_end ) {
103
- ets_printf ( "\nctx: cont \n" );
117
+ ets_puts_P ( PSTR ( "\nctx: cont \n" ) );
104
118
stack_end = cont_stack_end ;
105
119
}
106
120
else {
107
- ets_printf ( "\nctx: sys \n" );
121
+ ets_puts_P (( "\nctx: sys \n" ) );
108
122
stack_end = 0x3fffffb0 ;
109
123
// it's actually 0x3ffffff0, but the stuff below ets_run
110
124
// is likely not really relevant to the crash
@@ -123,7 +137,7 @@ void __wrap_system_restart_local() {
123
137
124
138
125
139
static void print_stack (uint32_t start , uint32_t end ) {
126
- ets_printf ( "\n>>>stack>>>\n" );
140
+ ets_puts_P ( PSTR ( "\n>>>stack>>>\n" ) );
127
141
for (uint32_t pos = start ; pos < end ; pos += 0x10 ) {
128
142
uint32_t * values = (uint32_t * )(pos );
129
143
@@ -133,7 +147,7 @@ static void print_stack(uint32_t start, uint32_t end) {
133
147
ets_printf ("%08x: %08x %08x %08x %08x %c\n" ,
134
148
pos , values [0 ], values [1 ], values [2 ], values [3 ], (looksLikeStackFrame )?'<' :' ' );
135
149
}
136
- ets_printf ( "<<<stack<<<\n" );
150
+ ets_puts_P ( PSTR ( "<<<stack<<<\n" ) );
137
151
}
138
152
139
153
/*
0 commit comments