Xiaomi Mi Router 4A Gigabit Edition (R4AG/R4A Gigabit) -- fully supported and flashable with OpenWRTInvasion

I have the Mi Router 4A Gigabit Edition packaged device

I get this when I want to install Openwrt. Can you help me?

root@XiaoQiang:/tmp# curl https://github.com/araujorm/openwrt/releases/download/
mir3g-v2-squashfs-sysupgrade.bin --output firmware.bin
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (51) Error

@maxgltc Do you have internet connectivity setup on the router, e.g. can you ping github.com ? (to exit ping do CTRL+C)

If so, try with:

curl -L -v https://github.com/araujorm/openwrt/releases/download/v19.07.4-xiaomi-miwifi-3gv2-mt76updated-2020-10-24/openwrt-ramips-mt7621-xiaomi_mir3g-v2-squashfs-sysupgrade.bin --output firmware.bin

-L is to tell curl to follow github's redirect headers (for example in my location it redirects to github's amazon AWS mirror)
-v is to see what is going on, if it doesn't work then please show the output to see if we can understand what the problem is

If even with that the curl version of Xiaomi's firmware doesn't work, then try with wget instead of curl, like this:

wget https://github.com/araujorm/openwrt/releases/download/v19.07.4-xiaomi-miwifi-3gv2-mt76updated-2020-10-24/openwrt-ramips-mt7621-xiaomi_mir3g-v2-squashfs-sysupgrade.bin -O firmware.bin

Don't forget to see if the download isn't corrupted, compare with this:

#  md5sum firmware.bin
a7b3a3d99f551b2ef9acfe20530a6891  firmware.bin

# ls -l firmware.bin
-rw-r--r--    1 root     root       5440264 Nov  8 13:52 firmware.bin

Thank you for your reply. I did what you suggested and here is the result

root@XiaoQiang:~# cd /tmp
root@XiaoQiang:/tmp# ping github.com
PING github.com ( 56 data bytes
64 bytes from seq=0 ttl=48 time=47.692 ms
64 bytes from seq=1 ttl=48 time=47.388 ms
64 bytes from seq=2 ttl=48 time=47.325 ms
--- github.com ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 47.325/47.468/47.692 ms
root@XiaoQiang:/tmp# curl -L -v https://github.com/araujorm/openwrt/releases/dow
iaomi_mir3g-v2-squashfs-sysupgrade.bin --output firmware.bin
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (51) Error
root@XiaoQiang:/tmp# wget https://github.com/araujorm/openwrt/releases/download/
mir3g-v2-squashfs-sysupgrade.bin -O firmware.bin
wget: not an http or ftp url: https://github.com/araujorm/openwrt/releases/download/v19.07.4-xiaomi-miwifi-3gv2-mt76updated-2020-10-24/openwrt-ramips-mt7621-xiaomi_mir3g-v2-squashfs-sysupgrade.bin

I'd say xiaomi's curl and wget version are too stripped and for some reason they are not working with github right now, maybe something with the certificate (in case of curl, as that wget doesn't even support https)... every site today works with https which (although secure and understandable) can be a headache for things like this.

Confirm first if the router's date and time are OK, because if that isn't correct then it will be a cause for SSL errors (and https is http over SSL).

Other than that, you can try @db260179 build and see if it works, since it's on gitlab, something like:

curl https://gitlab.com/db260179/xiaomi-m4a/uploads/1a59eba3073303f9a46e8e21970ea0fe/openwrt-19.07.4-r11208-ce6496d796-ramips-mt7621-xiaomi_mir4ag-squashfs-sysupgrade.bin --output firmware.bin

It should be stable (more than my build for certain flash chips) and working as well, but if you want later after getting it to work you can use the web interface to flash other firmwares like my build or a custom build you can do using @db260179 image builder (see https://gitlab.com/db260179/xiaomi-m4a/-/releases for downloads, New fixes feedback - Xiaomi Mi Router 4A Gigabit Edition (R4AG/R4A Gigabit) thread for feedback on that build)

More complicated would be to download the image to your pc, then set up your own web server (e.g. apache or nginx on linux, or something equivalent on other operating systems) so that they serve the image using http only, and later use wget or curl to download it from your pc... or setup a ftp server, wget should work with that too. It's out of the scope of this thread but if you're using a linux virtual machine you should find lots of tutorials around the web for basic setup of that.

Using a tftp server on your pc should also be possible, as I think xiaomi's firmware includes a tftp client but I'm not sure of that and can't check it now or tell the exact usage, since my router is already on openwrt.

If anyone else reading the thread has suggestions, please tell :slight_smile:

Edit: added --output firmware.bin to curl example above

I rebooted the router and that solved my problem somehow, thank you anyway for your patience :slight_smile:

When should we expect this device to use regular release of openwrt instead of snapshot one ?


maybe, possibly, early 2021?

But for it to work, it needs this applied in the master branch

Ok, this seems to be making traction - just need to change my commit to adjust the spi frequency and this device should officially added soon!


Finally, Mi router 4a gigabit is separated from 3gv2 in snapshot.



latest snapshot comes with new bugs. in order to enable wifi I have to reboot. I also can't enable both wifi at the same time . openvpn ssl also not support yet. perhaps new kernel related ?

Have you try curl --insecure ... to bypass ssl error ?

hope you guys are ok!
I'm using version OpenWrt 19.07.4 r11208-ce6496d796 (@araujorm release from 24/10) on my three 4A Gigabit routers as Bridge mode to my lan. However, I'm having some issues with DHCP requests. Sometimes, for a bit of time, the devices that connect to the router (LAN or WLAN) can't get an IP from my ISP router... I've already tried with the RelayD interface enabled and the problem still appears from time to time. After a random number of retries, the devices start to get IP again without any restart or reset... If I turn off all my Xiaomi routers, I don't have this problem in my home network.
Anyone with similar issues?

Kind regards

So good people!

This model is now fully added into the openwrt master branch with the bootloop fixed.

So next stable release you will be able to just download the specific image to install on this device - but still need to do the exploit for now from the oem firmware.

Snapshot release is now - https://downloads.openwrt.org/snapshots/targets/ramips/mt7621/openwrt-ramips-mt7621-xiaomi_mi-router-4a-gigabit-squashfs-sysupgrade.bin


awesome news!
for those of us who are already using araujorm's build, we should be able to simply update via luci?

Hi, i just recently got the router and i tried the exploit but with no success. When i try to connect via telnet it says telnet: Unable to connect to remote host: Connection refused. Im running it on Kubuntu if that makes a difference. The router is running 3.0.24

Edit: nvm running python with sudo solved the issue

Hello everyone
A few days ago I purchased a Xiaomi 4A Gigabit router
I followed the procedure described in the post OpenWRTInvasion using image:

https://raw.githubusercontent.com/acecilia/OpenWRTInvasion/master/firmwares/OpenWrt/06-06-2020/openwrt-ramips-mt7621-xiaomi_mir3g-v2-squashfs-sysupgrade.bin --output firmware.bin

But i have the following problem cant install luci interface

root@OpenWrt:~# opkg install luci
Installing luci (git-20.089.25318-f89efcf-1) to root...
Downloading http://downloads.openwrt.org/snapshots/packages/mipsel_24kc/luci/luci_git-20.089.25318-f89efcf-1_all.ipk
Collected errors:
 * satisfy_dependencies_for: Cannot satisfy the following dependencies for luci:
 * 	libiwinfo20181126
 * opkg_install_cmd: Cannot install package luci.

In the post, they use the image of @Zorro but unfortunately your links are down.
Can someone pass me the link of a stable and functional image for my Xiaomi 4A Gigabit installable from the exploit method.

Thank you

Use newest snapshots for 4a giga from here instead.


1 Like


Sorry if it was anwsered before.

I installed the new snapshot downloading directly from Openwrt but I was unable to get the switch working and the VLAN funcionality.

What changed from araujo versions to the new fixed snapshot?


The swconfig based switch drivers got replaced by the newer DSA based ones, requiring a different network configuration <-- meaning you mustn't keep your old config over the upgrade and need to start from defaults (https://openwrt.org/docs/guide-user/troubleshooting/failsafe_and_factory_reset should fix this)