mediatek: add support for Buffalo WSR-3200AX4S
authorINAGAKI Hiroshi <musashino.open@gmail.com>
Sun, 27 Aug 2023 14:23:20 +0000 (23:23 +0900)
committerHauke Mehrtens <hauke@hauke-m.de>
Sun, 24 Sep 2023 16:42:12 +0000 (18:42 +0200)
Buffalo WSR-3200AX4S is a 2.4/5 GHz band 11ax (Wi-Fi 6) router, based on
MT7622B.

Specification:

- SoC         : MediaTek MT7622B
- RAM         : DDR3 512 MiB
- Flash       : SPI-NAND 128 MiB (Winbond W25N01GVZEIG)
- WLAN        : 2.4/5 GHz 4T4R
  - 2.4 GHz   : MediaTek MT7622B (SoC)
  - 5 GHz     : MediaTek MT7915
- Ethernet    : 5x 10/100/1000 Mbps
  - Switch    : MediaTek MT7531
- LEDs/Keys   : 6x/5x (2x: buttons, 3x: slide-switches)
- UART        : through-hole on PCB (J4)
  - assignment: 3.3V, GND, TX, RX from tri-angle marking
  - settings  : 115200n8
- Power       : 12 VDC, 1.5 A

Flash instruction using factory.bin image:

1. Boot WSR-3200AX4S with "Router" mode
2. Access to "http://192.168.11.1/" and open firmware update page
   ("ファームウェア更新")
3. Select the OpenWrt factory.bin image and click update ("更新実行")
   button
4. Wait ~120 seconds to complete flashing

Note:

- This device has 2x OS images on flash. The first one will always be
  used for booting and the secondary is for backup.

- This support generates multiple factory*.bin image:

  - factory.bin      : for flashing from OEM WebUI
  - factory-uboot.bin: for flashing from U-Boot or clean installation
                       via sysupgrade (don't use for normal sysupgrade)

Known issues:

- Wi-Fi MAC addresses won't be applied to each adapter.

MAC Addresses:

LAN    : C4:3C:EA:xx:xx:60 (board_data, mac (text))
WAN    : C4:3C:EA:xx:xx:60 (board_data, mac (text))
2.4 GHz: C4:3C:EA:xx:xx:61
5 GHz  : C4:3C:EA:xx:xx:68

Signed-off-by: INAGAKI Hiroshi <musashino.open@gmail.com>
target/linux/mediatek/dts/mt7622-buffalo-wsr-3200ax4s.dts [new file with mode: 0644]
target/linux/mediatek/image/mt7622.mk
target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
target/linux/mediatek/mt7622/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
target/linux/mediatek/mt7622/base-files/etc/uci-defaults/09_fix_crc
target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh

diff --git a/target/linux/mediatek/dts/mt7622-buffalo-wsr-3200ax4s.dts b/target/linux/mediatek/dts/mt7622-buffalo-wsr-3200ax4s.dts
new file mode 100644 (file)
index 0000000..678c31b
--- /dev/null
@@ -0,0 +1,175 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include "mt7622-buffalo-wsr.dtsi"
+
+/ {
+       model = "Buffalo WSR-3200AX4S";
+       compatible = "buffalo,wsr-3200ax4s", "mediatek,mt7622";
+
+       memory {
+               reg = <0 0x40000000 0 0x1f000000>;
+       };
+};
+
+&pio {
+       /* Serial NAND is shared pin with SPI-NOR */
+       serial_nand_pins: serial-nand-pins {
+               mux {
+                       function = "flash";
+                       groups = "snfi";
+               };
+
+               conf-cmd-dat {
+                       pins = "SPI_WP", "SPI_HOLD", "SPI_MOSI",
+                              "SPI_MISO", "SPI_CS";
+                       input-enable;
+                       drive-strength = <16>;
+                       bias-pull-up;
+               };
+
+               conf-clk {
+                       pins = "SPI_CLK";
+                       drive-strength = <16>;
+                       bias-pull-down;
+               };
+       };
+};
+
+&mdio {
+       switch@1f {
+               compatible = "mediatek,mt7531";
+               reg = <0x1f>;
+               reset-gpios = <&pio 54 GPIO_ACTIVE_HIGH>;
+
+               ports {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+
+                       port@0 {
+                               reg = <0>;
+                               label = "lan4";
+                       };
+
+                       port@1 {
+                               reg = <1>;
+                               label = "lan3";
+                       };
+
+                       port@2 {
+                               reg = <2>;
+                               label = "lan2";
+                       };
+
+                       port@3 {
+                               reg = <3>;
+                               label = "lan1";
+                       };
+
+                       port@4 {
+                               reg = <4>;
+                               label = "wan";
+                       };
+
+                       port@6 {
+                               reg = <6>;
+                               label = "cpu";
+                               ethernet = <&gmac0>;
+                               phy-connection-type = "2500base-x";
+
+                               fixed-link {
+                                       speed = <2500>;
+                                       full-duplex;
+                                       pause;
+                               };
+                       };
+               };
+       };
+};
+
+&snfi {
+       pinctrl-names = "default";
+       pinctrl-0 = <&serial_nand_pins>;
+       status = "okay";
+
+       flash@0 {
+               compatible = "spi-nand";
+               reg = <0>;
+               spi-max-frequency = <104000000>;
+               nand-ecc-engine = <&snfi>;
+               mediatek,bmt-v2;
+               mediatek,bmt-table-size = <0x1000>;
+               /*
+                * - Preloader - (kernel (6MiB, in firmware))
+                * - Kernel2 - WTB
+                */
+               mediatek,bmt-remap-range = <0x0 0x8c0000>,
+                                          <0x1ac0000 0x5200000>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "Preloader";
+                               reg = <0x0 0x80000>;
+                               read-only;
+                       };
+
+                       partition@80000 {
+                               label = "ATF";
+                               reg = <0x80000 0x40000>;
+                               read-only;
+                       };
+
+                       partition@c0000 {
+                               label = "u-boot";
+                               reg = <0xc0000 0x80000>;
+                               read-only;
+                       };
+
+                       partition@140000 {
+                               label = "u-boot-env";
+                               reg = <0x140000 0x80000>;
+                               read-only;
+                       };
+
+                       factory: partition@1c0000 {
+                               label = "factory";
+                               reg = <0x1c0000 0x100000>;
+                               read-only;
+                       };
+
+                       partition@2c0000 {
+                               compatible = "brcm,trx";
+                               brcm,trx-magic = <0x33504844>;
+                               label = "firmware";
+                               reg = <0x2c0000 0x1800000>;
+                       };
+
+                       partition@1ac0000 {
+                               label = "Kernel2";
+                               reg = <0x1ac0000 0x1800000>;
+                       };
+
+                       partition@32c0000 {
+                               label = "glbcfg";
+                               reg = <0x32c0000 0x200000>;
+                               read-only;
+                       };
+
+                       partition@34c0000 {
+                               label = "board_data";
+                               reg = <0x34c0000 0x200000>;
+                               read-only;
+                       };
+
+                       partition@36c0000 {
+                               label = "WTB";
+                               reg = <0x36c0000 0x3600000>;
+                               read-only;
+                       };
+               };
+       };
+};
index 6f64740628cf6ffe3034af0d6cffb539e08b955b..65db1ebe2e36fc75ca38438e792ae1a1cac29bbe 100644 (file)
@@ -1,5 +1,7 @@
 DTS_DIR := $(DTS_DIR)/mediatek
 
+DEVICE_VARS += BUFFALO_TRX_MAGIC
+
 define Image/Prepare
        # For UBI we want only one extra block
        rm -f $(KDIR)/ubi_mark
@@ -95,33 +97,38 @@ define Device/bananapi_bpi-r64
 endef
 TARGET_DEVICES += bananapi_bpi-r64
 
-define Device/buffalo_wsr-2533dhp2
+define Device/buffalo_wsr
   DEVICE_VENDOR := Buffalo
-  DEVICE_MODEL := WSR-2533DHP2
-  DEVICE_DTS := mt7622-buffalo-wsr-2533dhp2
   DEVICE_DTS_DIR := ../dts
-  IMAGE_SIZE := 59392k
   KERNEL_SIZE := 6144k
   BLOCKSIZE := 128k
   PAGESIZE := 2048
-  SUBPAGESIZE := 512
   UBINIZE_OPTS := -E 5
   BUFFALO_TAG_PLATFORM := MTK
   BUFFALO_TAG_VERSION := 9.99
   BUFFALO_TAG_MINOR := 9.99
   IMAGES += factory.bin factory-uboot.bin
-  KERNEL_INITRAMFS := kernel-bin | lzma | \
+  KERNEL_INITRAMFS = kernel-bin | lzma | \
        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | \
        buffalo-trx
-  IMAGE/factory.bin := append-ubi | \
-       buffalo-trx 0x32504844 $$$$@ $(KDIR)/ubi_mark | \
-       buffalo-enc WSR-2533DHP2 $$(BUFFALO_TAG_VERSION) -l | \
-       buffalo-tag-dhp WSR-2533DHP2 JP JP | buffalo-enc-tag -l | buffalo-dhp-image
+  IMAGE/factory.bin = append-ubi | \
+       buffalo-trx $$$$(BUFFALO_TRX_MAGIC) $$$$@ $(KDIR)/ubi_mark | \
+       buffalo-enc $$(DEVICE_MODEL) $$(BUFFALO_TAG_VERSION) -l | \
+       buffalo-tag-dhp $$(DEVICE_MODEL) JP JP | buffalo-enc-tag -l | buffalo-dhp-image
   IMAGE/factory-uboot.bin := append-ubi | \
-       buffalo-trx 0x32504844 $$$$@ $(KDIR)/ubi_mark
+       buffalo-trx $$$$(BUFFALO_TRX_MAGIC) $$$$@ $(KDIR)/ubi_mark
   IMAGE/sysupgrade.bin := \
-       buffalo-trx 0x32504844 $(KDIR)/tmp/$$(DEVICE_NAME).null | \
+       buffalo-trx $$$$(BUFFALO_TRX_MAGIC) $(KDIR)/tmp/$$(DEVICE_NAME).null | \
        sysupgrade-tar kernel=$$$$@ | append-metadata
+endef
+
+define Device/buffalo_wsr-2533dhp2
+  $(Device/buffalo_wsr)
+  DEVICE_MODEL := WSR-2533DHP2
+  DEVICE_DTS := mt7622-buffalo-wsr-2533dhp2
+  IMAGE_SIZE := 59392k
+  SUBPAGESIZE := 512
+  BUFFALO_TRX_MAGIC := 0x32504844
   DEVICE_PACKAGES := kmod-mt7615-firmware swconfig
   DEVICE_COMPAT_VERSION := 1.1
   DEVICE_COMPAT_MESSAGE := Partition table has been changed due to kernel size restrictions. \
@@ -130,6 +137,16 @@ define Device/buffalo_wsr-2533dhp2
 endef
 TARGET_DEVICES += buffalo_wsr-2533dhp2
 
+define Device/buffalo_wsr-3200ax4s
+  $(Device/buffalo_wsr)
+  DEVICE_MODEL := WSR-3200AX4S
+  DEVICE_DTS := mt7622-buffalo-wsr-3200ax4s
+  IMAGE_SIZE := 24576k
+  BUFFALO_TRX_MAGIC := 0x33504844
+  DEVICE_PACKAGES := kmod-mt7915-firmware
+endef
+TARGET_DEVICES += buffalo_wsr-3200ax4s
+
 define Device/elecom_wrc-2533gent
   DEVICE_VENDOR := Elecom
   DEVICE_MODEL := WRC-2533GENT
index 38db921f5c58e98aee982cf1edbd938080548842..d1341099bc8d41593433da21a3a743b8bdbbdd4b 100644 (file)
@@ -9,6 +9,7 @@ mediatek_setup_interfaces()
 
        case $board in
        bananapi,bpi-r64|\
+       buffalo,wsr-3200ax4s|\
        elecom,wrc-x3200gst3|\
        linksys,e8450|\
        linksys,e8450-ubi|\
@@ -55,6 +56,11 @@ mediatek_setup_macs()
        local label_mac=""
 
        case $board in
+       buffalo,wsr-3200ax4s)
+               lan_mac=$(mtd_get_mac_ascii board_data "mac")
+               wan_mac=$lan_mac
+               label_mac=$lan_mac
+               ;;
        reyee,ax3200-e5|\
        ruijie,rg-ew3200gx-pro)
                lan_mac=$(macaddr_add $(get_mac_label) 1)
index f8639e9f4091470613543158d17535623f8533dd..7ee9f24071c5982ab0079dbfa4526c277a1202f7 100644 (file)
@@ -13,6 +13,11 @@ case "$board" in
        bananapi,bpi-r64)
                [ "$PHYNBR" = "0" ] && macaddr_add $(cat /sys/class/net/eth0/address) 2 > /sys${DEVPATH}/macaddress
                ;;
+       buffalo,wsr-3200ax4s)
+               basemac=$(mtd_get_mac_ascii board_data "mac")
+               [ "$PHYNBR" = "0" ] && macaddr_add $basemac 1 > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $basemac 8 > /sys${DEVPATH}/macaddress
+               ;;
        reyee,ax3200-e5|\
        ruijie,rg-ew3200gx-pro)
                [ "$PHYNBR" = "0" ] && macaddr_add $(get_mac_label) 3 > /sys${DEVPATH}/macaddress
index 81cb6b18b7a80bf949fb8be07c43cadbf92dc9f4..59b00a6e69b00b487da2ce4c1507f98c910c80bb 100644 (file)
@@ -7,4 +7,8 @@ buffalo,wsr-2533dhp2)
        mtd -M 0x44485032 ${kernel_size:+-c 0x$kernel_size} fixtrx firmware && exit 0
        exit 1
        ;;
+buffalo,wsr-3200ax4s)
+       mtd -M 0x44485033 ${kernel_size:+-c 0x$kernel_size} fixtrx firmware && exit 0
+       exit 1
+       ;;
 esac
index b37b7b1c6e5772fd919033dd6491d5059b92a926..ea3176d2d1e79fda8a2e5a72e4a3137756ab3a66 100755 (executable)
@@ -21,7 +21,8 @@ platform_do_upgrade() {
                        ;;
                esac
                ;;
-       buffalo,wsr-2533dhp2)
+       buffalo,wsr-2533dhp2|\
+       buffalo,wsr-3200ax4s)
                local magic="$(get_magic_long "$1")"
 
                # use "mtd write" if the magic is "DHP2 (0x44485032)"
@@ -67,7 +68,8 @@ platform_check_image() {
        [ "$#" -gt 1 ] && return 1
 
        case "$board" in
-       buffalo,wsr-2533dhp2)
+       buffalo,wsr-2533dhp2|\
+       buffalo,wsr-3200ax4s)
                buffalo_check_image "$board" "$magic" "$1" || return 1
                ;;
        elecom,wrc-x3200gst3|\