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() {
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"
}
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
}