diff options
author | Pawel Dembicki <paweldembicki@gmail.com> | 2020-08-24 14:29:32 +0200 |
---|---|---|
committer | Adrian Schmutzler <freifunk@adrianschmutzler.de> | 2020-10-26 00:40:12 +0100 |
commit | a254279a6c3048feb83909649c41ee4a7d37ec93 (patch) | |
tree | bc6d544a7d45fbf6f7362f28289c1d94dd894e38 /target/linux/layerscape/base-files/lib/upgrade | |
parent | c51f8030b623e03567a73fbcedc4ee69a8896688 (diff) | |
download | upstream-a254279a6c3048feb83909649c41ee4a7d37ec93.tar.gz upstream-a254279a6c3048feb83909649c41ee4a7d37ec93.tar.bz2 upstream-a254279a6c3048feb83909649c41ee4a7d37ec93.zip |
layerscape: Change to combined rootfs on sd images
At this moment layerscape images are ext4 only. It causes problem with
save changes durring sysupgrade and make "firstboot" and failsafe mode
useless.
This patch changes sd-card images to squashfs + f2fs combined images.
To make place, for saving config, kernel space ar now ext4 partition
with fit kernel.
This method of image generation is similar to rest of OpenWrt sd-card
targets.
Reviewed-by: Yangbo Lu <yangbo.lu@nxp.com>
Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
[reword README, reword DEVICE_COMPAT_MESSAGE, keep original indent]
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux/layerscape/base-files/lib/upgrade')
-rw-r--r-- | target/linux/layerscape/base-files/lib/upgrade/platform.sh | 103 |
1 files changed, 22 insertions, 81 deletions
diff --git a/target/linux/layerscape/base-files/lib/upgrade/platform.sh b/target/linux/layerscape/base-files/lib/upgrade/platform.sh index de01ac46de..a8d83de7ea 100644 --- a/target/linux/layerscape/base-files/lib/upgrade/platform.sh +++ b/target/linux/layerscape/base-files/lib/upgrade/platform.sh @@ -8,88 +8,28 @@ 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 + local diskdev partdev parttype=ext4 + local tar_file="$1" + local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$') + board_dir=${board_dir%/} 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 - echo "Writing image to /dev/$diskdev..." - dd if="$1" of="/dev/$diskdev" bs=1024 skip=15360 seek=15360 > /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 + if export_partdevice partdev 1; then + mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt 2>&1 + echo "Writing kernel..." + tar xf $tar_file ${board_dir}/kernel -O > /mnt/fitImage + umount /mnt fi - # write dtb - echo "Writing dtb to /dev/$diskdev..." - dd if="$1" of="/dev/$diskdev" bs=1024 skip=15360 seek=15360 count=1024 > /dev/null 2>&1 - # write kernel image - echo "Writing kernel to /dev/$diskdev..." - dd if="$1" of="/dev/$diskdev" bs=1024 skip=16384 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 + echo "Erasing rootfs..." + dd if=/dev/zero of=/dev/mmcblk0p2 bs=1M > /dev/null 2>&1 + echo "Writing rootfs..." + tar xf $tar_file ${board_dir}/root -O | dd of=/dev/mmcblk0p2 bs=512k > /dev/null 2>&1 } platform_do_upgrade_traverse_nandubi() { @@ -119,6 +59,7 @@ platform_copy_config_sdboot() { if export_partdevice partdev 1; then mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt 2>&1 + echo "Saving config backup..." cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE" umount /mnt fi @@ -128,6 +69,7 @@ platform_copy_config() { case "$board" in fsl,ls1012a-frwy-sdboot | \ + fsl,ls1021a-iot-sdboot | \ fsl,ls1021a-twr-sdboot | \ fsl,ls1043a-rdb-sdboot | \ fsl,ls1046a-rdb-sdboot | \ @@ -146,22 +88,20 @@ platform_check_image() { return $? ;; fsl,ls1012a-frdm | \ + fsl,ls1012a-frwy-sdboot | \ fsl,ls1012a-rdb | \ + fsl,ls1021a-iot-sdboot | \ fsl,ls1021a-twr | \ + fsl,ls1021a-twr-sdboot | \ fsl,ls1043a-rdb | \ + fsl,ls1043a-rdb-sdboot | \ fsl,ls1046a-rdb | \ + fsl,ls1046a-rdb-sdboot | \ fsl,ls1088a-rdb | \ + fsl,ls1088a-rdb-sdboot | \ 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" ;; @@ -192,6 +132,7 @@ platform_do_upgrade() { default_do_upgrade "$1" ;; fsl,ls1012a-frwy-sdboot | \ + fsl,ls1021a-iot-sdboot | \ fsl,ls1021a-twr-sdboot | \ fsl,ls1043a-rdb-sdboot | \ fsl,ls1046a-rdb-sdboot | \ |