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

Hello Guys . fresh openwrt build :
https://dl4.shatelland.com/files/e4b7e317-1ed7-4567-8179-0b7ba4857194/ec40e1bb-1342-493f-ac1e-66ada8fa26d2

sha256: ded558fd9531d3acb67e6d240c2be6e2da964d2af27c172fdca41f203b23ce15

Firmware Version: OpenWrt SNAPSHOT r13062-ef5d37ba5e / LuCI Master git-20.116.42735-f44ba48

kernel version: 5.4.35

included packages:
luci
open vpn
wireguard
sqm qos
adblock
vpn policy routing
DNS HTTPS Proxy

2 Likes

did you install python 3?

Hello, thank you for making it with sqm!, now my latency are wayyy better with, cake and layer_cake

1 Like

yes. not open .bat

download and install requirement files from here and try again it works for me on windows 10.

Error on open 0.start.main.bat, any help?

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

what router you have? be aware you can use the scripts only when your router running official firmware .
install all requirement and try again.

@juppin @Zorro
Hey, sorry for the late reply I see that @bouzouste already added screenshots about MAC addresses.
Indeed, all MACs are located at "Factory" partition. For 1G version "Factory" partition has offset 0x50000 for 100m version it is 0x30000 so keep it in mind. I know that we are able to read "Firmware" partition from OpenWRT CLI using mtd utility, but I didn't have a chance to check if we are able to write it back to flash using mtd. I did it all using HW SPI flasher. SPI flasher can be built with an stm32 "blue pill" board - check this repo. Use your preferable way.

Let's get started.
MAC offsets from the start of "Factory" image are next(for 100m version):

  • 0x0004 - WiFi 2.4G
  • 0x8004 - WiFi 5G
  • 0x0028 - Ethernet

As you can see(compare with @bouzouste's information), WiFi MACs locations are the same for 1G and 100m version.

Now let's change WiFi radiation power. But remember: DO NOT break your local law about allowable radio radiation power and bla-bla-bla - you know it :innocent: :slight_smile:.

Use the same "Firmware" partition and take a look at offset 0x00A0:


Starting with this offset you will need 14 bytes in a row.
Those values regulate maximum WiFi 2.4G radiation power, so replace all of them(14 bytes) with 0xFF.

Now go to offset 0x8060:


From this offset, you will need every fifth byte for 12 times.
Those values regulate maximum WiFi 5G radiation power, so replace all those 12 bytes with 0x7F.

Keep in mind that results values for 2.4G and 5G are different 0xFF and 0x7F respectively.
Happy WiFi radiating :smiley:.

5 Likes

By the way: had someone a chance to make a dump of stock image for R4AC aka 100m version?

1 Like

In my backup firmware for the Gigabit edition, the Base offset is actually 0x50000. :wink:

2 Likes

And here's a modified 5G power table (Gigabit version):

EDIT: After performing some testing, I saw decreased effective range and throughput after modifying the partition. It may be better to test some favourable reg domains instead.

2 Likes

Hi, could you please check the sha256 again?
I always get
55d55b7f4d291edee08d9c64638194b679a83100095a82be1cec6cabb737cde5
wherever i download/check the file. Your other builds match the checksum, just not this last one.

thanks

1 Like

Yes, you're right about offset for 1G, I made typo. Correct offset 0x50000.
About power table you may be right. Those values just removes software limitation, so you can set higher radiation rate in the settings, and even it can really radiate more power. But maybe HW has some power limit after which it will produce much more noise. I don't have any RF tools to check all those stuff.

1 Like

Hello. the problem is with where i upload it. i upload that file somewhere else and now sha256 should be OK .please go to below link and download it again. thank you very much

http://www.mediafire.com/file/7vkqypwlzoq1quk/openwrt-ramips-mt7621-xiaomi_mir3g-v2-squashfs-sysupgrade.bin/file

sha256: ded558fd9531d3acb67e6d240c2be6e2da964d2af27c172fdca41f203b23ce15

Perfect, now it matches the checksum. Thank you.

1 Like

add ('windows-1252') on decode in line 4, works for me.

line4 = subprocess.check_output(["cmd","/c","chcp","437","&","tracert","-d","
-h","1","1.1.1.1"]).decode('windows-1252').split("\r\n")[4].strip().split(" ")
1 Like

The wifi speed goes from 10MB to 5-8MB in few seconds while speedtesting. I built one myself and got the same result. Don't know the reason.
BTW, how did you configure the switch? I built one but the switch configuration wasn't correct. Thanks.

Try this setting in interface
Fragmentation Threshold > 2346 (default 256-2346)
RTS/CTS Threshold > 2347 (default 0-2347)

1 Like

switch doesnt work

Hi All!
Thanks to all for their great work. Got my two XIAOMI Mi R4A Gigabit today.
Decided to open one, ´cause I have seen photos from different Revision R0202 somewhere.
Do I have to use a revision-specific firmware to be compiled and flashed ?
Mine seem to be R0101
grafik

Can I contribute to this forum in one or the other way ? (only Software - no
hardware flashes).

Makku