From a57d6e2d47688cfa392d6ea7f36ae6f9d84affc5 Mon Sep 17 00:00:00 2001 From: Chris Blake Date: Wed, 20 Jul 2016 15:44:51 +0200 Subject: apm821xx: add support for the Cisco Meraki MR24 This patch adds support for the Cisco Meraki MR24 Access point to the apm821xx target. Board: MR24 - Meraki MR24 Cloud Managed Access Point CPU: APM82181 SoC 800 MHz (PLB=200 OPB=100 EBC=100) Flash size: 32MiB RAM Size: 128MiB Wireless: Atheros AR9380 5.0GHz + Atheros AR9380 2.4GHz Ethernet ports: 1x Gigabit Atheros AR8035 WARNING: The serial port needs a TTL/RS-232 v3.3 level converter! For flashing instructions, visit: Signed-off-by: Chris Blake --- target/linux/apm821xx/base-files/lib/apm821xx.sh | 4 ++ .../lib/preinit/05_set_iface_mac_apm821xx | 14 +++++ .../apm821xx/base-files/lib/upgrade/merakinand.sh | 65 ++++++++++++++++++++++ .../apm821xx/base-files/lib/upgrade/platform.sh | 9 +++ 4 files changed, 92 insertions(+) create mode 100644 target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx create mode 100755 target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh (limited to 'target/linux/apm821xx/base-files/lib') diff --git a/target/linux/apm821xx/base-files/lib/apm821xx.sh b/target/linux/apm821xx/base-files/lib/apm821xx.sh index 8f15ced8ca..82f85c56be 100755 --- a/target/linux/apm821xx/base-files/lib/apm821xx.sh +++ b/target/linux/apm821xx/base-files/lib/apm821xx.sh @@ -10,6 +10,10 @@ apm821xx_board_detect() { model=$(awk 'BEGIN{FS="[ \t]+:[ \t]"} /model/ {print $2}' /proc/cpuinfo) case "$model" in + *"Meraki MR24 Access Point") + name="mr24" + ;; + *) name="unknown" ;; diff --git a/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx b/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx new file mode 100644 index 0000000000..5dc7175730 --- /dev/null +++ b/target/linux/apm821xx/base-files/lib/preinit/05_set_iface_mac_apm821xx @@ -0,0 +1,14 @@ +#!/bin/sh + +. /lib/apm821xx.sh + +preinit_set_mac_address() { + case $(apm821xx_board_name) in + mr24) + mac_lan=$(mtd_get_mac_binary_ubi board-config 102) + [ -n "$mac_lan" ] && ifconfig eth0 hw ether "$mac_lan" + ;; + esac +} + +boot_hook_add preinit_main preinit_set_mac_address diff --git a/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh b/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh new file mode 100755 index 0000000000..5861d97f12 --- /dev/null +++ b/target/linux/apm821xx/base-files/lib/upgrade/merakinand.sh @@ -0,0 +1,65 @@ +#!/bin/sh +# +# Copyright (C) 2016 Chris Blake +# +# Custom upgrade script for Meraki NAND devices (ex. MR24) +# Based on merakinand.sh from the ar71xx target +# +. /lib/apm821xx.sh +. /lib/functions.sh + +merakinand_do_kernel_check() { + local board_name="$1" + local tar_file="$2" + local image_magic_word=`(tar xf $tar_file sysupgrade-$board_name/kernel -O 2>/dev/null | dd bs=1 count=4 skip=0 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"')` + + # What is our kernel magic string? + case "$board_name" in + "mr24") + [ "$image_magic_word" == "8e73ed8a" ] && { + echo "pass" && return 0 + } + ;; + esac + + exit 1 +} + +merakinand_do_platform_check() { + local board_name="$1" + local tar_file="$2" + local control_length=`(tar xf $tar_file sysupgrade-$board_name/CONTROL -O | wc -c) 2> /dev/null` + local file_type="$(identify_tar $2 sysupgrade-$board_name/root)" + local kernel_magic="$(merakinand_do_kernel_check $1 $2)" + + case "$board_name" in + "mr24") + [ "$control_length" = 0 -o "$file_type" != "squashfs" -o "$kernel_magic" != "pass" ] && { + echo "Invalid sysupgrade file for $board_name" + return 1 + } + ;; + *) + echo "Unsupported device $board_name"; + return 1 + ;; + esac + + return 0 +} + +merakinand_do_upgrade() { + local tar_file="$1" + local board_name="$(cat /tmp/sysinfo/board_name)" + + # Do we need to do any platform tweaks? + case "$board_name" in + "mr24") + nand_do_upgrade $1 + ;; + *) + echo "Unsupported device $board_name"; + exit 1 + ;; + esac +} diff --git a/target/linux/apm821xx/base-files/lib/upgrade/platform.sh b/target/linux/apm821xx/base-files/lib/upgrade/platform.sh index 2406113bad..ddf775f4ae 100755 --- a/target/linux/apm821xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/apm821xx/base-files/lib/upgrade/platform.sh @@ -11,6 +11,11 @@ platform_check_image() { [ "$#" -gt 1 ] && return 1 case "$board" in + mr24) + merakinand_do_platform_check $board "$1" + return $?; + ;; + *) ;; esac @@ -23,6 +28,10 @@ platform_pre_upgrade() { local board=$(apm821xx_board_name) case "$board" in + mr24) + merakinand_do_upgrade "$1" + ;; + *) ;; esac -- cgit v1.2.3