From: Michael Pratt Date: Fri, 9 Dec 2022 22:47:11 +0000 (-0500) Subject: ath79: allow skipping hash for Senao sysupgrade X-Git-Tag: v23.05.0-rc1~1383 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=766de7013fcef2a9d759e056bb40c1cb58cfd65f;p=openwrt%2Fstaging%2Fhauke.git ath79: allow skipping hash for Senao sysupgrade Some vendors of Senao boards have a similar flash layout situation that causes the need to split the firmware partition and use the lzma-loader, but do not store checksums of the partitions or otherwise do not even have a uboot environment partition. This adds simple shell logic to skip that part. Also, simplify some lines and variable usage. Signed-off-by: Michael Pratt --- diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/failsafe_datachk.sh b/target/linux/ath79/generic/base-files/lib/upgrade/failsafe_datachk.sh index de84233de1..23847a1aae 100644 --- a/target/linux/ath79/generic/base-files/lib/upgrade/failsafe_datachk.sh +++ b/target/linux/ath79/generic/base-files/lib/upgrade/failsafe_datachk.sh @@ -8,8 +8,6 @@ # So the kernel check is for the loader, the rootfs check is for kernel + rootfs platform_do_upgrade_failsafe_datachk() { - local setenv_script="/tmp/fw_env_upgrade" - local flash_base=0x9f000000 local kernel_mtd=$(find_mtd_index ${KERNEL_PART:-kernel}) @@ -34,31 +32,33 @@ platform_do_upgrade_failsafe_datachk() { local rootfs_md5=$($IMAGE_CMD $ROOTFS_FILE | dd bs=4k count=$rootfs_blocks iflag=fullblock | md5sum | cut -d ' ' -f1) # prepare new u-boot-env vars - printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $setenv_script - printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $setenv_script - printf "vmlinux_checksum %s\n" ${kernel_md5} >> $setenv_script + printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $ENV_SCRIPT + printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $ENV_SCRIPT + printf "vmlinux_checksum %s\n" ${kernel_md5} >> $ENV_SCRIPT - printf "rootfs_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $setenv_script - printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $setenv_script - printf "rootfs_checksum %s\n" ${rootfs_md5} >> $setenv_script + printf "rootfs_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $ENV_SCRIPT + printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $ENV_SCRIPT + printf "rootfs_checksum %s\n" ${rootfs_md5} >> $ENV_SCRIPT # store u-boot-env mkdir -p /var/lock - fw_setenv -s $setenv_script || { + [ -n "$SKIP_HASH" ] || fw_setenv -s $ENV_SCRIPT || { echo 'failed to update U-Boot environment' exit 1 } # sysupgrade - sleep 2 - sync - echo 3 > /proc/sys/vm/drop_caches + sleep 2 && sync && echo 3 > /proc/sys/vm/drop_caches + $IMAGE_CMD $KERNEL_FILE | mtd $MTD_ARGS write - ${KERNEL_PART:-kernel} - sleep 2 - sync + + sleep 2 && sync && echo 3 > /proc/sys/vm/drop_caches + if [ -n "$UPGRADE_BACKUP" ]; then $IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j $UPGRADE_BACKUP write - ${ROOTFS_PART:-rootfs} else $IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS write - ${ROOTFS_PART:-rootfs} fi + + sync } diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh index c58e005344..0de3dbf3b5 100644 --- a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh @@ -45,6 +45,7 @@ platform_do_upgrade() { watchguard,ap100|\ watchguard,ap200|\ watchguard,ap300) + ENV_SCRIPT="/tmp/fw_env" IMAGE_LIST="tar tzf $1" IMAGE_CMD="tar xzOf $1" KERNEL_PART="loader" diff --git a/target/linux/ath79/tiny/base-files/lib/upgrade/failsafe_datachk.sh b/target/linux/ath79/tiny/base-files/lib/upgrade/failsafe_datachk.sh index de84233de1..23847a1aae 100644 --- a/target/linux/ath79/tiny/base-files/lib/upgrade/failsafe_datachk.sh +++ b/target/linux/ath79/tiny/base-files/lib/upgrade/failsafe_datachk.sh @@ -8,8 +8,6 @@ # So the kernel check is for the loader, the rootfs check is for kernel + rootfs platform_do_upgrade_failsafe_datachk() { - local setenv_script="/tmp/fw_env_upgrade" - local flash_base=0x9f000000 local kernel_mtd=$(find_mtd_index ${KERNEL_PART:-kernel}) @@ -34,31 +32,33 @@ platform_do_upgrade_failsafe_datachk() { local rootfs_md5=$($IMAGE_CMD $ROOTFS_FILE | dd bs=4k count=$rootfs_blocks iflag=fullblock | md5sum | cut -d ' ' -f1) # prepare new u-boot-env vars - printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $setenv_script - printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $setenv_script - printf "vmlinux_checksum %s\n" ${kernel_md5} >> $setenv_script + printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $ENV_SCRIPT + printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $ENV_SCRIPT + printf "vmlinux_checksum %s\n" ${kernel_md5} >> $ENV_SCRIPT - printf "rootfs_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $setenv_script - printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $setenv_script - printf "rootfs_checksum %s\n" ${rootfs_md5} >> $setenv_script + printf "rootfs_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $ENV_SCRIPT + printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $ENV_SCRIPT + printf "rootfs_checksum %s\n" ${rootfs_md5} >> $ENV_SCRIPT # store u-boot-env mkdir -p /var/lock - fw_setenv -s $setenv_script || { + [ -n "$SKIP_HASH" ] || fw_setenv -s $ENV_SCRIPT || { echo 'failed to update U-Boot environment' exit 1 } # sysupgrade - sleep 2 - sync - echo 3 > /proc/sys/vm/drop_caches + sleep 2 && sync && echo 3 > /proc/sys/vm/drop_caches + $IMAGE_CMD $KERNEL_FILE | mtd $MTD_ARGS write - ${KERNEL_PART:-kernel} - sleep 2 - sync + + sleep 2 && sync && echo 3 > /proc/sys/vm/drop_caches + if [ -n "$UPGRADE_BACKUP" ]; then $IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j $UPGRADE_BACKUP write - ${ROOTFS_PART:-rootfs} else $IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS write - ${ROOTFS_PART:-rootfs} fi + + sync } diff --git a/target/linux/ath79/tiny/base-files/lib/upgrade/platform.sh b/target/linux/ath79/tiny/base-files/lib/upgrade/platform.sh index 6d05b88d45..eb8441c6d2 100644 --- a/target/linux/ath79/tiny/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/tiny/base-files/lib/upgrade/platform.sh @@ -19,6 +19,7 @@ platform_do_upgrade() { engenius,eap350-v1|\ engenius,ecb350-v1|\ engenius,enh202-v1) + ENV_SCRIPT="/tmp/fw_env" IMAGE_LIST="tar tzf $1" IMAGE_CMD="tar xzOf $1" KERNEL_PART="loader"