I am creating a project that uses an ESP8266 in a situation where I can never access it again (will be given to someone else) once completed. I am adding in OTA firmware upload methods (based on the HTTPWebUpdateServer examples) that will allow this user to upload firmware updates I can email to them.
In the event that I bodge some part of the firmware, where the device boots up but then gets stuck, can someone point me to a way where I can store and recall a previous or initial firmware image to load to fix the buggy one? (Aside from the implementation details, I have hardware pushbuttons that could be used to start this process, but if there's a foolproof automatic one that might be nicer)
My initial thought was to use SPIFFS, and upload the data to it at the same time as I send it to the Update class, but I'm not sure how to get the data back out. The bootloader does not speak SPIFFS, but I could pipe the data out of SPIFFS to the Update class to initiate an "OTA" flash from the onboard data (though I'm not sure how to do this in practice, so advice would be nice).
My device is a NodeMCU with 4M of flash, so space is not an issue here.
Of course, this does not actually help, since it would backup the image being uploaded, not the previous. Then I'm just stuck with two buggy images. How might I back up the executing flash from the SPI chip to SPIFFS instead? If that's not possible, how do I get versioning working so that it keeps the n-1th upgrade and not the most recent?
I also recently saw this page (https://www.esp32.com/viewtopic.php?t=3645) which mentions a "factory" partition. If that works how it sounds, how do I:
- create a custom partition layout?
- get the "original" firmware placed there?
- trigger a restore of the firmware from it?