@@ -82,28 +82,18 @@ static void ets_printf_P(const char *str, ...) {
82
82
}
83
83
}
84
84
85
- #define FAKE_REASON_NONE 255
86
- #define FAKE_REASON_USER 254
87
- static int fake_rst_reason = FAKE_REASON_NONE;
85
+ #define USER_REASON_NONE 255
86
+ #define USER_REASON_SWEXCEPTION 254
87
+ // using numbers different from "REASON_" in user_interface.h 0..6
88
+ static int user_reset_reason = USER_REASON_NONE;
88
89
89
90
void __wrap_system_restart_local () {
90
91
register uint32_t sp asm (" a1" );
91
92
uint32_t sp_dump = sp;
92
93
93
- #if 0
94
- if (gdb_present()) {
95
- /* When GDBStub is present, exceptions are handled by GDBStub,
96
- but Soft WDT will still call this function.
97
- Trigger an exception to break into GDB.
98
- TODO: check why gdb_do_break() or asm("break.n 0") do not
99
- break into GDB here. */
100
- raise_exception();
101
- }
102
- #endif
103
-
104
94
struct rst_info rst_info;
105
95
memset (&rst_info, 0 , sizeof (rst_info));
106
- if (fake_rst_reason == FAKE_REASON_NONE )
96
+ if (user_reset_reason == USER_REASON_NONE )
107
97
{
108
98
system_rtc_mem_read (0 , &rst_info, sizeof (rst_info));
109
99
if (rst_info.reason != REASON_SOFT_WDT_RST &&
@@ -114,7 +104,7 @@ void __wrap_system_restart_local() {
114
104
}
115
105
}
116
106
else
117
- rst_info.reason = fake_rst_reason ;
107
+ rst_info.reason = user_reset_reason ;
118
108
119
109
// TODO: ets_install_putc1 definition is wrong in ets_sys.h, need cast
120
110
ets_install_putc1 ((void *)&uart_write_char_d);
@@ -233,24 +223,13 @@ static void uart1_write_char_d(char c) {
233
223
}
234
224
235
225
static void raise_exception () {
236
- #if 0
237
-
238
- // works but also showing
239
- // "Fatal exception 29(StoreProhibitedCause)"
240
- *((char*)0) = 0;
241
-
242
- #else
243
-
244
226
if (gdb_present ())
245
- // *((char*)0) = 0;
246
227
__asm__ __volatile__ (" syscall" ); // triggers GDB when enabled
247
228
248
- fake_rst_reason = FAKE_REASON_USER ;
229
+ user_reset_reason = USER_REASON_SWEXCEPTION ;
249
230
ets_printf_P (PSTR (" \n User exception (panic/abort/assert)" ));
250
231
__wrap_system_restart_local ();
251
232
252
- #endif
253
-
254
233
while (1 ); // never reached, needed to satisfy "noreturn" attribute
255
234
}
256
235
0 commit comments