target/rockchip: supports istoreos upgrade
This commit is contained in:
parent
754c73115f
commit
d07bff2a66
@ -1,16 +0,0 @@
|
||||
move_config() {
|
||||
local partdev
|
||||
|
||||
. /lib/upgrade/common.sh
|
||||
|
||||
if export_bootdevice && export_partdevice partdev 1; then
|
||||
if mount -o rw,noatime "/dev/$partdev" /mnt; then
|
||||
if [ -f "/mnt/$BACKUP_FILE" ]; then
|
||||
mv -f "/mnt/$BACKUP_FILE" /
|
||||
fi
|
||||
umount /mnt
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
boot_hook_add preinit_mount_root move_config
|
||||
@ -1,12 +1,17 @@
|
||||
# modified by jjm2473
|
||||
# 1. keep overlay partition when upgrade
|
||||
# 2. reset rom uuid in ext_overlay (aka sandbox mode) when upgrade (stage2:istoreos_pre_upgrade)
|
||||
|
||||
REQUIRE_IMAGE_METADATA=1
|
||||
|
||||
platform_check_image() {
|
||||
local diskdev partdev diff
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
v "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
[ "$SAVE_CONFIG" -eq 1 ] && return 0
|
||||
|
||||
get_partitions "/dev/$diskdev" bootdisk
|
||||
|
||||
@ -21,47 +26,47 @@ platform_check_image() {
|
||||
rm -f /tmp/image.bs /tmp/partmap.bootdisk /tmp/partmap.image
|
||||
|
||||
if [ -n "$diff" ]; then
|
||||
echo "Partition layout has changed. Full image will be written."
|
||||
v "Partition layout has changed. Full image will be written."
|
||||
ask_bool 0 "Abort" && exit 1
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
platform_copy_config() {
|
||||
local partdev
|
||||
|
||||
if export_partdevice partdev 1; then
|
||||
mount -o rw,noatime "/dev/$partdev" /mnt
|
||||
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
|
||||
umount /mnt
|
||||
fi
|
||||
}
|
||||
|
||||
platform_do_upgrade() {
|
||||
local diskdev partdev diff
|
||||
|
||||
export_bootdevice && export_partdevice diskdev 0 || {
|
||||
echo "Unable to determine upgrade device"
|
||||
v "Unable to determine upgrade device"
|
||||
return 1
|
||||
}
|
||||
|
||||
sync
|
||||
|
||||
if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then
|
||||
get_partitions "/dev/$diskdev" bootdisk
|
||||
if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" -o -n "$UPGRADE_BACKUP" ]; then
|
||||
[ -n "$UPGRADE_BACKUP" ] || get_partitions "/dev/$diskdev" bootdisk
|
||||
|
||||
#extract the boot sector from the image
|
||||
get_image "$@" | dd of=/tmp/image.bs count=1 bs=512b
|
||||
|
||||
get_partitions /tmp/image.bs image
|
||||
|
||||
#compare tables
|
||||
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
|
||||
if [ -n "$UPGRADE_BACKUP" ]; then
|
||||
#keep overlay partition when upgrade
|
||||
diff=
|
||||
else
|
||||
#compare tables
|
||||
diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)"
|
||||
fi
|
||||
else
|
||||
diff=1
|
||||
fi
|
||||
|
||||
if [ -n "$diff" ]; then
|
||||
grep /overlay /proc/mounts > /dev/null && {
|
||||
/bin/mount -o noatime,remount,ro /overlay
|
||||
/usr/bin/umount -R -d -l /overlay 2>/dev/null || /bin/umount -l /overlay
|
||||
}
|
||||
|
||||
get_image "$@" | dd of="/dev/$diskdev" bs=4096 conv=fsync
|
||||
|
||||
# Separate removal and addtion is necessary; otherwise, partition 1
|
||||
@ -74,15 +79,23 @@ platform_do_upgrade() {
|
||||
|
||||
#iterate over each partition from the image and write it to the boot disk
|
||||
while read part start size; do
|
||||
if [ -n "$UPGRADE_BACKUP" -a "$part" -ge 3 ]; then
|
||||
v "Skip partition $part >= 3 when upgrading"
|
||||
continue
|
||||
fi
|
||||
if export_partdevice partdev $part; then
|
||||
echo "Writing image to /dev/$partdev..."
|
||||
get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
|
||||
v "Writing image to /dev/$partdev..."
|
||||
if [ "$part" -eq 3 ]; then
|
||||
echo "RESET000" | dd of="/dev/$partdev" bs=512 count=1 conv=sync,fsync 2>/dev/null
|
||||
else
|
||||
get_image "$@" | dd of="/dev/$partdev" ibs="512" obs=1M skip="$start" count="$size" conv=fsync
|
||||
fi
|
||||
else
|
||||
echo "Unable to find partition $part device, skipped."
|
||||
v "Unable to find partition $part device, skipped."
|
||||
fi
|
||||
done < /tmp/partmap.image
|
||||
|
||||
#copy partition uuid
|
||||
echo "Writing new UUID to /dev/$diskdev..."
|
||||
v "Writing new UUID to /dev/$diskdev..."
|
||||
get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ define Build/pine64-img
|
||||
# http://opensource.rock-chips.com/wiki_Boot_option#Boot_flow
|
||||
#
|
||||
# U-Boot SPL expects the U-Boot ITB to be located at sector 0x4000 (8 MiB) on the MMC storage
|
||||
PADDING=1 $(SCRIPT_DIR)/gen_image_generic.sh \
|
||||
$(SCRIPT_DIR)/gen_image_generic.sh \
|
||||
$@ \
|
||||
$(CONFIG_TARGET_KERNEL_PARTSIZE) $@.boot \
|
||||
$(CONFIG_TARGET_ROOTFS_PARTSIZE) $(IMAGE_ROOTFS) \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user