I enjoyed the thread that Balto had going about using an existing SPM in the BL section to update the BL section.
I've read that some have suggested updating an available BL area and then using that to update the entire BL, but that would count on the BL section having some available room.
If all that is needed as SPM/RET, couldn't a bootloader be written to make sure there is this opcode pair combination on every page in the BL? Let's take a 4 page small BL for example, you would then have 4 opportunities to call SPM in the BL, right?
A fully automated process to update both the BL and APP sections might go something like this:
Apparently indenting does not work, wrapping this in a code section instead:
#1 Trigger the bootloader in the device and power it (into bootloader mode) Query the BL to get both the BL and APP versions. If the BL version is old: Use the existing BL to flash an APP that is not the APP, but a program to update the BL (version on it set to 0.00) Reset it to allow the APP to run and update the BL. Wait the appropriate amount of time or make the APP indicate when it is done, then reset and start at #1. If the AP version is old: Use the BL to update it. When done, then reset and start at #1. The BL updater APP could simply read each BL page and flash it if it does not match what it needs to flash it to. It could run multiple times and only flash what is necessary. It could be smart enough to scan the BL area and look for the SPM/RTN combination so that if one page was flashed badly, it would still have a way to proceed by using SPM/RTN pairs from another page that still works.
Any thoughts on whether this would work or not? I know a BL should be bug free from day one, but it would be cool to have a way to update it if need be...