From 7698178b90569a96281e1a2616f7b55b70f11afb Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 7 Nov 2022 15:00:47 +0100 Subject: [PATCH] Update ESP8285 device detection --- tasmota/tasmota_support/support_esp.ino | 51 ++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/tasmota/tasmota_support/support_esp.ino b/tasmota/tasmota_support/support_esp.ino index 9f9e8cfde..9fa5c87cf 100644 --- a/tasmota/tasmota_support/support_esp.ino +++ b/tasmota/tasmota_support/support_esp.ino @@ -98,7 +98,7 @@ void *special_calloc(size_t num, size_t size) { return calloc(num, size); } -String GetDeviceHardware(void) { +String GetDeviceHardwareOld(void) { // esptool.py get_efuses uint32_t efuse1 = *(uint32_t*)(0x3FF00050); uint32_t efuse2 = *(uint32_t*)(0x3FF00054); @@ -118,6 +118,55 @@ String GetDeviceHardware(void) { return F("ESP8266EX"); } +String GetDeviceHardware(void) { + /* + ESP8266 SoCs + - 32-bit MCU & 2.4 GHz Wi-Fi + - High-performance 160 MHz single-core CPU + - +19.5 dBm output power ensures a good physical range + - Sleep current is less than 20 μA, making it suitable for battery-powered and wearable-electronics applications + - Peripherals include UART, GPIO, I2C, I2S, SDIO, PWM, ADC and SPI + */ + // esptool.py get_efuses + uint32_t efuse0 = *(uint32_t*)(0x3FF00050); +// uint32_t efuse1 = *(uint32_t*)(0x3FF00054); + uint32_t efuse2 = *(uint32_t*)(0x3FF00058); + uint32_t efuse3 = *(uint32_t*)(0x3FF0005C); + + bool r0_4 = efuse0 & (1 << 4); // ESP8285 + bool r2_16 = efuse2 & (1 << 16); // ESP8285 + if (r0_4 || r2_16) { // ESP8285 + // 1M 2M 2M 4M + // r0_4 1 1 0 0 + bool r3_25 = efuse3 & (1 << 25); // ESP8285 flash matrix 0 0 1 1 + bool r3_26 = efuse3 & (1 << 26); // ESP8285 flash matrix 0 1 0 1 + bool r3_27 = efuse3 & (1 << 27); // ESP8285 flash matrix 0 0 0 0 + uint32_t pkg_version = 0; + if (!r3_27) { + if (r0_4 && !r3_25) { + pkg_version = (r3_26) ? 2 : 1; + } + else if (!r0_4 && r3_25) { + pkg_version = (r3_26) ? 4 : 2; + } + } + bool max_temp = efuse0 & (1 << 5); // Max flash temperature (0 = 85C, 1 = 105C) + switch (pkg_version) { + case 1: + if (max_temp) { return F("ESP8285H08"); } // 1M flash + else { return F("ESP8285N08"); } + case 2: + if (max_temp) { return F("ESP8285H16"); } // 2M flash + else { return F("ESP8285N16"); } + case 4: + if (max_temp) { return F("ESP8285H32"); } // 4M flash + else { return F("ESP8285N32"); } + } + return F("ESP8285"); + } + return F("ESP8266EX"); +} + String GetDeviceHardwareRevision(void) { // No known revisions for ESP8266/85 return GetDeviceHardware();