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

Hi @Gingernut,
thanks for posting this. So do I get you right, you think it is the driver quality and not
a power source problem ? Power supply just delivers 1Amp at 12V. May be I'll try
another power supply and test again tonight just to be sure.
In case it was the software, may be the drivers included in the orginal firmware (which is an OpenWRT based thing) could be taken into an OpenWRT built, just to check if they run better.

3 Likes

There are posts that show how to include the OEM closed source wireless drivers but it's not a straight forward process.

I would suggest to repeat the iperf3 tests using the bidir command.

edit: You could also try playing around with interrupts as suggested here: https://github.com/openwrt/mt76/issues/391#issuecomment-615452348

# Set ethernet on CPU 2 (live core)
echo 4 >/proc/irq/22/smp_affinity
# Move mt76x2e 5GHz radio to CPU 1
echo 2 >/proc/irq/25/smp_affinity
6 Likes

Hi @Gingernut,
did not find the time yesterday. Going into iPerf3 it seems there are some specialities between Win- and Linux-Versions.
Windows Version does not seem to have '--bidir' option. I can just use '-R' = reverse.
Letting an iPerf Server run on the Router and let it send to the Client via Ethernet I get
[ 5] 0.00-10.04 sec 933 MBytes 779 Mbits/sec 0 sender
In non Reverse Mode over Ethernet (Laptop as Client and Router as Server)
[ 5] 0.00-10.05 sec 246 MBytes 205 Mbits/sec
Doing it the other way ... (Router is client and Laptop is Server)
[ 5] 0.00-10.01 sec 1.06 GBytes 911 Mbits/sec 62 sender
[ 5] 0.00-10.01 sec 1.06 GBytes 911 Mbits/sec receiver
In reverse mode
[ 5] 0.00-10.00 sec 251 MBytes 211 Mbits/sec sender
[ 5] 0.00-10.00 sec 251 MBytes 210 Mbits/sec receiver
Could be some funny wrong Windows Firewall Setting or the Router as 'Server' is slow.

With Wifi I just get a bad link channel today with 400MBit/s. It still shows the drop in link-speed down to 270MBit/s. In Reverse or normal client Mode and the Laptop being the server I get
[ 5] 0.00-10.00 sec 247 MBytes 207 Mbits/sec sender
[ 5] 0.00-10.00 sec 247 MBytes 207 Mbits/sec receiver
In the opposite setup
[ 4] 0.00-10.00 sec 270 MBytes 227 Mbits/sec sender
[ 4] 0.00-10.00 sec 270 MBytes 227 Mbits/sec receiver

1 Like

Thx for testing.

You should run iperf3 on the end systems and not on the router it self.

iperf 3.7 should have the -bidir function both on Windows and Linux builds afaik.

Pre-compiled iperf 3.7 for Windows:

https://files.budman.pw/iperf3.7_64_updated_cygwin1dll.zip

1 Like
root@OpenWrt:~# iperf3 -c 172.28.10.203 -t 30 bidir

Connecting to host 172.28.10.203, port 5201
[  5] local 172.28.10.76 port 42592 connected to 172.28.10.203 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  79.4 MBytes   663 Mbits/sec    0    215 KBytes       
[  5]   1.00-2.00   sec  73.8 MBytes   620 Mbits/sec    0    277 KBytes       
[  5]   2.00-3.01   sec   112 MBytes   939 Mbits/sec    0    475 KBytes       
[  5]   3.01-4.00   sec   111 MBytes   937 Mbits/sec    0    551 KBytes       
[  5]   4.00-5.01   sec   110 MBytes   918 Mbits/sec    0    642 KBytes       
[  5]   5.01-6.00   sec   111 MBytes   939 Mbits/sec    0    680 KBytes       
[  5]   6.00-7.01   sec   112 MBytes   938 Mbits/sec    0    714 KBytes       
[  5]   7.01-8.00   sec   111 MBytes   940 Mbits/sec    0    714 KBytes       
[  5]   8.00-9.01   sec   112 MBytes   938 Mbits/sec    0    714 KBytes       


root@OpenWrt:~# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 172.28.10.203, port 56652
[  5] local 172.28.10.76 port 5201 connected to 172.28.10.203 port 56654
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-1.00   sec  27.3 MBytes   229 Mbits/sec                  
[  5]   1.00-2.00   sec  24.8 MBytes   208 Mbits/sec                  
[  5]   2.00-3.00   sec  23.6 MBytes   198 Mbits/sec                  
[  5]   3.00-4.00   sec  31.8 MBytes   266 Mbits/sec                  
[  5]   4.00-5.00   sec  23.2 MBytes   195 Mbits/sec                  
[  5]   5.00-6.00   sec  32.3 MBytes   271 Mbits/sec                  
[  5]   6.00-7.00   sec  32.4 MBytes   272 Mbits/sec                  
[  5]   7.00-8.00   sec  23.3 MBytes   195 Mbits/sec                  
[  5]   8.00-9.00   sec  25.6 MBytes   215 Mbits/sec                  
[  5]   9.00-10.00  sec  24.4 MBytes   205 Mbits/sec                  
[  5]  10.00-11.00  sec  25.1 MBytes   211 Mbits/sec                  
[  5]  10.00-11.00  sec  25.1 MBytes   211 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate
[  5]   0.00-11.00  sec   298 MBytes   227 Mbits/sec          
iperf3: the client has terminated

These are my results from router (172.28.10.76) and to router with the previous snapshot. I will now upgrade to the latest version from yesterday

2 Likes

Okay... doing an 'iperf3 -c 192.168.1.1 -t 30 --bidir' from End System to Router I get
[ 5][TX-C] 0.00-30.00 sec 374 MBytes 105 Mbits/sec sender
[ 5][TX-C] 0.00-30.07 sec 374 MBytes 104 Mbits/sec receiver
[ 7][RX-C] 0.00-30.00 sec 598 MBytes 167 Mbits/sec 0 sender
[ 7][RX-C] 0.00-30.07 sec 597 MBytes 167 Mbits/sec receiver
including the drop from 400MBit/s link rate down to 300MBit/s when transferring something.
[I am afk now]

2 Likes

Hi @galotzas
may be I am doing something wrong but shouldn't you use '--bidir' instead ?
Then you should get another output like this?

[ ID][Role] Interval Transfer Bitrate Retr
[ 5][RX-S] 0.00-30.07 sec 444 MBytes 124 Mbits/sec receiver
[ 8][TX-S] 0.00-30.07 sec 506 MBytes 141 Mbits/sec 120 sender

Hey @makku71. Yes, you are absolutely right. I forgot to put the --
These are my new results

root@OpenWrt:~# iperf3 -c 172.28.10.203 -t 30 --bidir

Connecting to host 172.28.10.203, port 5201
[  5] local 172.28.10.76 port 42604 connected to 172.28.10.203 port 5201
[  7] local 172.28.10.76 port 42606 connected to 172.28.10.203 port 5201
[ ID][Role] Interval           Transfer     Bitrate         Retr  Cwnd
[  5][TX-C]   0.00-1.00   sec  55.6 MBytes   467 Mbits/sec    0    551 KBytes       
[  7][RX-C]   0.00-1.00   sec  7.14 MBytes  59.8 Mbits/sec                  
[  5][TX-C]   1.00-2.00   sec  18.2 MBytes   153 Mbits/sec    0    551 KBytes       
[  7][RX-C]   1.00-2.00   sec  22.1 MBytes   186 Mbits/sec                  
[  5][TX-C]   2.00-3.00   sec  23.7 MBytes   199 Mbits/sec    0    609 KBytes       
[  7][RX-C]   2.00-3.00   sec  22.1 MBytes   185 Mbits/sec                  
[  5][TX-C]   3.00-4.00   sec  23.3 MBytes   195 Mbits/sec    0    609 KBytes       
[  7][RX-C]   3.00-4.00   sec  22.2 MBytes   185 Mbits/sec                  
[  5][TX-C]   4.00-5.00   sec  21.3 MBytes   179 Mbits/sec   30    434 KBytes       
[  7][RX-C]   4.00-5.00   sec  22.7 MBytes   190 Mbits/sec                  
[  5][TX-C]   5.00-6.00   sec  14.1 MBytes   119 Mbits/sec    0    436 KBytes       
[  7][RX-C]   5.00-6.00   sec  22.1 MBytes   186 Mbits/sec                  
[  5][TX-C]   6.00-7.00   sec  32.3 MBytes   270 Mbits/sec    0    543 KBytes       
[  7][RX-C]   6.00-7.00   sec  27.6 MBytes   231 Mbits/sec                  
^C[  5][TX-C]   7.00-7.75   sec  22.9 MBytes   256 Mbits/sec    0    570 KBytes       
[  7][RX-C]   7.00-7.75   sec  21.4 MBytes   239 Mbits/sec                  
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID][Role] Interval           Transfer     Bitrate         Retr
[  5][TX-C]   0.00-7.75   sec   211 MBytes   229 Mbits/sec   30             sender
[  5][TX-C]   0.00-7.75   sec  0.00 Bytes  0.00 bits/sec                  receiver
[  7][RX-C]   0.00-7.75   sec  0.00 Bytes  0.00 bits/sec                  sender
[  7][RX-C]   0.00-7.75   sec   167 MBytes   181 Mbits/sec                  receiver
iperf3: interrupt - the client has terminated
root@OpenWrt:~# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 172.28.10.203, port 57140
[  5] local 172.28.10.76 port 5201 connected to 172.28.10.203 port 57142
[  8] local 172.28.10.76 port 5201 connected to 172.28.10.203 port 57144
[ ID][Role] Interval           Transfer     Bitrate         Retr  Cwnd
[  5][RX-S]   0.00-1.00   sec  15.8 MBytes   132 Mbits/sec                  
[  8][TX-S]   0.00-1.00   sec  43.5 MBytes   364 Mbits/sec    0    542 KBytes       
[  5][RX-S]   1.00-2.00   sec  27.5 MBytes   231 Mbits/sec                  
[  8][TX-S]   1.00-2.00   sec  31.0 MBytes   260 Mbits/sec    0    573 KBytes       
[  5][RX-S]   2.00-3.00   sec  26.9 MBytes   226 Mbits/sec                  
[  8][TX-S]   2.00-3.00   sec  32.2 MBytes   270 Mbits/sec    0    631 KBytes       
[  5][RX-S]   3.00-4.00   sec  23.4 MBytes   196 Mbits/sec                  
[  8][TX-S]   3.00-4.00   sec  23.9 MBytes   201 Mbits/sec    0    631 KBytes       
[  5][RX-S]   4.00-5.00   sec  24.0 MBytes   201 Mbits/sec                  
[  8][TX-S]   4.00-5.00   sec  21.6 MBytes   181 Mbits/sec   18    441 KBytes       
[  5][RX-S]   5.00-6.00   sec  25.8 MBytes   216 Mbits/sec                  
[  8][TX-S]   5.00-6.00   sec  22.0 MBytes   184 Mbits/sec    0    477 KBytes       
[  5][RX-S]   6.00-7.00   sec  24.2 MBytes   203 Mbits/sec                  
[  8][TX-S]   6.00-7.00   sec  19.9 MBytes   167 Mbits/sec    0    510 KBytes       
[  5][RX-S]   7.00-8.00   sec  25.8 MBytes   217 Mbits/sec                  
[  8][TX-S]   7.00-8.00   sec  27.3 MBytes   229 Mbits/sec    0    583 KBytes       
[  5][RX-S]   7.00-8.00   sec  25.8 MBytes   217 Mbits/sec                  
[  8][TX-S]   7.00-8.00   sec  27.3 MBytes   229 Mbits/sec    0    583 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID][Role] Interval           Transfer     Bitrate         Retr
[  5][RX-S]   0.00-8.00   sec   203 MBytes   212 Mbits/sec                  receiver
[  8][TX-S]   0.00-8.00   sec   232 MBytes   244 Mbits/sec   18             sender
iperf3: the client has terminated

2 Likes

Uff, looks like I made the same mistake when testing :zipper_mouth_face:

3 Likes

i debrick it with method described here: power off router, hold reset, power on, look at dhcp receiver, change ip, and send 'test.bin' by tftp server.
May be 'test.bin' firmware was reject because its not for 3gv2 as you say. So thats why i got openwrt back...
But i can now connect to my router via luci, via ssh, but before it even ssh did not work. I mean i couldn't connect to any port.
Also can you write quick guide how to made stock firmware in my case? I'm not good at this stuff :slight_smile:

1 Like

This looks interesting!


Use google translate... That's what i did.

@ferogot @wimpie007 it's not possible to use these scripts when your router not running official firmware! owners of R3GV2 be aware before you flash openwrt you need to create a full backup from flash chip. then change the bootloader of your router after you change bootloader you can install any firmware you want and it is possible going back to stock firmware.

Also here is the updated scripts :


what's new:
5.start_download_openwrt.bat==> script will download latest snapshot into firmwares folder.

2020-05-07 01_13_16-firmwares

9.start_restore_backup.bat ==> rewrites the entire flash from data / backup.bin, including the bootloader and special sections.


older version with detailed guide is here:

5 Likes

Thanks Zorro!
does the start_create_backup.bat makes a correct/complete backup of the nand?
If i make a backup with it, and i fu&* up later on, i can restore it with the start_restore_backup.bat? (of course after the TFTP/bootp restore method to get on the official chinese firmware)

Is that tested?
Thanks for the great work!

1 Like

Used this to flash openwrt on my mi router 4a gigabit edition.So far so good.No problems faced.Just replaced the sysupgrade official firmware with the openwrt firmware renaming the file sysupgrade and followed the rest process......Easiest way till now.For me at least

1 Like

anyone knows what is the status of the snapshots for this device?
I have 2 new devices laying around, waiting for the right moment to be installed :slight_smile:

1 Like

Yeah, i don't know wich version to flash either:)
choices... choices...

1 Like

Hi @rubee,
just to clarify:

  1. Do I get you right you updated a Mi Router 4A Gigabit from
    Stock Firmware 2.X.Y to OpenWRT Snapshot by "just" renaming
    the OpenWRT into sysupgrade.bin or did you ...

  2. ... use Zorros manual how to do it, two post before yours ?

1 Like

it worked for me i successfully restored my backup.bin the process takes 10-15 minutes...
does the start_create_backup.bat makes a correct/complete backup of the nand?
yes, it will create a full backup from flash chip including your router mac address...

2 Likes

how to flash openwrt with the latest scripts :
1-download openwrt put it in "firmwares" folder
2-run 0.start_main.bat enter the password of your router
3-finally run" 5.start_write_OS.bat" choose the firmware you want to flash it and be patient process will take 7-10 minutes

2 Likes