mediatek: make sure MMC is not busy before commencing sysupgrade
authorDaniel Golle <daniel@makrotopia.org>
Wed, 27 Oct 2021 14:30:39 +0000 (15:30 +0100)
committerDaniel Golle <daniel@makrotopia.org>
Thu, 28 Oct 2021 15:27:27 +0000 (16:27 +0100)
In case of the block device still being in use, re-reading the
partition table fails. In that case, abort sysupgrade to avoid
corrupting the just-written image because of wrong offsets caused
by failure to re-read the partition table.

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh

index 0cdd8df8f99ef7981c391d6898b99b1606711b87..513741d6672863a0458acc179dae16c6893c79f7 100755 (executable)
@@ -12,6 +12,7 @@ platform_do_upgrade() {
                export_partdevice rootdev 0
                case "$rootdev" in
                mmc*)
+                       blockdev --rereadpt /dev/$rootdev || return 1
                        local fitpart=$(get_partition_by_name $rootdev "production")
                        [ "$fitpart" ] || return 1
                        dd if=/dev/zero of=/dev/$fitpart bs=4096 count=1 2>/dev/null
index 4564bc61dd499b3e3a5de8058617119b851f8d24..11da6314dce4f8ead85fb55b763e7b0c002f502e 100755 (executable)
@@ -86,6 +86,7 @@ platform_do_upgrade() {
        bananapi,bpi-r2)
                export_bootdevice
                export_partdevice rootdev 0
+               blockdev --rereadpt /dev/$rootdev || return 1
                export_partdevice fitpart 3
                [ "$fitpart" ] || return 1
                dd if=/dev/zero of=/dev/$fitpart bs=4096 count=1 2>/dev/null