mirror of
				git://git.openwrt.org/openwrt/openwrt.git
				synced 2025-11-03 14:34:27 -05:00 
			
		
		
		
	ath79: move image check for devices with RedBoot
Don't comence the switch to RAMFS when the image format is wrong. This led to rebooting the device, which could lead to false impression that upgrade succeded. Being here, factor out the code responsible for upgrading RedBoot devices to separate file. Signed-off-by: Tomasz Maciej Nowak <tmn505@gmail.com>
This commit is contained in:
		
							parent
							
								
									5c142aad7b
								
							
						
					
					
						commit
						5897c52e78
					
				@ -8,35 +8,19 @@ REQUIRE_IMAGE_METADATA=1
 | 
			
		||||
RAMFS_COPY_BIN='fw_printenv fw_setenv'
 | 
			
		||||
RAMFS_COPY_DATA='/etc/fw_env.config /var/lock/fw_printenv.lock'
 | 
			
		||||
 | 
			
		||||
redboot_fis_do_upgrade() {
 | 
			
		||||
	local append
 | 
			
		||||
	local sysup_file="$1"
 | 
			
		||||
	local kern_part="$2"
 | 
			
		||||
	local magic=$(get_magic_word "$sysup_file")
 | 
			
		||||
 | 
			
		||||
	if [ "$magic" = "7379" ]; then
 | 
			
		||||
		local board_dir=$(tar tf $sysup_file | grep -m 1 '^sysupgrade-.*/$')
 | 
			
		||||
 | 
			
		||||
		[ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP"
 | 
			
		||||
 | 
			
		||||
		if grep -q "mtd1.*loader" /proc/mtd; then
 | 
			
		||||
			tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \
 | 
			
		||||
				mtd -r $append write - loader:firmware
 | 
			
		||||
 | 
			
		||||
		else
 | 
			
		||||
			local kern_length=$(tar xf $sysup_file ${board_dir}kernel -O | wc -c)
 | 
			
		||||
 | 
			
		||||
			tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \
 | 
			
		||||
				mtd -r $append -F$kern_part:$kern_length:0x80060000,rootfs write - $kern_part:rootfs
 | 
			
		||||
		fi
 | 
			
		||||
	else
 | 
			
		||||
		echo "Unknown image, aborting!"
 | 
			
		||||
		return 1
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
platform_check_image() {
 | 
			
		||||
	return 0
 | 
			
		||||
	local board=$(board_name)
 | 
			
		||||
 | 
			
		||||
	case "$board" in
 | 
			
		||||
	jjplus,ja76pf2|\
 | 
			
		||||
	ubnt,routerstation|\
 | 
			
		||||
	ubnt,routerstation-pro)
 | 
			
		||||
		platform_check_image_redboot_fis "$1"
 | 
			
		||||
		;;
 | 
			
		||||
	*)
 | 
			
		||||
		return 0
 | 
			
		||||
		;;
 | 
			
		||||
	esac
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
platform_do_upgrade() {
 | 
			
		||||
@ -45,7 +29,7 @@ platform_do_upgrade() {
 | 
			
		||||
	case "$board" in
 | 
			
		||||
	adtran,bsap1800-v2|\
 | 
			
		||||
	adtran,bsap1840)
 | 
			
		||||
		redboot_fis_do_upgrade "$1" vmlinux_2
 | 
			
		||||
		platform_do_upgrade_redboot_fis "$1" vmlinux_2
 | 
			
		||||
		;;
 | 
			
		||||
	allnet,all-wap02860ac|\
 | 
			
		||||
	araknis,an-300-ap-i-n|\
 | 
			
		||||
@ -66,7 +50,7 @@ platform_do_upgrade() {
 | 
			
		||||
		platform_do_upgrade_failsafe_datachk "$1"
 | 
			
		||||
		;;
 | 
			
		||||
	jjplus,ja76pf2)
 | 
			
		||||
		redboot_fis_do_upgrade "$1" linux
 | 
			
		||||
		platform_do_upgrade_redboot_fis "$1" linux
 | 
			
		||||
		;;
 | 
			
		||||
	openmesh,a40|\
 | 
			
		||||
	openmesh,a60|\
 | 
			
		||||
@ -98,7 +82,7 @@ platform_do_upgrade() {
 | 
			
		||||
		;;
 | 
			
		||||
	ubnt,routerstation|\
 | 
			
		||||
	ubnt,routerstation-pro)
 | 
			
		||||
		redboot_fis_do_upgrade "$1" kernel
 | 
			
		||||
		platform_do_upgrade_redboot_fis "$1" kernel
 | 
			
		||||
		;;
 | 
			
		||||
	*)
 | 
			
		||||
		default_do_upgrade "$1"
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,31 @@
 | 
			
		||||
platform_check_image_redboot_fis() {
 | 
			
		||||
	if [ "$(get_magic_word "$1")" != "7379" ]; then
 | 
			
		||||
		v "Unknown image format, aborting!"
 | 
			
		||||
		return 1
 | 
			
		||||
	else
 | 
			
		||||
		return 0
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
platform_do_upgrade_redboot_fis() {
 | 
			
		||||
	local append
 | 
			
		||||
	local sysup_file="$1"
 | 
			
		||||
	local kern_part="$2"
 | 
			
		||||
 | 
			
		||||
	if [ "$(get_magic_word "$sysup_file")" = "7379" ]; then
 | 
			
		||||
		local board_dir=$(tar tf $sysup_file | grep -m 1 '^sysupgrade-.*/$')
 | 
			
		||||
 | 
			
		||||
		[ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP"
 | 
			
		||||
 | 
			
		||||
		if grep -q "mtd1.*loader" /proc/mtd; then
 | 
			
		||||
			tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \
 | 
			
		||||
				mtd -r $append write - loader:firmware
 | 
			
		||||
 | 
			
		||||
		else
 | 
			
		||||
			local kern_length=$(tar xf $sysup_file ${board_dir}kernel -O | wc -c)
 | 
			
		||||
 | 
			
		||||
			tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \
 | 
			
		||||
				mtd -r $append -F$kern_part:$kern_length:0x80060000,rootfs write - $kern_part:rootfs
 | 
			
		||||
		fi
 | 
			
		||||
	fi
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user