In this scenario, the biggest problem is updating the bootloader, which cannot do this type of fallback.
Generally people avoid updating the bootloader (for good reason) but it is necessary sometimes...
Worst case scenario is if the system does come up enough for the hardware watchdog to get kicked in a timely manner, but nothing else works.
The watchdog needs to be the last initialized bit of code on the system.
Even so, determining when a partition is "bad" is hard.
An 8 MB (64 megabits) SPI flash chip[1] is about $2. Two jumpers to power the SPI flash and set the boot/load option is another 3 - 4 cents. These take up less than 30 sq mm of board space. And they give you a tremendous back up in case of failure.
[1] http://www.mouser.com/Semiconductors/Memory/Flash-Memory/_/N...
All of the ARM chips I'm playing with these days have a serial boot loader in ROM that you can get to by setting a pin on the CPU and powering it up that way. In such a scenario it would take no extra parts.
I believe they emulate or copy the system used by FPGAs to read a configuration from a dedicated SPI chip. Its well understood and a lot of tools can program the SPI chip to have the right sequence of bits in it to do the right thing.
If I were designing a system with OTA updates, then I would design something like this with it for this very reason.
Also, no update should be carried out unless the user initiated it - for instance, a flashing led or an app notification tells the user an update is available - and it needs to be initiated by using the same controls as would be used for a roll-back, ensuring you do not end up locked out after updating.
That being said, the idea of a lock being online scares the bejeezus out of me. Call me a luddite, but as a minimum I want my burglars or vandals to show up, rather than nessing with me from wherever.
Well they can't be burglars if they never show up :p
Now that I think about it, I hope these devices are validating the certificate of publisher and the updates are signed.
You're joking right? Really, the vast majority of this iot stuff is ridiculously bad in this respect. Plain text data transfer, unsigned updates from any source based on a text message and so on. It's a disaster waiting to happen.
> from which a signed payload can be loaded
All updates should be digitally signed by the lock manufacturer
While software mistakes do happen, it seems any moron these days thinks they can put out an IoT product because they know how to flash a led on Arduino and they make no effort whatsoever in thinking how to make their devices have minimum reliability
Have a user accessible USB port (from the inside) from which a signed payload can be loaded for cases like these. Would have saved several days for their customers and several shipping fees.