treewide: sysupgrade: get rid of platform_nand_pre_upgrade()

1) nand_do_upgrade() is always called by a target code
2) nand_do_upgrade() starts with calling platform_nand_pre_upgrade()

It means there is no need for the platform_nand_pre_upgrade() callback
at all. All code that was present there could bo moved & simplly called
by a target right before the nand_do_upgrade().

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
This commit is contained in:
Rafał Miłecki 2019-07-17 11:32:54 +02:00
parent 3b30ff2975
commit 1cbe0d659c
8 changed files with 64 additions and 88 deletions

View File

@ -746,19 +746,18 @@ platform_check_image() {
return 1 return 1
} }
platform_nand_pre_upgrade() { platform_do_upgrade_mikrotik_rb() {
local board=$(board_name)
case "$board" in
rb*)
CI_KERNPART=none CI_KERNPART=none
local fw_mtd=$(find_mtd_part kernel) local fw_mtd=$(find_mtd_part kernel)
fw_mtd="${fw_mtd/block/}" fw_mtd="${fw_mtd/block/}"
[ -n "$fw_mtd" ] || return [ -n "$fw_mtd" ] || return
mtd erase kernel mtd erase kernel
tar xf "$1" sysupgrade-routerboard/kernel -O | nandwrite -o "$fw_mtd" - tar xf "$1" sysupgrade-routerboard/kernel -O | nandwrite -o "$fw_mtd" -
;;
wi2a-ac200i) nand_do_upgrade "$1"
}
platform_do_upgrade_nokia() {
case "$(fw_printenv -n dualPartition)" in case "$(fw_printenv -n dualPartition)" in
imgA) imgA)
fw_setenv dualPartition imgB fw_setenv dualPartition imgB
@ -774,8 +773,8 @@ platform_nand_pre_upgrade() {
ubidetach -d 0 2>/dev/null >/dev/null ubidetach -d 0 2>/dev/null >/dev/null
CI_UBIPART=ubi_alt CI_UBIPART=ubi_alt
CI_KERNPART=kernel_alt CI_KERNPART=kernel_alt
;;
esac nand_do_upgrade "$1"
} }
platform_do_upgrade() { platform_do_upgrade() {
@ -859,6 +858,14 @@ platform_do_upgrade() {
nbg6716|\ nbg6716|\
r6100|\ r6100|\
rambutan|\ rambutan|\
wndr3700v4|\
wndr4300)
nand_do_upgrade "$1"
;;
mr18|\
z1)
merakinand_do_upgrade "$1"
;;
rb-411|\ rb-411|\
rb-411u|\ rb-411u|\
rb-433|\ rb-433|\
@ -890,21 +897,17 @@ platform_do_upgrade() {
rb-2011uias-2hnd|\ rb-2011uias-2hnd|\
rb-2011uias-2hnd-r2|\ rb-2011uias-2hnd-r2|\
rb-sxt2n|\ rb-sxt2n|\
rb-sxt5n|\ rb-sxt5n)
wi2a-ac200i|\ platform_do_upgrade_mikrotik_rb "$1"
wndr3700v4|\
wndr4300)
nand_do_upgrade "$1"
;;
mr18|\
z1)
merakinand_do_upgrade "$1"
;; ;;
uap-pro|\ uap-pro|\
unifi-outdoor-plus) unifi-outdoor-plus)
MTD_CONFIG_ARGS="-s 0x180000" MTD_CONFIG_ARGS="-s 0x180000"
default_do_upgrade "$1" default_do_upgrade "$1"
;; ;;
wi2a-ac200i)
platform_do_upgrade_nokia "$1"
;;
wp543|\ wp543|\
wpe72) wpe72)
platform_do_upgrade_compex "$1" platform_do_upgrade_compex "$1"

View File

@ -47,12 +47,22 @@ zyxel_do_upgrade() {
platform_do_upgrade() { platform_do_upgrade() {
case "$(board_name)" in case "$(board_name)" in
8dev,jalapeno |\ 8dev,jalapeno |\
alfa-network,ap120c-ac |\
avm,fritzbox-7530 |\ avm,fritzbox-7530 |\
avm,fritzrepeater-3000 |\ avm,fritzrepeater-3000 |\
qxwlan,e2600ac-c2) qxwlan,e2600ac-c2)
nand_do_upgrade "$1" nand_do_upgrade "$1"
;; ;;
alfa-network,ap120c-ac)
part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
if [ "$part" = "rootfs1" ]; then
fw_setenv active 2 || exit 1
CI_UBIPART="rootfs2"
else
fw_setenv active 1 || exit 1
CI_UBIPART="rootfs1"
fi
nand_do_upgrade "$1"
;;
asus,map-ac2200) asus,map-ac2200)
CI_KERNPART="linux" CI_KERNPART="linux"
nand_do_upgrade "$1" nand_do_upgrade "$1"
@ -83,25 +93,3 @@ platform_do_upgrade() {
;; ;;
esac esac
} }
platform_nand_pre_upgrade() {
case "$(board_name)" in
alfa-network,ap120c-ac)
part="$(awk -F 'ubi.mtd=' '{printf $2}' /proc/cmdline | sed -e 's/ .*$//')"
if [ "$part" = "rootfs1" ]; then
fw_setenv active 2 || exit 1
CI_UBIPART="rootfs2"
else
fw_setenv active 1 || exit 1
CI_UBIPART="rootfs1"
fi
;;
asus,rt-ac58u)
CI_UBIPART="UBI_DEV"
CI_KERNPART="linux"
;;
meraki,mr33)
CI_KERNPART="part.safe"
;;
esac
}

View File

@ -21,10 +21,12 @@ platform_do_upgrade() {
netgear,r7500v2 |\ netgear,r7500v2 |\
netgear,r7800 |\ netgear,r7800 |\
qcom,ipq8064-ap148 |\ qcom,ipq8064-ap148 |\
qcom,ipq8064-ap161 |\ qcom,ipq8064-ap161)
zyxel,nbg6817)
nand_do_upgrade "$1" nand_do_upgrade "$1"
;; ;;
zyxel,nbg6817)
zyxel_do_upgrade "$1"
;;
linksys,ea8500) linksys,ea8500)
platform_do_upgrade_linksys "$1" platform_do_upgrade_linksys "$1"
;; ;;
@ -44,11 +46,3 @@ platform_do_upgrade() {
;; ;;
esac esac
} }
platform_nand_pre_upgrade() {
case "$(board_name)" in
zyxel,nbg6817)
zyxel_do_upgrade "$1"
;;
esac
}

View File

@ -118,5 +118,7 @@ zyxel_do_upgrade() {
zyxel_do_flash $tar_file $kernel $rootfs $dualflagmtd zyxel_do_flash $tar_file $kernel $rootfs $dualflagmtd
nand_do_upgrade "$1"
return 0 return 0
} }

View File

@ -26,10 +26,7 @@ platform_do_upgrade() {
# stage2 directly but need to refactor nand_upgrade_success # stage2 directly but need to refactor nand_upgrade_success
# for this to work. # for this to work.
# Also the nand functions don't allow url to be used # Also the nand functions don't allow url to be used
nand_do_upgrade $1
}
platform_nand_pre_upgrade() {
local board=$(board_name) local board=$(board_name)
case "$board" in case "$board" in
@ -48,4 +45,6 @@ platform_nand_pre_upgrade() {
echo "Upgrading partition $CI_UBIPART (/dev/mtd$(find_mtd_index $CI_UBIPART))" echo "Upgrading partition $CI_UBIPART (/dev/mtd$(find_mtd_index $CI_UBIPART))"
;; ;;
esac esac
nand_do_upgrade $1
} }

View File

@ -9,17 +9,6 @@ platform_check_image() {
return 0 return 0
} }
platform_nand_pre_upgrade() {
local board=$(board_name)
case "$board" in
ubiquiti,edgerouterx|\
ubiquiti,edgerouterx-sfp)
platform_upgrade_ubnt_erx "$1"
;;
esac
}
platform_do_upgrade() { platform_do_upgrade() {
local board=$(board_name) local board=$(board_name)
@ -35,8 +24,6 @@ platform_do_upgrade() {
hiwifi,hc5962|\ hiwifi,hc5962|\
netgear,r6220|\ netgear,r6220|\
netgear,r6350|\ netgear,r6350|\
ubiquiti,edgerouterx|\
ubiquiti,edgerouterx-sfp|\
xiaomi,mir3g|\ xiaomi,mir3g|\
xiaomi,mir3p) xiaomi,mir3p)
nand_do_upgrade "$1" nand_do_upgrade "$1"
@ -45,6 +32,10 @@ platform_do_upgrade() {
MTD_ARGS="-t romfile" MTD_ARGS="-t romfile"
default_do_upgrade "$1" default_do_upgrade "$1"
;; ;;
ubiquiti,edgerouterx|\
ubiquiti,edgerouterx-sfp)
platform_upgrade_ubnt_erx "$1"
;;
*) *)
default_do_upgrade "$1" default_do_upgrade "$1"
;; ;;

View File

@ -73,4 +73,6 @@ platform_upgrade_ubnt_erx() {
fi fi
ubnt_update_target_kernel ${factory_mtd} ${kernel_part} || exit 1 ubnt_update_target_kernel ${factory_mtd} ${kernel_part} || exit 1
nand_do_upgrade "$1"
} }

View File

@ -10,11 +10,8 @@ platform_check_image() {
return 0; return 0;
} }
platform_nand_pre_upgrade() { platform_do_upgrade() {
mtd erase kernel mtd erase kernel
tar xf "$1" "sysupgrade-$(board_name)/kernel" -O | nandwrite -o /dev/mtd0 - tar xf "$1" "sysupgrade-$(board_name)/kernel" -O | nandwrite -o /dev/mtd0 -
}
platform_do_upgrade() {
nand_do_upgrade "$1" nand_do_upgrade "$1"
} }