iscilyas / openwrt-r3p

Xiaomi Mi Router 3 Pro
GNU General Public License v2.0
63 stars 7 forks source link

ramips: add support for Xiaomi Mi Router 3 Pro #1

Closed iscilyas closed 5 years ago

iscilyas commented 5 years ago

Hardware:

CPU: MediaTek MT7621 (2x800MHz) RAM: 512MB DDR3 FLASH: 256MB NAND WiFi: 2.4GHz 4x4 MT7615 b/g/n WiFI: 5GHz 4x4 MT7615 a/n/ac USB: 1x 3.0 ETH: 1x WAN 10/100/1000 3x LAN 10/100/1000 LED: Power/Status BTN: RESET UART: 115200 8n1

Installation:

Stock Xiaomi firmware has the MTD split into (among others)

Similar to the Xiaomi MIR3G, we keep stock Xiaomi firmware in kernel0 for ease of recovery, and install OpenWRT into kernel1 and after.

The installation file for OpenWRT is a *squashfs-factory.bin file that contains the kernel and a ubi partition. This is flashed as follows:

trick the bootloader into booting from 'kernel1'

nvram set flag_try_sys1_failed=1 nvram set flag_try_sys2_failed=0 nvram commit

write the first 4MB of factory.bin into kernel1 and

the remainder into rootfs0

The new kernel will rewrite the partition table.

dd if=factory.bin bs=1M count=4 | mtd write - kernel1 dd if=factory.bin bs=1M skip=4 | mtd write - rootfs0 reboot

Reverting to stock:

The part of stock firmware we've kept in kernel0 allows us to run stock recovery, which will re-flash stock firmware from a *.bin file on a USB.

For this we do the following:

fw_setenv flag_try_sys1_failed 0 fw_setenv flag_try_sys2_failed 1 reboot

After reboot the LED status light will blink red, at which point pressing the 'reset' button will cause stock firmware to be installed from USB.