mirror of https://github.com/arendst/Tasmota.git
parent
e965daa7b5
commit
7b10bec8fe
|
@ -536,17 +536,24 @@ void SettingsLoad(void)
|
|||
void SettingsErase(uint8_t type)
|
||||
{
|
||||
/*
|
||||
0 = Erase from program end until end of physical flash
|
||||
1 = Erase SDK parameter area at end of linker memory model (0x0FDxxx - 0x0FFFFF) solving possible wifi errors
|
||||
2 = Erase Tasmota settings
|
||||
Erase only works from flash start address to SDK recognized flash end address (flashchip->chip_size = ESP.getFlashChipSize).
|
||||
Addresses above SDK recognized size (up to ESP.getFlashChipRealSize) are not accessable.
|
||||
The only way to erase whole flash is esptool which uses direct SPI writes to flash.
|
||||
|
||||
0 = Erase from program end until end of flash as seen by SDK
|
||||
1 = Erase 16k SDK parameter area near end of flash as seen by SDK (0x0xFCxxx - 0x0xFFFFF) solving possible wifi errors
|
||||
2 = Erase Tasmota settings (0x0xF4xxx - 0x0xFBFFF)
|
||||
*/
|
||||
|
||||
#ifndef FIRMWARE_MINIMAL
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("SDK: Flash size 0x%08X"), flashchip->chip_size);
|
||||
|
||||
uint32_t _sectorStart = (ESP.getSketchSize() / SPI_FLASH_SEC_SIZE) + 1;
|
||||
uint32_t _sectorEnd = ESP.getFlashChipRealSize() / SPI_FLASH_SEC_SIZE;
|
||||
// uint32_t _sectorEnd = ESP.getFlashChipRealSize() / SPI_FLASH_SEC_SIZE;
|
||||
uint32_t _sectorEnd = ESP.getFlashChipSize() / SPI_FLASH_SEC_SIZE;
|
||||
if (1 == type) {
|
||||
_sectorStart = SETTINGS_LOCATION +2; // SDK parameter area above EEPROM area (0x0FDxxx - 0x0FFFFF)
|
||||
_sectorEnd = SETTINGS_LOCATION +5;
|
||||
// source Esp.cpp and core_esp8266_phy.cpp
|
||||
_sectorStart = (ESP.getFlashChipSize() / SPI_FLASH_SEC_SIZE) - 4;
|
||||
}
|
||||
else if (2 == type) {
|
||||
_sectorStart = SETTINGS_LOCATION - CFG_ROTATES; // Tasmota parameter area (0x0F4xxx - 0x0FBFFF)
|
||||
|
@ -565,7 +572,7 @@ void SettingsErase(uint8_t type)
|
|||
if (result) {
|
||||
Serial.println(F(" " D_OK));
|
||||
} else {
|
||||
Serial.println(F(" " D_ERROR));
|
||||
Serial.println(F(" " D_ERROR)); //
|
||||
}
|
||||
delay(10);
|
||||
}
|
||||
|
@ -574,24 +581,10 @@ void SettingsErase(uint8_t type)
|
|||
#endif // FIRMWARE_MINIMAL
|
||||
}
|
||||
|
||||
// Copied from 2.4.0 as 2.3.0 is incomplete
|
||||
bool SettingsEraseConfig(void) {
|
||||
const size_t cfgSize = 0x4000;
|
||||
size_t cfgAddr = ESP.getFlashChipSize() - cfgSize;
|
||||
|
||||
for (size_t offset = 0; offset < cfgSize; offset += SPI_FLASH_SEC_SIZE) {
|
||||
if (!ESP.flashEraseSector((cfgAddr + offset) / SPI_FLASH_SEC_SIZE)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void SettingsSdkErase(void)
|
||||
{
|
||||
WiFi.disconnect(true); // Delete SDK wifi config
|
||||
SettingsErase(1);
|
||||
SettingsEraseConfig();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
|
|
|
@ -612,6 +612,20 @@ char* GetPowerDevice(char* dest, uint32_t idx, size_t size)
|
|||
return GetPowerDevice(dest, idx, size, 0);
|
||||
}
|
||||
|
||||
String GetDeviceHardware(void)
|
||||
{
|
||||
// esptool.py get_efuses
|
||||
uint32_t efuse1 = *(uint32_t*)(0x3FF00050);
|
||||
uint32_t efuse2 = *(uint32_t*)(0x3FF00054);
|
||||
// uint32_t efuse3 = *(uint32_t*)(0x3FF00058);
|
||||
// uint32_t efuse4 = *(uint32_t*)(0x3FF0005C);
|
||||
|
||||
// AddLog_P2(LOG_LEVEL_DEBUG, PSTR("FUS: efuses 0x%08X 0x%08X, name %s"), efuse1, efuse2);
|
||||
|
||||
bool is_8285 = ( (efuse1 & (1 << 4)) || (efuse2 & (1 << 16)) );
|
||||
return String((is_8285) ? F("ESP8285") : F("ESP8266EX"));
|
||||
}
|
||||
|
||||
float ConvertTemp(float c)
|
||||
{
|
||||
float result = c;
|
||||
|
|
|
@ -369,9 +369,10 @@ void CmndStatus(void)
|
|||
|
||||
if ((0 == payload) || (2 == payload)) {
|
||||
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS2_FIRMWARE "\":{\"" D_JSON_VERSION "\":\"%s%s\",\"" D_JSON_BUILDDATETIME "\":\"%s\",\""
|
||||
D_JSON_BOOTVERSION "\":%d,\"" D_JSON_COREVERSION "\":\"" ARDUINO_ESP8266_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\"}}"),
|
||||
D_JSON_BOOTVERSION "\":%d,\"" D_JSON_COREVERSION "\":\"" ARDUINO_ESP8266_RELEASE "\",\"" D_JSON_SDKVERSION "\":\"%s\","
|
||||
"\"Hardware\":\"%s\"}}"),
|
||||
my_version, my_image, GetBuildDateAndTime().c_str(),
|
||||
ESP.getBootVersion(), ESP.getSdkVersion());
|
||||
ESP.getBootVersion(), ESP.getSdkVersion(), GetDeviceHardware().c_str());
|
||||
MqttPublishPrefixTopic_P(option, PSTR(D_CMND_STATUS "2"));
|
||||
}
|
||||
|
||||
|
|
|
@ -618,6 +618,3 @@ void EspRestart(void)
|
|||
// ESP.restart(); // This results in exception 3 on restarts on core 2.3.0
|
||||
ESP.reset();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue