platform: esp32: fix build, implement more crash info output

This commit is contained in:
Torrie Fischer 2023-12-23 11:15:31 +01:00
parent 389da5b115
commit 13a3dd5158

View File

@ -7,6 +7,32 @@ __NOINIT_ATTR static uint8_t s_rebootCount;
__NOINIT_ATTR static uint16_t s_forceSafeMode;
#define SAFE_MODE_MAGIC 6942
template<>
void
PlatformImpl<HAL_ESP32>::forceSafeMode()
{
s_forceSafeMode = SAFE_MODE_MAGIC;
}
template<>
void
PlatformImpl<HAL_ESP32>::bootSplash()
{
Log.trace("ESP32 startup reason: %d", Platform::bootopts.resetReason);
}
template<>
void
PlatformImpl<HAL_ESP32>::printCrashInfo()
{
/*auto rInfo = ESP.getResetInfoPtr();
if (Platform::bootopts.resetReason == REASON_EXCEPTION_RST) {
Log.error("Fatal exception (%d):", rInfo->exccause);
}
Log.error("epc1=%X, epc2=%X, epc3=%X, excvaddr=%X, depc=%X",
rInfo->epc1, rInfo->epc2, rInfo->epc3, rInfo->excvaddr, rInfo->depc);*/
}
template<>
void
PlatformImpl<HAL_ESP32>::initBootOptions(BootOptions& opts)
@ -18,12 +44,12 @@ PlatformImpl<HAL_ESP32>::initBootOptions(BootOptions& opts)
// on platformio builds
if (opts.crashCount++ >= 3) {
// Boot into safe mode if the watchdog reset us three times in a row.
isSafeMode = true;
opts.isSafeMode = true;
}
} else {
opts.crashCount = 0;
}
s_rebootCount = crashCount;
s_rebootCount = opts.crashCount;
}
template<>
@ -44,8 +70,8 @@ template<>
const char*
PlatformImpl<HAL_ESP32>::deviceID()
{
uint64_t chipid;
chipid = ESP.getEfuseMac();
static char s_deviceID[15];
uint64_t chipid = ESP.getEfuseMac();
snprintf(s_deviceID, sizeof(s_deviceID), "%08X", (uint32_t)chipid);
return s_deviceID;
}
@ -95,6 +121,7 @@ PlatformImpl<HAL_ESP32>::getLocalTime(struct tm* timedata, int timezone)
memset(&rawtime, 0, sizeof(rawtime));
time(&rawtime);
(*timedata) = (*localtime(&rawtime));
timedata->tm_hour += timezone;
return (timedata->tm_year > (2016-1990));
}