diff options
author | Chris Blake <chrisrblake93@gmail.com> | 2016-09-20 07:14:29 -0500 |
---|---|---|
committer | John Crispin <john@phrozen.org> | 2016-09-27 17:50:22 +0200 |
commit | 68d649f5cd9ee2f6fda00df7bde4b9074474becf (patch) | |
tree | 8e5364f7fd24c938ca6046ea2d85aa1e24a52826 /target/linux/ar71xx/base-files | |
parent | b1f39d3d7ee7ba0714e45af64a935b01877a5175 (diff) | |
download | mtk-20170518-68d649f5cd9ee2f6fda00df7bde4b9074474becf.zip mtk-20170518-68d649f5cd9ee2f6fda00df7bde4b9074474becf.tar.gz mtk-20170518-68d649f5cd9ee2f6fda00df7bde4b9074474becf.tar.bz2 |
ar71xx: add support for Cisco Meraki Z1 Cloud Managed Teleworker Gateway
This patch adds support for Cisco's Z1.
Detailed instructions for the flashing the device can
be found in the OpenWrt wiki:
<https://wiki.openwrt.org/toh/meraki/z1>
Signed-off-by: Chris Blake <chrisrblake93@gmail.com>
Diffstat (limited to 'target/linux/ar71xx/base-files')
9 files changed, 90 insertions, 18 deletions
diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds b/target/linux/ar71xx/base-files/etc/board.d/01_leds index cf05859..7551455 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/01_leds +++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds @@ -813,6 +813,10 @@ wzr-hp-g300nh) ucidef_set_led_usbdev "usb" "USB" "buffalo:blue:usb" "1-1" ;; +z1) + ucidef_set_led_netdev "wlan1" "WLAN1" "z1:blue:tricolor0" "wlan1" + ;; + zbt-we1526) ucidef_set_led_netdev "wan" "WAN" "zbt-we1526:green:wan" "eth1" ucidef_set_led_switch "lan1" "LAN1" "zbt-we1526:green:lan1" "switch0" "0x10" diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network b/target/linux/ar71xx/base-files/etc/board.d/02_network index b637113..2a50c9d 100755 --- a/target/linux/ar71xx/base-files/etc/board.d/02_network +++ b/target/linux/ar71xx/base-files/etc/board.d/02_network @@ -538,6 +538,12 @@ wndr3700) ucidef_add_switch_port_attr "switch0" 5 led 2 ;; +z1) + ucidef_set_interfaces_lan_wan "eth0" "eth1" + ucidef_add_switch "switch0" \ + "0@eth0" "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "5:wan" + ;; + *) ucidef_set_interfaces_lan_wan "eth0" "eth1" ;; diff --git a/target/linux/ar71xx/base-files/etc/diag.sh b/target/linux/ar71xx/base-files/etc/diag.sh index 69ef609..6ce49b0 100644 --- a/target/linux/ar71xx/base-files/etc/diag.sh +++ b/target/linux/ar71xx/base-files/etc/diag.sh @@ -426,6 +426,9 @@ get_status_led() { wrt160nl) status_led="wrt160nl:blue:wps" ;; + z1) + status_led="z1:green:tricolor0" + ;; zbt-we1526) status_led="zbt-we1526:green:status" ;; diff --git a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom index 3b0229d..3141625 100644 --- a/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom +++ b/target/linux/ar71xx/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom @@ -73,6 +73,16 @@ case "$FIRMWARE" in ath9k_eeprom_extract "caldata" 4096 2048 ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 0) ;; + z1) + . /lib/upgrade/nand.sh + + if [ -n "$(nand_find_volume ubi0 caldata)" ]; then + ath9k_ubi_eeprom_extract "caldata" 4096 2048 + else + ath9k_eeprom_extract "origcaldata" 4096 2048 + fi + ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +2) + ;; *) ath9k_eeprom_die "board $board is not supported yet" ;; @@ -100,6 +110,16 @@ case "$FIRMWARE" in ath9k_eeprom_extract "caldata" 20480 2048 ath9k_patch_firmware_mac $(mtd_get_mac_binary caldata 12) ;; + z1) + . /lib/upgrade/nand.sh + + if [ -n "$(nand_find_volume ubi0 caldata)" ]; then + ath9k_ubi_eeprom_extract "caldata" 86016 4096 + else + ath9k_eeprom_extract "origcaldata" 86016 4096 + fi + ath9k_patch_firmware_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) +3) + ;; *) ath9k_eeprom_die "board $board is not supported yet" ;; diff --git a/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration b/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration index aa0e1b4..ee8f63b 100644 --- a/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration +++ b/target/linux/ar71xx/base-files/etc/uci-defaults/03_network-switchX-migration @@ -78,6 +78,7 @@ whr-hp-g300n|\ whr-hp-gn|\ wzr-hp-ag300h|\ wzr-hp-g450h|\ +z1|\ ew-dorin|\ ew-dorin-router) migrate_switch_name "eth0" "switch0" diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh b/target/linux/ar71xx/base-files/lib/ar71xx.sh index 7a3759e..dae6fb2 100755 --- a/target/linux/ar71xx/base-files/lib/ar71xx.sh +++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh @@ -1134,6 +1134,9 @@ ar71xx_board_detect() { *WHR-HP-G300N) name="whr-hp-g300n" ;; + *Z1) + name="z1" + ;; *ZBT-WE1526) name="zbt-we1526" ;; diff --git a/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx b/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx index 39da309..60e2787 100644 --- a/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx +++ b/target/linux/ar71xx/base-files/lib/preinit/05_set_iface_mac_ar71xx @@ -49,6 +49,10 @@ preinit_set_mac_address() { wrt160nl) fetch_mac_from_mtd nvram lan_hwaddr wan_hwaddr ;; + z1) + mac_lan=$(mtd_get_mac_binary_ubi board-config 102) + [ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan" + ;; esac } diff --git a/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh b/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh index cc7a86c..78cde20 100644 --- a/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/merakinand.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (C) 2015 Chris Blake <chrisrblake93@gmail.com> +# Copyright (C) 2015-2016 Chris Blake <chrisrblake93@gmail.com> # # Custom upgrade script for Meraki NAND devices (ex. MR18) # Based on dir825.sh and stock nand functions @@ -14,34 +14,52 @@ get_magic_at() { dd bs=1 count=2 skip=$pos if=$mtddev 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"' } -mr18_is_caldata_valid() { - local mtddev=$1 +meraki_is_caldata_valid() { + local board=$1 + local mtddev=$2 local magic - magic=$(get_magic_at $mtddev 4096) - [ "$magic" != "0202" ] && return 0 + case "$board" in + "mr18") + magic=$(get_magic_at $mtddev 4096) + [ "$magic" != "0202" ] && return 0 + + magic=$(get_magic_at $mtddev 20480) + [ "$magic" != "0202" ] && return 0 - magic=$(get_magic_at $mtddev 20480) - [ "$magic" != "0202" ] && return 0 + magic=$(get_magic_at $mtddev 36864) + [ "$magic" != "0202" ] && return 0 + + return 1 + ;; + "z1") + magic=$(get_magic_at $mtddev 4096) + [ "$magic" != "0202" ] && return 0 - magic=$(get_magic_at $mtddev 36864) - [ "$magic" != "0202" ] && return 0 + magic=$(get_magic_at $mtddev 86016) + [ "$magic" != "a55a" ] && return 0 - return 1 + return 1 + ;; + *) + return 1 + ;; + esac } merakinand_copy_caldata() { local cal_src=$1 local cal_dst=$2 - local ubidev=$( nand_find_ubi $CI_UBIPART ) + local ubidev="$(nand_find_ubi $CI_UBIPART)" local board_name="$(cat /tmp/sysinfo/board_name)" local rootfs_size="$(ubinfo /dev/ubi0 -N rootfs_data | grep "Size" | awk '{ print $6 }')" # Setup partitions using board name, in case of future platforms case "$board_name" in - "mr18") + "mr18"|\ + "z1") # Src is MTD - mtd_src=$(find_mtd_chardev $cal_src) + mtd_src="$(find_mtd_chardev $cal_src)" [ -n "$mtd_src" ] || { echo "no mtd device found for partition $cal_src" exit 1 @@ -56,12 +74,12 @@ merakinand_copy_caldata() { exit 1 } - mr18_is_caldata_valid "$mtd_src" && { + meraki_is_caldata_valid "$board_name" "$mtd_src" && { echo "no valid calibration data found in $cal_src" exit 1 } - mr18_is_caldata_valid "/dev/$mtd_dst" && { + meraki_is_caldata_valid "$board_name" "/dev/$mtd_dst" && { echo "Copying calibration data from $cal_src to $cal_dst..." dd if="$mtd_src" of=/tmp/caldata.tmp 2>/dev/null ubiupdatevol "/dev/$mtd_dst" /tmp/caldata.tmp @@ -89,6 +107,11 @@ merakinand_do_kernel_check() { echo "pass" && return 0 } ;; + "z1") + [ "$image_magic_word" == "4d495053" ] && { + echo "pass" && return 0 + } + ;; esac exit 1 @@ -102,7 +125,8 @@ merakinand_do_platform_check() { local kernel_magic="$(merakinand_do_kernel_check $1 $2)" case "$board_name" in - "mr18") + "mr18"|\ + "z1") [ "$control_length" = 0 -o "$file_type" != "squashfs" -o "$kernel_magic" != "pass" ] && { echo "Invalid sysupgrade file for $board_name" return 1 @@ -128,6 +152,11 @@ merakinand_do_upgrade() { merakinand_copy_caldata "odm-caldata" "caldata" nand_do_upgrade $1 ;; + "z1") + # Check and create UBI caldata if it's invalid + merakinand_copy_caldata "origcaldata" "caldata" + nand_do_upgrade $1 + ;; *) echo "Unsupported device $board_name"; exit 1 diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index 716fa52..c78d1fb 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -472,7 +472,8 @@ platform_check_image() { } return 0 ;; - mr18) + mr18 | \ + z1 ) merakinand_do_platform_check $board $1 return $?; ;; @@ -543,7 +544,8 @@ platform_pre_upgrade() { wndr4300 ) nand_do_upgrade "$1" ;; - mr18) + mr18 | \ + z1 ) merakinand_do_upgrade "$1" ;; esac |