diff options
Diffstat (limited to 'target/linux/ath79/generic/base-files/lib')
-rwxr-xr-x | target/linux/ath79/generic/base-files/lib/functions/k2t.sh | 55 | ||||
-rw-r--r-- | target/linux/ath79/generic/base-files/lib/upgrade/platform.sh | 61 |
2 files changed, 116 insertions, 0 deletions
diff --git a/target/linux/ath79/generic/base-files/lib/functions/k2t.sh b/target/linux/ath79/generic/base-files/lib/functions/k2t.sh new file mode 100755 index 0000000000..1158df818b --- /dev/null +++ b/target/linux/ath79/generic/base-files/lib/functions/k2t.sh @@ -0,0 +1,55 @@ +#!/bin/sh +# +# Copyright (C) 2018 Weijie Gao <hackpascal@gmail.com> +# +# Helper function to extract mac addresses from mtd part for Phicomm K2T +# + +. /lib/functions.sh +. /lib/functions/system.sh +. /usr/share/libubox/jshn.sh + +k2t_config_load() { + local mtd_blk=$(find_mtd_part config) + + if [ -z "$mtd_blk" ]; then + echo "k2t_config_load: no mtd part named config" >&2 + exit 1 + fi + + local json_size=$(dd if=$mtd_blk bs=1 count=8 2>/dev/null) + + json_size="0x$json_size" + json_size=$((json_size)) + + if [ "$?" -ne 0 ]; then + echo "k2t_config_load: invalid json data size" >&2 + exit 2 + fi + + if [ "$json_size" -eq 0 ]; then + echo "k2t_config_load: empty json data" >&2 + exit 3 + fi + + local json_data=$(dd if=$mtd_blk bs=1 skip=8 count=$json_size 2>/dev/null) + + json_load "$json_data" +} + +k2t_get_mac() { + local old_ns + + json_set_namespace "k2t" old_ns + + if k2t_config_load; then + json_select "this_dev_info" + json_get_var val "$1" + json_select .. + fi + + json_set_namespace old_ns + + echo $val +} + diff --git a/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh new file mode 100644 index 0000000000..83c4e78d25 --- /dev/null +++ b/target/linux/ath79/generic/base-files/lib/upgrade/platform.sh @@ -0,0 +1,61 @@ +# +# Copyright (C) 2011 OpenWrt.org +# + +PART_NAME=firmware +REQUIRE_IMAGE_METADATA=1 + +redboot_fis_do_upgrade() { + local append + local sysup_file="$1" + local kern_part="$2" + local magic=$(get_magic_word "$sysup_file") + + if [ "$magic" = "4349" ]; then + local kern_length=0x$(dd if="$sysup_file" bs=2 skip=1 count=4 2>/dev/null) + + [ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP" + dd if="$sysup_file" bs=64k skip=1 2>/dev/null | \ + mtd -r $append -F$kern_part:$kern_length:0x80060000,rootfs write - $kern_part:rootfs + + elif [ "$magic" = "7379" ]; then + local board_dir=$(tar tf $sysup_file | grep -m 1 '^sysupgrade-.*/$') + local kern_length=$(tar xf $sysup_file ${board_dir}kernel -O | wc -c) + + [ -f "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP" + 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 + + else + echo "Unknown image, aborting!" + return 1 + fi +} + +platform_check_image() { + return 0 +} + +platform_do_upgrade() { + local board=$(board_name) + + case "$board" in + adtran,bsap1800-v2|\ + adtran,bsap1840) + redboot_fis_do_upgrade "$1" vmlinux_2 + ;; + jjplus,ja76pf2) + echo "Sysupgrade disabled due bug FS#2428" + ;; + ubnt,routerstation|\ + ubnt,routerstation-pro) + echo "Sysupgrade disabled due bug FS#2428" + ;; + zyxel,nbg6716) + nand_do_upgrade "$1" + ;; + *) + default_do_upgrade "$1" + ;; + esac +} |