From 7cbdd409b570bb35ab3e1326a08169144814835e Mon Sep 17 00:00:00 2001 From: Christian Baars Date: Sun, 21 Aug 2022 20:22:39 +0200 Subject: [PATCH] fix wrong flashmode report --- tasmota/tasmota_support/support_esp.ino | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tasmota/tasmota_support/support_esp.ino b/tasmota/tasmota_support/support_esp.ino index c29552cc0..608313b1b 100644 --- a/tasmota/tasmota_support/support_esp.ino +++ b/tasmota/tasmota_support/support_esp.ino @@ -121,6 +121,8 @@ String GetDeviceHardwareRevision(void) { #ifdef ESP32 #include "bootloader_flash.h" +#include "soc/soc.h" +#include "soc/spi_reg.h" // ESP32_ARCH contains the name of the architecture (used by autoconf) #if CONFIG_IDF_TARGET_ESP32 #ifdef CORE32SOLO1 @@ -981,7 +983,26 @@ typedef enum { } FlashMode_t; */ String ESP_getFlashChipMode(void) { +#if ESP8266 uint32_t flash_mode = ESP.getFlashChipMode(); +#else + uint32_t spi_ctrl = REG_READ(SPI_CTRL_REG(0)); + uint32_t flash_mode; + /* Not all of the following constants are already defined in older versions of spi_reg.h, so do it manually for now*/ + if (spi_ctrl & BIT(24)) { //SPI_FREAD_QIO + flash_mode = 0; + } else if (spi_ctrl & BIT(20)) { //SPI_FREAD_QUAD + flash_mode = 1; + } else if (spi_ctrl & BIT(23)) { //SPI_FREAD_DIO + flash_mode = 2; + } else if (spi_ctrl & BIT(14)) { // SPI_FREAD_DUAL + flash_mode = 3; + } else if (spi_ctrl & BIT(13)) { //SPI_FASTRD_MODE + flash_mode = 4; + } else { + flash_mode = 5; + } +#endif if (flash_mode > 5) { flash_mode = 3; } char stemp[6]; return GetTextIndexed(stemp, sizeof(stemp), flash_mode, kFlashModes);