From 94032af61d59f0c910f828cd18bdbdf41c1f2a80 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Wed, 11 Jan 2023 13:58:21 +0100 Subject: [PATCH] ESP8266 hardware info * basic HW info, similar to ESP32 * minor stability improvement for 8266 --- wled00/json.cpp | 25 ++++++++++++++++++++++++- wled00/wled.cpp | 25 +++++++++++++++++++++++++ wled00/wled.h | 4 ++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/wled00/json.cpp b/wled00/json.cpp index 97b4b549..eccc8ca9 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -30,6 +30,15 @@ #else // for 8266 #include #include + +#include +#include +#include + +#include +#include +#include +#include #endif // end WLEDMM @@ -839,7 +848,21 @@ void serializeInfo(JsonObject root) #else // for 8266 root[F("e32core0code")] = (int)ESP.getResetInfoPtr()->reason; - root[F("e32core0text")] = F(""); + root[F("e32core0text")] = ESP.getResetReason(); + + root[F("e32model")] = F("ESP8266 (id 0x") + String(ESP.getChipId(), 16) + String(") "); // can only be "ESP8266EX" or "ESP8285" + root[F("e32cores")] = 1; + root[F("e32speed")] = ESP.getCpuFreqMHz(); + root[F("e32flash")] = int((ESP.getFlashChipRealSize()/1024)/1024); + root[F("e32flashspeed")] = int(ESP.getFlashChipSpeed()/1000000); + root[F("e32flashmode")] = int(ESP.getFlashChipMode()); + switch (ESP.getFlashChipMode()) { + case FM_QIO: root[F("e32flashtext")] = F(" (QIO)"); break; + case FM_QOUT: root[F("e32flashtext")] = F(" (QOUT)");break; + case FM_DIO: root[F("e32flashtext")] = F(" (DIO)"); break; + case FM_DOUT: root[F("e32flashtext")] = F(" (DOUT)");break; + default: root[F("e32flashtext")] = F(" (other)"); break; + } #endif // end WLEDMM diff --git a/wled00/wled.cpp b/wled00/wled.cpp index bfb05e2a..dab3b3ea 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -276,6 +276,8 @@ void WLED::setup() #endif Serial.begin(115200); + if (!Serial) delay(1000); // WLEDMM make sure that Serial has initalized + #if !ARDUINO_USB_CDC_ON_BOOT Serial.setTimeout(50); // this causes troubles on new MCUs that have a "virtual" USB Serial (HWCDC) #else @@ -346,6 +348,29 @@ void WLED::setup() #endif #else + // WLEDMM: more info for 8266 + DEBUG_PRINTLN(); + DEBUG_PRINTF("CPU: ESP8266 (id 0x%08X)", ESP.getChipId()); + DEBUG_PRINT(F(", ")); DEBUG_PRINT(ESP.getCpuFreqMHz()); DEBUG_PRINTLN(F("MHz.")); + USER_PRINT(F("CPU Last Restart Reason = ")); + USER_PRINT((int)ESP.getResetInfoPtr()->reason); USER_PRINT(F(" -> ")); + USER_PRINTLN(ESP.getResetInfo()); + + DEBUG_PRINT(F("FLASH: ")); DEBUG_PRINT((ESP.getFlashChipRealSize()/1024)/1024); + DEBUG_PRINT(F("MB, Mode ")); DEBUG_PRINT((int)ESP.getFlashChipMode()); + #ifdef WLED_DEBUG + switch (ESP.getFlashChipMode()) { + // missing: Octal modes + case FM_QIO: DEBUG_PRINT(F(" (QIO)")); break; + case FM_QOUT: DEBUG_PRINT(F(" (QOUT)"));break; + case FM_DIO: DEBUG_PRINT(F(" (DIO)")); break; + case FM_DOUT: DEBUG_PRINT(F(" (DOUT)"));break; + default: break; + } + #endif + DEBUG_PRINT(F(", speed ")); DEBUG_PRINT(ESP.getFlashChipSpeed()/1000000);DEBUG_PRINTLN(F("MHz.")); + USER_PRINTLN(); + DEBUG_PRINT(F("esp8266 ")); DEBUG_PRINTLN(ESP.getCoreVersion()); #endif diff --git a/wled00/wled.h b/wled00/wled.h index 1d0221f1..1b2a665b 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -458,7 +458,11 @@ WLED_GLOBAL byte macroDoublePress[WLED_MAX_BUTTONS] _INIT({0}); // Security CONFIG WLED_GLOBAL bool otaLock _INIT(false); // prevents OTA firmware updates without password. ALWAYS enable if system exposed to any public networks WLED_GLOBAL bool wifiLock _INIT(false); // prevents access to WiFi settings when OTA lock is enabled +#ifdef ARDUINO_ARCH_ESP32 WLED_GLOBAL bool aOtaEnabled _INIT(true); // ArduinoOTA allows easy updates directly from the IDE. Careful, it does not auto-disable when OTA lock is on +#else +WLED_GLOBAL bool aOtaEnabled _INIT(false); // WLEDMM: start with OTA disabled, as it seems to be unstable on 8266 +#endif WLED_GLOBAL char settingsPIN[5] _INIT(""); // PIN for settings pages WLED_GLOBAL bool correctPIN _INIT(true); WLED_GLOBAL unsigned long lastEditTime _INIT(0);