[openwrt/openwrt] mediatek: filogic: add support for ASUS RT-AX52

LEDE Commits lede-commits at lists.infradead.org
Fri Apr 25 08:06:42 PDT 2025


blocktrron pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/50d9ca6e5a04724e4263a348bdbe5ff4b1c43998

commit 50d9ca6e5a04724e4263a348bdbe5ff4b1c43998
Author: Christoph Krapp <achterin at gmail.com>
AuthorDate: Mon Apr 14 20:47:56 2025 +0200

    mediatek: filogic: add support for ASUS RT-AX52
    
    Hardware
    --------
    SOC:   MediaTek MT7981b
    RAM:   256MB DDR3
    FLASH: 128MB SPI-NAND (Winbond W25N01GV)
    WIFI:  Mediatek MT7981b DBDC 802.11ax 2.4/5 GHz
    ETH:   MediaTek MT7531 Switch
    UART:  3V3 115200 8N1 (Pinout silkscreened / Do not connect VCC)
    
    Installation
    -----------------------------------------------------------
    Vendor-UI Method
    -----------------------------------------------------------
    1. Download the OpenWrt initramfs.trx image.
    
    2. Connect the PC via LAN to one of the yellow router ports and wait
       until your PC to get a DHCP lease.
    
    3. Browse to http://192.168.50.1
    
    4. If your router is brand new, finish the setup process and log into
       the Web-UI.
    
    5. Navigate to Administration -> Firmware Upgrade and upload the
       downloaded OpenWrt image.
    
    6. Wait for OpenWrt to boot. Transfer the sysupgrade image to the device
       using scp and install using sysupgrade.
    
       $ sysupgrade -n <path-to-sysupgrade.bin>
    -----------------------------------------------------------
    TFTP Method
    -----------------------------------------------------------
    1. Download the OpenWrt initramfs image. Copy the image to a TFTP server
       reachable at 192.168.1.70/24. Rename the image to rtax52.bin.
    
    2. Connect the PC with TFTP server to the RT-AX52.
       Set a static ip on the ethernet interface of your PC.
         (ip address: 192.168.1.70, subnet mask:255.255.255.0)
      Conect to the serial console,
       interrupt the autoboot process by pressing '4' when prompted.
    
    3. Download & Boot the OpenWrt initramfs image.
    
       $ setenv ipaddr 192.168.1.1
       $ setenv serverip 192.168.1.70
       $ tftpboot 0x46000000 rtax52.bin
       $ bootm 0x46000000
    
    4. Wait for OpenWrt to boot. Transfer the sysupgrade image to the device
       using scp and install using sysupgrade.
    
       $ sysupgrade -n <path-to-sysupgrade.bin>
    ---------------------------------------------------------------------------
    Revert to stock firmware:
    1: Download the rt-ax52 firmware from ASUS official website. Save
       the firmware to tftp server directory and rename to RT-AX52.trx
    
    2: Connect the PC with TFTP server to the RT-AX52.
       Set a static ip on the ethernet interface of your PC.
         (ip address: 192.168.1.70, subnet mask:255.255.255.0)
    
    3: Conect to the serial console,  power on again,  interrupt the
       autoboot process by pressing '4' when prompted.
      $: ubi remove linux
      $: ubi remove jffs2
      $: ubi remove rootfs
      $: ubi remove rootfs_data
      $: ubi create linux 0x45fe000
      $: reset
    
      Then the dut will reboot,interrupt the autoboot process by
      pressing '2' when prompted.
           2: Load System code then write to Flash via TFTP.
           Warning!! Erase Linux in Flash then burn new one. Are you sure?(Y/N)
           $: enter y
      you will see the follow, type enter directly:
           Input device IP (192.168.1.1) ==:
           Input server IP (192.168.1.70) ==:
           Input Linux Kernel filename (RT-AX52.trx) ==:
    
    4: wait for the device run up
    
    Based on support for ASUS RT-AX52 by liudongdongdong7397
    and trx image generation by remittor
    
    Signed-off-by: Christoph Krapp <achterin at gmail.com>
---
 target/linux/mediatek/dts/mt7981b-asus-rt-ax52.dts | 301 +++++++++++++++++++++
 .../filogic/base-files/etc/board.d/01_leds         |   3 +
 .../filogic/base-files/etc/board.d/02_network      |   1 +
 .../etc/hotplug.d/ieee80211/11_fix_wifi_mac        |   1 +
 .../filogic/base-files/lib/upgrade/platform.sh     |   2 +
 target/linux/mediatek/image/Makefile               |   5 +
 target/linux/mediatek/image/filogic.mk             |  18 ++
 7 files changed, 331 insertions(+)

diff --git a/target/linux/mediatek/dts/mt7981b-asus-rt-ax52.dts b/target/linux/mediatek/dts/mt7981b-asus-rt-ax52.dts
new file mode 100644
index 0000000000..7f4926b493
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7981b-asus-rt-ax52.dts
@@ -0,0 +1,301 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+#include "mt7981.dtsi"
+/ {
+	model = "ASUS RT-AX52";
+	compatible = "asus,rt-ax52", "mediatek,mt7981";
+
+	aliases {
+		serial0 = &uart0;
+		label-mac-device = &gmac0;
+		led-boot = &led_system;
+		led-failsafe = &led_system;
+		led-running = &led_system;
+		led-upgrade = &led_system;
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+		bootargs-override = "";
+	};
+
+	memory {
+		reg = <0 0x40000000 0 0x10000000>;
+	};
+
+	keys {
+		compatible = "gpio-keys";
+
+		reset {
+			label = "reset";
+			gpios = <&pio 1 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_RESTART>;
+		};
+
+		wps {
+			label = "wps";
+			gpios = <&pio 0 GPIO_ACTIVE_LOW>;
+			linux,code = <KEY_WPS_BUTTON>;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		wlan24 {
+			function = LED_FUNCTION_WLAN_2GHZ;
+			color = <LED_COLOR_ID_WHITE>;
+			gpios = <&pio 34 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "phy0tpt";
+		};
+
+		wlan5 {
+			function = LED_FUNCTION_WLAN_5GHZ;
+			color = <LED_COLOR_ID_WHITE>;
+			gpios = <&pio 35 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "phy1tpt";
+		};
+
+		wan {
+			function = LED_FUNCTION_WAN;
+			color = <LED_COLOR_ID_BLUE>;
+			gpios = <&pio 8 GPIO_ACTIVE_LOW>;
+		};
+
+		led_system: system {
+			label = "blue:system";
+			gpios = <&pio 12 GPIO_ACTIVE_HIGH>;
+		};
+	};
+
+	timer {
+		clock-frequency = <12996791>;
+	};
+};
+
+&uart0 {
+	status = "okay";
+};
+
+&eth {
+	status = "okay";
+
+	gmac0: mac at 0 {
+		/* LAN */
+		compatible = "mediatek,eth-mac";
+		reg = <0>;
+		nvmem-cells = <&macaddr_factory_4>;
+		nvmem-cell-names = "mac-address";
+		phy-mode = "2500base-x";
+
+		fixed-link {
+			speed = <2500>;
+			full-duplex;
+			pause;
+		};
+	};
+
+	gmac1: mac at 1 {
+		/* WAN */
+		compatible = "mediatek,eth-mac";
+		reg = <1>;
+		nvmem-cells = <&macaddr_factory_4>;
+		nvmem-cell-names = "mac-address";
+		phy-mode = "gmii";
+		phy-handle = <&phy0>;
+		label = "wan";
+	};
+
+	mdio: mdio-bus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		phy0: ethernet-phy at 0 {
+			compatible = "ethernet-phy-id03a2.9461";
+			reg = <0>;
+			phy-mode = "gmii";
+			#nvmem-cells = <&phy_calibration>;
+			#nvmem-cell-names = "phy-cal-data";
+		};
+
+		switch at 1f {
+			compatible = "mediatek,mt7531";
+			reg = <31>;
+			reset-gpios = <&pio 39 0>;
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port at 0 {
+					reg = <0>;
+					label = "lan3";
+				};
+
+				port at 1 {
+					reg = <1>;
+					label = "lan2";
+				};
+
+				port at 2 {
+					reg = <2>;
+					label = "lan1";
+				};
+
+				port at 6 {
+					reg = <6>;
+					label = "cpu";
+					ethernet = <&gmac0>;
+					phy-mode = "2500base-x";
+
+					fixed-link {
+						speed = <2500>;
+						full-duplex;
+						pause;
+					};
+				};
+			};
+		};
+	};
+};
+
+&spi0 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi0_flash_pins>;
+	status = "okay";
+
+	spi_nand_flash: flash at 0 {
+		compatible = "u-boot-dont-touch-spi-nand";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		reg = <0>;
+
+		spi-max-frequency = <52000000>;
+		spi-tx-bus-width = <4>;
+		spi-rx-bus-width = <4>;
+
+		/*
+		 * ASUS bootloader tries to replace the partitions defined in
+		 * Device Tree and by that also deletes all additional properties
+		 * needed for UBI and NVMEM-on-UBI.
+		 * Prevent this from happening by tricking the loader to delete and
+		 * replace a bait node instead (works with older bootloaders).
+		 */
+		partitions: dummy {
+			compatible = "u-boot-dummy-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				reg = <0x0 0x0>;
+				label = "remove_me";
+			};
+		};
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 0 {
+				reg = <0x0 0x400000>;
+				label = "bootloader";
+				read-only;
+			};
+
+			partition at 400000 {
+				compatible = "linux,ubi";
+				reg = <0x400000 0xfc00000>;
+				label = "UBI_DEV";
+
+				volumes {
+					ubi_factory: ubi-volume-factory {
+						volname = "Factory";
+					};
+				};
+			};
+		};
+	};
+};
+
+&ubi_factory {
+	nvmem-layout {
+		compatible = "fixed-layout";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		eeprom_factory_0: eeprom at 0 {
+			reg = <0x0 0x1000>;
+		};
+
+		macaddr_factory_4: macaddr at 4 {
+			reg = <0x4 0x6>;
+		};
+	};
+};
+
+&spi1 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spic_pins>;
+	status = "disabled";
+};
+
+&pio {
+	i2c_pins: i2c-pins-g0 {
+		mux {
+			function = "i2c";
+			groups = "i2c0_0";
+		};
+	};
+
+	spi0_flash_pins: spi0-pins {
+		mux {
+			function = "spi";
+			groups = "spi0", "spi0_wp_hold";
+		};
+
+		conf-pu {
+			pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
+			drive-strength = <MTK_DRIVE_8mA>;
+			bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
+		};
+
+		conf-pd {
+			pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
+			drive-strength = <MTK_DRIVE_8mA>;
+			bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
+		};
+	};
+
+	spic_pins: spi1-pins {
+		mux {
+			function = "spi";
+			groups = "spi1_1";
+		};
+	};
+
+	uart1_pins: uart1-pins-g1 {
+		mux {
+			function = "uart";
+			groups = "uart1_1";
+		};
+	};
+
+	uart2_pins: uart2-pins-g1 {
+		mux {
+			function = "uart";
+			groups = "uart2_1";
+		};
+	};
+};
+
+&watchdog {
+	status = "okay";
+};
+
+&wifi {
+	nvmem-cells = <&eeprom_factory_0>;
+	nvmem-cell-names = "eeprom";
+
+	status = "okay";
+};
diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
index 14f22d0f43..924234353d 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
@@ -16,6 +16,9 @@ acer,predator-w6d)
 	ucidef_set_led_netdev "internet" "INTERNET" "mdio-bus:06:amber:wan" "eth1" "link_10 link_100 link_1000 tx rx"
 	ucidef_set_led_netdev "internet" "INTERNET" "mdio-bus:06:green:wan" "eth1" "link_2500 tx rx"
 	;;
+asus,rt-ax52)
+	ucidef_set_led_netdev "wan" "wan" "blue:wan" "wan" "link tx rx"
+	;;
 asus,tuf-ax4200)
 	ucidef_set_led_netdev "wan" "WAN" "mdio-bus:06:white:wan" "eth1" "link tx rx"
 	;;
diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
index 2f0eccb1ed..0bff673e78 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
@@ -31,6 +31,7 @@ mediatek_setup_interfaces()
 	arcadyan,mozart)
 		ucidef_set_interfaces_lan_wan "lan0 eth1" eth2
 		;;
+	asus,rt-ax52|\
 	asus,rt-ax59u|\
 	asus,zenwifi-bt8|\
 	asus,zenwifi-bt8-ubootmod|\
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
index 228c9bae80..8d7531800c 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
@@ -37,6 +37,7 @@ case "$board" in
 			macaddr_setbit_la $(macaddr_setbit $(macaddr_add $addr 1) 28) > \
 			/sys${DEVPATH}/macaddress
 		;;
+	asus,rt-ax52|\
 	asus,tuf-ax4200|\
 	asus,tuf-ax6000)
 		CI_UBIPART="UBI_DEV"
diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
index 01753c0a03..3235c9ac53 100755
--- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
@@ -118,6 +118,7 @@ platform_do_upgrade() {
 		CI_ROOTPART="rootfs"
 		emmc_do_upgrade "$1"
 		;;
+	asus,rt-ax52|\
 	asus,rt-ax59u|\
 	asus,tuf-ax4200|\
 	asus,tuf-ax6000|\
@@ -286,6 +287,7 @@ platform_pre_upgrade() {
 	local board=$(board_name)
 
 	case "$board" in
+	asus,rt-ax52|\
 	asus,rt-ax59u|\
 	asus,tuf-ax4200|\
 	asus,tuf-ax6000|\
diff --git a/target/linux/mediatek/image/Makefile b/target/linux/mediatek/image/Makefile
index d4f79ec974..668d9a8cb0 100644
--- a/target/linux/mediatek/image/Makefile
+++ b/target/linux/mediatek/image/Makefile
@@ -33,6 +33,11 @@ define Device/Default
 	pad-rootfs | append-metadata
 endef
 
+define Build/asus-trx
+	$(STAGING_DIR_HOST)/bin/asusuimage $(wordlist 1,$(words $(1)),$(1)) -i $@ -o $@.new
+	mv $@.new $@
+endef
+
 include $(SUBTARGET).mk
 
 define Image/Build
diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
index 7946dee79b..bd5ac79257 100644
--- a/target/linux/mediatek/image/filogic.mk
+++ b/target/linux/mediatek/image/filogic.mk
@@ -251,6 +251,24 @@ define Device/arcadyan_mozart
 endef
 TARGET_DEVICES += arcadyan_mozart
 
+define Device/asus_rt-ax52
+  DEVICE_VENDOR := ASUS
+  DEVICE_MODEL := RT-AX52
+  DEVICE_DTS := mt7981b-asus-rt-ax52
+  DEVICE_DTS_DIR := ../dts
+  DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware
+  IMAGES := sysupgrade.bin
+  KERNEL := kernel-bin | lzma | \
+	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb
+  KERNEL_INITRAMFS := kernel-bin | lzma | \
+	fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb  with-initrd | pad-to 64k
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+  ARTIFACTS := initramfs.trx
+  ARTIFACT/initramfs.trx := append-image-stage initramfs-kernel.bin | \
+	uImage none | asus-trx -v 3 -n $$(DEVICE_MODEL)
+endef
+TARGET_DEVICES += asus_rt-ax52
+
 define Device/asus_rt-ax59u
   DEVICE_VENDOR := ASUS
   DEVICE_MODEL := RT-AX59U




More information about the lede-commits mailing list