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

thanks but i get this error when running any .bat file

how can I solve it?

Traceback (most recent call last):
  File "main.py", line 10, in <module>
    line4 = subprocess.check_output(["cmd","/c","chcp","437","&","tracert","-d","-h","1",""]).decode().split("\r\
n")[4].strip().split(" ")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 1: invalid start byte

@hectorcamp had a similar problem. May be it works for you too ..
See here.
Solution for him is here.

how to configure the dhcp server?

I've made a quick video for you on how to set it up, sorry its a bit rough. Over the next few days, I will do a full video guide on how to debrick and install if anyone's interested give me a like and a sub on Youtube, please.
DHCP Setup Video Here
Just a note this is for use with the DHCP server from here: dhcpserver.de
Hope this helps!


Sorry, I've fallen a little behind on this. Can anyone tell me the latest and most stable version? I would like to make a full video guide and want it to be as up to date as possible.

well, here is an easy debrick method :

1)download TinyPXE.zip and unpack it.

2)connect ethernet cable to the router, set static ip to your local network(192.168.1.x)
2020-05-12 21_28_15-Window

3)turn off your router and hold down the reset button then power on your router when power LED start flashing slowly release it .
4)run pxesrv.exe (it is fully configured), click "Online"

2020-05-12 21_29_16-Window

wait 7-10 minutes when power led turns blue power off your router then power on it.


Very nice, thats the simplest method yet, and you've even included the firmware thanks Zorro. Can i ask whats the latest version of OpenWrt firmware that is working stable?


Sorry, excuse my ignorance:

1 Like

Hi guys!

Just posting to say that I'm using the 19.07.2 build that @Zorro uploaded (the one of the #2 link) and it's working great on my Mi 4 Gigabit Edition, way better than the old snapshots from when I first modded my router to install OpenWRT. It's fast, with flow offloading my 300/15 connection works without any issue at full speed and so far very stable. Totally recommended.


Hello, if you find any bug, I appreciate that you can report it here. I would like to flash my router

1 Like

@rogerpueyo Nitpick regarding the topic title: The correct spelling is OpenWrt.

1 Like

I am fully aware of it :wink: but the tool is indeed named OpenWRTInvasion


You can flash it. One of my two Devices runs this image for a couple of days now in daily use without any trouble. You will do fine until there is a fully supported Version 20 of OpenWRT for this device.
Follow the excellent descriptions and enjoy !

1 Like

I've just made a video showing the complete install method and debrick method if needed. Hopefully its helpfull!


Thank you for you works and also for the video.
I am stuck and need your help.

I was able to run OpenWRTInvasion but I cannot connect to telnet. I don't know how to solve that. I am now running on firmware 2.28.62. Initialy my router was with chinese firmware.

pi@raspberrypi:~/OpenWRTInvasion $ python3 remote_command_execution_vulnerability.py
Router IP address:
stok: c8f27652af5b21d497cc68e9e9d453ea
stok: c8f27652af5b21d497cc68e9e9d453ea
start uploading config file...
start exec command...
done! Now you can connect to the router using telnet (user: root, password: none)
In MacOS, execute in the terminal:
pi@raspberrypi:~/OpenWRTInvasion $ telnet
telnet: Unable to connect to remote host: Connection refused

Thank you for your help

1 Like

after you've set the password in the stock firmware webinterface, do a reboot and try to connect to it again. I needed a reboot to be able to connect.

1 Like

I tried a reboot, confirmed by the change of stok but same result.
I plug the router on the lan 2.
And I am doing the hack from my remote rpi3B trough SSH (my computer is under windows and the script of Zoro don't want to work Rrrr).

I configured the router as an access point to be able to reach it though my normal network.

I don't know if one of these elements can explain my problem.

1 Like

i am new and unfamiliar with linux .
i have mi4a gigabit router and also a ch341 programmer
i have problem with stock firmware related to vpn because when i input my pptp account parameters in router and want to access filtered websites in my cellphone like youtube , it doesn't work and websites remain filtered but my ip and geo location changes so i decided to flash a new firmware that solves my vpn problem .
my question is : is there a dd-wrt firmware or edited dump with vpn funtionality like asuswrt for pptp and l2tp and openvpn client tested and functional that i flash it with programmer on my router?

Normally I've found a reboot cures it when I've had issues. Out if curiosity, the IP you're using is not default did you change it?


I think the OpenWrtInvasion method is preferred over the CH341, If you need help check my video above. It show me doing it on Linux but you can achieve the same on Windows or Mac. I think you're asking if their is an OpenWrt image that has VPN functionality and the answer is yes, off the top of my head I think Zorro's second image has it but it's definitely a possibility (although because we are mostly using snapshots it can be difficult to install additional packages)