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 <mcpratt@pm.me>
This commit is contained in:
		 Michael Pratt
					Michael Pratt
				
			
				
					committed by
					
						 Hauke Mehrtens
						Hauke Mehrtens
					
				
			
			
				
	
			
			
			 Hauke Mehrtens
						Hauke Mehrtens
					
				
			
						parent
						
							8342c092a0
						
					
				
				
					commit
					766de7013f
				
			| @@ -8,8 +8,6 @@ | |||||||
| # So the kernel check is for the loader, the rootfs check is for kernel + rootfs | # So the kernel check is for the loader, the rootfs check is for kernel + rootfs | ||||||
|  |  | ||||||
| platform_do_upgrade_failsafe_datachk() { | platform_do_upgrade_failsafe_datachk() { | ||||||
| 	local setenv_script="/tmp/fw_env_upgrade" |  | ||||||
|  |  | ||||||
| 	local flash_base=0x9f000000 | 	local flash_base=0x9f000000 | ||||||
|  |  | ||||||
| 	local kernel_mtd=$(find_mtd_index ${KERNEL_PART:-kernel}) | 	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) | 	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 | 	# prepare new u-boot-env vars | ||||||
| 	printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $setenv_script | 	printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $ENV_SCRIPT | ||||||
| 	printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $setenv_script | 	printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $ENV_SCRIPT | ||||||
| 	printf "vmlinux_checksum %s\n" ${kernel_md5} >> $setenv_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_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $ENV_SCRIPT | ||||||
| 	printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $setenv_script | 	printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $ENV_SCRIPT | ||||||
| 	printf "rootfs_checksum %s\n" ${rootfs_md5} >> $setenv_script | 	printf "rootfs_checksum %s\n" ${rootfs_md5} >> $ENV_SCRIPT | ||||||
|  |  | ||||||
| 	# store u-boot-env | 	# store u-boot-env | ||||||
| 	mkdir -p /var/lock | 	mkdir -p /var/lock | ||||||
| 	fw_setenv -s $setenv_script || { | 	[ -n "$SKIP_HASH" ] || fw_setenv -s $ENV_SCRIPT || { | ||||||
| 		echo 'failed to update U-Boot environment' | 		echo 'failed to update U-Boot environment' | ||||||
| 		exit 1 | 		exit 1 | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	# sysupgrade | 	# sysupgrade | ||||||
| 	sleep 2 | 	sleep 2 && sync && echo 3 > /proc/sys/vm/drop_caches | ||||||
| 	sync |  | ||||||
| 	echo 3 > /proc/sys/vm/drop_caches |  | ||||||
| 	$IMAGE_CMD $KERNEL_FILE | mtd $MTD_ARGS write - ${KERNEL_PART:-kernel} | 	$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 | 	if [ -n "$UPGRADE_BACKUP" ]; then | ||||||
| 		$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j $UPGRADE_BACKUP write - ${ROOTFS_PART:-rootfs} | 		$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j $UPGRADE_BACKUP write - ${ROOTFS_PART:-rootfs} | ||||||
| 	else | 	else | ||||||
| 		$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS write - ${ROOTFS_PART:-rootfs} | 		$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS write - ${ROOTFS_PART:-rootfs} | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
|  | 	sync | ||||||
| } | } | ||||||
|   | |||||||
| @@ -45,6 +45,7 @@ platform_do_upgrade() { | |||||||
| 	watchguard,ap100|\ | 	watchguard,ap100|\ | ||||||
| 	watchguard,ap200|\ | 	watchguard,ap200|\ | ||||||
| 	watchguard,ap300) | 	watchguard,ap300) | ||||||
|  | 		ENV_SCRIPT="/tmp/fw_env" | ||||||
| 		IMAGE_LIST="tar tzf $1" | 		IMAGE_LIST="tar tzf $1" | ||||||
| 		IMAGE_CMD="tar xzOf $1" | 		IMAGE_CMD="tar xzOf $1" | ||||||
| 		KERNEL_PART="loader" | 		KERNEL_PART="loader" | ||||||
|   | |||||||
| @@ -8,8 +8,6 @@ | |||||||
| # So the kernel check is for the loader, the rootfs check is for kernel + rootfs | # So the kernel check is for the loader, the rootfs check is for kernel + rootfs | ||||||
|  |  | ||||||
| platform_do_upgrade_failsafe_datachk() { | platform_do_upgrade_failsafe_datachk() { | ||||||
| 	local setenv_script="/tmp/fw_env_upgrade" |  | ||||||
|  |  | ||||||
| 	local flash_base=0x9f000000 | 	local flash_base=0x9f000000 | ||||||
|  |  | ||||||
| 	local kernel_mtd=$(find_mtd_index ${KERNEL_PART:-kernel}) | 	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) | 	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 | 	# prepare new u-boot-env vars | ||||||
| 	printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $setenv_script | 	printf "vmlinux_start_addr 0x%08x\n" $((flash_base + kernel_offset)) >> $ENV_SCRIPT | ||||||
| 	printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $setenv_script | 	printf "vmlinux_size 0x%08x\n" ${kernel_size} >> $ENV_SCRIPT | ||||||
| 	printf "vmlinux_checksum %s\n" ${kernel_md5} >> $setenv_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_start_addr 0x%08x\n" $((flash_base + rootfs_offset)) >> $ENV_SCRIPT | ||||||
| 	printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $setenv_script | 	printf "rootfs_size 0x%08x\n" ${rootfs_size} >> $ENV_SCRIPT | ||||||
| 	printf "rootfs_checksum %s\n" ${rootfs_md5} >> $setenv_script | 	printf "rootfs_checksum %s\n" ${rootfs_md5} >> $ENV_SCRIPT | ||||||
|  |  | ||||||
| 	# store u-boot-env | 	# store u-boot-env | ||||||
| 	mkdir -p /var/lock | 	mkdir -p /var/lock | ||||||
| 	fw_setenv -s $setenv_script || { | 	[ -n "$SKIP_HASH" ] || fw_setenv -s $ENV_SCRIPT || { | ||||||
| 		echo 'failed to update U-Boot environment' | 		echo 'failed to update U-Boot environment' | ||||||
| 		exit 1 | 		exit 1 | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	# sysupgrade | 	# sysupgrade | ||||||
| 	sleep 2 | 	sleep 2 && sync && echo 3 > /proc/sys/vm/drop_caches | ||||||
| 	sync |  | ||||||
| 	echo 3 > /proc/sys/vm/drop_caches |  | ||||||
| 	$IMAGE_CMD $KERNEL_FILE | mtd $MTD_ARGS write - ${KERNEL_PART:-kernel} | 	$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 | 	if [ -n "$UPGRADE_BACKUP" ]; then | ||||||
| 		$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j $UPGRADE_BACKUP write - ${ROOTFS_PART:-rootfs} | 		$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS $MTD_CONFIG_ARGS -j $UPGRADE_BACKUP write - ${ROOTFS_PART:-rootfs} | ||||||
| 	else | 	else | ||||||
| 		$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS write - ${ROOTFS_PART:-rootfs} | 		$IMAGE_CMD $ROOTFS_FILE | mtd $MTD_ARGS write - ${ROOTFS_PART:-rootfs} | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
|  | 	sync | ||||||
| } | } | ||||||
|   | |||||||
| @@ -19,6 +19,7 @@ platform_do_upgrade() { | |||||||
| 	engenius,eap350-v1|\ | 	engenius,eap350-v1|\ | ||||||
| 	engenius,ecb350-v1|\ | 	engenius,ecb350-v1|\ | ||||||
| 	engenius,enh202-v1) | 	engenius,enh202-v1) | ||||||
|  | 		ENV_SCRIPT="/tmp/fw_env" | ||||||
| 		IMAGE_LIST="tar tzf $1" | 		IMAGE_LIST="tar tzf $1" | ||||||
| 		IMAGE_CMD="tar xzOf $1" | 		IMAGE_CMD="tar xzOf $1" | ||||||
| 		KERNEL_PART="loader" | 		KERNEL_PART="loader" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user