From b80708aef0b34db393fc984af570ca672f69ce12 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Thu, 21 Nov 2019 15:00:35 +0100 Subject: [PATCH] Add hardware detection Add hardware detection to be overruled with SetOption51 (#6969) --- tasmota/_changelog.ino | 1 + tasmota/support.ino | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/tasmota/_changelog.ino b/tasmota/_changelog.ino index 5c60f17a5..c54ed15d1 100644 --- a/tasmota/_changelog.ino +++ b/tasmota/_changelog.ino @@ -4,6 +4,7 @@ * Add command TempOffset -12.6 .. 12.6 to set global temperature sensor offset (#6958) * Fix check deepsleep for valid values in Settings (#6961) * Fix Wifi instability when light is on, due to sleep=0 (#6961, #6608) + * Add hardware detection to be overruled with SetOption51 (#6969) * * 7.0.0.4 20191108 * Add command WifiPower 0 .. 20.5 to set Wifi Output Power which will be default set to 17dBm diff --git a/tasmota/support.ino b/tasmota/support.ino index 0fa564aed..bbc86a779 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -521,7 +521,7 @@ char* GetPowerDevice(char* dest, uint32_t idx, size_t size) return GetPowerDevice(dest, idx, size, 0); } -String GetDeviceHardware(void) +bool IsEsp8285(void) { // esptool.py get_efuses uint32_t efuse1 = *(uint32_t*)(0x3FF00050); @@ -529,10 +529,22 @@ String GetDeviceHardware(void) // uint32_t efuse3 = *(uint32_t*)(0x3FF00058); // uint32_t efuse4 = *(uint32_t*)(0x3FF0005C); -// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("FUS: efuses 0x%08X 0x%08X, name %s"), efuse1, efuse2); - bool is_8285 = ( (efuse1 & (1 << 4)) || (efuse2 & (1 << 16)) ); - return String((is_8285) ? F("ESP8285") : F("ESP8266EX")); + if (is_8285 && (ESP.getFlashChipRealSize() > 1048576)) { + is_8285 = false; // ESP8285 can only have 1M flash + } + return is_8285; +} + +String GetDeviceHardware(void) +{ + char buff[10]; + if (IsEsp8285()) { + strcpy_P(buff, PSTR("ESP8285")); + } else { + strcpy_P(buff, PSTR("ESP8266EX")); + } + return String(buff); } float ConvertTemp(float c) @@ -1025,11 +1037,14 @@ uint8_t ValidPin(uint32_t pin, uint32_t gpio) uint8_t result = gpio; if (FlashPin(pin)) { - result = GPIO_NONE; // Disable flash pins GPIO6, GPIO7, GPIO8 and GPIO11 + result = GPIO_NONE; // Disable flash pins GPIO6, GPIO7, GPIO8 and GPIO11 } - if ((WEMOS == Settings.module) && (!Settings.flag3.user_esp8285_enable)) { // SetOption51 - Enable ESP8285 user GPIO's - if ((pin == 9) || (pin == 10)) { result = GPIO_NONE; } // Disable possible flash GPIO9 and GPIO10 + if (!IsEsp8285() && !Settings.flag3.user_esp8285_enable) { // SetOption51 - Enable ESP8285 user GPIO's + if ((pin == 9) || (pin == 10)) { + result = GPIO_NONE; // Disable possible flash GPIO9 and GPIO10 + } } + return result; }