Adding OpenWrt support for Xiaomi "Redmi Router AX6S"/"Xiaomi Router AX3200"

are you sure you add only the folders i just say?

i use debian

Yes Sir, simply put:

  1. New Ubuntu 22.04 Server VM

  2. Install build tools

  3. Clone OpenWRT 22.03 and (some other) repo containing mtkwifi/mt_wifi

  4. Copy the three folders from mtkwifi/mt_wifi to openwrt/package and update/install feeds

  5. Build

ok let me see why is not working, if so i ll send my folder. i don't know if i can post it here

I'll make another attempt as well, but not tonight

Btw, do you use Ubuntu 22.04?

no us i said i'm on debian

Ah, I missed that line - gotcha

ok you can try to delete from mt7622 and mt_wifi folders the folder 'files'

And then update/install feeds? then build?

1 Like

i build on last stable 21.3.0

You mean 22.03.0?

yes last stable 22.03.0,sorry if i wrote 21.3.0

1 Like

Ok, new error (due to deleting the files-folders), I'll try again with your repo, debian and doing as little else as possible... what I just tried was @hck's instructions + yours:

#Create new VM, install Ubuntu 22.04 Server, update repos, install build essentials per https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem#debianubuntu


#Get source
git clone https://github.com/padavanonly/immortalwrtmt7622.git -b openwrt-18.06-k5.4 immortalwrt
git clone https://git.openwrt.org/openwrt/openwrt.git -b v22.03.0 openwrt

#Removed files-folder from mt7622 and mt_wifi as per suggestion https://forum.openwrt.org/t/adding-openwrt-support-for-xiaomi-redmi-router-ax6s-xiaomi-router-ax3200/111085/959?u=spwnrpe
rm -rf immortalwrt/package/mt7622/files
rm -rf immortalwrt/package/mt_wifi/files

#Import drivers etc.
mkdir mtwifi
cp -r immortalwrt/package/luci-app-mtwifi immortalwrt/package/mt7622 immortalwrt/package/mt_wifi mtwifi/
cp openwrt/feeds.conf.default openwrt/feeds.conf
echo src-link mtwifi $PWD/mtwifi/ >> openwrt/feeds.conf

#Tweaks
find mtwifi/ -type f | xargs -L 1 sed -i '/brctl/d'
find mtwifi/ -type f | xargs -L 1 sed -i 's/br-lan/none/g'
sed -i -E 's/^(.+?mt7615.)1(.+?mt7615.)1(.+?)$/\11\21\3\n\12\22\3/' mtwifi/luci-app-mtwifi/root/usr/lib/lua/mtkwifi.lua
sed -i -E 's/_\(\"Wireless\"\)/_("MTK Wifi")/' mtwifi/luci-app-mtwifi/luasrc/controller/mtkwifi.lua
sed -i -E 's/WscConfMode=[0-9]+/WscConfMode=0/' mtwifi/luci-app-mtwifi/files/*.dat
sed -i -E 's/WscConfStatus=[0-9]+/WscConfStatus=2/' mtwifi/luci-app-mtwifi/files/*.dat
sed -i -E '/(macaddr|MacAddress)=/d' mtwifi/luci-app-mtwifi/files/*.dat

#Translation
ch=("正在处理,请耐心等待"                        "无线中继"           "中继参数"                   "上级无线SSID" "上级无线信道"      "设置完成后,请回到上级页面点击“连接中继”" "上级无线加密模式"              "上级无线加密算法"     "上级无线密码"      "重启无线"      "保存设置" "重置设置" "无线名称" "加密方式"  "信号强度" "动作"    "配置无线高级设置"         "无线高级设置"            "区域代码"      "无线模式"        "信道带宽"           "2G 40MHZ模式辅助信道"    "范围0到-100,-100最不容易剔除,推荐-85"  "弱信号剔除"             "保存&应用"     "重置"   "无线参数(直接修改无线配置)"                           "警告"    "如果你不了解请不要修改"                            "保存" "你将修改无线参数,确认要修改?"                                     "恢复出厂设置"                         "确认恢复<%=devname%> 至出厂设置?"                                                       "正常模式"    "绿色模式"     "模式" "信道"     "范围"   "默认值"  "无线概况"           "高级设置" "添加SSID"           "添加" "接口"      "停用"    "启用无线"                   "禁用无线"                    "修改无线基本设置"          "基本设置" "删除网络"                   "移除"   "已连接"     "无线中继未连接"                           "未连接"       "上级SSID" "连接中继" "断开中继"    "修改中继参数" "中继设置" "加密"       "算法"          "密钥更新时间"          "密码" "隐藏 SSID"   "隔离客户端"    "WMM 模式"     "强制发射速率 ( 0为自动,建议值 )" "扫描网络"               "类型"  "中继" "状态"    "启用"   "禁用")
en=("Please waiting while the page is loading" "Wireless Repeater" "Connection Configurations" "Root AP SSID" "Root AP Channel" "This will overwrite ap channel"       "Root AP Authentication Mode" "Root AP Encryption" "Root AP WPA Key"  "Restart Wifi" "Save"    "Reset"   "SSID"    "Security" "RSSI"    "Action" "Configure Wi-Fi device" "Device Configurations"  "Country Code" "Operating Mode" "Channel BandWidth" "2.4G 40Mhz Ext Channel" "range 0 to -100, -85 is recommended" "Weak Signal Rejection" "Save \& Apply" "Reset" "Raw Configurations ( Edit WiFi profile directly )" "WARNING" "DO NOT MESS WITH IT IF YOU DON'T UNDERSTAND IT" "Save" "You are going to overwrite the profile directly, are you sure?" "Restore Profile to Factory Setting"  "You are going to reset the profile of <%=devname%> to factory default, are you sure?" "Mixed Mode" "Green Field" "Mode" "Channel" "range" "default" "Wireless Overview" "Config"   "Add Wi-Fi network" "Add" "Interface" "Disable" "Enable this Wi-Fi network" "Disable this Wi-Fi network" "Edit this Wi-Fi network" "Config"  "Delete this Wi-Fi network" "Remove" "Connected" "Wireless is disabled or not associated" "Disconnected" "SSID"     "Reload"  "Disconnect" "Config"      "Config"  "Auth Mode" "WPA Algorithm" "Key Renewal Interval" "Key" "Hidden SSID" "AP Isolation" "WMM Capable" "Force TX Rate"                "Scan Wireless Network" "Type" "STA"  "Status" "Enable" "Disable")
for l in {99..1}; do
    for i in ${!ch[*]}; do
        if [[ ${#ch[$i]} -eq $l ]]; then
            find mtwifi/luci-app-mtwifi/ -type f | xargs -L 1 sed -i "s/${ch[$i]}/${en[$i]}/g"
        fi
    done
done

#Build
cd openwrt
./scripts/feeds update -a
./scripts/feeds install -a
#Results in:
# Installing package 'luci-app-mtwifi' from mtwifi
# Installing package 'mt7622' from mtwifi
# Installing package 'mt_wifi' from mtwifi
wget -O .config https://downloads.openwrt.org/releases/22.03.0/targets/mediatek/mt7622/config.buildinfo
make menuconfig
#mark "M" Kernel Modules -> Wireless Drivers: kmod-mt7622, kmod-mt_wifi, LuCI -> Applications: luci-app-mtwifi, Extra Packages: l1profile
make -j $(nproc)

#Packages in ./bin

# Previous error:
# make[4]: Entering directory '/home/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/linux-5.10.138'
#   CC [M]  /home/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt_wifi/mt_wifi_ap/../mt_wifi/os/linux/rt_profile.o
#   /home/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt_wifi/mt_wifi_ap/../mt_wifi/os/linux/rt_profile.c:43:10: fatal error: net/ra_nat.h: No such file or directory
#   43 | #include <net/ra_nat.h>
#      |          ^~~~~~~~~~~~~~
# compilation terminated.

# New error:
# install -m0755 ./files/mtkhnat.ko /home/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt7622_mt_wifi/.pkgdir/kmod-mt7622/lib/
# install: cannot stat './files/mtkhnat.ko': No such file or directory
# make[3]: *** [Makefile:268: /home/openwrt/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt7622_mt_wifi/.pkgdir/kmod-mt7622.installed] Error 1
# make[3]: Leaving directory '/home/openwrt/mtwifi/mt7622'
# time: package/feeds/mtwifi/mt7622/compile#84.40#10.32#94.44
#     ERROR: package/feeds/mtwifi/mt7622 failed to build.
# make[2]: *** [package/Makefile:116: package/feeds/mtwifi/mt7622/compile] Error 1
# make[2]: Leaving directory '/home/openwrt/openwrt'
# make[1]: *** [package/Makefile:110: /home/openwrt/openwrt/staging_dir/target-aarch64_cortex-a53_musl/stamp/.package_compile] Error 2
# make[1]: Leaving directory '/home/openwrt/openwrt'
# make: *** [/home/openwrt/openwrt/include/toplevel.mk:230: world] Error 2
1 Like

wait a bit i ll send my folder

Tried again, now I got the same error as before... net/ra_nat.h missing... I tried searching for it and found:

openwrt@openwrt-build-vm:~/openwrt$ find . -name "ra_nat.h"
openwrt@openwrt-build-vm:~/openwrt$ cd ../mtwifi/
openwrt@openwrt-build-vm:~/mtwifi$ find . -name "ra_nat.h"
./mt7622/src/mt_wifi/include/hwnat/ra_nat.h
openwrt@openwrt-build-vm:~/mtwifi$ cd ../immortalwrt/
openwrt@openwrt-build-vm:~/immortalwrt$ find . -name "ra_nat.h"
./package/mt7622/src/mt_wifi/include/hwnat/ra_nat.h
./target/linux/mediatek/files/include/net/ra_nat.h

Does your process for putting together your folder (mtwifi) differ from mine as described above? if so, in what way?

yes not the same as mine

i just see another commit, try to build on snapshot, or if you like compile on stable, i sented you a message

Surprisingly the wired performance of my router is limited.
Network setup is "1000Mbps FTTH -- ax3200 -- client on '10Gbps' cable".
With my previous (AX1800) router the client had shown 930Mbps download speed with ookla speedtest.
With AX3200, the router itself still gains 930Mbps, but the client has 750Mbps only.
With extensive, looped testing the cpu load doesn't go beyond 0.30-0.35. QoS is not enabled. I've re-plugged the client several times, don't expect any cable contact issue. So no obvious reason of why being limited.
Does anyone have a hint on this speed problem? Or how to debug this?

hi, i have compiled a firmware with a different dts, how do i need flash the router now, i don't want brick it, i don't want open the case again. i did that because i want try hardware nat.
this is the dts:

// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/dts-v1/;

#include <dt-bindings/input/input.h>
#include <dt-bindings/gpio/gpio.h>

#include "mt7622.dtsi"
#include "mt6380.dtsi"

/ {
	model = "Xiaomi Redmi Router AX6S";
	compatible = "xiaomi,redmi-router-ax6s", "mediatek,mt7622";

	aliases {
		serial0 = &uart0;
		led-boot = &led_power_amber;
		led-failsafe = &led_power_amber;
		led-running = &led_power_blue;
		led-upgrade = &led_power_blue;
	};

	chosen {
		stdout-path = "serial0:115200n8";
		bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n8 swiotlb=512";
	};

	memory {
		reg = <0 0x40000000 0 0x8000000>;
	};

	gsw: gsw@0 {
		compatible = "mediatek,mt753x";
		mediatek,ethsys = <&ethsys>;
		#address-cells = <1>;
		#size-cells = <0>;
	};
	
	leds {
		compatible = "gpio-leds";

		led_power_blue: power_blue {
			label = "blue:power";
			gpios = <&pio 18 GPIO_ACTIVE_LOW>;
		};

		led_power_amber: power_amber {
			label = "amber:power";
			gpios = <&pio 17 GPIO_ACTIVE_LOW>;
		};

		led_net_blue: net_blue {
			label = "blue:net";
			gpios = <&pio 01 GPIO_ACTIVE_LOW>;
		};

		led_net_amber: net_amber {
			label = "amber:net";
			gpios = <&pio 16 GPIO_ACTIVE_LOW>;
		};

	};

	keys {
		compatible = "gpio-keys";

		reset {
			label = "reset";
			gpios = <&pio 0 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};

		mesh {
			label = "mesh";
			gpios = <&pio 102 GPIO_ACTIVE_LOW>;
			linux,code = <BTN_9>;
			linux,input-type = <EV_SW>;
		};
	};
};

&cpu0 {
	proc-supply = <&mt6380_vcpu_reg>;
	sram-supply = <&mt6380_vm_reg>;
};

&cpu1 {
	proc-supply = <&mt6380_vcpu_reg>;
	sram-supply = <&mt6380_vm_reg>;
};

&pio {
	eth_pins: eth-pins {
		mux {
			function = "eth";
			groups = "mdc_mdio", "rgmii_via_gmac2";
		};
	};

	pcie0_pins: pcie0-pins {
		mux {
			function = "pcie";
			groups = "pcie0_pad_perst",
				 "pcie0_1_waken",
				 "pcie0_1_clkreq";
		};
	};

	pcie1_pins: pcie1-pins {
		mux {
			function = "pcie";
			groups = "pcie1_pad_perst",
				 "pcie1_0_waken",
				 "pcie1_0_clkreq";
		};
	};

	pmic_bus_pins: pmic-bus-pins {
		mux {
			function = "pmic";
			groups = "pmic_bus";
		};
	};

	pwm7_pins: pwm1-2-pins {
		mux {
			function = "pwm";
			groups = "pwm_ch7_2";
		};
	};

	/* Serial NAND is shared pin with SPI-NOR */
	serial_nand_pins: serial-nand-pins {
		mux {
			function = "flash";
			groups = "snfi";
		};
	};

	uart0_pins: uart0-pins {
		mux {
			function = "uart";
			groups = "uart0_0_tx_rx" ;
		};
	};

	watchdog_pins: watchdog-pins {
		mux {
			function = "watchdog";
			groups = "watchdog";
		};
	};
};

 &eth {
 	status = "okay";

 	gmac0: mac@0 {
 		compatible = "mediatek,eth-mac";
 		reg = <0>;

 		phy-connection-type = "2500base-x";

 		nvmem-cells = <&macaddr_factory_4>;
 		nvmem-cell-names = "mac-address";
 		mac-address-increment = <(-1)>;

 		fixed-link {
 			speed = <2500>;
 			full-duplex;
 			pause;
 		};
 	};
 		

 	
 	mdio:mdio-bus {
 		#address-cells = <1>;
 		#size-cells = <0>;
 	};
 };

&gsw {
	mediatek,mdio = <&mdio>;
	mediatek,portmap = "lwlll";
	mediatek,mdio_master_pinmux = <2>;
	reset-gpios = <&pio 54 0>;
	interrupt-parent = <&pio>;
	interrupts = <53 IRQ_TYPE_LEVEL_HIGH>,<77 IRQ_TYPE_EDGE_FALLING>;
	status = "okay";


 	port6: port@6 {
 		compatible = "mediatek,mt753x-port";
 		reg = <6>;
 		phy-mode = "sgmii";
 		fixed-link {
 			speed = <2500>;
 			full-duplex;
 		};
 	};
};

&hnat {
	mtketh-wan = "eth0.2";
	mtketh-ppd = "eth0.1";
	mtketh-lan = "eth0";
	mtketh-max-gmac = <0x1>;
	ext-devices = "wlan1", "wlan0","rai0","ra0","apcli0","apclii0";
	status = "okay";
};

&snand {
	pinctrl-names = "default";
	pinctrl-0 = <&serial_nand_pins>;
	status = "okay";

	mediatek,bmt-v2;
	mediatek,bmt-table-size = <0x1000>;
	mediatek,bmt-remap-range = <0x0 0x6c0000>;

	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 0x40000>;
		};

		partition@180000 {
			label = "bdata";
			reg = <0x180000 0x40000>;
		};

		factory: partition@1c0000 {
			label = "factory";
			reg = <0x1c0000 0x80000>;
			read-only;

			compatible = "nvmem-cells";
			#address-cells = <1>;
			#size-cells = <1>;

			macaddr_factory_4: macaddr@4 {
				reg = <0x4 0x6>;
			};
		};

		partition@240000 {
			label = "crash";
			reg = <0x240000 0x40000>;
			read-only;
		};

		partition@280000 {
			label = "crash_log";
			reg = <0x280000 0x40000>;
			read-only;
		};

		/* Shrunk and renamed from "firmware"
		 * as to not break luci size checks
		 */
		partition@2c0000 {
 			label = "kernel";
 			compatible = "denx,fit";
 			reg = <0x2c0000 0xA00000>;
 		};


 		/* ubi partition is the result of squashing
 		 * consecutive stock partitions:
 		 * - firmware (partially)
 		 * - firmware1
 		 * - overlay
 		 * - obr
 		 */
 		partition@cc0000 {
 			label = "ubi";
 			reg = <0xCC0000 0x6000000>;
 		};
	};
};

&pcie0 {
	pinctrl-names = "default";
	pinctrl-0 = <&pcie0_pins>;
	status = "okay";
};

&pcie1 {
	pinctrl-names = "default";
	pinctrl-0 = <&pcie1_pins>;
	status = "okay";
};

&slot0 {
	status = "okay";

	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0000 0 0 0 0>;
		mediatek,mtd-eeprom = <&factory 0x5000>;
		ieee80211-freq-limit = <5000000 6000000>;
	};
};

&pwm {
	pinctrl-names = "default";
	pinctrl-0 = <&pwm7_pins>;
	status = "okay";
};

&pwrap {
	pinctrl-names = "default";
	pinctrl-0 = <&pmic_bus_pins>;
	status = "okay";
};

&rtc {
	status = "disabled";
};

&uart0 {
	pinctrl-names = "default";
	pinctrl-0 = <&uart0_pins>;
	status = "okay";
};

&watchdog {
	pinctrl-names = "default";
	pinctrl-0 = <&watchdog_pins>;
	status = "okay";
};

&wmac {
	status = "okay";

	mediatek,mtd-eeprom = <&factory 0x0>;
};

@anon4457646

Hello, could you please help me with building MTK drivers with stable built? Came across the same problem, looks like something wrong with kernel configuration, if I understand it correctly:

...
ERROR: modpost: "ppe_dev_register_hook" [/home/newton/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt_wifi/mt_wifi_ap/mt_wifi.ko] undefined!

ERROR: modpost: "ra_sw_nat_hook_rx" [/home/newton/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt_wifi/mt_wifi_ap/mt_wifi.ko] undefined!

ERROR: modpost: "ra_sw_nat_hook_tx" [/home/newton/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt_wifi/mt_wifi_ap/mt_wifi.ko] undefined!

ERROR: modpost: "ppe_dev_unregister_hook" [/home/newton/openwrt/build_dir/target-aarch64_cortex-a53_musl/linux-mediatek_mt7622/mt_wifi/mt_wifi_ap/mt_wifi.ko] undefined!
...

@spwnrpe Hello, did you managed to solve your issue?

Not yet, I've gotten some pointers and I'll get on it as soon as I can