ramips: add support for Netgear WAX202
authorWenli Looi <wlooi@ucalgary.ca>
Sat, 2 Jul 2022 20:18:59 +0000 (20:18 +0000)
committerChristian Marangi <ansuelsmth@gmail.com>
Tue, 19 Jul 2022 12:49:04 +0000 (14:49 +0200)
Netgear WAX202 is an 802.11ax (Wi-Fi 6) router.

Specifications:
* SoC: MT7621A
* RAM: 512 MiB NT5CC256M16ER-EK
* Flash: NAND 128 MiB F59L1G81MB-25T
* Wi-Fi:
  * MT7915D: 2.4/5 GHz (DBDC)
* Ethernet: 4x 1GbE
  * Switch: SoC built-in
* USB: None
* UART: 115200 baud (labeled on board)

Load addresses (same as ipTIME AX2004M):
* stock
  * 0x80010000: FIT image
  * 0x81001000: kernel image -> entry
* OpenWrt
  * 0x80010000: FIT image
  * 0x82000000: uncompressed kernel+relocate image
  * 0x80001000: relocated kernel image -> entry

Installation:
* Flash the factory image through the stock web interface, or TFTP to
  the bootloader. NMRP can be used to TFTP without opening the case.
* Note that the bootloader accepts both encrypted and unencrypted
  images, while the stock web interface only accepts encrypted ones.

Revert to stock firmware:
* Flash the stock firmware to the bootloader using TFTP/NMRP.

References in WAX202 GPL source:
https://www.downloads.netgear.com/files/GPL/WAX202_V1.0.5.1_Source.rar

* openwrt/target/linux/ramips/dts/mt7621-ax-nand-wax202.dts
  DTS file for this device.

Signed-off-by: Wenli Looi <wlooi@ucalgary.ca>
target/linux/ramips/dts/mt7621_netgear_wax202.dts [new file with mode: 0644]
target/linux/ramips/image/mt7621.mk
target/linux/ramips/mt7621/base-files/etc/board.d/01_leds
target/linux/ramips/mt7621/base-files/etc/board.d/02_network
target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac
target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh

diff --git a/target/linux/ramips/dts/mt7621_netgear_wax202.dts b/target/linux/ramips/dts/mt7621_netgear_wax202.dts
new file mode 100644 (file)
index 0000000..fef8094
--- /dev/null
@@ -0,0 +1,277 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7621.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       compatible = "netgear,wax202", "mediatek,mt7621-soc";
+       model = "Netgear WAX202";
+
+       aliases {
+               led-boot = &led_power_green;
+               led-failsafe = &led_power_orange;
+               led-running = &led_power_green;
+               led-upgrade = &led_power_orange;
+       };
+
+       chosen {
+               bootargs = "console=ttyS0,115200";
+       };
+
+       keys {
+               compatible = "gpio-keys";
+
+               reset {
+                       label = "reset";
+                       gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_RESTART>;
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_power_green: power_green {
+                       label = "green:power";
+                       gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
+               };
+
+               led_power_orange: power_orange {
+                       label = "orange:power";
+                       gpios = <&gpio 17 GPIO_ACTIVE_HIGH>;
+               };
+
+               led_net_green: net_green {
+                       label = "green:net";
+                       gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
+               };
+
+               led_net_blue: net_blue {
+                       label = "blue:net";
+                       gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
+               };
+
+               led_lan1_green: lan1_green {
+                       label = "green:lan1";
+                       gpios = <&switch0 3 GPIO_ACTIVE_LOW>;
+               };
+
+               led_lan1_orange: lan1_orange {
+                       label = "orange:lan1";
+                       gpios = <&gpio 15 GPIO_ACTIVE_LOW>;
+               };
+
+               led_lan2_green: lan2_green {
+                       label = "green:lan2";
+                       gpios = <&switch0 6 GPIO_ACTIVE_LOW>;
+               };
+
+               led_lan2_orange: lan2_orange {
+                       label = "orange:lan2";
+                       gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
+               };
+
+               led_lan3_green: lan3_green {
+                       label = "green:lan3";
+                       gpios = <&switch0 12 GPIO_ACTIVE_LOW>;
+               };
+
+               led_lan3_orange: lan3_orange {
+                       label = "orange:lan3";
+                       gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
+               };
+
+               led_wifi2g_green: wifi2g_green {
+                       label = "green:wifi2g";
+                       gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy0radio";
+               };
+
+               led_wifi2g_blue: wifi2g_blue {
+                       label = "blue:wifi2g";
+                       gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
+               };
+
+               led_wifi5g_green: wifi5g_green {
+                       label = "green:wifi5g";
+                       gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "phy1radio";
+               };
+
+               led_wifi5g_blue: wifi5g_blue {
+                       label = "blue:wifi5g";
+                       gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
+               };
+       };
+};
+
+&nand {
+       status = "okay";
+
+       partitions {
+               compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               partition@0 {
+                       label = "Bootloader";
+                       reg = <0x0 0x80000>;
+                       read-only;
+               };
+
+               partition@80000 {
+                       label = "Config";
+                       reg = <0x80000 0x80000>;
+                       read-only;
+               };
+
+               factory: partition@100000 {
+                       label = "Factory";
+                       reg = <0x100000 0x80000>;
+                       read-only;
+               };
+
+               partition@180000 {
+                       label = "firmware";
+                       reg = <0x180000 0x2600000>;
+
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "kernel";
+                               reg = <0x0 0x400000>;
+                       };
+
+                       partition@400000 {
+                               label = "ubi";
+                               reg = <0x400000 0x2200000>;
+                       };
+               };
+
+               partition@2780000 {
+                       label = "firmware_backup";
+                       reg = <0x2780000 0x2600000>;
+                       read-only;
+               };
+
+               partition@4d80000 {
+                       label = "CFG";
+                       reg = <0x4d80000 0x800000>;
+                       read-only;
+               };
+
+               partition@5580000 {
+                       label = "RAE";
+                       reg = <0x5580000 0x400000>;
+                       read-only;
+               };
+
+               partition@5980000 {
+                       label = "POT";
+                       reg = <0x5980000 0x100000>;
+                       read-only;
+               };
+
+               partition@5a80000 {
+                       label = "Language";
+                       reg = <0x5a80000 0x400000>;
+                       read-only;
+               };
+
+               partition@5e80000 {
+                       label = "Traffic";
+                       reg = <0x5e80000 0x200000>;
+                       read-only;
+               };
+
+               partition@6080000 {
+                       label = "Cert";
+                       reg = <0x6080000 0x100000>;
+                       read-only;
+               };
+
+               partition@6180000 {
+                       label = "NTGRcryptK";
+                       reg = <0x6180000 0x100000>;
+                       read-only;
+               };
+
+               partition@6280000 {
+                       label = "NTGRcryptD";
+                       reg = <0x6280000 0x500000>;
+                       read-only;
+               };
+
+               partition@6780000 {
+                       label = "LOG";
+                       reg = <0x6780000 0x100000>;
+                       read-only;
+               };
+
+               partition@6880000 {
+                       label = "User_data";
+                       reg = <0x6880000 0x640000>;
+                       read-only;
+               };
+       };
+};
+
+&pcie {
+       status = "okay";
+};
+
+&pcie1 {
+       wifi@0,0 {
+               compatible = "mediatek,mt76";
+               reg = <0x0000 0 0 0 0>;
+               mediatek,mtd-eeprom = <&factory 0x0>;
+       };
+};
+
+&pcie2 {
+       status = "disabled";
+};
+
+&state_default {
+       gpio {
+               groups = "uart3", "uart2", "jtag", "wdt";
+               function = "gpio";
+       };
+};
+
+&switch0 {
+       gpio-controller;
+       #gpio-cells = <2>;
+
+       ports {
+               port@0 {
+                       status = "okay";
+                       label = "wan";
+               };
+
+               port@1 {
+                       status = "okay";
+                       label = "lan1";
+               };
+
+               port@2 {
+                       status = "okay";
+                       label = "lan2";
+               };
+
+               /* port@3 is not used */
+
+               port@4 {
+                       status = "okay";
+                       label = "lan3";
+               };
+       };
+};
+
+&xhci {
+       status = "disabled";
+};
index f79ba5fb5a49aa5cd4c429fcc0fac649c5c6dade..4d2f2a3610d15ab7836cc3eaa4e69ec3b1701676 100644 (file)
@@ -1427,6 +1427,29 @@ define Device/netgear_wac124
 endef
 TARGET_DEVICES += netgear_wac124
 
+define Device/netgear_wax202
+  $(Device/dsa-migration)
+  DEVICE_VENDOR := NETGEAR
+  DEVICE_MODEL := WAX202
+  DEVICE_PACKAGES := kmod-mt7915e
+  NETGEAR_ENC_MODEL := WAX202
+  NETGEAR_ENC_REGION := US
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  UBINIZE_OPTS := -E 5
+  IMAGE_SIZE := 38912k
+  KERNEL_SIZE := 4096k
+  KERNEL_LOADADDR := 0x82000000
+  KERNEL := kernel-bin | relocate-kernel 0x80001000 | lzma | \
+       fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb | \
+       append-squashfs4-fakeroot
+  IMAGES += factory.img
+  IMAGE/factory.img := append-kernel | pad-to $$(KERNEL_SIZE) | \
+       append-ubi | check-size | netgear-encrypted-factory
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+TARGET_DEVICES += netgear_wax202
+
 define Device/netgear_wndr3700-v5
   $(Device/dsa-migration)
   $(Device/netgear_sercomm_nor)
index 0caa23feacc67c59509595e88ca17242a455babf..4b912283e1e1b331ee0723c4fb68dba608de3b98 100644 (file)
@@ -116,6 +116,12 @@ netgear,r7450)
        ucidef_set_led_netdev "lan3" "LAN3" "white:lan3" "lan3"
        ucidef_set_led_netdev "lan4" "LAN4" "white:lan4" "lan4"
        ;;
+netgear,wax202)
+       ucidef_set_led_netdev "internet" "Internet" "green:net" "wan"
+       ucidef_set_led_netdev "lan1" "LAN1" "green:lan1" "lan1"
+       ucidef_set_led_netdev "lan2" "LAN2" "green:lan2" "lan2"
+       ucidef_set_led_netdev "lan3" "LAN3" "green:lan3" "lan3"
+       ;;
 oraybox,x3a)
        ucidef_set_led_netdev "wan" "wan link" "red:status" "wan"
        ucidef_set_led_netdev "lan" "lan link" "green:status" "br-lan"
index 8abee198a5ba8b1b8c10b6274f7f34cfd3e4d054..39e095584dfe99ca5c476389c912d51bbdf0df4b 100644 (file)
@@ -27,6 +27,7 @@ ramips_setup_interfaces()
        ampedwireless,ally-r1900k|\
        gehua,ghl-r-001|\
        hiwifi,hc5962|\
+       netgear,wax202|\
        xiaomi,mi-router-3-pro|\
        xiaomi,mi-router-ac2100|\
        xiaomi,mi-router-cr6606|\
@@ -197,6 +198,11 @@ ramips_setup_macs()
                wan_mac=$label_mac
                lan_mac=$(macaddr_add $label_mac 1)
                ;;
+       netgear,wax202)
+               lan_mac=$(mtd_get_mac_ascii Config mac)
+               wan_mac=$(macaddr_add "$lan_mac" 1)
+               label_mac=$lan_mac
+               ;;
        raisecom,msg1500-x-00)
                lan_mac=$(mtd_get_mac_ascii Config protest_lan_mac)
                wan_mac=$(mtd_get_mac_ascii Config protest_wan_mac)
index 3390104e8088efd80cba844f5876d104b2793d71..4649b9e9d0a89b69cc3e4809b3b83a190a5f9362 100644 (file)
@@ -76,6 +76,11 @@ case "$board" in
                [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 1 > /sys${DEVPATH}/macaddress
                [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
                ;;
+       netgear,wax202)
+               hw_mac_addr=$(mtd_get_mac_ascii Config mac)
+               [ "$PHYNBR" = "0" ] && macaddr_add $hw_mac_addr 2 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $hw_mac_addr 3 > /sys${DEVPATH}/macaddress
+               ;;
        oraybox,x3a)
                if [ "$PHYNBR" = "1" ]; then
                        hw_mac_addr="$(mtd_get_mac_binary factory 0x4)"
index 7d44fcf90f0df2560d6b4a0c37bedb60c3f39edb..9becffa357b4957be9486798cc12133e35c33ec5 100755 (executable)
@@ -84,6 +84,7 @@ platform_do_upgrade() {
        netgear,r7450|\
        netgear,wac104|\
        netgear,wac124|\
+       netgear,wax202|\
        netis,wf2881|\
        raisecom,msg1500-x-00|\
        sercomm,na502|\