imx: make sdcard/eMMC sysupgrade more resilient
authorLech Perczak <lech.perczak@gmail.com>
Thu, 28 Apr 2022 21:32:12 +0000 (23:32 +0200)
committerPiotr Dymacz <pepe2k@gmail.com>
Mon, 11 Jul 2022 12:18:40 +0000 (14:18 +0200)
Ensure, that kernel update is performed atomically on filesystem, to
reduce likelihood of failure if power-cut occurs during sysupgrade. If
kernel update fails for whatever reason, skip updating rootfs as well.

Signed-off-by: Lech Perczak <lech.perczak@gmail.com>
target/linux/imx/base-files/lib/imx.sh

index a451de3779ee0c1fadec48a19982c30adff298ec..9c692357588ec45445627d9a80878471f53731f0 100644 (file)
@@ -41,9 +41,12 @@ imx_sdcard_do_upgrade() {
        board_dir="${board_dir%/}"
 
        imx_sdcard_mount_boot
-       get_image "$1" | tar Oxf - ${board_dir}/kernel > /boot/uImage
-       get_image "$1" | tar Oxf - ${board_dir}/root > $(rootpart_from_uuid)
-       sync
+       get_image "$1" | tar Oxf - ${board_dir}/kernel > /boot/uImage-new && \
+               mv /boot/uImage-new /boot/uImage && \
+               sync && \
+               get_image "$1" | tar Oxf - ${board_dir}/root > $(rootpart_from_uuid) && \
+               sync
+
        umount /boot
 }