Look into partition table changes
I would like to update the partition table to take some space away from the coredump partition (it is bigger than necessary) in order to create a partition for SPIFFS storage. The idea is to get things like user settings off of the SD card, since we support hotswap now. Also can do some fun things like storing custom menu backgrounds (scrolling text on the main menu causes them to be read over and over, loading from SD would not be feasible)
For new builds this is easy enough, we just update the partition layout. Trouble is we need to update existing players that have been built, through the normal firmware update process, without making them tether to a PC or anything. My plan to do that is to actually not modify it during fw update, but to do it upon first boot into the new OS version.
Modifying the partition table from esp-idf is not supported but there's no technical reason it isn't possible. It's just a region in flash like anything else.
The most straightforward solution I have thought of (and I did some digging around online) is to just store binary copies of the original and new partition tables. Upon update, check if the current table matches, if so replace it, if not then cancel the update. This will be a complicated dance but we can make it work within the existing firmware update process, we will just need to be careful to avoid breaking anything (for example, a failed update to the new partition table version should NOT prevent downgrading to older firmware... in fact even after a successful update you should still be able to downgrade).
- Everything in esp-idf is referenced by partition type. So we can add new partitions (SPIFFS) without breaking old ones (Coredump, OTA0, OTA1). This means we can downgrade all the way back to 0.90 even when on the new partition table.
- Firmware update process is not modified from current.
- Upon first boot into the new OS, it will check the partition table against the known-good old one. If it matches, write and verify the new one, then reboot so the OS picks it up. If it doesn't match, do nothing, just continue boot and run normally...
- Since access to this would be through the normal VFS stuff, there are actually minimal changes required to support both partition table versions. If there is no SPIFFS partition then use
/sd/.mega/optionsfilewhatever
, if there is then use/spiffs/.mega/optionfilewhatever
. - If we have the new partition table, and there is no options file in SPIFFS, import it from the card during boot.
If anyone sees issues with this or has any better ideas I would love to hear them.