info page: add ESP restart reason
this is another "restart reason" - sometimes provides clearer information, especially in case of crash or watchdog reset.
This commit is contained in:
@@ -691,6 +691,7 @@ ${inforow("Environment",i.arch + " " + i.core + " (" + i.lwip + ")")}
|
||||
<tr><td colspan=2><hr style="height:1px;border-width:0;color:SeaGreen;background-color:SeaGreen"></td></tr>
|
||||
${i.e32model?inforow(i.e32model + " ☾",i.e32cores +" core(s)"," "+i.e32speed+" Mhz"):""}
|
||||
${i.e32flash?inforow("Flash "+i.e32flash+"MB"+" mode "+i.e32flashmode+i.e32flashtext + " ☾",i.e32flashspeed," Mhz"):""}
|
||||
${i.e32code?inforow("Last ESP Restart ☾",i.e32code+" "+i.e32text):""}
|
||||
${i.e32core0code?inforow("Core0 rst reason ☾",i.e32core0code, " "+i.e32core0text):""}
|
||||
${i.e32core1code?inforow("Core1 rst reason ☾",i.e32core1code, " "+i.e32core1text):""}
|
||||
<!-- WLEDMM end-->
|
||||
|
||||
@@ -136,6 +136,15 @@ void serveJson(AsyncWebServerRequest* request);
|
||||
bool serveLiveLeds(AsyncWebServerRequest* request, uint32_t wsClient = 0);
|
||||
#endif
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
#include <esp_system.h>
|
||||
int getCoreResetReason(int core);
|
||||
String resetCode2Info(int reason);
|
||||
esp_reset_reason_t getRestartReason();
|
||||
String restartCode2Info(esp_reset_reason_t reason);
|
||||
String restartCode2InfoLong(esp_reset_reason_t reason);
|
||||
#endif
|
||||
|
||||
//led.cpp
|
||||
void setValuesFromSegment(uint8_t s);
|
||||
void setValuesFromMainSeg();
|
||||
|
||||
@@ -654,7 +654,12 @@ void serializeState(JsonObject root, bool forPreset, bool includeBri, bool segme
|
||||
|
||||
// begin WLEDMM
|
||||
#ifdef ARDUINO_ARCH_ESP32
|
||||
static String resetCode2Info(int reason) {
|
||||
int getCoreResetReason(int core) {
|
||||
if (core >= ESP.getChipCores()) return 0;
|
||||
return((int)rtc_get_reset_reason(core));
|
||||
}
|
||||
|
||||
String resetCode2Info(int reason) {
|
||||
switch(reason) {
|
||||
|
||||
case 1 : // 1 = Vbat power on reset
|
||||
@@ -707,6 +712,42 @@ static String resetCode2Info(int reason) {
|
||||
return F("unknown"); break;
|
||||
}
|
||||
}
|
||||
|
||||
esp_reset_reason_t getRestartReason() {
|
||||
return(esp_reset_reason());
|
||||
}
|
||||
String restartCode2InfoLong(esp_reset_reason_t reason) {
|
||||
switch (reason) {
|
||||
case ESP_RST_UNKNOWN: return(F("Reset reason can not be determined")); break;
|
||||
case ESP_RST_POWERON: return(F("Restart due to power-on event")); break;
|
||||
case ESP_RST_EXT: return(F("Reset by external pin (not applicable for ESP32)")); break;
|
||||
case ESP_RST_SW: return(F("Software restart via esp_restart()")); break;
|
||||
case ESP_RST_PANIC: return(F("Software reset due to panic or unhandled exception (SW error)")); break;
|
||||
case ESP_RST_INT_WDT: return(F("Reset (software or hardware) due to interrupt watchdog")); break;
|
||||
case ESP_RST_TASK_WDT: return(F("Reset due to task watchdog")); break;
|
||||
case ESP_RST_WDT: return(F("Reset due to other watchdogs")); break;
|
||||
case ESP_RST_DEEPSLEEP:return(F("Restart after exiting deep sleep mode")); break;
|
||||
case ESP_RST_BROWNOUT: return(F("Brownout Reset (software or hardware)")); break;
|
||||
case ESP_RST_SDIO: return(F("Reset over SDIO")); break;
|
||||
}
|
||||
return(F("unknown"));
|
||||
}
|
||||
String restartCode2Info(esp_reset_reason_t reason) {
|
||||
switch (reason) {
|
||||
case ESP_RST_UNKNOWN: return(F("unknown reason")); break;
|
||||
case ESP_RST_POWERON: return(F("power-on event")); break;
|
||||
case ESP_RST_EXT: return(F("external pin reset")); break;
|
||||
case ESP_RST_SW: return(F("SW restart by esp_restart()")); break;
|
||||
case ESP_RST_PANIC: return(F("SW error (panic or exception)")); break;
|
||||
case ESP_RST_INT_WDT: return(F("interrupt watchdog")); break;
|
||||
case ESP_RST_TASK_WDT: return(F("task watchdog")); break;
|
||||
case ESP_RST_WDT: return(F("other watchdog")); break;
|
||||
case ESP_RST_DEEPSLEEP:return(F("exit from deep sleep")); break;
|
||||
case ESP_RST_BROWNOUT: return(F("Brownout Reset")); break;
|
||||
case ESP_RST_SDIO: return(F("Reset over SDIO")); break;
|
||||
}
|
||||
return(F("unknown"));
|
||||
}
|
||||
#endif
|
||||
// end WLEDMM
|
||||
|
||||
@@ -882,6 +923,9 @@ void serializeInfo(JsonObject root)
|
||||
root[F("e32core1code")] = (int)rtc_get_reset_reason(1);
|
||||
root[F("e32core1text")] = resetCode2Info(rtc_get_reset_reason(1));
|
||||
}
|
||||
root[F("e32code")] = (int)getRestartReason();
|
||||
root[F("e32text")] = restartCode2Info(getRestartReason());
|
||||
|
||||
static char msgbuf[32];
|
||||
snprintf(msgbuf, sizeof(msgbuf)-1, "%s rev.%d", ESP.getChipModel(), ESP.getChipRevision());
|
||||
root[F("e32model")] = msgbuf;
|
||||
|
||||
@@ -336,6 +336,18 @@ void WLED::setup()
|
||||
USER_PRINT(F(" rev.")); USER_PRINT(ESP.getChipRevision());
|
||||
USER_PRINT(F(", ")); USER_PRINT(ESP.getChipCores()); USER_PRINT(F(" core(s)"));
|
||||
USER_PRINT(F(", ")); USER_PRINT(ESP.getCpuFreqMHz()); USER_PRINTLN(F("MHz."));
|
||||
|
||||
// WLEDMM begin
|
||||
USER_PRINT(F("CPU "));
|
||||
esp_reset_reason_t resetReason = getRestartReason();
|
||||
USER_PRINT(restartCode2InfoLong(resetReason));
|
||||
int core0code = getCoreResetReason(0);
|
||||
int core1code = getCoreResetReason(1);
|
||||
USER_PRINTF("Core#0 %s (%d)", resetCode2Info(core0code).c_str(), core0code);
|
||||
if (core1code > 0) {USER_PRINTF("; Core#1 %s (%d)", resetCode2Info(core1code).c_str(), core1code);}
|
||||
USER_PRINTLN(F("."));
|
||||
// WLEDMM end
|
||||
|
||||
USER_PRINT(F("FLASH: ")); USER_PRINT((ESP.getFlashChipSize()/1024)/1024);
|
||||
USER_PRINT(F("MB, Mode ")); USER_PRINT(ESP.getFlashChipMode());
|
||||
#ifdef WLED_DEBUG
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
// version code in format yymmddb (b = daily build)
|
||||
#define VERSION 2303010
|
||||
#define VERSION 2303051
|
||||
|
||||
//uncomment this if you have a "my_config.h" file you'd like to use
|
||||
//#define WLED_USE_MY_CONFIG
|
||||
|
||||
Reference in New Issue
Block a user