I have a u-boot which copies a multiimage (Linux kernel+rootfs+dts) from a serial FLASH to the DDR. The device is remotely powered. The device requires fail safe remote firmware upgrade which survives power failure. I always keep two images on the FLASH. While I write a new firmware to the FLASH there is always another, older, firmware image on the FLASH. U-boot after power up shall boot the most recent firmware.
Boot time is important, but not critical. For example, I thought to let u-boot to boot the first "valid" image. A Linux application would decide if a reboot is required and modify u-boot environment.
I can patch u-boot - add a command which finds the most recent firmware on the FLASH. I would expect that somebody somewhere already solved this problem and likely better than me. Is there a patch/script for u-boot which allows to automatically choose the latest firmware based on some metadata?
Any other approaches to the problem?