Installing OpenWrt on a Xiaomi AX3200


Installing OpenWrt on my Xiaomi AX3200 began with a lie.

Before I could write a firmware image, I had to persuade the router that it was negotiating a mesh with another Xiaomi router. That unlocked a special network mode, which unlocked command injection, which unlocked Telnet and SSH, which finally made replacing the operating system possible.

The flash took seconds. Getting safely to the flash command was the project.

A supported but locked router

In June 2025 I bought an international Xiaomi Router AX3200 (RB01, MediaTek mt7622). OpenWrt supports the AX3200 through the same target as the closely related Redmi Router AX6S. That is why the factory image has xiaomi_redmi-router-ax6s in its filename (openwrt-24.10.1-mediatek-mt7622-xiaomi_redmi-router-ax6s-factory.bin) even when the case says AX3200.

Hardware support did not imply an installation button in Xiaomi’s web interface. The stock system exposed no normal administrative shell and would not accept an unsigned OpenWrt image.

The available route chained together community discoveries about Xiaomi’s own firmware.

Pretending to be a mesh node

The original unlock procedure used two routers. A reset second router connected in the right topology could make the first enter mesh-controller mode, reported as netmode 4. That state exposed a vulnerable LuCI endpoint.

I used jmceleney’s Python script (xiaomi-enable-mesh-telnet.py), which replayed the necessary side of the mesh negotiation instead. It posed as the missing mesh node and convinced one physical AX3200 to become the controller.

After logging into Xiaomi’s web UI, I confirmed netmode 4 through an authenticated request. The next requests abused command injection in the system-time endpoint to set persistent bdata flags (telnet_en, ssh_en and uart_en to 1).

The procedure temporarily wrote a marker to a flash partition and rebooted the router between stages. It was not a friendly supported unlock. A wired connection was essential because the intermediate state could disrupt Wi-Fi.

Xiaomi’s stock root password could then be derived deterministically from the device serial number with unlock_pwd.py. That produced a real root shell on the router I owned. Owner access existed, but Xiaomi made it an exercise in reproducing its own internal credential derivation.

XMiR-Patcher

I used XMiR-Patcher for the dangerous part.

It did considerably more than copy a binary to flash. The tool connected over SSH, inspected the MTD layout, device tree, kernel command line, bootloader and NVRAM data, parsed the OpenWrt FIT image and verified that the xiaomi,redmi-router-ax6s target matched the detected RB01 hardware.

The modern factory image contains a 298 KiB UBI-aware loader (ARM64 OpenWrt Linux-u-boot, UBI offset 0x80000) ahead of the 11,520 KiB rootfs. Xiaomi’s vendor U-Boot cannot boot UBI directly, so it first loads a mainline U-Boot image, which then finds and verifies the OpenWrt kernel and root filesystem.

XMiR-Patcher recognized the router’s dual-firmware layout, assembled the 12,032 KiB firmware image, erased and wrote the firmware MTD region at 0x002C0000, checked the MD5 of what it wrote, activated firmware slot 0 and rebooted.

The router came back as OpenWrt 24.10.1 (r28597-0425664679).

One successful boot is not enough

Xiaomi’s bootloader tracks failed starts and can fall back between firmware slots. Seeing an OpenWrt shell once did not prove that the tenth reboot would still select it.

I updated the U-Boot environment to lock in slot 0, mark the boot successful and neutralize the fallback retry counters:

fw_setenv boot_fw1 "run boot_rd_img;bootm"
fw_setenv flag_try_sys1_failed 8
fw_setenv flag_try_sys2_failed 8
fw_setenv flag_boot_rootfs 0
fw_setenv flag_boot_success 1
fw_setenv flag_last_success 1

The community instructions describe this as preventing an apparent brick after reboot. More precisely, it prevents Xiaomi’s fallback logic from undoing an otherwise successful installation.

XMiR-Patcher backed up several critical partitions during validation (bl_uboot, Nvram, Bdata and Preloader), though a safer repeat should explicitly archive a complete MTD dump—especially factory radio calibration and original firmware slots—before writing anything.

Becoming the actual router

The successful flash was not the end of the story. It was the point at which the AX3200 became ordinary infrastructure.

That same evening I migrated nineteen static DHCP leases into OpenWrt’s UCI configuration (uci add dhcp host) and dnsmasq with a short ash script. The router became the local source of names and addresses rather than an appliance configured around Xiaomi’s assumptions.

In July 2025 I installed adblock-lean. The first run processed 278,676 raw entries from HaGeZi’s tif.mini and pro lists in fourteen seconds, produced a 1.61 MiB compressed dnsmasq blocklist with 230,950 active entries and passed checks for both ad blocking and ordinary DNS resolution.

In August 2025 I added Tailscale. The AX3200 advertised the home LAN as a subnet route, joined the Tailscale interface to the LAN firewall zone and exposed dnsmasq on it. With Tailscale Split DNS pointing my private .test domain at the router, remote machines got the same local hostnames and ad blocking as machines inside the house.

This is the practical payoff of alternative firmware. The router was not liberated merely because a shell prompt said OpenWrt. It was liberated because months later it was still doing increasingly useful work using standard, inspectable components.

The exploit becomes maintenance

There is an uncomfortable contrast in this installation.

The vendor path required impersonating a mesh node, exploiting an authenticated command injection bug, modifying hidden flags and deriving a root password from a serial number. The resulting community firmware offered documented configuration, normal package management, SSH, reproducible images and years of public maintenance.

The security-sensitive path was the one required to leave the locked system. The boring path began after I had escaped it.

That does not make every OpenWrt installation safe. Writing the wrong image, losing power during an erase, destroying calibration data or mishandling boot variables can still ruin the device.

It also means that the router’s useful life no longer depends on Xiaomi deciding which features, updates and access methods remain available for this model.