@@ -52,6 +52,13 @@ static void uart0_write_char_d(char c);
52
52
static void uart1_write_char_d (char c);
53
53
static void print_stack (uint32_t start, uint32_t end);
54
54
55
+ // using numbers different from "REASON_" in user_interface.h (=0..6)
56
+ enum rst_reason_sw
57
+ {
58
+ REASON_USER_SWEXCEPTION_RST = 254
59
+ };
60
+ static int s_user_reset_reason = REASON_DEFAULT_RST;
61
+
55
62
// From UMM, the last caller of a malloc/realloc/calloc which failed:
56
63
extern void *umm_last_fail_alloc_addr;
57
64
extern int umm_last_fail_alloc_size;
@@ -82,29 +89,24 @@ static void ets_printf_P(const char *str, ...) {
82
89
}
83
90
}
84
91
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;
89
-
90
92
void __wrap_system_restart_local () {
91
93
register uint32_t sp asm (" a1" );
92
94
uint32_t sp_dump = sp;
93
95
94
96
struct rst_info rst_info;
95
97
memset (&rst_info, 0 , sizeof (rst_info));
96
- if (user_reset_reason == USER_REASON_NONE )
98
+ if (s_user_reset_reason == REASON_DEFAULT_RST )
97
99
{
98
100
system_rtc_mem_read (0 , &rst_info, sizeof (rst_info));
99
101
if (rst_info.reason != REASON_SOFT_WDT_RST &&
100
102
rst_info.reason != REASON_EXCEPTION_RST &&
101
103
rst_info.reason != REASON_WDT_RST)
102
104
{
103
- return ;
105
+ rst_info. reason = REASON_DEFAULT_RST ;
104
106
}
105
107
}
106
108
else
107
- rst_info.reason = user_reset_reason ;
109
+ rst_info.reason = s_user_reset_reason ;
108
110
109
111
// TODO: ets_install_putc1 definition is wrong in ets_sys.h, need cast
110
112
ets_install_putc1 ((void *)&uart_write_char_d);
@@ -129,6 +131,9 @@ void __wrap_system_restart_local() {
129
131
else if (rst_info.reason == REASON_SOFT_WDT_RST) {
130
132
ets_printf_P (PSTR (" \n Soft WDT reset\n " ));
131
133
}
134
+ else {
135
+ ets_printf_P (PSTR (" \n Generic Soft Reset\n " ));
136
+ }
132
137
133
138
uint32_t cont_stack_start = (uint32_t ) &(g_pcont->stack );
134
139
uint32_t cont_stack_end = (uint32_t ) g_pcont->stack_end ;
@@ -226,7 +231,7 @@ static void raise_exception() {
226
231
if (gdb_present ())
227
232
__asm__ __volatile__ (" syscall" ); // triggers GDB when enabled
228
233
229
- user_reset_reason = USER_REASON_SWEXCEPTION ;
234
+ s_user_reset_reason = REASON_USER_SWEXCEPTION_RST ;
230
235
ets_printf_P (PSTR (" \n User exception (panic/abort/assert)" ));
231
236
__wrap_system_restart_local ();
232
237
0 commit comments