123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- From aa2cc7b9d5124216f0ea377f9ffe28e494da20c6 Mon Sep 17 00:00:00 2001
- From: Chen Minqiang <[email protected]>
- Date: Sat, 18 Nov 2017 21:35:39 +0800
- Subject: [PATCH] ramips: add xiaomi_miwifi-r3 support
- Specification:
- - CPU: 580 MHz
- - Flash size: 128 MiB NAND
- - RAM size: 128 MiB DDR2
- - Wireless No1: SoC-integrated: MT7620A 2x2 MIMO 802.11b/g/n (2.4 GHz)
- - Wireless No2: On-board chip: MT7612E 2x2 MIMO 802.11a/n/ac (5 GHz)
- - Switch: MT7620 built-in 10/100 switch w/ vlan support
- - USB: 2.0 x1
- Flash instructions:
- 1. access ssh via https://wiki.openwrt.org/toh/xiaomi/mir3
- 2. in ssh:
- nvram set flag_last_success=1
- nvram set boot_wait=on
- nvram set uart_en=1
- nvram commit
- mtd write lede-ramips-mt7620-miwifi-r3-squashfs-kernel1.bin kernel1
- mtd write lede-ramips-mt7620-miwifi-r3-squashfs-rootfs0.bin rootfs0
- reboot
- If you want to revert back to stock fw while on LEDE:
- insert usb stick (FAT/FAT32) with stock fw renamed to miwifi.bin
- fw_setenv flag_last_success 0
- power off the device
- hold the reset button and power on the device, keep holding the reset button until yellow led starts blinking.
- Signed-off-by: Chen Minqiang <[email protected]>
- ---
- package/boot/uboot-envtools/files/ramips | 1 +
- .../ramips/dts/mt7620a_xiaomi_miwifi-r3.dts | 187 ++++++++++++++++++
- target/linux/ramips/image/mt7620.mk | 17 ++
- .../mt7620/base-files/etc/board.d/02_network | 8 +
- .../mt7620/base-files/lib/upgrade/platform.sh | 7 +
- 5 files changed, 220 insertions(+)
- create mode 100644 target/linux/ramips/dts/mt7620a_xiaomi_miwifi-r3.dts
- diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips
- index 05ca7ffd12c8..6afc4470f7a7 100644
- --- a/package/boot/uboot-envtools/files/ramips
- +++ b/package/boot/uboot-envtools/files/ramips
- @@ -79,6 +79,7 @@ xiaomi,mi-router-3g|\
- xiaomi,mi-router-3-pro|\
- xiaomi,mi-router-4|\
- xiaomi,mi-router-ac2100|\
- +xiaomi,miwifi-r3|\
- xiaomi,redmi-router-ac2100)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000"
- ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x4000" "0x20000"
- diff --git a/target/linux/ramips/dts/mt7620a_xiaomi_miwifi-r3.dts b/target/linux/ramips/dts/mt7620a_xiaomi_miwifi-r3.dts
- new file mode 100644
- index 000000000000..301b6e3a02e6
- --- /dev/null
- +++ b/target/linux/ramips/dts/mt7620a_xiaomi_miwifi-r3.dts
- @@ -0,0 +1,187 @@
- +/dts-v1/;
- +
- +#include "mt7620a.dtsi"
- +
- +#include <dt-bindings/gpio/gpio.h>
- +#include <dt-bindings/input/input.h>
- +
- +/ {
- + compatible = "xiaomi,miwifi-r3", "ralink,mt7620a-soc";
- + model = "Xiaomi Mi Router R3";
- +
- + aliases {
- + led-status = &led_status_blue;
- + };
- +
- + chosen {
- + bootargs = "console=ttyS0,115200";
- + };
- +
- + keys {
- + compatible = "gpio-keys";
- +
- + reset {
- + label = "reset";
- + gpios = <&gpio1 6 GPIO_ACTIVE_HIGH>;
- + linux,code = <KEY_RESTART>;
- + };
- + };
- +
- + leds {
- + compatible = "gpio-leds";
- +
- + led_status_blue: blue {
- + label = "blue:status";
- + gpios = <&gpio1 0 GPIO_ACTIVE_LOW>;
- + default-state = "on";
- + };
- +
- + yellow {
- + label = "yellow:status";
- + gpios = <&gpio1 2 GPIO_ACTIVE_LOW>;
- + };
- +
- + red {
- + label = "red:status";
- + gpios = <&gpio1 5 GPIO_ACTIVE_LOW>;
- + };
- + };
- +
- + nand {
- + status = "okay";
- + #address-cells = <1>;
- + #size-cells = <1>;
- + compatible = "mtk,mt7620-nand";
- +
- + partitions {
- + compatible = "fixed-partitions";
- + #address-cells = <1>;
- + #size-cells = <1>;
- +
- + partition@0 {
- + label = "Bootloader";
- + reg = <0x0 0x40000>;
- + read-only;
- + };
- +
- + partition@40000 {
- + label = "Config";
- + reg = <0x40000 0x40000>;
- + };
- +
- + partition@80000 {
- + label = "Bdata";
- + reg = <0x80000 0x40000>;
- + read-only;
- + };
- +
- + factory: partition@0xc0000 {
- + label = "factory";
- + reg = <0xc0000 0x40000>;
- + read-only;
- + };
- +
- + partition@100000 {
- + label = "crash";
- + reg = <0x100000 0x40000>;
- + read-only;
- + };
- +
- + partition@140000 {
- + label = "crash_syslog";
- + reg = <0x140000 0x40000>;
- + read-only;
- + };
- +
- + partition@180000 {
- + label = "reserved0";
- + reg = <0x180000 0x80000>;
- + read-only;
- + };
- +
- + partition@200000 {
- + label = "kernel_stock";
- + reg = <0x200000 0x400000>;
- + };
- +
- + partition@600000 {
- + label = "kernel";
- + reg = <0x600000 0x400000>;
- + };
- +
- + /* ubi partition is the result of squashing
- + * next consequent stock partitions:
- + * - rootfs0 (rootfs partition for stock kernel0),
- + * - rootfs1 (rootfs partition for stock failsafe kernel1),
- + * - overlay (used as ubi overlay in stock fw)
- + * resulting 117,5MiB space for packages.
- + */
- + partition@a00000 {
- + label = "ubi";
- + reg = <0xa00000 0x7600000>;
- + };
- + };
- + };
- +};
- +
- +&gpio1 {
- + status = "okay";
- +};
- +
- +&ehci {
- + status = "okay";
- +};
- +
- +&ohci {
- + status = "okay";
- +};
- +
- +ðernet {
- + pinctrl-names = "default";
- + pinctrl-0 = <&ephy_pins>;
- + mtd-mac-address = <&factory 0x28>;
- + nvmem-cells = <&macaddr_factory_28>;
- + nvmem-cell-names = "mac-address";
- + mediatek,portmap = "llllw";
- +};
- +
- +&wmac {
- + ralink,mtd-eeprom = <&factory 0>;
- +};
- +
- +&pcie {
- + status = "okay";
- +};
- +
- +&pcie0 {
- + wifi@0,0 {
- + compatible = "pci14c3,7662";
- + reg = <0x0000 0 0 0 0>;
- + mediatek,mtd-eeprom = <&factory 0x8000>;
- + ieee80211-freq-limit = <5000000 6000000>;
- + };
- +};
- +
- +&pinctrl {
- + state_default: pinctrl0 {
- + gpio {
- + groups = "rgmii1";
- + function = "gpio";
- + };
- +
- + pa {
- + groups = "pa";
- + function = "pa";
- + };
- + };
- +};
- +
- +&factory {
- + compatible = "nvmem-cells";
- + #address-cells = <1>;
- + #size-cells = <1>;
- +
- + macaddr_factory_28: macaddr@28 {
- + reg = <0x28 0x6>;
- + };
- +};
- diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk
- index a9dea1db57f9..ebf4cfc4117c 100644
- --- a/target/linux/ramips/image/mt7620.mk
- +++ b/target/linux/ramips/image/mt7620.mk
- @@ -1248,6 +1248,23 @@ define Device/xiaomi_miwifi-mini
- endef
- TARGET_DEVICES += xiaomi_miwifi-mini
-
- +define Device/xiaomi_miwifi-r3
- + SOC := mt7620a
- + BLOCKSIZE := 128k
- + PAGESIZE := 2048
- + KERNEL_SIZE := 4096k
- + IMAGE_SIZE := 32768k
- + UBINIZE_OPTS := -E 5
- + IMAGES += kernel1.bin rootfs0.bin
- + IMAGE/kernel1.bin := append-kernel | check-size $$$$(KERNEL_SIZE)
- + IMAGE/rootfs0.bin := append-ubi | check-size $$$$(IMAGE_SIZE)
- + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
- + DEVICE_VENDOR := Xiaomi
- + DEVICE_MODEL := Mi Router R3
- + DEVICE_PACKAGES := kmod-mt76x2 kmod-usb2 kmod-usb-ohci uboot-envtools
- +endef
- +TARGET_DEVICES += xiaomi_miwifi-r3
- +
- define Device/youku_yk-l1
- SOC := mt7620a
- IMAGE_SIZE := 32448k
- diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
- index f7bc41669f80..e252b6e04611 100644
- --- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
- +++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network
- @@ -240,6 +240,10 @@ ramips_setup_interfaces()
- ucidef_add_switch "switch0" \
- "0:lan" "1:lan" "4:wan" "6@eth0"
- ;;
- + xiaomi,miwifi-r3)
- + ucidef_add_switch "switch0" \
- + "1:lan" "4:lan" "0:wan" "6@eth0"
- + ;;
- zbtlink,zbt-we1026-5g-16m)
- ucidef_add_switch "switch0" \
- "0:lan" "6t@eth0"
- @@ -384,6 +388,10 @@ ramips_setup_macs()
- wan_mac=$(mtd_get_mac_binary factory 0x2e)
- label_mac=$(mtd_get_mac_binary factory 0x8004)
- ;;
- + xiaomi,miwifi-r3)
- + wan_mac=$(mtd_get_mac_binary factory 0x28)
- + lan_mac=$(macaddr_setbit_la "$wan_mac")
- + ;;
- zbtlink,zbt-we1026-5g-16m)
- label_mac=$(mtd_get_mac_binary factory 0x4)
- ;;
- diff --git a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh
- index 9f71dc918e50..5519312289fa 100755
- --- a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh
- +++ b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh
- @@ -30,6 +30,11 @@ platform_do_upgrade() {
- }
- default_do_upgrade "$1"
- ;;
- + xiaomi,miwifi-r3)
- + # this make it compatible with breed
- + dd if=/dev/mtd0 bs=64 count=1 2>/dev/null | grep -qi breed && CI_KERNPART_EXT="kernel_stock"
- + nand_do_upgrade "$1"
- + ;;
- *)
- default_do_upgrade "$1"
- ;;
|