From e150717e95f68cfe02050015639f8d46bf10f8e5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 2 Dec 2019 10:31:33 +0100 Subject: [PATCH] Restore hardware detection --- RELEASENOTES.md | 1 - tasmota/CHANGELOG.md | 1 - tasmota/support.ino | 35 ++++++++++++++++++++++++++++++----- tasmota/support_command.ino | 5 +++-- tasmota/tasmota.ino | 2 ++ 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index cc067d531..8bc11b7ab 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -49,7 +49,6 @@ The following binary downloads have been compiled with ESP8266/Arduino library c ### Version 7.1.1.1 Betty -- Remove inconsistent hardware detection introduced in version 7.0.0.5 - Fix lost functionality of GPIO9 and GPIO10 on some devices (#7080) - Fix Zigbee uses Hardware Serial if GPIO 1/3 or GPIO 13/15 and SerialLog 0 (#7071) - Change light color schemes 2, 3 and 4 from color wheel to Hue driven diff --git a/tasmota/CHANGELOG.md b/tasmota/CHANGELOG.md index 4e798c754..c639e5392 100644 --- a/tasmota/CHANGELOG.md +++ b/tasmota/CHANGELOG.md @@ -2,7 +2,6 @@ ### 7.1.1.1 20191201 -- Remove inconsistent hardware detection introduced in version 7.0.0.5 - Fix lost functionality of GPIO9 and GPIO10 on some devices (#7080) - Fix Zigbee uses Hardware Serial if GPIO 1/3 or GPIO 13/15 and SerialLog 0 (#7071) - Change light color schemes 2, 3 and 4 from color wheel to Hue driven diff --git a/tasmota/support.ino b/tasmota/support.ino index 1e639494b..8ce7f2840 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -521,6 +521,31 @@ char* GetPowerDevice(char* dest, uint32_t idx, size_t size) return GetPowerDevice(dest, idx, size, 0); } +void GetEspHardwareType(void) +{ + // esptool.py get_efuses + uint32_t efuse1 = *(uint32_t*)(0x3FF00050); + uint32_t efuse2 = *(uint32_t*)(0x3FF00054); +// uint32_t efuse3 = *(uint32_t*)(0x3FF00058); +// uint32_t efuse4 = *(uint32_t*)(0x3FF0005C); + + is_8285 = ( (efuse1 & (1 << 4)) || (efuse2 & (1 << 16)) ); + if (is_8285 && (ESP.getFlashChipRealSize() > 1048576)) { + is_8285 = false; // ESP8285 can only have 1M flash + } +} + +String GetDeviceHardware(void) +{ + char buff[10]; + if (is_8285) { + strcpy_P(buff, PSTR("ESP8285")); + } else { + strcpy_P(buff, PSTR("ESP8266EX")); + } + return String(buff); +} + float ConvertTemp(float c) { float result = c; @@ -1008,18 +1033,18 @@ bool FlashPin(uint32_t pin) 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 + return GPIO_NONE; // Disable flash pins GPIO6, GPIO7, GPIO8 and GPIO11 } + +// if (!is_8285 && !Settings.flag3.user_esp8285_enable) { // SetOption51 - Enable ESP8285 user GPIO's 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 + return GPIO_NONE; // Disable possible flash GPIO9 and GPIO10 } } - return result; + return gpio; } bool ValidGPIO(uint32_t pin, uint32_t gpio) diff --git a/tasmota/support_command.ino b/tasmota/support_command.ino index e5c19c0e0..fe8640045 100644 --- a/tasmota/support_command.ino +++ b/tasmota/support_command.ino @@ -376,9 +376,10 @@ void CmndStatus(void) if ((0 == payload) || (2 == payload)) { Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS2_FIRMWARE "\":{\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_BUILDDATETIME "\":\"%s\",\"" - D_JSON_BOOTVERSION "\":%d,\"" D_JSON_COREVERSION "\":\"" ARDUINO_ESP8266_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\"}}"), + D_JSON_BOOTVERSION "\":%d,\"" D_JSON_COREVERSION "\":\"" ARDUINO_ESP8266_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\"," + "\"Hardware\":\"%s\"}}"), my_version, my_image, GetBuildDateAndTime().c_str(), - ESP.getBootVersion(), ESP.getSdkVersion()); + ESP.getBootVersion(), ESP.getSdkVersion(), GetDeviceHardware().c_str()); MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "2")); } diff --git a/tasmota/tasmota.ino b/tasmota/tasmota.ino index 64a1125c6..b7b4523e0 100644 --- a/tasmota/tasmota.ino +++ b/tasmota/tasmota.ino @@ -157,6 +157,7 @@ bool spi_flg = false; // SPI configured bool soft_spi_flg = false; // Software SPI configured bool ntp_force_sync = false; // Force NTP sync bool ntp_synced_message = false; // NTP synced message flag +bool is_8285 = false; // Hardware device ESP8266EX (0) or ESP8285 (1) myio my_module; // Active copy of Module GPIOs (17 x 8 bits) gpio_flag my_module_flag; // Active copy of Template GPIO flags StateBitfield global_state; // Global states (currently Wifi and Mqtt) (8 bits) @@ -1591,6 +1592,7 @@ void setup(void) snprintf_P(my_hostname, sizeof(my_hostname)-1, Settings.hostname); } + GetEspHardwareType(); GpioInit(); SetSerialBaudrate(baudrate);