[openwrt/openwrt] mediatek: make sure MMC is not busy before commencing sysupgrade

LEDE Commits lede-commits at lists.infradead.org
Thu Oct 28 08:29:31 PDT 2021


dangole pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/4ae4035e6012c19a5f2931025c09f29d1c1939ae

commit 4ae4035e6012c19a5f2931025c09f29d1c1939ae
Author: Daniel Golle <daniel at makrotopia.org>
AuthorDate: Wed Oct 27 15:30:39 2021 +0100

    mediatek: make sure MMC is not busy before commencing sysupgrade
    
    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 at makrotopia.org>
---
 target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh | 1 +
 target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh | 1 +
 2 files changed, 2 insertions(+)

diff --git a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
index 0cdd8df8f9..513741d667 100755
--- a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
@@ -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
diff --git a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh
index 4564bc61dd..11da6314dc 100755
--- a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh
@@ -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



More information about the lede-commits mailing list