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

@esix4rmyy Definitely the flashed data is getting corrupted, either while flashing or after that.

My guess is that as the Xiaomi firmware also uses a jffs partition for storing it's data, that coincides with the area you are flashing into and has it mounted, it still manages to write to it before the router is restarted, effectively corrupting the data where you should have the rootfs.

If this is the case, there are a few possibilities to work around this:

  • modify the bootloader
    • get a flasher and do as described in the first posts so you are able to interact with the bootloader using a TTL UART adapter
    • then flash the sysupgrade image with option 2: Load system code then write to Flash via TFTP
    • if you don't have a flasher (although they're cheap and easy to get from China) you can try to dump the boot loader image from /dev/mtd1 (or whatever equivalent is present on Xiaomi firmware), modify it and flash it back with something like mtd -e Bootloader -r write mod_bootloader.bin Bootloader - but I haven't tried this, and if anything goes wrong, you will end up needing a flasher anyway to unbrick the device, without having made a stable backup copy of it... not recommended
  • try to flash a initramfs first instead - not sure if this will work... (but if it does, it should solve the issues of anyone still not being able to flash OpenWRT, without the need of a flasher)
    • I know that the initramfs can be used with an unlocked bootloader to boot a "ram only" version of OpenWRT using the option 1: Load system code to SDRAM via TFTP.
    • if it also works by flashing it with mtd, and from there flash the final sysimage, then it may be a solution for the problem you're having
    • you won't lose much to try this method, as you won't be modifying the bootloader, so it should be as safe as what you've been doing so far... but as always, if something goes wrong, you'll need a flasher to unbrick
    • I've published a new release (without the intermediate loader hack/patch) in https://github.com/araujorm/openwrt/releases/tag/mir4ag-19.07-20200722 where I've included the initramfs along the sysupgrade image; if you want to try this method, I've put there what I believe are the instructions that should work (as I said, untested... but that sysupgrade image is good, I'm using it right now)

Please tell me the outcome, should you proceed with any of these suggestions.

Best of luck.

2 Likes

Hi @araujorm, I'm a novice user,
just wondering,
what are the advantages of your build with others?
I want to try to your build but I want to know more
Thanks.

@jekseparo OpenWRT has currently 3 active branches: 18.06 (old, very few commits, kernel 4.9), 19.07 (few commits, mostly are only about very serious security issues, kernel 4.14) and master (unstable/experimental, many daily commits, kernel 5.x).

Master branch is very unstable and is undergoing structural changes since they switched to kernel 5 (namely, you can't currently configure multiple vlans on the same ethernet port using the web interface, so it's lacking features compared to previous branches in my opinion - that should change in the future, I hope, but I have nothing to do with OpenWRT dev team so I can't control that).

However, currently this router is only officially supported by OpenWRT in master branch. So a few talented guys here ported support for it to the stable branch, and when OpenWRT team launched officially the release 19.07.3, they made their own builds and shared them here (it's the case of @Byte and @Zorro).

With these, not only you get a more stable system, you can also use the opkg package manager to install more stuff at your will (most packages from the official repo will work, except those that depend on specific kernel builds). However, a few people complained about the wifi driver being outdated and slower than what they found on master branch. So your mileage may vary.

My builds are also based on 19.07 branch but they didn't "stop" at the point when 19.07.3 was released a few months ago - since then, some fixes have been inserted on that branch by OpenWRT team, namely a bump in kernel version from 4.14.180 to 4.14.187, which includes at least one CVE security fix.

But that's not the only difference. The 19.07 branch of the wifi driver never saw newer commits, and on master branch they started dedicating themselves to kernel 5.x support only. So nowadays most of what you see there is related to newer and shinier mt76 based wifi devices that have nothing to do with the router debated on this topic, and you can't use the master version on kernel 4 (it will fail to compile). But there are some few generic fixes and possible improvements there that seemed relevant to me so I tried to backport them. As such, the wifi driver in my builds may be a bit better than other 19.07 based builds on this topic (that is yet to be proven, and probably it's just a placebo effect - even to myself - but don't tell anyone).

All the code I adapted can be seen and downloaded is in GitHub, as I said in previous posts. Compiled builds can be downloaded from there too, click on the "releases section". There, you can take a look at the list of commits there and you'll see the possible fixes/improvements I talked about.

This is what I use in my router, at least until I find master builds are mature and good enough for me. Anyone is free to try it or not :slight_smile:

I just glued some things together that seemed relevant, mostly for personal use, so YMMV. Remember, the real credit ends up being to the OpenWRT team, also to @Zorro and @Byte as they inspired me to try this - previously I was building snapshot builds from master branch on my machine, but the result stopped being what I wanted since they changed to kernel 5.x (but as I said, should be a matter of time until they're good for me again). So I'm grateful to everyone who has been sharing ideas.

(BTW... it's been a year following this thread already... time passes...)

3 Likes

Thanks for the explanation. I will try to your build. If there are obstacles I will convey here.
thanks.

1 Like

Can anyone point me to the post of how to recover of bricked device? thanks

Couple of people have made good guides:

And:

I also made a video guide on how to install and do the debrick if needed here: https://youtu.be/VxzEvdDWU_s (the debrick guide is at the end of the video).

1 Like

Hi @araujorm , do you have a clean building, without additional applications.?
thanks.

I haven't done any but it's pretty easy for me to do one if you want.

Note that certain packages won't be installable from the repos if they depend on the kernel signature that is pretty much unique for every build, like openvpn (since it depends on ssl libraries built in the kernel) or wireguard. Do you want me to include those?

Alternatively you can install a VM with Linux and clone my repo and build yours at your taste... tell me what you prefer.

OK, maybe some time later, I will try to build my own based on your repo, although I am still unfamiliar in that regard.

And one more, i got a bug from your build, my device if i turn it off then i turn on then the dhcp client doesn't work. My computer's Ethernet is not getting an IP address (unidentified network). Previously I thought this was a problem with my cable or laptop, but after I replaced the cable and tried with another computer, it turned out that the incident repeated.

thanks

can we install for wifi client security EAP-PEAP on this build?

What build you guys with PPPoE gigabit have?
I've tried @Byte, @araujorm and cannot max gigabit connection with HW offload ON.
However, for me @araujorm (sha256:c97abdb078f9237e1a8afda5d46306c07eb083574df2199096f09ae9a0baa0e0) is way faster with HW nat ~860mbps while @Byte is slower.
I have left to test official snapshot and @Zorro, after I do a full flashrom dump to avoid brick.
cannot offer feedback for @araujorm WIFI drivers

@jekseparo sorry but I can't be of much help there since I don't use my router for DHCP, but others seem to have it working. Does it happen with other builds too?

@joedotnet for that I think you need the package wpad-full, default builds include the wpad-medium or mini variants. Try installing wpad-full full with opkg and see if it works, or else you will need to build your own image with support for it.

@read my tests with ethernet performance with this router vary but I never passed the 800-ish Mbit/s with it. Usually the performance is below that when testing with iperf3 (with and without -R) running via SSH to the router. I think the CPU ends up being the bottleneck, but don't take that for granted. It could be interesting to see if with stock firmware or master (kernel 5 based) openwrt snapshots is better (I can't do these tests myself since my router is in "production" and my "costumers" here at home will kick me if I mess with it and take it offline for too long...)

thanks for the build
I flashed @Byte @Zorro and yours, and from all current 3, best "near-gigabit" (HW offload ON) speed for my PPPoE is still your build: sha256:c97abdb078f9237e1a8afda5d46306c07eb083574df2199096f09ae9a0baa0e0
will test snapshot and report back

Hi

I am trying to find the original rom for the 3gv2 but the usual link are not working for me.
I am trying to debrick the router.

Can someone point me to a original rom that work with the 3gv2?

I am posting on this thread because look very active. Already thank you

in repo no wpad event one
googling wpad-full i can't find it.
can you point me
or you can insert this wpad-full on your build. thanks

I think its just called wpad you can find it under software (after updating the list) or ssh:
opkg update
opkg install wpad

You can find the link in description of this video, its in the folder and is called test.bin, the 3gv2 is the same as the 4A.

1 Like

This is specifically for your build, for other builds there is no problem. it looks like your build has a problem with the dhcp distribution package.