mirror of https://github.com/arendst/Tasmota.git
Merge pull request #706 from arendst/revert-705-OTA-RemoveFlashMode
Revert "Ota remove flash mode"
This commit is contained in:
commit
3fea292e16
122
README.md
122
README.md
|
@ -1,61 +1,61 @@
|
||||||
## Sonoff-Tasmota
|
## Sonoff-Tasmota
|
||||||
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
Provide ESP8266 based Sonoff by [iTead Studio](https://www.itead.cc/) and ElectroDragon IoT Relay with Serial, Web and MQTT control allowing 'Over the Air' or OTA firmware updates using Arduino IDE.
|
||||||
|
|
||||||
Current version is **5.5.1b** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
Current version is **5.5.1a** - See [sonoff/_releasenotes.ino](https://github.com/arendst/Sonoff-Tasmota/blob/master/sonoff/_releasenotes.ino) for change information.
|
||||||
|
|
||||||
### ATTENTION All versions
|
### ATTENTION All versions
|
||||||
|
|
||||||
Only Flash Mode DOUT is supported. Do not use Flash Mode DIO / QIO / QOUT as it might seem to brick your device.
|
Only Flash Mode DOUT is supported. Do not use Flash Mode DIO / QIO / QOUT as it might seem to brick your device.
|
||||||
|
|
||||||
See [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki/Theo's-Tasmota-Tips) for background information.
|
See [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki/Theo's-Tasmota-Tips) for background information.
|
||||||
|
|
||||||
### ATTENTION Version 5.x.x specific information
|
### ATTENTION Version 5.x.x specific information
|
||||||
|
|
||||||
This version uses a new linker script to free flash memory for future code additions. It moves the settings from Spiffs to Eeprom. If you compile your own firmware download the new linker to your IDE or Platformio base folder. See [Wiki > Prerequisite](https://github.com/arendst/Sonoff-Tasmota/wiki/Prerequisite).
|
This version uses a new linker script to free flash memory for future code additions. It moves the settings from Spiffs to Eeprom. If you compile your own firmware download the new linker to your IDE or Platformio base folder. See [Wiki > Prerequisite](https://github.com/arendst/Sonoff-Tasmota/wiki/Prerequisite).
|
||||||
|
|
||||||
Best practice to implement is:
|
Best practice to implement is:
|
||||||
- Open the webpage to your device
|
- Open the webpage to your device
|
||||||
- Perform option ``Backup Configuration``
|
- Perform option ``Backup Configuration``
|
||||||
- Upgrade new firmware using ``Firmware upgrade``
|
- Upgrade new firmware using ``Firmware upgrade``
|
||||||
- If configuration conversion fails keep the webpage open and perform ``Restore Configuration``
|
- If configuration conversion fails keep the webpage open and perform ``Restore Configuration``
|
||||||
|
|
||||||
You should now have a device with 32k more code memory to play with.
|
You should now have a device with 32k more code memory to play with.
|
||||||
|
|
||||||
### Version Information
|
### Version Information
|
||||||
|
|
||||||
- This version provides all (Sonoff) modules in one file and starts up with Sonoff Basic.
|
- This version provides all (Sonoff) modules in one file and starts up with Sonoff Basic.
|
||||||
- Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```.
|
- Once uploaded select module using the configuration webpage or the commands ```Modules``` and ```Module```.
|
||||||
- After reboot select config menu again or use commands ```GPIOs``` and ```GPIO``` to change GPIO with desired sensor.
|
- After reboot select config menu again or use commands ```GPIOs``` and ```GPIO``` to change GPIO with desired sensor.
|
||||||
|
|
||||||
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoffbasic.jpg" width="250" align="right" />
|
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoffbasic.jpg" width="250" align="right" />
|
||||||
|
|
||||||
See [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki) for more information.<br />
|
See [Wiki](https://github.com/arendst/Sonoff-Tasmota/wiki) for more information.<br />
|
||||||
See [Community](https://groups.google.com/d/forum/sonoffusers) for forum and more user experience.
|
See [Community](https://groups.google.com/d/forum/sonoffusers) for forum and more user experience.
|
||||||
|
|
||||||
The following devices are supported:
|
The following devices are supported:
|
||||||
- [iTead Sonoff Basic](http://sonoff.itead.cc/en/products/sonoff/sonoff-basic)
|
- [iTead Sonoff Basic](http://sonoff.itead.cc/en/products/sonoff/sonoff-basic)
|
||||||
- [iTead Sonoff RF](http://sonoff.itead.cc/en/products/sonoff/sonoff-rf)
|
- [iTead Sonoff RF](http://sonoff.itead.cc/en/products/sonoff/sonoff-rf)
|
||||||
- [iTead Sonoff SV](https://www.itead.cc/sonoff-sv.html)<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoff_th.jpg" width="250" align="right" />
|
- [iTead Sonoff SV](https://www.itead.cc/sonoff-sv.html)<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoff_th.jpg" width="250" align="right" />
|
||||||
- [iTead Sonoff TH10/TH16 with temperature sensor](http://sonoff.itead.cc/en/products/sonoff/sonoff-th)
|
- [iTead Sonoff TH10/TH16 with temperature sensor](http://sonoff.itead.cc/en/products/sonoff/sonoff-th)
|
||||||
- [iTead Sonoff Dual](http://sonoff.itead.cc/en/products/sonoff/sonoff-dual)
|
- [iTead Sonoff Dual](http://sonoff.itead.cc/en/products/sonoff/sonoff-dual)
|
||||||
- [iTead Sonoff Pow](http://sonoff.itead.cc/en/products/sonoff/sonoff-pow)
|
- [iTead Sonoff Pow](http://sonoff.itead.cc/en/products/sonoff/sonoff-pow)
|
||||||
- [iTead Sonoff 4CH](http://sonoff.itead.cc/en/products/sonoff/sonoff-4ch)
|
- [iTead Sonoff 4CH](http://sonoff.itead.cc/en/products/sonoff/sonoff-4ch)
|
||||||
- [iTead Sonoff 4CH Pro](http://sonoff.itead.cc/en/products/sonoff/sonoff-4ch-pro)
|
- [iTead Sonoff 4CH Pro](http://sonoff.itead.cc/en/products/sonoff/sonoff-4ch-pro)
|
||||||
- [iTead S20 Smart Socket](http://sonoff.itead.cc/en/products/residential/s20-socket)
|
- [iTead S20 Smart Socket](http://sonoff.itead.cc/en/products/residential/s20-socket)
|
||||||
- [iTead Slampher](http://sonoff.itead.cc/en/products/residential/slampher-rf)
|
- [iTead Slampher](http://sonoff.itead.cc/en/products/residential/slampher-rf)
|
||||||
- [iTead Sonoff Touch](http://sonoff.itead.cc/en/products/residential/sonoff-touch)
|
- [iTead Sonoff Touch](http://sonoff.itead.cc/en/products/residential/sonoff-touch)
|
||||||
- [iTead Sonoff SC](http://sonoff.itead.cc/en/products/residential/sonoff-sc)
|
- [iTead Sonoff SC](http://sonoff.itead.cc/en/products/residential/sonoff-sc)
|
||||||
- [iTead Sonoff Led](http://sonoff.itead.cc/en/products/appliances/sonoff-led)
|
- [iTead Sonoff Led](http://sonoff.itead.cc/en/products/appliances/sonoff-led)
|
||||||
- [iTead Sonoff BN-SZ01 Ceiling Led](http://sonoff.itead.cc/en/products/appliances/bn-sz01)
|
- [iTead Sonoff BN-SZ01 Ceiling Led](http://sonoff.itead.cc/en/products/appliances/bn-sz01)
|
||||||
- [iTead Sonoff RF Bridge 433](http://sonoff.itead.cc/en/products/appliances/sonoff-rf-bridge-433)
|
- [iTead Sonoff RF Bridge 433](http://sonoff.itead.cc/en/products/appliances/sonoff-rf-bridge-433)
|
||||||
- [iTead Sonoff Dev](https://www.itead.cc/sonoff-dev.html)
|
- [iTead Sonoff Dev](https://www.itead.cc/sonoff-dev.html)
|
||||||
- [iTead 1 Channel Switch 5V / 12V](https://www.itead.cc/smart-home/inching-self-locking-wifi-wireless-switch.html)
|
- [iTead 1 Channel Switch 5V / 12V](https://www.itead.cc/smart-home/inching-self-locking-wifi-wireless-switch.html)
|
||||||
- [iTead Motor Clockwise/Anticlockwise](https://www.itead.cc/smart-home/motor-reversing-wifi-wireless-switch.html)
|
- [iTead Motor Clockwise/Anticlockwise](https://www.itead.cc/smart-home/motor-reversing-wifi-wireless-switch.html)
|
||||||
- [Electrodragon IoT Relay Board](http://www.electrodragon.com/product/wifi-iot-relay-board-based-esp8266/)
|
- [Electrodragon IoT Relay Board](http://www.electrodragon.com/product/wifi-iot-relay-board-based-esp8266/)
|
||||||
|
|
||||||
Planned support:
|
Planned support:
|
||||||
- [iTead Sonoff T1](http://sonoff.itead.cc/en/products/residential/sonoff-t1)
|
- [iTead Sonoff T1](http://sonoff.itead.cc/en/products/residential/sonoff-t1)
|
||||||
- [iTead Sonoff B1](http://sonoff.itead.cc/en/products/residential/sonoff-b1)
|
- [iTead Sonoff B1](http://sonoff.itead.cc/en/products/residential/sonoff-b1)
|
||||||
|
|
||||||
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonofftoucheu.jpg" height="280" align="left" />
|
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonofftoucheu.jpg" height="280" align="left" />
|
||||||
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoff4ch.jpg" height="250" align="right" />
|
<img src="https://github.com/arendst/arendst.github.io/blob/master/media/sonoff4ch.jpg" height="250" align="right" />
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
/* 5.5.1b
|
/* 5.5.1a
|
||||||
* Extent max number of WS2812 pixels from 256 to 512 (#667)
|
* Extent max number of WS2812 pixels from 256 to 512 (#667)
|
||||||
* Add OTA handling if server responds with no update available (#695)
|
|
||||||
* Removed undocumented command FlashMode (#696)
|
|
||||||
* Fix compile time error message due to increased message buffer size (#703)
|
|
||||||
*
|
*
|
||||||
* 5.5.1 20170805
|
* 5.5.1 20170805
|
||||||
* Fix Sonoff Rf Bridge issues
|
* Fix Sonoff Rf Bridge issues
|
||||||
|
@ -897,4 +894,4 @@
|
||||||
* 1.0.5 20160310
|
* 1.0.5 20160310
|
||||||
* Initial public release
|
* Initial public release
|
||||||
* Show debug info by selecting option from IDE Tools Debug port: Serial
|
* Show debug info by selecting option from IDE Tools Debug port: Serial
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -141,23 +141,33 @@ uint32_t _cfgLocation = CFG_LOCATION;
|
||||||
/*
|
/*
|
||||||
* Based on cores/esp8266/Updater.cpp
|
* Based on cores/esp8266/Updater.cpp
|
||||||
*/
|
*/
|
||||||
void setFlashModeDout()
|
void setFlashMode(byte option, byte mode)
|
||||||
{
|
{
|
||||||
|
char log[LOGSZ];
|
||||||
uint8_t *_buffer;
|
uint8_t *_buffer;
|
||||||
uint32_t address;
|
uint32_t address;
|
||||||
|
|
||||||
eboot_command ebcmd;
|
// option 0 - Use absolute address 0
|
||||||
eboot_command_read(&ebcmd);
|
// option 1 - Use OTA/Upgrade relative address
|
||||||
address = ebcmd.args[0];
|
|
||||||
|
if (option) {
|
||||||
|
eboot_command ebcmd;
|
||||||
|
eboot_command_read(&ebcmd);
|
||||||
|
address = ebcmd.args[0];
|
||||||
|
} else {
|
||||||
|
address = 0;
|
||||||
|
}
|
||||||
_buffer = new uint8_t[FLASH_SECTOR_SIZE];
|
_buffer = new uint8_t[FLASH_SECTOR_SIZE];
|
||||||
if (SPI_FLASH_RESULT_OK == spi_flash_read(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE)) {
|
if (SPI_FLASH_RESULT_OK == spi_flash_read(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE)) {
|
||||||
if (_buffer[2] != 3) { // DOUT
|
if (_buffer[2] != mode) {
|
||||||
_buffer[2] = 3;
|
_buffer[2] = mode &3;
|
||||||
noInterrupts();
|
noInterrupts();
|
||||||
if (SPI_FLASH_RESULT_OK == spi_flash_erase_sector(address / FLASH_SECTOR_SIZE)) {
|
if (SPI_FLASH_RESULT_OK == spi_flash_erase_sector(address / FLASH_SECTOR_SIZE)) {
|
||||||
spi_flash_write(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE);
|
spi_flash_write(address, (uint32_t*)_buffer, FLASH_SECTOR_SIZE);
|
||||||
}
|
}
|
||||||
interrupts();
|
interrupts();
|
||||||
|
snprintf_P(log, sizeof(log), PSTR("FLSH: Set Flash Mode to %d"), (option) ? mode : ESP.getFlashChipMode());
|
||||||
|
addLog(LOG_LEVEL_DEBUG, log);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delete[] _buffer;
|
delete[] _buffer;
|
||||||
|
@ -719,4 +729,4 @@ void CFG_Delta()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
- Select IDE Tools - Flash Size: "1M (no SPIFFS)"
|
||||||
====================================================*/
|
====================================================*/
|
||||||
|
|
||||||
#define VERSION 0x05050102 // 5.5.1b
|
#define VERSION 0x05050101 // 5.5.1a
|
||||||
|
|
||||||
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
|
enum log_t {LOG_LEVEL_NONE, LOG_LEVEL_ERROR, LOG_LEVEL_INFO, LOG_LEVEL_DEBUG, LOG_LEVEL_DEBUG_MORE, LOG_LEVEL_ALL};
|
||||||
enum week_t {Last, First, Second, Third, Fourth};
|
enum week_t {Last, First, Second, Third, Fourth};
|
||||||
|
@ -1282,6 +1282,14 @@ void mqttDataCb(char* topic, byte* data, unsigned int data_len)
|
||||||
}
|
}
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Sleep\":\"%d%s (%d%s)\"}"), sleep, (sysCfg.flag.value_units) ? " mS" : "", sysCfg.sleep, (sysCfg.flag.value_units) ? " mS" : "");
|
snprintf_P(svalue, sizeof(svalue), PSTR("{\"Sleep\":\"%d%s (%d%s)\"}"), sleep, (sysCfg.flag.value_units) ? " mS" : "", sysCfg.sleep, (sysCfg.flag.value_units) ? " mS" : "");
|
||||||
}
|
}
|
||||||
|
else if (!strcmp_P(type,PSTR("FLASHMODE"))) { // 0 = QIO, 1 = QOUT, 2 = DIO, 3 = DOUT
|
||||||
|
if ((payload >= 0) && (payload <= 3)) {
|
||||||
|
if (ESP.getFlashChipMode() != payload) {
|
||||||
|
setFlashMode(0, payload &3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
snprintf_P(svalue, sizeof(svalue), PSTR("{\"FlashMode\":%d}"), ESP.getFlashChipMode());
|
||||||
|
}
|
||||||
else if (!strcmp_P(type,PSTR("UPGRADE")) || !strcmp_P(type,PSTR("UPLOAD"))) {
|
else if (!strcmp_P(type,PSTR("UPGRADE")) || !strcmp_P(type,PSTR("UPLOAD"))) {
|
||||||
// Check if the payload is numerically 1, and had no trailing chars.
|
// Check if the payload is numerically 1, and had no trailing chars.
|
||||||
// e.g. "1foo" or "1.2.3" could fool us.
|
// e.g. "1foo" or "1.2.3" could fool us.
|
||||||
|
@ -2380,21 +2388,21 @@ void stateloop()
|
||||||
if (otaretry) {
|
if (otaretry) {
|
||||||
// snprintf_P(log, sizeof(log), PSTR("OTA: Attempt %d"), OTA_ATTEMPTS - otaretry);
|
// snprintf_P(log, sizeof(log), PSTR("OTA: Attempt %d"), OTA_ATTEMPTS - otaretry);
|
||||||
// addLog(LOG_LEVEL_INFO, log);
|
// addLog(LOG_LEVEL_INFO, log);
|
||||||
otaok = (HTTP_UPDATE_FAILED != ESPhttpUpdate.update(sysCfg.otaUrl));
|
otaok = (HTTP_UPDATE_OK == ESPhttpUpdate.update(sysCfg.otaUrl));
|
||||||
if (!otaok) {
|
if (!otaok) {
|
||||||
otaflag = 2;
|
otaflag = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (90 == otaflag) { // Allow MQTT to reconnect
|
if (90 == otaflag) { // Allow MQTT to reconnect
|
||||||
otaflag = 0;
|
otaflag = 0;
|
||||||
if (otaok) {
|
if (otaok) {
|
||||||
setFlashModeDout(); // Force DOUT for both ESP8266 and ESP8285
|
setFlashMode(1, 3); // DOUT for both ESP8266 and ESP8285
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("Successful. Restarting"));
|
snprintf_P(svalue, sizeof(svalue), PSTR("Successful. Restarting"));
|
||||||
} else {
|
} else {
|
||||||
snprintf_P(svalue, sizeof(svalue), PSTR("Failed %s"), ESPhttpUpdate.getLastErrorString().c_str());
|
snprintf_P(svalue, sizeof(svalue), PSTR("Failed %s"), ESPhttpUpdate.getLastErrorString().c_str());
|
||||||
}
|
}
|
||||||
restartflag = 2; // Restart anyway to keep memory clean webserver
|
restartflag = 2; // Restart anyway to keep memory clean webserver
|
||||||
mqtt_publish_topic_P(1, PSTR("UPGRADE"), svalue);
|
mqtt_publish_topic_P(1, PSTR("UPGRADE"), svalue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2868,4 +2876,4 @@ void loop()
|
||||||
|
|
||||||
// yield(); // yield == delay(0), delay contains yield, auto yield in loop
|
// yield(); // yield == delay(0), delay contains yield, auto yield in loop
|
||||||
delay(sleep); // https://github.com/esp8266/Arduino/issues/2021
|
delay(sleep); // https://github.com/esp8266/Arduino/issues/2021
|
||||||
}
|
}
|
||||||
|
|
|
@ -1245,7 +1245,7 @@ void handleUploadLoop()
|
||||||
_uploaderror = 4;
|
_uploaderror = 4;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
upload.buf[2] = 3; // Force DOUT - ESP8285
|
upload.buf[2] = 3; // Force DOUT - ESP8285
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_uploadfiletype) { // config
|
if (_uploadfiletype) { // config
|
||||||
|
@ -1615,4 +1615,4 @@ boolean isIp(String str)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // USE_WEBSERVER
|
#endif // USE_WEBSERVER
|
||||||
|
|
Loading…
Reference in New Issue