2
votes

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?

1
"I always keep two images on the FLASH" -- I would improve upon that scheme by storing the kernel and dtb images as files in a /boot directory in the rootfs. Then you get flash wear-leveling, updates are nondestructive to previous versions, and can have more than just two versions. The vulnerability to power failure is reduced to just a few rename operations instead of the entire update procedure.sawdust
@sawdust This is a great advice. Thank you!Larytet

1 Answers

1
votes

Yes. Use Uboot's bootcount feature. It increments every boot retry. and is supposed to be cleared by an application on the filesystem after the kernel was booted. If it reached a a threshold. you can then boot another image from uboot.