diff --git a/pio-tools/add_c_flags.py b/pio-tools/add_c_flags.py index 020a77f82a68..40d8a3937abb 100644 --- a/pio-tools/add_c_flags.py +++ b/pio-tools/add_c_flags.py @@ -4,4 +4,4 @@ env.Append(CFLAGS=["-Wno-discarded-qualifiers", "-Wno-implicit-function-declaration"]) # General options that are passed to the C++ compiler -env.Append(CXXFLAGS=["-Wno-volatile"]) \ No newline at end of file +env.Append(CXXFLAGS=["-Wno-volatile"]) diff --git a/pio-tools/pre_source_dir.py b/pio-tools/pre_source_dir.py index 6027d2ba9628..8ff1e8753f54 100644 --- a/pio-tools/pre_source_dir.py +++ b/pio-tools/pre_source_dir.py @@ -10,3 +10,8 @@ def FindInoNodes(env): ) env.AddMethod(FindInoNodes) + +# Pass flashmode at build time to macro +tasmota_flash_mode = "-DCONFIG_TASMOTA_FLASHMODE_" + (env.BoardConfig().get("build.flash_mode", "dio")).upper() +env.Append(CXXFLAGS=[tasmota_flash_mode]) +print(tasmota_flash_mode) diff --git a/tasmota/include/tasmota_globals.h b/tasmota/include/tasmota_globals.h index ae6ec9a706d4..a6f964e77331 100644 --- a/tasmota/include/tasmota_globals.h +++ b/tasmota/include/tasmota_globals.h @@ -69,6 +69,23 @@ String EthernetMacAddress(void); #include "include/tasmota_configurations.h" // Preconfigured configurations +/*-------------------------------------------------------------------------------------------*\ + * ESP8266 and ESP32 build time definitions +\*-------------------------------------------------------------------------------------------*/ + +// created in pio-tools/pre_source_dir.py +#if defined(CONFIG_TASMOTA_FLASHMODE_QIO) + #define D_TASMOTA_FLASHMODE "QIO" +#elif defined(CONFIG_TASMOTA_FLASHMODE_QOUT) + #define D_TASMOTA_FLASHMODE "QOUT" +#elif defined(CONFIG_TASMOTA_FLASHMODE_DIO) + #define D_TASMOTA_FLASHMODE "DIO" +#elif defined(CONFIG_TASMOTA_FLASHMODE_DOUT) + #define D_TASMOTA_FLASHMODE "DOUT" +#else +#error "Please add missing flashmode definition in the lines above!" // could be upcoming octal modes +#endif // value check of CONFIG_TASMOTA_FLASHMODE + /*********************************************************************************************\ * ESP8266 specific parameters \*********************************************************************************************/ @@ -118,6 +135,7 @@ String EthernetMacAddress(void); /*-------------------------------------------------------------------------------------------*\ * End ESP32 specific parameters \*-------------------------------------------------------------------------------------------*/ + /*-------------------------------------------------------------------------------------------*\ * Start ESP32-C32 specific parameters - disable features not present in ESP32-C3 \*-------------------------------------------------------------------------------------------*/ diff --git a/tasmota/tasmota_support/support_command.ino b/tasmota/tasmota_support/support_command.ino index 40be1cf49122..d074df54e369 100644 --- a/tasmota/tasmota_support/support_command.ino +++ b/tasmota/tasmota_support/support_command.ino @@ -829,7 +829,7 @@ void CmndStatus(void) #endif // ESP32 D_JSON_PROGRAMFLASHSIZE "\":%d,\"" D_JSON_FLASHSIZE "\":%d" ",\"" D_JSON_FLASHCHIPID "\":\"%06X\"" - ",\"FlashFrequency\":%d,\"" D_JSON_FLASHMODE "\":\"%s\""), + ",\"FlashFrequency\":%d,\"" D_JSON_FLASHMODE "\":\"" D_TASMOTA_FLASHMODE "\""), ESP_getSketchSize()/1024, ESP_getFreeSketchSpace()/1024, ESP_getFreeHeap1024(), #ifdef ESP32 uxTaskGetStackHighWaterMark(nullptr) / 1024, ESP.getPsramSize()/1024, ESP.getFreePsram()/1024, @@ -839,7 +839,7 @@ void CmndStatus(void) ESP_getFlashChipSize()/1024, ESP.getFlashChipRealSize()/1024 #endif // ESP8266 , ESP_getFlashChipId() - , ESP.getFlashChipSpeed()/1000000, ESP_getFlashChipMode().c_str()); + , ESP.getFlashChipSpeed()/1000000); ResponseAppendFeatures(); XsnsDriverState(); ResponseAppend_P(PSTR(",\"Sensors\":")); diff --git a/tasmota/tasmota_support/support_esp.ino b/tasmota/tasmota_support/support_esp.ino index c7d284ae7010..fb353bb65c29 100644 --- a/tasmota/tasmota_support/support_esp.ino +++ b/tasmota/tasmota_support/support_esp.ino @@ -1171,25 +1171,6 @@ float ESP_getFreeHeap1024(void) { } */ -const char kFlashModes[] PROGMEM = "QIO|QOUT|DIO|DOUT|Fast|Slow"; -/* -typedef enum { - FM_QIO = 0x00, - FM_QOUT = 0x01, - FM_DIO = 0x02, - FM_DOUT = 0x03, - FM_FAST_READ = 0x04, - FM_SLOW_READ = 0x05, - FM_UNKNOWN = 0xff -} FlashMode_t; -*/ -String ESP_getFlashChipMode(void) { - uint32_t flash_mode = ESP.getFlashChipMode(); - if (flash_mode > 5) { flash_mode = 3; } - char stemp[6]; - return GetTextIndexed(stemp, sizeof(stemp), flash_mode, kFlashModes); -} - /*********************************************************************************************\ * High entropy hardware random generator * Thanks to DigitalAlchemist diff --git a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino index 54c477c7bdfc..31339e392304 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino @@ -2465,7 +2465,7 @@ void HandleInformation(void) WSContentSend_P(PSTR("}1}2 ")); // Empty line WSContentSend_P(PSTR("}1" D_ESP_CHIP_ID "}2%d (%s)"), ESP_getChipId(), GetDeviceHardwareRevision().c_str()); - WSContentSend_P(PSTR("}1" D_FLASH_CHIP_ID "}20x%06X (%s)"), ESP_getFlashChipId(), ESP_getFlashChipMode().c_str()); + WSContentSend_P(PSTR("}1" D_FLASH_CHIP_ID "}20x%06X (" D_TASMOTA_FLASHMODE ")"), ESP_getFlashChipId()); #ifdef ESP32 WSContentSend_P(PSTR("}1" D_FLASH_CHIP_SIZE "}2%d KB"), ESP.getFlashChipSize() / 1024); WSContentSend_P(PSTR("}1" D_PROGRAM_FLASH_SIZE "}2%d KB"), ESP_getFlashChipMagicSize() / 1024);