Add more crash dump information

This commit is contained in:
Theo Arends 2019-12-28 14:54:26 +01:00
parent ba1afe979b
commit ab167b0974
5 changed files with 27 additions and 7 deletions

View File

@ -60,3 +60,4 @@ The following binary downloads have been compiled with ESP8266/Arduino library c
- Add SerialConfig to ``Status 1`` - Add SerialConfig to ``Status 1``
- Add WifiPower to ``Status 5`` - Add WifiPower to ``Status 5``
- Add support for DS1624, DS1621 Temperature sensor by Leonid Myravjev - Add support for DS1624, DS1621 Temperature sensor by Leonid Myravjev
- Add Zigbee attribute decoder for Xiaomi Aqara Cube

View File

@ -57,8 +57,13 @@ void OsWatchTicker(void)
// AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING)); // Save iram space // AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_OSWATCH " " D_BLOCKED_LOOP ". " D_RESTARTING)); // Save iram space
RtcSettings.oswatch_blocked_loop = 1; RtcSettings.oswatch_blocked_loop = 1;
RtcSettingsSave(); RtcSettingsSave();
// ESP.restart(); // normal reboot // ESP.restart(); // normal reboot
ESP.reset(); // hard reset // ESP.reset(); // hard reset
// Force an exception to get a stackdump
volatile uint32_t dummy;
dummy = *((uint32_t*) 0x00000000);
} }
} }

View File

@ -333,9 +333,7 @@ void CmndStatus(void)
if ((!Settings.flag.mqtt_enabled) && (6 == payload)) { payload = 99; } // SetOption3 - Enable MQTT if ((!Settings.flag.mqtt_enabled) && (6 == payload)) { payload = 99; } // SetOption3 - Enable MQTT
if (!energy_flg && (9 == payload)) { payload = 99; } if (!energy_flg && (9 == payload)) { payload = 99; }
if (!CrashFlag() && (12 == payload)) { payload = 99; }
bool exception_flg = (ResetReason() == REASON_EXCEPTION_RST) || (ResetReason() == REASON_SOFT_WDT_RST);
if (!exception_flg && (12 == payload)) { payload = 99; }
if ((0 == payload) || (99 == payload)) { if ((0 == payload) || (99 == payload)) {
uint32_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!devices_present) ? 1 : devices_present; uint32_t maxfn = (devices_present > MAX_FRIENDLYNAMES) ? MAX_FRIENDLYNAMES : (!devices_present) ? 1 : devices_present;
@ -482,7 +480,7 @@ void CmndStatus(void)
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "11")); MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "11"));
} }
if (exception_flg) { if (CrashFlag()) {
if ((0 == payload) || (12 == payload)) { if ((0 == payload) || (12 == payload)) {
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS12_STATUS "\":")); Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS12_STATUS "\":"));
CrashDump(); CrashDump();
@ -578,6 +576,9 @@ void CmndRestart(void)
case -2: case -2:
CmndWDT(); CmndWDT();
break; break;
case -3:
CmndBlockedLoop();
break;
case 99: case 99:
AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING)); AddLog_P(LOG_LEVEL_INFO, PSTR(D_LOG_APPLICATION D_RESTARTING));
EspRestart(); EspRestart();

View File

@ -50,7 +50,7 @@ void CmndCrash(void)
dummy = *((uint32_t*) 0x00000000); dummy = *((uint32_t*) 0x00000000);
} }
// do an infinite loop to trigger WDT watchdog // Do an infinite loop to trigger WDT watchdog
void CmndWDT(void) void CmndWDT(void)
{ {
volatile uint32_t dummy = 0; volatile uint32_t dummy = 0;
@ -59,6 +59,14 @@ void CmndWDT(void)
} }
} }
// This will trigger the os watch after OSWATCH_RESET_TIME (=120) seconds
void CmndBlockedLoop(void)
{
while (1) {
delay(1000);
}
}
// Clear the RTC dump counter when we do a normal reboot, this avoids garbage data to stay in RTC // Clear the RTC dump counter when we do a normal reboot, this avoids garbage data to stay in RTC
void CrashDumpClear(void) void CrashDumpClear(void)
{ {
@ -70,6 +78,11 @@ void CrashDumpClear(void)
* CmndCrashDump - dump the crash history - called by `Status 12` * CmndCrashDump - dump the crash history - called by `Status 12`
\*********************************************************************************************/ \*********************************************************************************************/
bool CrashFlag(void)
{
return ((ResetReason() == REASON_EXCEPTION_RST) || (ResetReason() == REASON_SOFT_WDT_RST) || oswatch_blocked_loop);
}
void CrashDump(void) void CrashDump(void)
{ {
ResponseAppend_P(PSTR("{\"Exception\":%d,\"Reason\":\"%s\",\"EPC\":[\"%08x\",\"%08x\",\"%08x\"],\"EXCVADDR\":\"%08x\",\"DEPC\":\"%08x\""), ResponseAppend_P(PSTR("{\"Exception\":%d,\"Reason\":\"%s\",\"EPC\":[\"%08x\",\"%08x\",\"%08x\"],\"EXCVADDR\":\"%08x\",\"DEPC\":\"%08x\""),

View File

@ -532,7 +532,7 @@ void MqttConnected(void)
} }
#endif // USE_WEBSERVER #endif // USE_WEBSERVER
Response_P(PSTR("{\"" D_JSON_RESTARTREASON "\":")); Response_P(PSTR("{\"" D_JSON_RESTARTREASON "\":"));
if (ResetReason() == REASON_EXCEPTION_RST) { if (CrashFlag()) {
CrashDump(); CrashDump();
} else { } else {
ResponseAppend_P(PSTR("\"%s\""), GetResetReason().c_str()); ResponseAppend_P(PSTR("\"%s\""), GetResetReason().c_str());