ath79: add Cisco Meraki Z1
authorChristian Lamparter <chunkeey@gmail.com>
Wed, 23 Jun 2021 20:46:52 +0000 (22:46 +0200)
committerChristian Lamparter <chunkeey@gmail.com>
Sun, 24 Oct 2021 01:04:29 +0000 (03:04 +0200)
Specifications:

SOC: Atheros AR9344 @ 560MHz
RAM: 2x Winbond W9751G6KB-25 (128 MiB)
FLASH: Hynix H27U1G8F2BTR (128 MiB)
WIFI1: Atheros AR9340 5.0GHz (SoC)
WIFI2: Atheros AR9280 2.4GHz
SWITCH: Atheros AR8236 (5x Gigabit (1x WAN, 4x LAN)
LED: 1x Power-LED, 1 x RGB Tricolor-LED
INPUT: One Reset Button
USB: One USB 2.0 Port
UART: JP1 on PCB (Labeled UART), 3.3v-Level, 115200n8
        (GND, TX, RX, VCC - GND is next to the UART silk screen)

Flashing Instructions:

Since this device is brought over from an old AR71xx, there's
already a wiki-page with detailed instructions:
<https://openwrt.org/toh/meraki/z1>

The gist:
1. Get a root-shell on the device (see wiki). (needs UART access)
2. make a backup (to a PC/safe location) of the existing Meraki
   firmware.
3. copy over the OpenWrt initramfs kernel for the Z1.
   This gets written into the kernel NAND partition.
   (Verify that written image is complete!)

After the following reboot and successfull boot of the staging
OpenWrt initramfs image:

4. copy over the sysupgrade.bin for the router and use sysupgrade
   to make the installation permanent.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
target/linux/ath79/dts/ar9344_meraki_z1.dts [new file with mode: 0644]
target/linux/ath79/image/nand.mk
target/linux/ath79/nand/base-files/etc/board.d/01_leds
target/linux/ath79/nand/base-files/etc/board.d/02_network
target/linux/ath79/nand/base-files/etc/hotplug.d/firmware/10-ath9k-eeprom

diff --git a/target/linux/ath79/dts/ar9344_meraki_z1.dts b/target/linux/ath79/dts/ar9344_meraki_z1.dts
new file mode 100644 (file)
index 0000000..3a7fabd
--- /dev/null
@@ -0,0 +1,164 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include "ar9344.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "meraki,z1", "qca,ar9344";
+       model = "Cisco Meraki Z1";
+
+       aliases {
+               led-boot = &led_power_orange;
+               led-failsafe = &led_power_orange;
+               led-upgrade = &led_power_orange;
+               label-mac-device = &eth0;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,115200n8";
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+               reset {
+                       label = "Reset button";
+                       linux,code = <KEY_RESTART>;
+                       gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
+                       debounce-interval = <60>;
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_power_orange: power_orange {
+                       label = "orange:power";
+                       gpios = <&gpio 17 GPIO_ACTIVE_LOW>;
+               };
+       };
+};
+
+&ref {
+       clock-frequency = <40000000>;
+};
+
+&gpio {
+       pinctrl-names = "default";
+       pinctrl-0 = <&jtag_disable_pins>;
+
+       gpio_ext_lna0 {
+               gpio-hog;
+               gpios = <18 0>;
+               output-low;
+               line-name = "z1:ext:lna0";
+       };
+
+       gpio_ext_lna1 {
+               gpio-hog;
+               gpios = <19 0>;
+               output-low;
+               line-name = "z1:ext:lna1";
+       };
+};
+
+&usb {
+       status = "okay";
+};
+
+&usb_phy {
+       status = "okay";
+};
+
+&pcie {
+       status = "okay";
+
+       ath9k: wifi@0,0 {
+               compatible = "pci168c,002a"; /* check the pciid - AR9283 */
+               reg = <0x0000 0 0 0 0>;
+               qca,no-eeprom;
+       };
+};
+
+&wmac {
+       status = "okay";
+};
+
+&nand {
+       status = "okay";
+
+       partitions {
+               compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               partition@0 {
+                       label = "loader1";
+                       reg = <0x0 0x20000>;
+                       read-only;
+               };
+
+               partition@20000 {
+                       label = "kernel";
+                       reg = <0x20000 0x7e0000>;
+               };
+
+               partition@800000 {
+                       label = "loader2";
+                       reg = <0x800000 0x20000>;
+                       read-only;
+               };
+
+               partition@820000 {
+                       label = "recovery";
+                       reg = <0x820000 0x7e0000>;
+               };
+
+               partition@1000000 {
+                       label = "ubi";
+                       reg = <0x1000000 0x6fe0000>;
+               };
+
+               partition@7fe0000 {
+                       label = "origcaldata";
+                       reg = <0x7fe0000 0x20000>;
+                       read-only;
+               };
+       };
+};
+
+&mdio0 {
+       status = "okay";
+
+       phy0: ethernet-phy@0 {
+               reg = <0>;
+
+#if 0
+               /* dummy values */
+               qca,ar8327-initvals = <
+                       0x04 0x87600000 /* PORT0 PAD MODE CTRL */
+                       0x7c 0x0000007e /* PORT0_STATUS */
+                       >;
+#endif
+       };
+};
+
+&eth0 {
+       status = "okay";
+
+       pll-data = <0x06000000 0x00000101 0x00001313>;
+       phy-mode = "rgmii-id";
+
+       fixed-link {
+               speed = <1000>;
+               full-duplex;
+       };
+
+       gmac-config {
+               device = <&gmac>;
+               rgmii-gmac0 = <1>;
+               switch-only-mode = <1>;
+       };
+};
index 52631789d9c5b34bd40743cf79eea784efa77aaa..bece02cd12c8011eacf67e4edf3ab8b10f5be381 100644 (file)
@@ -1,3 +1,11 @@
+define Build/meraki-old-nand
+       -$(STAGING_DIR_HOST)/bin/mkmerakifw-old \
+               -B $(1) -s \
+               -i $@ \
+               -o $@.new
+       @mv $@.new $@
+endef
+
 # attention: only zlib compression is allowed for the boot fs
 define Build/zyxel-buildkerneljffs
        rm -rf  $(KDIR_TMP)/zyxelnbg6716
@@ -148,6 +156,19 @@ define Device/glinet_gl-e750
 endef
 TARGET_DEVICES += glinet_gl-e750
 
+define Device/meraki_z1
+  SOC = ar9344
+  DEVICE_VENDOR := Meraki
+  DEVICE_MODEL := Z1
+  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ledtrig-usbport kmod-owl-loader
+  KERNEL_SIZE := 8064k
+  BLOCKSIZE := 64k
+  PAGESIZE := 2048
+  KERNEL := kernel-bin | meraki-old-nand z1
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+TARGET_DEVICES += meraki_z1
+
 # fake rootfs is mandatory, pad-offset 129 equals (2 * uimage_header + 0xff)
 define Device/netgear_ath79_nand
   DEVICE_VENDOR := NETGEAR
index fc745547634e275d13f5db19bb393bbb6291fb27..4b4fd9a94ea18ff351a1f5bff172e72d24c0cdeb 100644 (file)
@@ -10,6 +10,9 @@ glinet,gl-ar300m-nand|\
 glinet,gl-ar300m-nor)
        ucidef_set_led_netdev "lan" "LAN" "green:lan" "eth0"
        ;;
+meraki,z1)
+       ucidef_set_led_default "diag" "DIAG" "green:tricolor" "1"
+       ;;
 netgear,wndr3700-v4|\
 netgear,wndr4300|\
 netgear,wndr4300sw|\
index 7402fc067a5b3ca01ed7b3f70c6393ac17f850fb..4dc3b0669c05002e58a9975faa2ace8cb3767525 100644 (file)
@@ -32,6 +32,10 @@ ath79_setup_interfaces()
                ucidef_add_switch "switch0" \
                        "0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1"
                ;;
+       meraki,z1)
+               ucidef_add_switch "switch0" \
+                       "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
+               ;;
        zyxel,nbg6716)
                ucidef_add_switch "switch0" \
                        "0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan" "6@eth1"
@@ -54,6 +58,10 @@ ath79_setup_macs()
        netgear,wndr4500-v3)
                wan_mac=$(mtd_get_mac_binary caldata 0x6)
                ;;
+       meraki,z1)
+               lan_mac=$(mtd_get_mac_binary_ubi board-config 102)
+               wan_mac=$(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) 1)
+               ;;
        esac
 
        [ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
index cac955905af138d112182b0bd998a42b93eabdd1..caa0fc64ecb29d025dd3ad08489bad2850d3113a 100644 (file)
@@ -20,6 +20,16 @@ case "$FIRMWARE" in
        netgear,wndr4500-v3)
                caldata_extract "caldata" 0x1000 0x440
                ;;
+       meraki,z1)
+               . /lib/upgrade/nand.sh
+
+               if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
+                       caldata_extract_ubi "caldata" 0x1000 0x800
+               else
+                       caldata_extract "origcaldata" 0x1000 0x800
+                       ath9k_patch_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) 2)
+               fi
+               ;;
        *)
                caldata_die "board $board is not supported yet"
                ;;
@@ -35,6 +45,16 @@ case "$FIRMWARE" in
        netgear,wndr4500-v3)
                caldata_extract "caldata" 0x5000 0x440
                ;;
+       meraki,z1)
+               . /lib/upgrade/nand.sh
+
+               if [ -n "$(nand_find_volume ubi0 caldata)" ]; then
+                       caldata_extract_ubi "caldata" 0x15000 0x1000
+               else
+                       caldata_extract "origcaldata" 0x15000 01000
+                       ath9k_patch_mac $(macaddr_add $(mtd_get_mac_binary_ubi board-config 102) 3)
+               fi
+               ;;
        *)
                caldata_die "board $board is not supported yet"
                ;;