Wednesday, December 14, 2016

Step-by-step: Install OpenWRT on the Xiaomi Wifi Mini router from a Windows Computer (2016 edition)

UPDATE: These instructions no longer work because Xiaomi has patched the firmware bug that allowed us to bypass the security and unlock the ROM.  Now a user must install the "Developer Edition" of the official Xiaomi firmware, register the router with a Xiaomi account, and then unlock the router.  These instructions are posted in another post [LINK].

I found the instructions to install OpenWRT on the Xiaomi Wifi Mini to be difficult to follow [openwrt device page], so I've summarized the instructions below.  Please note that this is for OpenWRT 15.05.1 on the Xiaomi Mini Wifi (小米 路由器MINI )

NOTE: It appears that the Xiaomi Mini has been discontinued since it is no longer listed as an active product on Xiaomi's store. They have replaced it with two other models which do not have active OpenWRT development - however they are still available from 3rd party sellers on tmall.com

Unlock the Router & Enable Telnet

1. Connect the router to power.
2. Connect an internet patch cable to the WAN Uplink port (blue colored).
3. Connect a Windows computer to one of the Ethernet switch ports on the router (white colored).
4. Launch a web browser and connect to the administrator console by going to the following address:
http://192.168.31.1, If you cannot reach the administrator console:
     * Check the IP address on your computer and verify the it starts with 192.168.31
     * Verify that you have any VPN software turned OFF
     * Verify that the Proxy settings are disabled in “Internet Options”
5. Follow the setup wizard and configure the router.
     * Note: It will ask you to set the wifi and the administrator password. Set it to 1234567890
     * Note: All settings made during this process will be erased later, so don’t spend time making it nice...
After you complete the setup wizard, the router will reboot.
6. Connect to the web administrator console again and sign-in to the router and copy the value of the stok URL parameter from the address (for example: "9c2428de4d17e2db7e5a6a337e6f57a3")

7. Replace the <STOK> placeholder below with the value from the new router and copy this address into the URL in your browser. (Note: This will start the telnetd service on the router):
http://192.168.31.1/cgi-bin/luci/;stok=<STOK>/api/xqnetwork/set_wifi_ap?ssid=whatever&encryption=NONE&enctype=NONE&channel=1%3B%2Fusr%2Fsbin%2Ftelnetd
After about 30 seconds a successful command will display the following error code:
Chinese: {"msg":"未能連線到指定Wi-Fi(Probe timeout)","code":1616}
or English: {"msg":"Couldn't connect to this network(Probe timeout)","code":1616}
8. Replace the <STOK> placeholder below with the value from the new router and copy this address into the URL in your browser. (Note: This will change the root password from 1234567890 to 123456abc on the router):
http://192.168.31.1/cgi-bin/luci/;stok=<STOK>/api/xqsystem/set_name_password?oldPwd=1234567890&newPwd=123456abc
After about 5 seconds a successful command will display the following error code:
{"code":0}

Install OpenWRT on the Router from a Windows Computer

1. Run putty (download it if you do not have it on your computer) and start a Telnet connection to the router with the following two options:
  • Host Name (or IP address):    192.168.31.1
  • Connection type:                     Telnet


2. Sign into the console using the following account information
  • XiaoQiang login:    root
  • Password:         123456abc

3. Get the latest firmware from OpenWRT using these Telnet shell commands:
  • # cd /tmp
  • wget http://downloads.openwrt.org/chaos_calmer/15.05.1/ramips/mt7620/openwrt-15.05.1-ramips-mt7620-xiaomi-miwifi-mini-squashfs-sysupgrade.bin

4. Check the MTD layout on the router to make sure you don't damage it:
  • cat /proc/mtd

If you find a line "OS1" go ahead with flashing:
mtd -r write openwrt-15.05.1-ramips-mt7620-xiaomi-miwifi-mini-squashfs-sysupgrade.bin OS1
     * Note: for LEDE, replace the file name with the correct one, like this: mtd -r write lede-17.01.2-ramips-mt7620-miwifi-mini-squashfs-sysupgrade.bin OS1
After flashing is complete, the router will reboot. Wait about 10 minutes to ensure that the firmware is installed properly and then power off the router and power it back on my disconnecting the power.

Please note that the OpenWrt binary defaults to the red color of the led instead of the orange/blue during and after finishing the boot that Xiaomi uses.

Comments on how OpenWRT runs on the Xiaomi Wifi Mini Router

  • There is LOTS of memory on the Xiaomi - it is a luxurious amount of space to install packages on and run them in memory.
  • The ROM is stable.
  • I have tested several VPN/proxy packages's on it like OpenVPN, stunnel, and shadowsocks; they all run well on OpenWRT and this hardware.
  • The Wifi is not stable. From extensive testing I assume that Xiaomi is running some custom drivers or doing some software tricks to make the wifi work properly (the wifi works perfectly on the stock Xiaomi ROM).  Suggestion - Use the Xiaomi as a router and attach another Wifi router to it for WAP functions.
  • The wifi is available for international shipping from several 3rd party sellers on Aliexpress (in China they retail for 130rmb - about US$20) [Search Results]