Installing OpenWRT on Xiaomi Mi Router 4C

Hello,

I am trying to install OpenWRT on a Xiaomi Mi Router 4C:

https://openwrt.org/toh/xiaomi/xiaomi_mi_router_4c

The installation guide points to the OpenWRTinvasion script to flash the router:

I have Python3 installed on my Linux laptop.

Before proceeding with the installation, I have a question regarding the following note on the OpenWRTInvasion Github page:

" NOTE: FROM VERSION 0.0.2 THE ROUTER NEEDS INTERNET ACCESS."

How can I ensure that my router has internet access during the installation? You typically connect the router on the WAN port via a lan cable to the ethernet port of the laptop, which is then offline during the flashing process.

Is there a way around this requirement or how can you serve the router internet access via the laptop?

Thanks for your feedback!

It can download busybox to your pc and upload to router, just one of 2 needs internet. And it is not permanent - no busybox, just restart connect and try again.

I am sorry, but I don't understand your comment and I never used busybox. Could you please add a little bit more detail? Thank you!

There is script_tools/busybox.mipsel that will be uploaded in absence of internet connection.That line in readme is moot.
Exploit is in memory only, you have unlimited tries.
Courage, my friens, and run script to record your terminal for replay.

Thanks, are you referring to this one?

Yes, you checked out the repo and it has the required binary in place. Safely disregard that warning,

 -----------------------------------------------------
       Welcome to XiaoQiang!
 -----------------------------------------------------
  $$$$$$\  $$$$$$$\  $$$$$$$$\      $$\      $$\        $$$$$$\  $$\   $$\
 $$  __$$\ $$  __$$\ $$  _____|     $$ |     $$ |      $$  __$$\ $$ | $$  |
 $$ /  $$ |$$ |  $$ |$$ |           $$ |     $$ |      $$ /  $$ |$$ |$$  /
 $$$$$$$$ |$$$$$$$  |$$$$$\         $$ |     $$ |      $$ |  $$ |$$$$$  /
 $$  __$$ |$$  __$$< $$  __|        $$ |     $$ |      $$ |  $$ |$$  $$<
 $$ |  $$ |$$ |  $$ |$$ |           $$ |     $$ |      $$ |  $$ |$$ |\$$\
 $$ |  $$ |$$ |  $$ |$$$$$$$$\       $$$$$$$$$  |       $$$$$$  |$$ | \$$\
 \__|  \__|\__|  \__|\________|      \_________/        \______/ \__|  \__|


Wouldn't it be possible to simply connect a second USB-ethernet card to my laptop so that I can connect to the WAN port of the Xiaomi router while connecting my laptop via the standatd built-in ethernet port to my normal router (internet facing)?

Wouldn't that meet the internet connectivity requirement of the OpenWRTInvasion script without any further difficulties?

Exploit works without any internet connectivity. It does not permanently change OEM firmware.
You will need cable ONLY for initial OpenWRT setup.

It means your router 4C needs to be setup to INTERNET ACCESS online in factory FW, before you flash openwrt.

1 Like

You dont need connection, script gives question - do you want to use existing busybox, download via router or download from host.
Worked for me 3 times :wink:

OK, I'll try it next time.

I was always make 4C online first, then I can see the stok string.

invasion script starts webserver with included busybox, extracts stok, like you dont have to copy paste anything. Just press "enter" 7 times and you are ready to flash OpenWRT.
Worked like that both times i tried, looking at screen recordings in invasion checkout directory 02/2019 and 08/2022

Temporary processes in temporary filesystem:

16917 root         0 SW   [kworker/u2:2]
18787 root      1740 S <  ./busybox telnetd
18789 root      1740 S <  ./busybox tcpsvd -vE 0.0.0.0 21 ./ftpd -Sw /
18908 root       564 S <  /tmp/dropbear/dropbear
19608 root      1804 S    sleep 120
19645 root      1804 S    sleep 300
19662 root       640 R <  /tmp/dropbear/dropbear
19667 root      1820 S <  -ash
19677 root      1812 R <  ps

I would reset device first, may help if some self-protecting backdoor is active....

Thanks guys! Will try the installation and report back if I encounter any issues...

1 Like

Install zram-swap, without it 64MB will run out when receiving dozen guests. It is burried deep in compaction guides.

2 Likes

Are you referring to this package?

https://openwrt.org/packages/pkgdata/zram-swap

What's the best way to install and configure it for the 4C router?

Can this package be directly added to the factory firmware when downloading it by simply customizing the installed package section?

https://firmware-selector.openwrt.org/?version=23.05.0&target=ramips%2Fmt76x8&id=xiaomi_mi-router-4c

In openwrt luci web interface System/Software...
Update lists, then type in filter zram-swap, install it.
Then also install luci-app-attendedsysupgrade and upgrade to 23.05.3
If you like command lines try wiki or we give you links.

Like here https://openwrt.org/docs/guide-quick-start/start

When you are ready to go How to mark a topic as [Solved]

Just for info, for many Xiaomi routers there is no need to connect them to the internet for setupt to complete. You could just connect WAN and LAN1/2 with ethernet cable, then the router sees itself as upstream router. Your PC then gets IP in 192.168.28.0/24 (important for OpenWRTInvasion). For xiaomi 4C there was a bug, where TX power was limited. I wonder if it is still there. There are some workarounds online.

1 Like

Thanks for your comment @ilija.culap.

Just for clarification:

Do you suggest to connect the 4C via its WAN port to an existing modem / router / gateway (with internet access)?

And the laptop that is used to access the 4C and flash the formware via the laptop's ethernet port and the 4C's ethernet port 1 or 2?