[openwrt/openwrt] ramips: add support for Xiaomi Mi Router 4C
LEDE Commits
lede-commits at lists.infradead.org
Wed Nov 25 13:34:29 EST 2020
adrian pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/4287f739894ba2f95aca107e785b41a053c21315
commit 4287f739894ba2f95aca107e785b41a053c21315
Author: Ataberk Özen <ataberkozen123 at gmail.com>
AuthorDate: Wed Aug 19 21:43:54 2020 +0300
ramips: add support for Xiaomi Mi Router 4C
This commit adds support for Xiaomi's Mi Router 4C device.
Specifications:
- CPU: MediaTek MT7628AN (580MHz)
- Flash: 16MB
- RAM: 64MB DDR2
- 2.4 GHz: IEEE 802.11b/g/n with Integrated LNA and PA
- Antennas: 4x external single band antennas
- WAN: 1x 10/100M
- LAN: 2x 10/100M
- LEDs: 2x yellow/blue. Programmable (labelled as power on case)
- Non-programmable (shows WAN activity)
- Button: Reset
How to install:
1- Use OpenWRTInvasion to gain telnet and ftp access.
2- Push openwrt firmware to /tmp/ using ftp.
3- Connect to router using telnet. (IP: 192.168.31.1 -
Username: root - No password)
4- Use command "mtd -r write /tmp/firmware.bin OS1" to flash into
the router..
5- It takes around 2 minutes. After that router will restart itself
to OpenWrt.
Signed-off-by: Ataberk Özen <ataberkozen123 at gmail.com>
[wrap commit message, bump PKG_RELEASE for uboot-envtools, remove
dts-v1 from DTS, fix LED labels]
Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
package/boot/uboot-envtools/Makefile | 2 +-
package/boot/uboot-envtools/files/ramips | 1 +
.../ramips/dts/mt7628an_xiaomi_mi-router-4c.dts | 133 +++++++++++++++++++++
target/linux/ramips/image/mt76x8.mk | 8 ++
.../mt76x8/base-files/etc/board.d/02_network | 5 +
.../ramips/mt76x8/base-files/etc/init.d/bootcount | 1 +
6 files changed, 149 insertions(+), 1 deletion(-)
diff --git a/package/boot/uboot-envtools/Makefile b/package/boot/uboot-envtools/Makefile
index 7ab3619a85..398f37de12 100644
--- a/package/boot/uboot-envtools/Makefile
+++ b/package/boot/uboot-envtools/Makefile
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=uboot-envtools
PKG_DISTNAME:=u-boot
PKG_VERSION:=2020.04
-PKG_RELEASE:=7
+PKG_RELEASE:=8
PKG_SOURCE:=$(PKG_DISTNAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:= \
diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips
index 3ef345d065..a2753eed7a 100644
--- a/package/boot/uboot-envtools/files/ramips
+++ b/package/boot/uboot-envtools/files/ramips
@@ -31,6 +31,7 @@ mediatek,linkit-smart-7688|\
samknows,whitebox-v8|\
xiaomi,mir3g-v2|\
xiaomi,mi-router-4a-gigabit|\
+xiaomi,mi-router-4c|\
xiaomi,miwifi-nano|\
zbtlink,zbt-wg2626)
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
diff --git a/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts
new file mode 100644
index 0000000000..a6445c8717
--- /dev/null
+++ b/target/linux/ramips/dts/mt7628an_xiaomi_mi-router-4c.dts
@@ -0,0 +1,133 @@
+//SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+#include "mt7628an.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+ compatible = "xiaomi,mi-router-4c", "mediatek,mt7628an-soc";
+ model = "Xiaomi Mi Router 4C";
+
+ aliases {
+ led-boot = &led_power_yellow;
+ led-failsafe = &led_power_yellow;
+ led-running = &led_power_blue;
+ led-upgrade = &led_power_yellow;
+ label-mac-device = ðernet;
+ };
+
+ chosen {
+ bootargs = "console=ttyS0,115200";
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ led_power_blue: power_blue {
+ label = "blue:power";
+ gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
+ };
+
+ led_power_yellow: power_yellow {
+ label = "yellow:power";
+ gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
+ };
+ };
+
+ keys {
+ compatible = "gpio-keys";
+
+ reset {
+ label = "reset";
+ gpios = <&gpio 38 GPIO_ACTIVE_LOW>;
+ linux,code = <KEY_RESTART>;
+ };
+ };
+};
+
+&state_default {
+ gpio {
+ groups = "gpio", "wdt", "wled_an";
+ function = "gpio";
+ };
+};
+
+&ehci {
+ status = "disabled";
+};
+
+&ohci {
+ status = "disabled";
+};
+
+&esw {
+ mediatek,portmap = <0x3d>;
+ mediatek,portdisable = <0x29>;
+};
+
+&wmac {
+ status = "okay";
+};
+
+ðernet {
+ mtd-mac-address = <&factory 0x28>;
+};
+
+&spi0 {
+ status = "okay";
+
+ flash at 0 {
+ compatible = "jedec,spi-nor";
+ reg = <0>;
+ spi-max-frequency = <40000000>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition at 0 {
+ label = "bootloader";
+ reg = <0x0 0x20000>;
+ read-only;
+ };
+
+ partition at 20000 {
+ label = "config";
+ reg = <0x20000 0x10000>;
+ read-only;
+ };
+
+ factory: partition at 30000 {
+ label = "factory";
+ reg = <0x30000 0x10000>;
+ read-only;
+ };
+
+ partition at 40000 {
+ label = "crash";
+ reg = <0x40000 0x10000>;
+ read-only;
+ };
+
+ partition at 50000 {
+ label = "cfg_bak";
+ reg = <0x50000 0x10000>;
+ read-only;
+ };
+
+ partition at 60000 {
+ label = "overlay";
+ reg = <0x60000 0x100000>;
+ read-only;
+ };
+
+ partition at 160000 {
+ label = "firmware";
+ reg = <0x160000 0xea0000>;
+ compatible = "denx,uimage";
+ };
+ };
+ };
+};
diff --git a/target/linux/ramips/image/mt76x8.mk b/target/linux/ramips/image/mt76x8.mk
index 72539f7a14..edd42a4dd5 100644
--- a/target/linux/ramips/image/mt76x8.mk
+++ b/target/linux/ramips/image/mt76x8.mk
@@ -752,6 +752,14 @@ define Device/xiaomi_mir4a-100m
endef
TARGET_DEVICES += xiaomi_mir4a-100m
+define Device/xiaomi_mi-router-4c
+ IMAGE_SIZE := 14976k
+ DEVICE_VENDOR := Xiaomi
+ DEVICE_MODEL := Mi Router 4C
+ DEVICE_PACKAGES := uboot-envtools
+endef
+TARGET_DEVICES += xiaomi_mi-router-4c
+
define Device/xiaomi_miwifi-nano
IMAGE_SIZE := 16064k
DEVICE_VENDOR := Xiaomi
diff --git a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
index f4e3fcacb5..6f0078c70a 100755
--- a/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
+++ b/target/linux/ramips/mt76x8/base-files/etc/board.d/02_network
@@ -137,6 +137,10 @@ ramips_setup_interfaces()
ucidef_add_switch "switch0" \
"4:lan:1" "2:lan:2" "0:wan" "6 at eth0"
;;
+ xiaomi,mi-router-4c)
+ ucidef_add_switch "switch0" \
+ "4:lan:1" "2:lan:2" "1:wan" "6 at eth0"
+ ;;
xiaomi,miwifi-nano)
ucidef_add_switch "switch0" \
"0:lan:2" "2:lan:1" "4:wan" "6 at eth0"
@@ -234,6 +238,7 @@ ramips_setup_macs()
label_mac=$(mtd_get_mac_binary factory 0x4)
wan_mac=$(mtd_get_mac_binary factory 0x28)
;;
+ xiaomi,mi-router-4c|\
xiaomi,mir4a-100m)
wan_mac=$(mtd_get_mac_binary factory 0x4)
;;
diff --git a/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount b/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount
index 3c21433cc5..23f1e71b41 100755
--- a/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount
+++ b/target/linux/ramips/mt76x8/base-files/etc/init.d/bootcount
@@ -8,6 +8,7 @@ boot() {
[ -n "$(fw_printenv bootcount bootchanged 2>/dev/null)" ] &&\
echo -e "bootcount\nbootchanged\n" | /usr/sbin/fw_setenv -s -
;;
+ xiaomi,mi-router-4c|\
xiaomi,miwifi-nano)
fw_setenv flag_boot_success 1
;;
More information about the lede-commits
mailing list