mediatek: add support for ZyXEL NWA50AX Pro
authorDavid Bauer <mail@david-bauer.net>
Sat, 15 Jul 2023 16:10:31 +0000 (18:10 +0200)
committerDavid Bauer <mail@david-bauer.net>
Sun, 23 Jul 2023 14:10:08 +0000 (16:10 +0200)
Hardware
--------
CPU:    Mediatek MT7981
RAM:    512M DDR4
FLASH:  256M NAND
ETH:    MaxLinear GPY211 (2.5GbE N Base-T)
WiFi:   Mediatek MT7981 (2.4GHz 2T2R:2 5GHz 3T3R:2 802.11ax)
BTN:    1x Reset
LED:    1x Multi-Color

UART Console
------------
Available below the rubber cover next to the ethernet port.

Settings: 115200 8N1

Layout:

<12V> <LAN> GND-RX-TX-VCC

Logic-Level is 3V3. Don't connect VCC to your UART adapter!

Installation Web-UI
-------------------
Upload the Factory image using the devices Web-Interface.

As the device uses a dual-image partition layout, OpenWrt can only
installed on Slot A. This requires the current active image prior
flashing the device to be on Slot B.

In case this is not the case, OpenWrt will boot only one time, returning
to the ZyXEL firmware the second boot.

If this happens, first install a ZyXEL firmware upgrade of any version
and install OpenWrt after that.

Installation TFTP / Recovery
----------------------------
This installation routine is especially useful in case of a bricked
device.

Attach to the UART console header of the device. Interrupt the boot
procedure by pressing Enter.

The bootloader has a reduced command-set available from CLI, but more
commands can be executed by abusing the atns command.

Boot a OpenWrt initramfs image available on a TFTP server at
192.168.1.66. Rename the image to nwa50axpro-openwrt-initramfs.bin.

 $ atnf nwa50axpro-openwrt-initramfs.bin
 $ atna 192.168.1.88
 $ atns "192.168.1.66; tftpboot; setenv fdt_high 0xffffffffffffffff;
   bootm"

Upon booting, set the booted image to the correct slot:

 $ zyxel-bootconfig /dev/mtd9 get-status
 $ zyxel-bootconfig /dev/mtd9 set-image-status 0 valid
 $ zyxel-bootconfig /dev/mtd9 set-active-image 0

Copy the OpenWrt sysupgrade image to the device using scp.
Write the sysupgrade image to NAND using sysupgrade.

 $ sysupgrade -n image.bin

Signed-off-by: David Bauer <mail@david-bauer.net>
(cherry picked from commit f0445746f6fd96fc7c5394b238153bd2ff22bc5b)

package/utils/zyxel-bootconfig/files/95_apply_bootconfig
scripts/mkits-zyxel-fit-filogic.sh [new file with mode: 0755]
target/linux/mediatek/dts/mt7981b-zyxel-nwa50ax-pro.dts [new file with mode: 0644]
target/linux/mediatek/filogic/base-files/etc/board.d/02_network
target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
target/linux/mediatek/image/filogic.mk

index 500b81234a60f6d9584770ead493dd9e2d98c226..c98bc8fbe24ae5a1958e3884d1a73928fb384b0d 100644 (file)
@@ -3,6 +3,7 @@ apply_bootconfig() {
 
        case $(board_name) in
        zyxel,nwa50ax|\
+       zyxel,nwa50ax-pro|\
        zyxel,nwa55axe)
                mtd_idx=$(find_mtd_index "bootconfig")
                zyxel-bootconfig "/dev/mtd$mtd_idx" set-image-status 0 valid
diff --git a/scripts/mkits-zyxel-fit-filogic.sh b/scripts/mkits-zyxel-fit-filogic.sh
new file mode 100755 (executable)
index 0000000..319e187
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+#
+# Licensed under the terms of the GNU GPL License version 2 or later.
+# Author: David Bauer <mail@david-bauer.net>, based on mkits-zyxel-factory.sh.
+
+usage() {
+       echo "Usage: `basename $0` output file compat-models"
+       exit 1
+}
+
+# We need at least 3 arguments
+[ "$#" -lt 3 ] && usage
+
+# Target output file
+OUTPUT="$1"; shift
+FILE="$1"; shift
+MODELS="$1"; shift
+
+# Create a default, fully populated DTS file
+echo "\
+/dts-v1/;
+
+/ {
+       timestamp = <0x684090B4>;
+       description = \"Zyxel FIT (Flattened Image Tree)\";
+       compat-models = [${MODELS}];
+       fw_version = \"9.99(###.1)\";
+       #address-cells = <1>;
+
+       images {
+               ubi {
+                       data = /incbin/(\"${FILE}\");
+                       type = \"firmware\";
+                       compression = \"none\";
+                       hash {
+                               algo = \"sha256\";
+                       };
+               };
+       };
+};" > ${OUTPUT}
diff --git a/target/linux/mediatek/dts/mt7981b-zyxel-nwa50ax-pro.dts b/target/linux/mediatek/dts/mt7981b-zyxel-nwa50ax-pro.dts
new file mode 100644 (file)
index 0000000..75dd84c
--- /dev/null
@@ -0,0 +1,225 @@
+/dts-v1/;
+
+#include "mt7981.dtsi"
+
+/ {
+       model = "ZyXEL NWA50AX Pro";
+       compatible = "zyxel,nwa50ax-pro", "mediatek,mt7981";
+
+       aliases {
+               led-boot = &led_green;
+               led-failsafe = &led_red;
+               led-running = &led_green;
+               led-upgrade = &led_red;
+               serial0 = &uart0;
+               label-mac-device = &gmac1;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       gpio-keys {
+               compatible = "gpio-keys";
+
+               reset {
+                       label = "reset";
+                       linux,code = <KEY_RESTART>;
+                       gpios = <&pio 1 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_green: led@0 {
+                       label = "green:system";
+                       gpios = <&pio 4 GPIO_ACTIVE_HIGH>;
+               };
+
+               led@1 {
+                       label = "blue:system";
+                       gpios = <&pio 6 GPIO_ACTIVE_HIGH>;
+               };
+
+               led_red: led@2 {
+                       label = "red:system";
+                       gpios = <&pio 7 GPIO_ACTIVE_HIGH>;
+               };
+       };
+};
+
+&uart0 {
+       status = "okay";
+};
+
+&watchdog {
+       status = "okay";
+};
+
+&eth {
+       pinctrl-names = "default";
+       pinctrl-0 = <&mdio_pins>;
+
+       status = "okay";
+
+       gmac1: mac@1 {
+               compatible = "mediatek,eth-mac";
+               reg = <1>;
+               phy-mode = "2500base-x";
+
+               phy-handle = <&phy0>;
+
+               nvmem-cells = <&macaddr_mrd_1fff8>;
+               nvmem-cell-names = "mac-address";
+       };
+};
+
+&mdio_bus {
+       reset-gpios = <&pio 12 GPIO_ACTIVE_LOW>;
+       reset-delay-us = <1500000>;
+       reset-post-delay-us = <1000000>;
+
+       phy0: ethernet-phy@5 {
+               reg = <5>;
+               compatible = "ethernet-phy-ieee802.3-c45";
+       };
+};
+
+&spi0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&spi0_flash_pins>;
+       status = "okay";
+
+       spi_nand: flash@0 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "spi-nand";
+               reg = <0>;
+               spi-max-frequency = <52000000>;
+
+               spi-cal-enable;
+               spi-cal-mode = "read-data";
+               spi-cal-datalen = <7>;
+               spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4E 0x41 0x4E 0x44>;
+               spi-cal-addrlen = <5>;
+               spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>;
+
+               spi-tx-buswidth = <4>;
+               spi-rx-buswidth = <4>;
+               mediatek,nmbm;
+               mediatek,bmt-max-ratio = <1>;
+               mediatek,bmt-max-reserved-blocks = <64>;
+
+               mediatek,bmt-remap-range =
+                       <0x0 0x580000>,
+                       <0xef00000 0xef80000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "BL2";
+                               reg = <0x00000 0x0100000>;
+                               read-only;
+                       };
+
+                       partition@100000 {
+                               label = "u-boot-env";
+                               reg = <0x0100000 0x0080000>;
+                       };
+
+                       factory: partition@180000 {
+                               label = "Factory";
+                               reg = <0x180000 0x0200000>;
+                               read-only;
+
+                               compatible = "nvmem-cells";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               macaddr: macaddr@a {
+                                       reg = <0xa 0x6>;
+                               };
+                       };
+
+                       partition@380000 {
+                               label = "FIP";
+                               reg = <0x380000 0x0200000>;
+                               read-only;
+                       };
+
+                       partition@580000 {
+                               label = "ubi";
+                               reg = <0x580000 0x3200000>;
+                       };
+
+                       partition@3780000 {
+                               label = "ubi_1";
+                               reg = <0x3780000 0x3200000>;
+                               read-only;
+                       };
+
+                       partition@6980000 {
+                               label = "rootfs-data";
+                               reg = <0x6980000 0x3c00000>;
+                               read-only;
+                       };
+
+                       partition@a580000 {
+                               label = "logs";
+                               reg = <0xa580000 0x3a80000>;
+                               read-only;
+                       };
+
+                       partition@e000000 {
+                               label = "myzyxel";
+                               reg = <0xe000000 0xf00000>;
+                               read-only;
+                       };
+
+                       partition@ef00000 {
+                               label = "bootconfig";
+                               reg = <0xef00000 0x80000>;
+                       };
+
+                       partition@ef80000 {
+                               label = "mrd";
+                               reg = <0xef80000 0x80000>;
+                               read-only;
+
+                               compatible = "nvmem-cells";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               macaddr_mrd_1fff8: macaddr@1fff8 {
+                                       reg = <0x1fff8 0x6>;
+                               };
+                       };
+               };
+       };
+};
+
+&pio {
+       spi0_flash_pins: spi0-pins {
+               mux {
+                       function = "spi";
+                       groups = "spi0", "spi0_wp_hold";
+               };
+       };
+
+       pwm_pins: pwm0-pins {
+               mux {
+                       function = "pwm";
+                       groups = "pwm0_1";
+               };
+       };
+};
+
+&wifi {
+       status = "okay";
+
+       mediatek,mtd-eeprom = <&factory 0x0>;
+};
index 6abc81a0b0561deb4fee427d183330b1251075ac..3b170ddc1885fc97a08d5603140320c55321d8cc 100644 (file)
@@ -11,7 +11,8 @@ mediatek_setup_interfaces()
        asus,tuf-ax4200)
                ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" eth1
                ;;
-       netgear,wax220)
+       netgear,wax220|\
+       zyxel,nwa50ax-pro)
                ucidef_set_interface_lan "eth0"
                ;;
        bananapi,bpi-r3)
index ab23b100444ce490aea722759d1f06db43f7fecc..3620e3a6fbc032fc5d442bba8a55fe5af750e094 100644 (file)
@@ -61,4 +61,9 @@ case "$board" in
                addr=$(mtd_get_mac_binary "Factory" 0x4)
                [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
                ;;
+       zyxel,nwa50ax-pro)
+               hw_mac_addr="$(mtd_get_mac_binary mrd 0x1fff8)"
+               [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
+               ;;
 esac
index 8d5caad113137ccf30eddfc1c03cf6f964d14711..c41cba3a642dced705d7f5f28304e67da3fa5163 100644 (file)
@@ -75,6 +75,13 @@ define Build/append-gl-metadata
        }
 endef
 
+define Build/zyxel-nwa-fit-filogic
+       $(TOPDIR)/scripts/mkits-zyxel-fit-filogic.sh \
+               $@.its $@ "80 e1 ff ff ff ff ff ff ff ff"
+       PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage -f $@.its $@.new
+       @mv $@.new $@
+endef
+
 define Device/asus_tuf-ax4200
   DEVICE_VENDOR := ASUS
   DEVICE_MODEL := TUF-AX4200
@@ -424,3 +431,21 @@ define Device/zyxel_ex5601-t0-stock
        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd
 endef
 TARGET_DEVICES += zyxel_ex5601-t0-stock
+
+define Device/zyxel_nwa50ax-pro
+  DEVICE_VENDOR := ZyXEL
+  DEVICE_MODEL := NWA50AX Pro
+  DEVICE_DTS := mt7981b-zyxel-nwa50ax-pro
+  DEVICE_DTS_DIR := ../dts
+  DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware zyxel-bootconfig
+  DEVICE_DTS_LOADADDR := 0x44000000
+  UBINIZE_OPTS := -E 5
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  IMAGE_SIZE := 51200k
+  KERNEL_IN_UBI := 1
+  IMAGES += factory.bin
+  IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE) | zyxel-nwa-fit-filogic
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+TARGET_DEVICES += zyxel_nwa50ax-pro