diff options
author | Yangbo Lu <yangbo.lu@nxp.com> | 2020-05-28 16:02:28 +0800 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2020-07-11 14:44:23 +0200 |
commit | 0841b68c91d3536dffc4aca67a58adf37720be6d (patch) | |
tree | 18f25ac5c15d278d4f124b64fa8efe9a4bbcfc3b /target/linux/layerscape/base-files | |
parent | c4d0e57e160e9d5c9ada8c99e385cdd5f742e79e (diff) | |
download | upstream-0841b68c91d3536dffc4aca67a58adf37720be6d.tar.gz upstream-0841b68c91d3536dffc4aca67a58adf37720be6d.tar.bz2 upstream-0841b68c91d3536dffc4aca67a58adf37720be6d.zip |
layerscape: support sysupgrade for SD card ext4 rootfs
Support sysupgrade for SD card ext4 rootfs.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Diffstat (limited to 'target/linux/layerscape/base-files')
-rw-r--r-- | target/linux/layerscape/base-files/lib/upgrade/platform.sh | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/target/linux/layerscape/base-files/lib/upgrade/platform.sh b/target/linux/layerscape/base-files/lib/upgrade/platform.sh index 9b8c07138f..8a136d9439 100644 --- a/target/linux/layerscape/base-files/lib/upgrade/platform.sh +++ b/target/linux/layerscape/base-files/lib/upgrade/platform.sh @@ -8,6 +8,85 @@ RAMFS_COPY_DATA="/etc/fw_env.config /var/lock/fw_printenv.lock" REQUIRE_IMAGE_METADATA=1 +platform_check_image_sdboot() { + local diskdev partdev diff + + export_bootdevice && export_partdevice diskdev 0 || { + echo "Unable to determine upgrade device" + return 1 + } + + # get partitions table from boot device + get_partitions "/dev/$diskdev" bootdisk + + # get partitions table from sysupgrade.bin + dd if="$1" of=/tmp/image.bs bs=512b count=1 > /dev/null 2>&1 + sync + get_partitions /tmp/image.bs image + + # compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.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." + ask_bool 0 "Abort" && exit 1 + return 0 + fi +} +platform_do_upgrade_sdboot() { + local diskdev partdev diff + + export_bootdevice && export_partdevice diskdev 0 || { + echo "Unable to determine upgrade device" + return 1 + } + + if [ "$UPGRADE_OPT_SAVE_PARTITIONS" = "1" ]; then + # get partitions table from boot device + get_partitions "/dev/$diskdev" bootdisk + + # get partitions table from sysupgrade.bin + dd if="$1" of=/tmp/image.bs bs=512b count=1 > /dev/null 2>&1 + sync + get_partitions /tmp/image.bs image + + # compare tables + diff="$(grep -F -x -v -f /tmp/partmap.bootdisk /tmp/partmap.image)" + else + diff=1 + fi + + if [ -n "$diff" ]; then + dd if="$1" of="/dev/$diskdev" bs=1024 count=4 > /dev/null 2>&1 + dd if="$1" of="$diskdev" bs=1024 skip=4 seek=16384 > /dev/null 2>&1 + sync + + # Separate removal and addtion is necessary; otherwise, partition 1 + # will be missing if it overlaps with the old partition 2 + partx -d - "/dev/$diskdev" + partx -a - "/dev/$diskdev" + + return 0 + fi + + # write kernel image + dd if="$1" of="$diskdev" bs=1024 skip=4 seek=16384 count=16384 > /dev/null 2>&1 + sync + + # iterate over each partition from the image and write it to the boot disk + while read part start size; do + if export_partdevice partdev $part; then + echo "Writing image to /dev/$partdev..." + dd if="$1" of="/dev/$partdev" bs=512 skip="$start" count="$size" > /dev/null 2>&1 + sync + else + echo "Unable to find partition $part device, skipped." + fi + done < /tmp/partmap.image + +} platform_do_upgrade_traverse_nandubi() { bootsys=$(fw_printenv bootsys | awk -F= '{{print $2}}') newbootsys=2 @@ -25,6 +104,15 @@ platform_do_upgrade_traverse_nandubi() { nand_do_upgrade "$1" || (echo "Upgrade failed, setting bootsys ${bootsys}" && fw_setenv bootsys $bootsys) } +platform_copy_config() { + local partdev parttype=ext4 + + if export_partdevice partdev 1; then + mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt + cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE" + umount /mnt + fi +} platform_check_image() { local board=$(board_name) @@ -43,6 +131,14 @@ platform_check_image() { fsl,ls2088a-rdb) return 0 ;; + fsl,ls1012a-frwy-sdboot | \ + fsl,ls1021a-twr-sdboot | \ + fsl,ls1043a-rdb-sdboot | \ + fsl,ls1046a-rdb-sdboot | \ + fsl,ls1088a-rdb-sdboot) + platform_check_image_sdboot "$1" + return 0 + ;; *) echo "Sysupgrade is not currently supported on $board" ;; @@ -72,6 +168,14 @@ platform_do_upgrade() { PART_NAME=firmware default_do_upgrade "$1" ;; + fsl,ls1012a-frwy-sdboot | \ + fsl,ls1021a-twr-sdboot | \ + fsl,ls1043a-rdb-sdboot | \ + fsl,ls1046a-rdb-sdboot | \ + fsl,ls1088a-rdb-sdboot) + platform_do_upgrade_sdboot "$1" + return 0 + ;; *) echo "Sysupgrade is not currently supported on $board" ;; |