diff --git a/tasmota/settings.h b/tasmota/settings.h index 075759b71..6ab5aa7de 100644 --- a/tasmota/settings.h +++ b/tasmota/settings.h @@ -521,18 +521,24 @@ typedef struct { uint8_t ex_switchmode[8]; // 3A4 - Free since 9.2.0.6 - myio my_gp; // 3AC 2 x 18 bytes (ESP8266) / 2 x 40 bytes (ESP32) + myio my_gp; // 3AC 2 x 18 bytes (ESP8266) / 2 x 40 bytes (ESP32) / 2 x 22 bytes (ESP32-C3) #ifdef ESP8266 uint16_t gpio16_converted; // 3D0 uint8_t free_esp8266_3D2[42]; // 3D2 -#endif - mytmplt user_template; // 3FC 2 x 15 bytes (ESP8266) / 2 x 37 bytes (ESP32) -#ifdef ESP8266 - - uint8_t free_esp8266_41A[55]; // 41A - #endif // ESP8266 #ifdef ESP32 +#ifdef CONFIG_IDF_TARGET_ESP32C3 + uint8_t free_esp32c3_3D8[36]; // 3D8 - Due to smaller myio +#endif // CONFIG_IDF_TARGET_ESP32C3 +#endif // ESP32 + mytmplt user_template; // 3FC 2 x 15 bytes (ESP8266) / 2 x 37 bytes (ESP32) / 2 x 23 bytes (ESP32-C3) +#ifdef ESP8266 + uint8_t free_esp8266_41A[55]; // 41A +#endif // ESP8266 +#ifdef ESP32 +#ifdef CONFIG_IDF_TARGET_ESP32C3 + uint8_t free_esp32c3_42A[28]; // 42A - Due to smaller mytmplt +#endif // CONFIG_IDF_TARGET_ESP32C3 uint8_t eth_type; // 446 uint8_t eth_clk_mode; // 447 diff --git a/tasmota/settings.ino b/tasmota/settings.ino index 5569f2deb..3afdcab17 100644 --- a/tasmota/settings.ino +++ b/tasmota/settings.ino @@ -657,6 +657,7 @@ void SettingsLoad(void) { #ifndef FIRMWARE_MINIMAL if ((0 == settings_location) || (Settings->cfg_holder != (uint16_t)CFG_HOLDER)) { // Init defaults if cfg_holder differs from user settings in my_user_config.h +// if ((0 == settings_location) || (Settings->cfg_size != sizeof(TSettings)) || (Settings->cfg_holder != (uint16_t)CFG_HOLDER)) { // Init defaults if cfg_holder differs from user settings in my_user_config.h #ifdef USE_UFILESYS if (TfsLoadFile(TASM_FILE_SETTINGS_LKG, (uint8_t*)Settings, sizeof(TSettings)) && (Settings->cfg_crc32 == GetSettingsCrc32())) { settings_location = 1; @@ -1361,6 +1362,19 @@ void SettingsDelta(void) { Settings->mqtt_wifi_timeout = MQTT_WIFI_CLIENT_TIMEOUT / 100; } +#ifdef CONFIG_IDF_TARGET_ESP32C3 + if (Settings->version < 0x09050002) { + if (Settings->cfg_size != sizeof(TSettings)) { + // Fix onetime Settings layout due to changed ESP32-C3 myio and mytmplt types sizes + memmove_P((uint8_t*)&Settings->user_template, (uint8_t*)&Settings->free_esp32c3_3D8, sizeof(TSettings) - 0x3FC); + memmove_P((uint8_t*)&Settings->eth_type, (uint8_t*)&Settings->free_esp32c3_42A, sizeof(TSettings) - 0x446); + // Reset for future use + memset(&Settings->free_esp32c3_3D8, 0x00, sizeof(Settings->free_esp32c3_3D8)); + memset(&Settings->free_esp32c3_42A, 0x00, sizeof(Settings->free_esp32c3_42A)); + } + } +#endif + Settings->version = VERSION; SettingsSave(1); } diff --git a/tasmota/tasmota_version.h b/tasmota/tasmota_version.h index 6c969103b..ce1a6e095 100644 --- a/tasmota/tasmota_version.h +++ b/tasmota/tasmota_version.h @@ -20,6 +20,6 @@ #ifndef _TASMOTA_VERSION_H_ #define _TASMOTA_VERSION_H_ -const uint32_t VERSION = 0x09050001; +const uint32_t VERSION = 0x09050002; #endif // _TASMOTA_VERSION_H_