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

Thanks bro.

I think this update bricked my router xD just thing morning i think the router rebooted and lost all of the settings i’ve configured. When i was trying to input then ip address for the Lan it didnt save and tried to restore the previous settings then it hanged on me. After that i couldnt log in into the luci and on ssh. I tried resetting the router with the reset button, its now stuck with the orange light constantly flashing for mins now.

Mines bricked but not because of the latest update.
I think when using the reset button to reset it overwrites the uboot bootdelay we set.

While trying to remod it my SPI flash chip SOIC clamp popped off while writing to flash and bricked the router.

As these clamps are low quality mine won't even grip the chip now so I can't write to it until my new clamp arrives.

v2.28.132 stock firmware? mi routher 4A giga version
hello i bought this version, i have installed china rom the device is not working healthy. global software send rom file?

So I had a busy Sunday installing openwrt on my Mi Router 4A Gigabit.
I had ordered a CH341A programmer from AliExpress and carefully gathered all scattered information on the net about how to upgrade the router.
First I reworked the programmer to be compatible with 3.3V signals and even added the recommended capacitor to the reset line.
I already failed miserably reading the flash since the programmer always disconnected during the read.
It actually identified the chip correctly but never finished the read process.
Digging into the problem I found that the 3.3V LDO seems to be overheating quickly and dropping the 3.3V output.
An added heat sink to the LDO did not make a change.
Nor did the use of the USB 3.0 port on my computer.
lsusb was not showing the device anymore until I replugged it.
A powered USB hub also did not work.
The LDO is rated for 1A output. Obviously the router draws more than that.

So I ended up de-soldering the flash chip and reading it with the provided clip.
Then I flashed back the changed binary and soldered it back into the router.
From here everything went pretty much as expected.

Just my five cents in case anybody else runs into that problem.

you could connect to other usb port some uart or other programmer that have 3.3v output and connect both outputs - it solvved same problem for me :wink:

...or just replace the crappy 3.3V LDO on the programmer with a quality switching regulator...

Okay here is my experience with upgrading the Miwifi 4A-gigabit. Thank you all who posted information in this thread, especially the OP.
I purchased 2 of them in December from Aliexpress (around $25 each shipped) and received them yesterday.
I used my laptop with Funtoo Linux to do the hacking and upgrade. The ch341 adapter by itself could read the flash chip (which in both my routers is a GD 25Q127), but failed at erasing or writing to the chip. So I used the extra oomph from a USb/serial adapter's 3.3V, and with this the ch341 could erase and write to the chip as well.
For hexediting I used qhexedit. I used a delay of 9 because my reaction time is a bit long.
Writing back the firmware to the chip was not a problem once I connected the extra 3.3V.
I compiled my own firmware images from the github repository with Luci and OpenVPN built-in as I will be using the routers with NordVPN. Did the initial flash via tftp of the kernel-initrd then after booted in OpenWRT I flashed the sysupgrade for good measure.
Everything seems to work fine.
Total time for each router (including disassembly/assembly, soldering UART pins, connecting ch341 with SOIC clamp and USB UART, reading chip, editing, flashing back and doing the tftp upgrade) was around 30 minutes or less. Image compilation took about 2h, but once done I used the same of course for both routers.
I did read, edit and flash back each router's chip separately as a binary comparison of the 2 stock firmware files showed a lot of differences, likely in the calibration data.
Thank you all again.


Nice. Just one tip when compiling openwrt: make -j8 (adapt to the number of the threads on your CPU) so it will parallelize what is possible, and the build time will reduce drammatically.

Even though I double checked everything. I just broke my Mi Router 4A Gigabit on my first try reading the SPI flash. Even had some magic smoke escaping.

I had this error with ch341prog and I reseated the clamp. Must have shorted something. Well... sh** :rage:

ch341SpiRead: Failed to write 3 bytes 'LIBUSB_ERROR_NO_DEVICE'

Is there any way to fix this or have I just wasted 30€?

I have another one arriving here on Monday. Now I'm afraid I kill this one, too.

Okay. I hate myself right now. I think I figured out how I killed my flash chip.
I never shorted anything. The one thing I didn't check was my voltages.

The chip seems to survive 5V in circuit, but after my error messages I tried reading it out of circuit. And that's where I think I fried the chip.

To anyone trying this the first time. CHECK YOUR VOLTAGES. Other than the 5V pin there should either be 0V or something really close to 3.3V on your pins.

I'll try again with another Mi Router hopefully tomorrow. Now with my programmer modded to 3.3V. And hopefully with a little less smoke.

If this works all well I'll order a new flash chip and try to fix my first victim

@araujorm actually I compiled it first on 8 threads (the default in my Funtoo setup) and the kernel gave a compilation error. I had to lower it to 1 thread to get the kernel to compile properly.

Your compilation failed because of missing source download.
You have to download the sources before building multi threaded.

make download
make -j4

With the right voltages everything worked fine this time

I managed to flash the updated image without any additional 3.3 volt connections. I used a USB 3.0 port on my laptop (in fact the fast charging port, but this extra power does not appear to be provided while the laptop is on).

I did run into issues flashing OpenWRT after that: it turns out you must disconnect the SOIC8 clamp from the flash chip, it is not sufficient to just unplug it from the CH341A programmer.

Okay, I have a problem with OpenWRT snapshot on this hardware. I can configure it and works fine, but when I reboot or power cycle it loses all its settings. "save" and "save and apply" don't actually save the settings. I can apply new settings but they only stick around until the next reboot. I haven't seen anything unusual in the logs.

Probably you are running the initramfs image?
Do you have your root / on flash? tmpfs means it's in ram and not persistent.
Check it with df on a ssh shell.

Doesn't look this way.

root@OpenWrt:~# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root                 4864      4864         0 100% /rom
tmpfs                    61532       244     61288   0% /tmp
tmpfs                    61532       100     61432   0% /tmp/root
overlayfs:/tmp/root      61532       100     61432   0% /
tmpfs                      512         0       512   0% /dev
/dev/mtdblock10           8064      8064         0 100% /rom/overlay

I did flash the sysupgrade image after the initramfs.

What's the exact size of the sysimage you used? Is it too close to 16 MiB?

Also, can you show the contents of the /proc/mtd table of the router to see if it's something strange with it? (do cat /proc/mtd and post the resulting output)

Sure it looks this way...
/ Is in /tmp/root and this is a tmpfs.
Your device is running definitely with a non persistent rootfs.

There is enough space for a persistent rootfs!