openwrtv4/target/linux/mediatek/base-files/lib/upgrade/platform.sh
Mathias Kresin e4e984f2a0 treewide: use only board_name function to get name
Do not parse /tmp/sysinfo/board_name, /proc/cpuinfo or the device tree
compatible string directly. Always use the board_name function to get
the board name.

The admswconfig package still reads /proc/cpuinfo directly. The code
looks somehow broken and the whole adm5120 which uses this package
looks unmaintained. Leave it as it is for now.

Signed-off-by: Mathias Kresin <dev@kresin.me>
2017-07-15 23:13:34 +02:00

54 lines
1.1 KiB
Bash
Executable file

#
# Copyright (C) 2016 OpenWrt.org
#
platform_do_upgrade() {
local tar_file="$1"
local board="$(board_name)"
echo "flashing kernel"
tar xf $tar_file sysupgrade-$board/kernel -O | mtd write - kernel
echo "flashing rootfs"
tar xf $tar_file sysupgrade-$board/root -O | mtd write - rootfs
return 0
}
platform_check_image() {
local tar_file="$1"
local board=$(board_name)
case "$board" in
mediatek,mt7623-rfb-nand-ephy |\
mediatek,mt7623-rfb-nand)
nand_do_platform_check $board $1
return $?
;;
mediatek,mt7623-rfb-emmc)
local kernel_length=`(tar xf $tar_file sysupgrade-$board/kernel -O | wc -c) 2> /dev/null`
local rootfs_length=`(tar xf $tar_file sysupgrade-$board/root -O | wc -c) 2> /dev/null`
;;
*)
echo "Sysupgrade is not supported on your board yet."
return 1
;;
esac
[ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && {
echo "The upgarde image is corrupt."
return 1
}
return 0
}
platform_pre_upgrade() {
case "$(board_name)" in
mediatek,mt7623-rfb-nand-ephy |\
mediatek,mt7623-rfb-nand)
nand_do_upgrade $1
;;
esac
}