From 90ac94fb7aa6d231a373375eed352b08387534fd Mon Sep 17 00:00:00 2001 From: csharper2005 <82600916+csharper2005@users.noreply.github.com> Date: Wed, 21 Aug 2024 19:17:09 +0300 Subject: [PATCH] mediatek: add support for Routerich AX3000 (#303) * mediatek: add support for Routerich AX3000 Routerich AX3000 is a wireless WiFi 6 router. Specification ------------- - SoC : MediaTek MT7981BA dual-core ARM Cortex-A53 1.3 GHz - RAM : DDR3 256 MiB (ESMT M15T2G16128A) - Flash : SPI-NAND 128 MiB (ESMT F50L1G41LB) - WLAN : MediaTek MT7976CN dual-band WiFi 6 - 2.4 GHz : b/g/n/ax, MIMO 2x2 - 5 GHz : a/n/ac/ax, MIMO 2x2 - Ethernet : 10/100/1000 Mbps x4 (MediaTek MT7531AE) - USB : 1x 2.0 - UART : through-hole on PCB - [J500] GND, TX, RX, 3.3V (115200n8) - Buttons : Mesh, Reset - LEDs : 1x Power (Blue) 1x WiFi 2.4 GHz (Blue) 1x WiFi 5 GHz (Red) 1x Mesh (Blue) 3x LAN activity (Blue) 1x WAN activity (Blue) 2x WAN no-internet (Red) - Power : 12 VDC, 1.5 A Installation ------------ Flash OpenWrt 'sysupgrade.bin' image using stock firmware web-interface (without keeping settings). Return to stock --------------- Install stock firmware image (without keeping settings) using OpenWrt sysupgrade method. Recovery -------- Connect uart, use u-boot menu to flash stock firmware image or boot OpenWrt initramfs image. MAC addresses ------------- +---------+-------------------+-----------+ | | MAC | Algorithm | +---------+-------------------+-----------+ | WAN | 24:0f:5e:xx:xx:b4 | label | | LAN | 24:0f:5e:xx:xx:b5 | label+1 | | WLAN 2g | 24:0f:5e:xx:xx:b6 | label+2 | | WLAN 5g | 24:0f:5e:xx:xx:b7 | label+3 | +---------+-------------------+-----------+ The WLAN 2g MAC was found in 'Factory', 0x4 Signed-off-by: Mikhail Zhilkin --------- Signed-off-by: Mikhail Zhilkin Co-authored-by: hanwckf Co-authored-by: hanwckf --- defconfig/mt7981-ax3000.config | 2 + .../dts/mediatek/mt7981-routerich-ax3000.dts | 294 ++++++++++++++++++ target/linux/mediatek/image/mt7981.mk | 16 + .../mt7981/base-files/etc/board.d/01_leds | 9 + .../mt7981/base-files/etc/board.d/02_network | 18 +- .../mt7981/base-files/lib/upgrade/platform.sh | 4 +- target/linux/mediatek/mt7981/config-5.4 | 1 + 7 files changed, 342 insertions(+), 2 deletions(-) create mode 100644 target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-routerich-ax3000.dts diff --git a/defconfig/mt7981-ax3000.config b/defconfig/mt7981-ax3000.config index 2c1e3abcdf..f337b7da03 100644 --- a/defconfig/mt7981-ax3000.config +++ b/defconfig/mt7981-ax3000.config @@ -31,6 +31,8 @@ CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_mt7981-clt-r30b1=y CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_mt7981-clt-r30b1="" CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_mt7981-clt-r30b1-112M=y CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_mt7981-clt-r30b1-112M="" +CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_routerich_ax3000=y +CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_routerich_ax3000="" CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_xiaomi_mi-router-ax3000t=y CONFIG_TARGET_DEVICE_PACKAGES_mediatek_mt7981_DEVICE_xiaomi_mi-router-ax3000t="" CONFIG_TARGET_DEVICE_mediatek_mt7981_DEVICE_xiaomi_mi-router-ax3000t-stock=y diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-routerich-ax3000.dts b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-routerich-ax3000.dts new file mode 100644 index 0000000000..26158293ed --- /dev/null +++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7981-routerich-ax3000.dts @@ -0,0 +1,294 @@ +/dts-v1/; +#include "mt7981.dtsi" + +/ { + model = "Routerich AX3000"; + compatible = "routerich,ax3000", "mediatek,mt7981"; + + aliases { + led-boot = &led_power_blue; + led-failsafe = &led_power_blue; + led-running = &led_power_blue; + led-upgrade = &led_power_blue; + }; + + chosen { + bootargs = "console=ttyS0,115200n1 loglevel=8 \ + earlycon=uart8250,mmio32,0x11002000"; + }; + + memory { + reg = <0 0x40000000 0 0x10000000>; + }; + + gpio-leds { + compatible = "gpio-leds"; + + led-0 { + label = "red:wlan5g"; + gpios = <&pio 5 GPIO_ACTIVE_LOW>; + }; + + led-1 { + label = "red:wan"; + gpios = <&pio 6 GPIO_ACTIVE_HIGH>; + }; + + led_power_blue: led-2 { + label = "blue:power"; + gpios = <&pio 7 GPIO_ACTIVE_LOW>; + }; + + led-3 { + label = "blue:lan1"; + gpios = <&pio 9 GPIO_ACTIVE_LOW>; + }; + + led-4 { + label = "blue:lan2"; + gpios = <&pio 10 GPIO_ACTIVE_LOW>; + }; + + led-5 { + label = "blue:lan3"; + gpios = <&pio 11 GPIO_ACTIVE_LOW>; + }; + + led-6 { + label = "blue:wan"; + gpios = <&pio 12 GPIO_ACTIVE_LOW>; + }; + + led-7 { + label = "blue:wlan2g"; + gpios = <&pio 34 GPIO_ACTIVE_LOW>; + }; + + led-8 { + label = "blue:mesh"; + gpios = <&pio 35 GPIO_ACTIVE_LOW>; + }; + }; + + gpio-keys { + compatible = "gpio-keys"; + + button-mesh { + label = "mesh"; + linux,code = ; + gpios = <&pio 0 GPIO_ACTIVE_LOW>; + }; + + button-reset { + label = "reset"; + linux,code = ; + gpios = <&pio 1 GPIO_ACTIVE_LOW>; + }; + }; + + gsw: gsw@0 { + compatible = "mediatek,mt753x"; + mediatek,ethsys = <ðsys>; + #address-cells = <1>; + #size-cells = <0>; + }; + + nmbm_spim_nand { + compatible = "generic,nmbm"; + + #address-cells = <1>; + #size-cells = <1>; + + lower-mtd-device = <&spi_nand>; + forced-create; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0_all { + label = "spi0.0"; + reg = <0x0 0x8000000>; + read-only; + }; + + partition@0 { + label = "BL2"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "u-boot-env"; + reg = <0x100000 0x80000>; + }; + + partition@180000 { + label = "Factory"; + reg = <0x180000 0x200000>; + read-only; + }; + + partition@380000 { + label = "FIP"; + reg = <0x380000 0x200000>; + read-only; + }; + + partition@580000 { + label = "ubi"; + reg = <0x580000 0x4000000>; + }; + + partition@4580000 { + label = "firmware_backup"; + reg = <0x4580000 0x2000000>; + read-only; + }; + + partition@6580000 { + label = "zrsave"; + reg = <0x6580000 0x100000>; + read-only; + }; + + partition@6680000 { + label = "config2"; + reg = <0x6680000 0x100000>; + read-only; + }; + }; + }; +}; + +&uart0 { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +ð { + status = "okay"; + + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + + gmac1: mac@1 { + compatible = "mediatek,eth-mac"; + reg = <1>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + + mdio: mdio-bus { + #address-cells = <1>; + #size-cells = <0>; + }; +}; + +&gsw { + mediatek,mdio = <&mdio>; + mediatek,mdio_master_pinmux = <0>; + reset-gpios = <&pio 39 0>; + interrupt-parent = <&pio>; + interrupts = <38 IRQ_TYPE_LEVEL_HIGH>; + status = "okay"; + + port5: port@5 { + compatible = "mediatek,mt753x-port"; + reg = <5>; + phy-mode = "sgmii"; + + fixed-link { + speed = <2500>; + full-duplex; + }; + }; + + port6: port@6 { + compatible = "mediatek,mt753x-port"; + mediatek,ssc-on; + reg = <6>; + phy-mode = "sgmii"; + + fixed-link { + speed = <2500>; + full-duplex; + }; + }; +}; + +&hnat { + mtketh-wan = "eth1"; + mtketh-lan = "eth0"; + mtketh-max-gmac = <2>; + + status = "okay"; +}; + +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi0_flash_pins>; + status = "okay"; + + spi_nand: spi_nand@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "spi-nand"; + reg = <0>; + + spi-max-frequency = <52000000>; + spi-tx-bus-width = <4>; + spi-rx-bus-width = <4>; + + 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>; + }; +}; + +&pio { + spi0_flash_pins: spi0-pins { + mux { + function = "spi"; + groups = "spi0", "spi0_wp_hold"; + }; + + conf-pu { + pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP"; + drive-strength = ; + bias-pull-up = ; + }; + + conf-pd { + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO"; + drive-strength = ; + bias-pull-down = ; + }; + }; +}; + +&xhci { + mediatek,u3p-dis-msk = <0x0>; + status = "okay"; +}; diff --git a/target/linux/mediatek/image/mt7981.mk b/target/linux/mediatek/image/mt7981.mk index bb02e6c153..00a6fab58f 100644 --- a/target/linux/mediatek/image/mt7981.mk +++ b/target/linux/mediatek/image/mt7981.mk @@ -683,3 +683,19 @@ define Device/nradio_wt9103_512m IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata endef TARGET_DEVICES += nradio_wt9103_512m + +define Device/routerich_ax3000 + DEVICE_VENDOR := Routerich + DEVICE_MODEL := AX3000 + DEVICE_DTS := mt7981-routerich-ax3000 + DEVICE_DTS_DIR := $(DTS_DIR)/mediatek + SUPPORTED_DEVICES := routerich,ax3000 mediatek,mt7981-spim-snand-rfb + UBINIZE_OPTS := -E 5 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 65536k + KERNEL_IN_UBI := 1 + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + DEVICE_PACKAGES := $(MT7981_USB_PKGS) +endef +TARGET_DEVICES += routerich_ax3000 diff --git a/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds b/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds index 1d0e5de40f..9037b758b3 100755 --- a/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds +++ b/target/linux/mediatek/mt7981/base-files/etc/board.d/01_leds @@ -57,6 +57,15 @@ nradio,wt9103) ucidef_set_led_netdev "5g" "5G" "hc:blue:cmode5" "eth1" "tx rx" ucidef_set_led_netdev "lan" "LAN" "hc:blue:cmode4" "br-lan" "tx rx" ;; +routerich,ax3000) + ucidef_set_led_switch "lan1" "LAN1" "blue:lan1" "switch0" "0x01" + ucidef_set_led_switch "lan2" "LAN2" "blue:lan2" "switch0" "0x04" + ucidef_set_led_switch "lan3" "LAN3" "blue:lan3" "switch0" "0x08" + ucidef_set_led_switch "wan" "WAN" "blue:wan" "switch0" "0x10" + ucidef_set_led_switch "wan off" "WAN Off" "red:wan" "switch0" "0x10" "" "link" + ucidef_set_led_netdev "wlan2g" "WLAN 2G" "blue:wlan2g" "ra0" + ucidef_set_led_netdev "wlan5g" "WLAN 5G" "red:wlan5g" "rax0" + ;; esac board_config_flush diff --git a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network index 828952b66c..c43e8b3ec0 100755 --- a/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/mt7981/base-files/etc/board.d/02_network @@ -82,6 +82,11 @@ mediatek_setup_interfaces() nradio,wt9103) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3 lan4" eth1 ;; + routerich,ax3000) + ucidef_set_interfaces_lan_wan "eth0" "eth1" + ucidef_add_switch "switch0" \ + "0:lan:1" "2:lan:2" "3:lan:3" "4:wan" "6u@eth0" "5u@eth1" + ;; ikuai,q3000 |\ ruijie,rg-x30e*) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" wan @@ -242,10 +247,21 @@ mediatek_setup_macs() label_mac=$wan_mac local wifi_mac="$(mtd_get_mac_binary $part_name 0x04)" ;; + routerich,ax3000) + local wifi_mac="$(mtd_get_mac_binary $part_name 0x4)" + label_mac=$(macaddr_add $wifi_mac -2) + lan_mac=$(macaddr_add $wifi_mac -1) + wan_mac=$label_mac + local b1dat="$(l1dat if2dat rax0)" + if [ -f ${b1dat} ] && ! grep -q "MacAddress=" ${b1dat}; then + local b1mac="$(macaddr_add $wifi_mac 1)" + echo "MacAddress=$b1mac" >> ${b1dat} + fi + ;; ikuai,q3000) wan_mac=$(mtd_get_mac_binary $part_name 0x10048) lan_mac=$(macaddr_add $wan_mac 1) - ;; + ;; ruijie,rg-x30e*) label_mac=$(mtd_get_mac_ascii product_info ethaddr) wan_mac=$label_mac diff --git a/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh index 4211015a83..6654394967 100644 --- a/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/mt7981/base-files/lib/upgrade/platform.sh @@ -206,6 +206,7 @@ platform_do_upgrade() { cmcc,rax3000m |\ h3c,nx30pro |\ *konka,komi-a31* |\ + routerich,ax3000 |\ *nokia,ea0326gmp* |\ *snand*) nand_do_upgrade "$1" @@ -257,7 +258,8 @@ platform_check_image() { *nokia,ea0326gmp* |\ nradio,wt9103 |\ *snand* |\ - *emmc*) + *emmc* |\ + routerich,ax3000) # tar magic `ustar` magic="$(dd if="$1" bs=1 skip=257 count=5 2>/dev/null)" diff --git a/target/linux/mediatek/mt7981/config-5.4 b/target/linux/mediatek/mt7981/config-5.4 index d1b2b56737..5a433e9cf4 100644 --- a/target/linux/mediatek/mt7981/config-5.4 +++ b/target/linux/mediatek/mt7981/config-5.4 @@ -481,6 +481,7 @@ CONFIG_SPI_MT65XX=y CONFIG_SPI_MTK_SNFI=y CONFIG_SRCU=y CONFIG_SWCONFIG=y +CONFIG_SWCONFIG_LEDS=y CONFIG_SWIOTLB=y CONFIG_SWPHY=y CONFIG_SYSCTL_EXCEPTION_TRACE=y