Chat freely about anything...

User avatar
By craigfoo
#48710 I'm successfully using the ESP8266httpUpdate library for OTA updates using a remote server. The current firmware can grab the new .bin file and restart with the new file perfectly. Is there a way to have a default version of firmware stored on the ESP8266 just in case the new OTA firmware mucks something up?

This is the basic memory layout for OTA updates:

Image

I'm wondering if I'd be able to store a default version or even a previous version in the same memory space. Then I would be able to use a button to roll back the firmware in case the new firmware mucked something up where it can't connect to get another firmware update. Can this be done?
User avatar
By Me-no-dev
#48720 It can be done if you save the current sketch to SPIFFS before flashing the one over it, then from the new sketch have it able to read the file and flash it just like OTA.
User avatar
By craigfoo
#48724 This suggestion makes sense. I'm following along in the ESP8266httpUpdate library trying to see where it saves the current sketch to SPIFFS but I'm not sure where this is happening. Any hints?

So if I saved the current .bin file to SPIFFS, could I start a HTTP server on the device and connect to itself ?

Maybe something like this?
ESPhttpUpdate.update(http://esp8266.local/firmware.bin)

Or is that what ESP8266HTTPUpdate::updateSpiffs does?
User avatar
By Me-no-dev
#48748 There isn't currently example on the steps that you need to take but they are something like that:
1. Upload a new sketch(OTA, HTTPUpdater...)
2. If upload successful, read the current sketch to a file on SPIFFS
3. Reboot to apply the new sketch
.......
You decide to revert:
Instead of uploading and flashing that way, read the saved sketch and flash it using the Updater class (same one used for the OTA stuff)