summaryrefslogtreecommitdiffstats
path: root/target/linux/mediatek/base-files/lib/upgrade/platform.sh
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2016-04-27 08:58:15 +0000
committerJo-Philipp Wich <jo@mein.io>2016-04-28 11:48:51 +0200
commit090b134786a009427442aee7e2ea48e47be5e60f (patch)
tree221955b231c89be46130cd388aa2435e4247aa5c /target/linux/mediatek/base-files/lib/upgrade/platform.sh
parent9e4d671f75cf02264711fa27c91215038f2a03f8 (diff)
downloadopenwrt-090b134786a009427442aee7e2ea48e47be5e60f.tar.gz
openwrt-090b134786a009427442aee7e2ea48e47be5e60f.tar.bz2
openwrt-090b134786a009427442aee7e2ea48e47be5e60f.zip
mediatek: sync and patches add support for several boards
Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 49263
Diffstat (limited to 'target/linux/mediatek/base-files/lib/upgrade/platform.sh')
-rwxr-xr-xtarget/linux/mediatek/base-files/lib/upgrade/platform.sh41
1 files changed, 41 insertions, 0 deletions
diff --git a/target/linux/mediatek/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/base-files/lib/upgrade/platform.sh
new file mode 100755
index 0000000000..be72114adb
--- /dev/null
+++ b/target/linux/mediatek/base-files/lib/upgrade/platform.sh
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2016 OpenWrt.org
+#
+
+platform_do_upgrade() {
+ local tar_file="$1"
+ local board="$(cat /tmp/sysinfo/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=$(cat /tmp/sysinfo/board_name)
+
+ case "$board" in
+ NAND | \
+ 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
+}