Skip to content

Commit d0a806d

Browse files
committed
Enter safe mode after panic or brownout
Uses the IDF's reset reason. Does nothing before reset. Fixes #3389
1 parent 1df0334 commit d0a806d

File tree

1 file changed

+8
-0
lines changed
  • ports/esp32s2/supervisor

1 file changed

+8
-0
lines changed

ports/esp32s2/supervisor/port.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ safe_mode_t port_init(void) {
102102
return NO_HEAP;
103103
}
104104

105+
esp_reset_reason_t reason = esp_reset_reason();
106+
if (reason == ESP_RST_BROWNOUT) {
107+
return BROWNOUT;
108+
}
109+
if (reason == ESP_RST_PANIC) {
110+
return HARD_CRASH;
111+
}
112+
105113
return NO_SAFE_MODE;
106114
}
107115

0 commit comments

Comments
 (0)