aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mediatek/mt7623
diff options
context:
space:
mode:
authorDaniel Golle <daniel@makrotopia.org>2021-11-12 11:50:26 +0000
committerDaniel Golle <daniel@makrotopia.org>2021-11-12 15:03:02 +0000
commitc3c67fe7b1fbfc9b08e1a2d056b120aa63ef4145 (patch)
tree2f0af24b485efd8741a6cf676d52c0cacfc5f73b /target/linux/mediatek/mt7623
parent0cbc6b16db8ce03a522b9acb49ea46cc2134697a (diff)
downloadupstream-c3c67fe7b1fbfc9b08e1a2d056b120aa63ef4145.tar.gz
upstream-c3c67fe7b1fbfc9b08e1a2d056b120aa63ef4145.tar.bz2
upstream-c3c67fe7b1fbfc9b08e1a2d056b120aa63ef4145.zip
mediatek: mt7623: re-write sysupgrade uImage.FIT on MMC
Re-reading the partition table doesn't work reliably, it fails if anything on the device is still in use and it's not trivial to prevent every possible case of a block device still being in use somehow. Therefore, instead of relying on the in-kernel partition parser to know where to write the configuration backup, use OpenWrt's format-agnostic fwtool to strip off all metadata from the image and count its blocks while writing. In that way we can know where to write the config backup without needing the kernel to parse the MBR and FIT structures. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Diffstat (limited to 'target/linux/mediatek/mt7623')
-rwxr-xr-xtarget/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh27
-rw-r--r--target/linux/mediatek/mt7623/target.mk2
2 files changed, 13 insertions, 16 deletions
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 29c4bf1e03..0afc15afc9 100755
--- a/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/mt7623/base-files/lib/upgrade/platform.sh
@@ -1,6 +1,6 @@
REQUIRE_IMAGE_METADATA=1
-RAMFS_COPY_BIN='blockdev'
+RAMFS_COPY_BIN='fwtool'
# Full system upgrade including preloader for MediaTek SoCs on eMMC or SD
mtk_mmc_full_upgrade() {
@@ -84,19 +84,14 @@ platform_do_upgrade() {
case "$board" in
bananapi,bpi-r2)
+ sync
export_bootdevice
- export_partdevice rootdev 0
- blockdev --rereadpt /dev/$rootdev || return 1
export_partdevice fitpart 3
[ "$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
+ export UPGRADE_MMC_PARTDEV="/dev/$fitpart"
+ 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
;;
unielec,u7623-02-emmc-512m)
@@ -172,10 +167,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/mt7623/target.mk b/target/linux/mediatek/mt7623/target.mk
index ad05367f86..cc5ff3f27d 100644
--- a/target/linux/mediatek/mt7623/target.mk
+++ b/target/linux/mediatek/mt7623/target.mk
@@ -9,7 +9,7 @@ CPU_TYPE:=cortex-a7
CPU_SUBTYPE:=neon-vfpv4
KERNELNAME:=Image dtbs zImage
FEATURES+=display usbgadget
-DEFAULT_PACKAGES+=blockdev uboot-envtools
+DEFAULT_PACKAGES+=uboot-envtools
define Target/Description
Build firmware images for MediaTek mt7623 ARM based boards.