Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32: pass flashmode at build time to macro definition #19299

Merged
merged 2 commits into from
Aug 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pio-tools/add_c_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
env.Append(CXXFLAGS=["-Wno-volatile"])
5 changes: 5 additions & 0 deletions pio-tools/pre_source_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
18 changes: 18 additions & 0 deletions tasmota/include/tasmota_globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
\*********************************************************************************************/
Expand Down Expand Up @@ -118,6 +135,7 @@ String EthernetMacAddress(void);
/*-------------------------------------------------------------------------------------------*\
* End ESP32 specific parameters
\*-------------------------------------------------------------------------------------------*/

/*-------------------------------------------------------------------------------------------*\
* Start ESP32-C32 specific parameters - disable features not present in ESP32-C3
\*-------------------------------------------------------------------------------------------*/
Expand Down
4 changes: 2 additions & 2 deletions tasmota/tasmota_support/support_command.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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\":"));
Expand Down
19 changes: 0 additions & 19 deletions tasmota/tasmota_support/support_esp.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tasmota/tasmota_xdrv_driver/xdrv_01_9_webserver.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down