(05-07-2020, 09:35 AM)lupyuen Wrote: Yep I'll be supporting External SPI Flash for storing the Standby Firmware Image... But first I will have to make MCUBoot work with Internal Flash :-)Both?
MCUBoot currently supports only 2 Firmware Images: Active and Standby. The new firmware image is downloaded directly into the Standby slot. After downloading the new firmware, MCUBoot swaps the Active and Standby images. The swap also happens when rolling back to the previous firmware.
Is this good enough? Or do we need 3 images?
![Big Grin Big Grin](https://forum.pine64.org/images/smilies/biggrin.png)
I definitely don't think any quibbles about the recovery partition should be allowed to slow down any kind of proof-of-concept development. The only thing I think that should be done at the proof-of-concept stage is to reserve the space for it in the default SPI flash layout: repartitioning flash devices always results in more pain than you think it will... so better to reserve the space early.
Nevertheless I do think it will be needed in the long term. mcuboot is based around active/standby images but they did have to accept reality and also offer a UART based loader system (the BOOT SERIAL mode) to cope with emergencies such as both images being inoperable (e.g. a bug that prevents boot but has been dormant until after the point it exists in both images). The PineTime cannot implement BOOT SERIAL mode so I think a third boot slot is useful to handle emergencies. The code should be very simple because it will nothing except copy the recovery image to the application slot overwriting whatever is there. No slot exchange, no backing up slot 0, just a couple of files from nrfx and maybe 150 lines of C.
PS If you are getting to grips with how to write to flash then take a look at the tool I use for OTA updates to wasp-bootloader since it ends up as an example of how easy using nrfx is. Some of the nrfx drivers can't be used from a bootloader but the nrfx driver for the NVM has a liberal software license, minimal dependencies and doesn't use interrupts makes into super easy to integrate:
https://github.com/daniel-thompson/wasp-...lash.c#L31
Oh yes... and if you want to reuse anything from wasp-os (the code to put up a splash screen in the bootloader for example) then let me know. I'm happy both to clean it up for reuse and to relicense if needed.