Hi, today I will tell you how to install OpenWrt on Xiaomi Mi 4A Gigabit Edition Router. This router has 128 MB of RAM and 16 MB of Flash which is more than enough for OpenWrt.
I chose this router because before using this router I had 1 router and a modem because the modem couldn’t give a good signal after 5-8 meters. Also since it gave a bit of signal the device would not automatically switch to the router that’s why I needed a better router to disable the WIFI of the main modem, disable the old router, and only use 2 of these routers, mesh them with OpenWrt to a single network and use it like that. But when the router came where once had 5MB down 2 MB up had 15 MB down and 5MB up on a 100/5 ISP plan with one modem without OpenWrt (With OpenWrt it was even higher)

What Is OpenWrt/Why Choose It

For the OpenWrt team, it’s wireless freedom. For me, it’s making your router/modem your empire.
OpenWrt has features like plugins like AdBlock, ssh, better control over the modem, more customization, and more.
It modifies the files for better wifi signals

Starting To Install

WARNING!!!!!!!!

Me, anybody, any site mentioned or linked to on this post take no responsibility in any form if something wrong happens

First off when starting to install you need:

a USB stick that is at least 8 GBs (to install Linux mint on)
an Internet connection
some patience
Rufus or balenaEtcher (for writing Linux mint on the USB)
a Linux Mint ISO from the official Linux Mint Site (You can use any other Linux distro if you want. I tried it on only Linux Mint.)

To flash the Linux Mint ISO file that you’ve downloaded open Rufus or Etcher. (If it does have do complete the setup)
After that plugin, the USB stick and start flashing (Note that it will delete all the files on the USB stick)
After it finished flashing open BIOS (probably press the F2, F11, F12, or the DEl key while turning on the computer)
Change the first boot drive to USB then save & exit.
When Mint Opens up press the first option (Or live trial etc.)
Then open the terminal and type :

sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoclean -y && sudo apt-get autoremove -y 

This'll update all of the components of Linux Mint to the latest version

After that’s complete, type in

git clone https://github.com/acecilia/OpenWRTInvasion.git
cd OpenWRTInvasion

This'll download the OpenWrt installer, and go into it's folder

Once that's done, type 
pip3 install -r requirements.txt 

This'll install the required stuff for the installer.

After that, we run the installer.

python3 remote_command_execution_vulnerability.py

It'll ask you for a code, to get this code go to your router's local IP. (Default 192.168.31.1)  and  copy the part in the URl where it says: stok=codecodecodecodecode (without the /) 

After approx. In 45 seconds you should be able to connect to the router.
Type: telnet 192.168.31.1 and type root for both the username and password.





When it’s connected, type cd /tmp and then curl -L https://downloads.openwrt.org/releases/21.02.3/targets/ramips/mt7621/openwrt-21.02.3-ramips-mt7621-xiaomi_mi-router-4a-gigabit-squashfs-sysupgrade.bin –output firmware.bin –ipv4 -k

To check if the file isn’t corrupted, type

./busybox sha256sum firmware.bin

If both the strings match, then continue. If not, redownload the file.

Finally to permanently install OpenWrt, type

mtd -e OS1 -r write firmware.bin OS1

We are waiting for it to perform the installation procces and reboot the device. After the process is finished and the device is turned on without any problems, let's get well soon. I recommend that you download the firmware file that we installed on the device above, this time, and after the device boots up, flash it again to the device without checking the Keep settings option from the Flash new firmware image section of the System → Backup/Flash Firmware page at 192.168.1.1. This is a recommended event after initial setup. The device is ready for use.

Good luck with your new router. What happens next is entirely up to you. You can  use it freely for many different purposes. For example; You can install and use many useful programs such as SQM, AdBlock, Wireguard, OpenVPN, DDNS, Multiwan, DNS over TLS, and upnp. You can even write a program of your own choice. You are only limited by your imagination.

By Nix