aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-11-12 14:54:52 +0000
committerDaniel Golle <daniel@makrotopia.org>2021-11-12 15:03:07 +0000
commit8fd0268b5f346fba26329c73225c3c425f2658eb (patch)
treedb3c7bf3d9519d30d15c7db1b85feb37001fed2e /target
parentc3c67fe7b1fbfc9b08e1a2d056b120aa63ef4145 (diff)
downloadupstream-8fd0268b5f346fba26329c73225c3c425f2658eb.tar.gz
upstream-8fd0268b5f346fba26329c73225c3c425f2658eb.tar.bz2
upstream-8fd0268b5f346fba26329c73225c3c425f2658eb.zip
mediatek: mt7622: bpi-r64: rewrite MMC uImage.FIT sysupgrade
Similar to mt7623, also no longer use 'blockdev' and stop relying on in-kernel partition parsers. Instead, strip off all metadata using 'fwtool' while writing the firmware image and scrape the number of blocks written from 'dd', then use that block offset to stash the configuration backup. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'target')
-rwxr-xr-xtarget/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh29
-rw-r--r--target/linux/mediatek/mt7622/target.mk2
2 files changed, 14 insertions, 17 deletions
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 98775c6a13..b9fa055854 100755
--- a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
@@ -1,5 +1,5 @@
REQUIRE_IMAGE_METADATA=1
-RAMFS_COPY_BIN='fw_printenv fw_setenv blockdev'
+RAMFS_COPY_BIN='fw_printenv fw_setenv fwtool'
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
platform_do_upgrade() {
@@ -12,17 +12,12 @@ platform_do_upgrade() {
export_partdevice rootdev 0
case "$rootdev" in
mmc*)
- blockdev --rereadpt /dev/$rootdev || return 1
- local fitpart=$(find_mmc_part "production" $rootdev)
- [ "$fitpart" ] || return 1
- dd if=/dev/zero of=$fitpart bs=4096 count=1 2>/dev/null
- blockdev --rereadpt /dev/$rootdev
- get_image "$1" | dd of=$fitpart
- blockdev --rereadpt /dev/$rootdev
- local datapart=$(find_mmc_part "rootfs_data" $rootdev)
- [ "$datapart" ] || return 0
- dd if=/dev/zero of=$datapart bs=4096 count=1 2>/dev/null
- echo $datapart > /tmp/sysupgrade.datapart
+ sync
+ export UPGRADE_MMC_PARTDEV=$(find_mmc_part "production" $rootdev)
+ [ "$UPGRADE_MMC_PARTDEV" ] || return 1
+ export UPGRADE_MMC_IMAGE_BLOCKS=$(($(get_image "$1" | fwtool -i /dev/null -T - | dd of=$UPGRADE_MMC_PARTDEV bs=512 2>&1 | grep "records out" | cut -d' ' -f1)))
+ [ "$UPGRADE_MMC_IMAGE_BLOCKS" ] || return 0
+ dd if=/dev/zero of=$UPGRADE_MMC_PARTDEV bs=512 seek=$UPGRADE_MMC_IMAGE_BLOCKS count=8
;;
*)
CI_KERNPART="fit"
@@ -92,10 +87,12 @@ platform_check_image() {
}
platform_copy_config_mmc() {
- [ -e "$UPGRADE_BACKUP" ] || return
- local datapart=$(cat /tmp/sysupgrade.datapart)
- [ "$datapart" ] || echo "no rootfs_data partition, cannot keep configuration." >&2
- dd if="$UPGRADE_BACKUP" of=$datapart
+ if [ ! -e "$UPGRADE_BACKUP" ] ||
+ [ ! -e "$UPGRADE_MMC_PARTDEV" ] ||
+ [ ! "$UPGRADE_MMC_IMAGE_BLOCKS" ]; then
+ return
+ fi
+ dd if="$UPGRADE_BACKUP" of="$UPGRADE_MMC_PARTDEV" bs=512 seek=$UPGRADE_MMC_IMAGE_BLOCKS
sync
}
diff --git a/target/linux/mediatek/mt7622/target.mk b/target/linux/mediatek/mt7622/target.mk
index 5403bf5f87..92c3f47370 100644
--- a/target/linux/mediatek/mt7622/target.mk
+++ b/target/linux/mediatek/mt7622/target.mk
@@ -2,7 +2,7 @@ ARCH:=aarch64
SUBTARGET:=mt7622
BOARDNAME:=MT7622
CPU_TYPE:=cortex-a53
-DEFAULT_PACKAGES += kmod-mt7615e kmod-mt7615-firmware wpad-basic-wolfssl blockdev uboot-envtools
+DEFAULT_PACKAGES += kmod-mt7615e kmod-mt7615-firmware wpad-basic-wolfssl uboot-envtools
KERNELNAME:=Image dtbs
define Target/Description