reset reason

This commit is contained in:
MichaelDvP
2026-03-20 14:50:58 +01:00
parent 205d826adb
commit d04e7c36f3

View File

@@ -34,25 +34,7 @@
#endif
#ifndef EMSESP_STANDALONE
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
#if CONFIG_IDF_TARGET_ESP32 // ESP32/PICO-D4
#include "../esp32/rom/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "../esp32s2/rom/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32C3
#include "../esp32c3/rom/rtc.h"
#elif CONFIG_IDF_TARGET_ESP32S3
#include "../esp32s3/rom/rtc.h"
#else
#error Target CONFIG_IDF_TARGET is not supported
#endif
#else // ESP32 Before IDF 4.0
#include "../rom/rtc.h"
#endif
#include <esp_mac.h>
#endif
#ifndef EMSESP_STANDALONE
#include "esp_efuse.h"
#endif
@@ -2534,37 +2516,38 @@ bool System::command_restart(const char * value, const int8_t id) {
std::string System::reset_reason(uint8_t cpu) const {
#ifndef EMSESP_STANDALONE
switch (rtc_get_reset_reason(cpu)) {
case 1:
switch (esp_rom_get_reset_reason(cpu)) {
case RESET_REASON_CHIP_POWER_ON:
return ("Power on reset");
// case 2 :reset pin not on esp32
case 3:
case 2: // not on esp32
return ("reset pin");
case RESET_REASON_CORE_SW:
return ("Software reset");
case 4: // not on S2, C3
return ("Legacy watch dog reset");
case 5:
case RESET_REASON_CORE_DEEP_SLEEP:
return ("Deep sleep reset");
case 6: // not on S2, C3
case 6: // RESET_REASON_CORE_SDIO: // not on S2, S3, C3
return ("Reset by SDIO");
case 7:
case RESET_REASON_CORE_MWDT0:
return ("Timer group0 watch dog reset");
case 8:
case RESET_REASON_CORE_MWDT1:
return ("Timer group1 watch dog reset");
case 9:
case RESET_REASON_CORE_RTC_WDT:
return ("RTC watch dog reset");
case 10:
return ("Intrusion reset CPU");
case 11:
case RESET_REASON_CPU0_MWDT0:
return ("Timer group reset CPU");
case 12:
case RESET_REASON_CPU0_SW:
return ("Software reset CPU");
case 13:
case RESET_REASON_CPU0_RTC_WDT:
return ("RTC watch dog reset: CPU");
case 14: // not on S2, C3
case 14: // RESET_REASON_CPU1_CPU0: // not on S2, S3, C3
return ("APP CPU reset by PRO CPU");
case 15:
case RESET_REASON_SYS_BROWN_OUT:
return ("Brownout reset");
case 16:
case RESET_REASON_SYS_RTC_WDT:
return ("RTC watch dog reset: CPU+RTC");
default:
break;