aboutsummaryrefslogtreecommitdiffstats
path: root/target
diff options
context:
space:
mode:
authorRichard Huynh <voxlympha@gmail.com>2021-12-01 12:27:39 +1100
committerDaniel Golle <daniel@makrotopia.org>2022-03-20 18:33:39 +0000
commit9f9477b2751231d57cdd8c227149b88c93491d93 (patch)
treedec5984c129bdc5e6c398a48900a6eeee6aa42f9 /target
parent4177de10df384e0106191e5b204b0aa11431fe77 (diff)
downloadupstream-9f9477b2751231d57cdd8c227149b88c93491d93.tar.gz
upstream-9f9477b2751231d57cdd8c227149b88c93491d93.tar.bz2
upstream-9f9477b2751231d57cdd8c227149b88c93491d93.zip
mediatek: Add support for Xiaomi Redmi Router AX6S
Also known as the "Xiaomi Router AX3200" in western markets, but only the AX6S is widely installation-capable at this time. SoC: MediaTek MT7622B RAM: DDR3 256 MiB (ESMT M15T2G16128A) Flash: SPI-NAND 128 MiB (ESMT F50L1G41LB or Gigadevice GD5F1GQ5xExxG) WLAN: 2.4/5 GHz 4T4R 2.4 GHz: MediaTek MT7622B 5 GHz: MediaTek MT7915E Ethernet: 4x 10/100/1000 Mbps Switch: MediaTek MT7531B LEDs/Keys: 2/2 (Internet + System LED, Mesh button + Reset pin) UART: Marked J1 on board VCC RX GND TX, beginning from "1". 3.3v, 115200n8 Power: 12 VDC, 1.5 A Notes: U-Boot passes through the ethaddr from uboot-env partition, but also has been known to reset it to a generic mac address hardcoded in the bootloader. However, bdata is also populated with the ethernet mac addresses, but is also typically never written to. Thus this is used instead. Installation: 1. Flash stock Xiaomi "closed beta" image labelled 'miwifi_rb03_firmware_stable_1.2.7_closedbeta.bin'. (MD5: 5eedf1632ac97bb5a6bb072c08603ed7) 2. Calculate telnet password from serial number and login 3. Execute commands to prepare device nvram set ssh_en=1 nvram set uart_en=1 nvram set boot_wait=on nvram set flag_boot_success=1 nvram set flag_try_sys1_failed=0 nvram set flag_try_sys2_failed=0 nvram commit 4. Download and flash image On computer: python -m http.server On router: cd /tmp wget http://<IP>:8000/factory.bin mtd -r write factory.bin firmware Device should reboot at this point. Reverting to stock: Stock Xiaomi recovery tftp that accepts their signed images, with default ips of 192.168.31.1 + 192.168.31.100. Stock image should be renamed to tftp server ip in hex (Eg. C0A81F64.img) Triggered by holding reset pin on powerup. A simple implementation of this would be via dnsmasq's dhcp-boot option or using the vendor's (Windows only) recovery tool available on their website. Signed-off-by: Richard Huynh <voxlympha@gmail.com>
Diffstat (limited to 'target')
-rw-r--r--target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts355
-rw-r--r--target/linux/mediatek/image/mt7622.mk20
-rw-r--r--target/linux/mediatek/mt7622/base-files/etc/board.d/01_leds3
-rw-r--r--target/linux/mediatek/mt7622/base-files/etc/board.d/02_network11
-rwxr-xr-xtarget/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh6
5 files changed, 393 insertions, 2 deletions
diff --git a/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts b/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts
new file mode 100644
index 0000000000..933d2c9275
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7622-xiaomi-redmi-router-ax6s.dts
@@ -0,0 +1,355 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/dts-v1/;
+
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+#include "mt7622.dtsi"
+#include "mt6380.dtsi"
+
+/ {
+ model = "Xiaomi Redmi Router AX6S";
+ compatible = "xiaomi,redmi-router-ax6s", "mediatek,mt7622";
+
+ aliases {
+ serial0 = &uart0;
+ led-boot = &led_power_amber;
+ led-failsafe = &led_power_amber;
+ led-running = &led_power_blue;
+ led-upgrade = &led_power_blue;
+ };
+
+ chosen {
+ stdout-path = "serial0:115200n8";
+ bootargs = "earlycon=uart8250,mmio32,0x11002000 console=ttyS0,115200n8 swiotlb=512";
+ };
+
+ memory {
+ reg = <0 0x40000000 0 0x8000000>;
+ };
+
+ leds {
+ compatible = "gpio-leds";
+
+ led_power_blue: power_blue {
+ label = "blue:power";
+ gpios = <&pio 18 GPIO_ACTIVE_LOW>;
+ };
+
+ led_power_amber: power_amber {
+ label = "amber:power";
+ gpios = <&pio 17 GPIO_ACTIVE_LOW>;
+ };
+
+ led_net_blue: net_blue {
+ label = "blue:net";
+ gpios = <&pio 01 GPIO_ACTIVE_LOW>;
+ };
+
+ led_net_amber: net_amber {
+ label = "amber:net";
+ gpios = <&pio 16 GPIO_ACTIVE_LOW>;
+ };
+
+ };
+
+ keys {
+ compatible = "gpio-keys";
+
+ reset {
+ label = "reset";
+ gpios = <&pio 0 GPIO_ACTIVE_LOW>;
+ linux,code = <KEY_RESTART>;
+ };
+
+ mesh {
+ label = "mesh";
+ gpios = <&pio 102 GPIO_ACTIVE_LOW>;
+ linux,code = <BTN_9>;
+ linux,input-type = <EV_SW>;
+ };
+ };
+};
+
+&cpu0 {
+ proc-supply = <&mt6380_vcpu_reg>;
+ sram-supply = <&mt6380_vm_reg>;
+};
+
+&cpu1 {
+ proc-supply = <&mt6380_vcpu_reg>;
+ sram-supply = <&mt6380_vm_reg>;
+};
+
+&pio {
+ eth_pins: eth-pins {
+ mux {
+ function = "eth";
+ groups = "mdc_mdio", "rgmii_via_gmac2";
+ };
+ };
+
+ pcie0_pins: pcie0-pins {
+ mux {
+ function = "pcie";
+ groups = "pcie0_pad_perst",
+ "pcie0_1_waken",
+ "pcie0_1_clkreq";
+ };
+ };
+
+ pmic_bus_pins: pmic-bus-pins {
+ mux {
+ function = "pmic";
+ groups = "pmic_bus";
+ };
+ };
+
+ pwm7_pins: pwm1-2-pins {
+ mux {
+ function = "pwm";
+ groups = "pwm_ch7_2";
+ };
+ };
+
+ /* Serial NAND is shared pin with SPI-NOR */
+ serial_nand_pins: serial-nand-pins {
+ mux {
+ function = "flash";
+ groups = "snfi";
+ };
+ };
+
+ uart0_pins: uart0-pins {
+ mux {
+ function = "uart";
+ groups = "uart0_0_tx_rx" ;
+ };
+ };
+
+ watchdog_pins: watchdog-pins {
+ mux {
+ function = "watchdog";
+ groups = "watchdog";
+ };
+ };
+};
+
+&eth {
+ pinctrl-names = "default";
+ pinctrl-0 = <&eth_pins>;
+ status = "okay";
+
+ gmac0: mac@0 {
+ compatible = "mediatek,eth-mac";
+ reg = <0>;
+
+ phy-connection-type = "2500base-x";
+
+ nvmem-cells = <&macaddr_factory_4>;
+ nvmem-cell-names = "mac-address";
+ mac-address-increment = <(-1)>;
+
+ fixed-link {
+ speed = <2500>;
+ full-duplex;
+ pause;
+ };
+ };
+
+ mdio-bus {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ switch@0 {
+ compatible = "mediatek,mt7531";
+ reg = <0>;
+ interrupt-controller;
+ #interrupt-cells = <1>;
+ interrupt-parent = <&pio>;
+ interrupts = <53 IRQ_TYPE_LEVEL_HIGH>;
+ reset-gpios = <&pio 54 GPIO_ACTIVE_HIGH>;
+
+ ports {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ wan: port@1 {
+ reg = <1>;
+ label = "wan";
+ };
+
+ port@2 {
+ reg = <2>;
+ label = "lan1";
+ };
+
+ port@3 {
+ reg = <3>;
+ label = "lan2";
+ };
+
+ port@4 {
+ reg = <4>;
+ label = "lan3";
+ };
+
+ port@6 {
+ reg = <6>;
+ label = "cpu";
+ ethernet = <&gmac0>;
+ phy-mode = "2500base-x";
+
+ fixed-link {
+ speed = <2500>;
+ full-duplex;
+ pause;
+ };
+ };
+ };
+ };
+ };
+};
+
+&snand {
+ pinctrl-names = "default";
+ pinctrl-0 = <&serial_nand_pins>;
+ status = "okay";
+
+ mediatek,bmt-v2;
+ mediatek,bmt-table-size = <0x1000>;
+ mediatek,bmt-remap-range = <0x0 0x6c0000>;
+
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ partition@0 {
+ label = "Preloader";
+ reg = <0x0 0x80000>;
+ read-only;
+ };
+
+ partition@80000 {
+ label = "ATF";
+ reg = <0x80000 0x40000>;
+ read-only;
+ };
+
+ partition@c0000 {
+ label = "u-boot";
+ reg = <0xc0000 0x80000>;
+ read-only;
+ };
+
+ partition@140000 {
+ label = "u-boot-env";
+ reg = <0x140000 0x40000>;
+ };
+
+ partition@180000 {
+ label = "bdata";
+ reg = <0x180000 0x40000>;
+ };
+
+ factory: partition@1c0000 {
+ label = "factory";
+ reg = <0x1c0000 0x80000>;
+ read-only;
+
+ compatible = "nvmem-cells";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ macaddr_factory_4: macaddr@4 {
+ reg = <0x4 0x6>;
+ };
+ };
+
+ partition@240000 {
+ label = "crash";
+ reg = <0x240000 0x40000>;
+ read-only;
+ };
+
+ partition@280000 {
+ label = "crash_log";
+ reg = <0x280000 0x40000>;
+ read-only;
+ };
+
+ /* Shrunk and renamed from "firmware"
+ * as to not break luci size checks
+ */
+ partition@2c0000 {
+ label = "kernel";
+ compatible = "denx,fit";
+ reg = <0x2c0000 0x400000>;
+ };
+
+
+ /* ubi partition is the result of squashing
+ * consecutive stock partitions:
+ * - firmware (partially)
+ * - firmware1
+ * - overlay
+ * - obr
+ */
+ partition@6c0000 {
+ label = "ubi";
+ reg = <0x6C0000 0x6f00000>;
+ };
+ };
+};
+
+&pcie0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pcie0_pins>;
+ status = "okay";
+};
+
+&slot0 {
+ status = "okay";
+
+ wifi@0,0 {
+ compatible = "mediatek,mt76";
+ reg = <0x0000 0 0 0 0>;
+ mediatek,mtd-eeprom = <&factory 0x5000>;
+ ieee80211-freq-limit = <5000000 6000000>;
+ };
+};
+
+&pwm {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pwm7_pins>;
+ status = "okay";
+};
+
+&pwrap {
+ pinctrl-names = "default";
+ pinctrl-0 = <&pmic_bus_pins>;
+ status = "okay";
+};
+
+&rtc {
+ status = "disabled";
+};
+
+&uart0 {
+ pinctrl-names = "default";
+ pinctrl-0 = <&uart0_pins>;
+ status = "okay";
+};
+
+&watchdog {
+ pinctrl-names = "default";
+ pinctrl-0 = <&watchdog_pins>;
+ status = "okay";
+};
+
+&wmac {
+ status = "okay";
+
+ mediatek,mtd-eeprom = <&factory 0x0>;
+};
diff --git a/target/linux/mediatek/image/mt7622.mk b/target/linux/mediatek/image/mt7622.mk
index daec843b49..8e0126f576 100644
--- a/target/linux/mediatek/image/mt7622.mk
+++ b/target/linux/mediatek/image/mt7622.mk
@@ -249,3 +249,23 @@ define Device/ubnt_unifi-6-lr-ubootmod
ARTIFACT/bl31-uboot.fip := bl31-uboot ubnt_unifi-6-lr
endef
TARGET_DEVICES += ubnt_unifi-6-lr-ubootmod
+
+define Device/xiaomi_redmi-router-ax6s
+ DEVICE_VENDOR := Xiaomi
+ DEVICE_MODEL := Redmi Router AX6S
+ DEVICE_ALT0_VENDOR := Xiaomi
+ DEVICE_ALT0_MODEL := Router AX3200
+ DEVICE_DTS := mt7622-xiaomi-redmi-router-ax6s
+ DEVICE_DTS_DIR := ../dts
+ BOARD_NAME := xiaomi,redmi-router-ax6s
+ DEVICE_PACKAGES := kmod-mt7915e
+ UBINIZE_OPTS := -E 5
+ IMAGES += factory.bin
+ BLOCKSIZE := 128k
+ PAGESIZE := 2048
+ KERNEL_SIZE := 4096k
+ KERNEL_INITRAMFS_SUFFIX := -recovery.itb
+ IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi
+ IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+endef
+TARGET_DEVICES += xiaomi_redmi-router-ax6s
diff --git a/target/linux/mediatek/mt7622/base-files/etc/board.d/01_leds b/target/linux/mediatek/mt7622/base-files/etc/board.d/01_leds
index 65a81df8da..5c32918d35 100644
--- a/target/linux/mediatek/mt7622/base-files/etc/board.d/01_leds
+++ b/target/linux/mediatek/mt7622/base-files/etc/board.d/01_leds
@@ -10,6 +10,9 @@ linksys,e8450|\
linksys,e8450-ubi)
ucidef_set_led_netdev "wan" "WAN" "inet:blue" "wan"
;;
+xiaomi,redmi-router-ax6s)
+ ucidef_set_led_netdev "wan" "WAN" "blue:net" "wan"
+ ;;
esac
board_config_flush
diff --git a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
index 4649d0dc57..c55fcbee2e 100644
--- a/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/mt7622/base-files/etc/board.d/02_network
@@ -24,6 +24,9 @@ mediatek_setup_interfaces()
ubnt,unifi-6-lr-ubootmod)
ucidef_set_interface_lan "eth0"
;;
+ xiaomi,redmi-router-ax6s)
+ ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" wan
+ ;;
*)
ucidef_add_switch "switch0" \
"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "6u@eth0" "5u@eth1"
@@ -35,14 +38,22 @@ mediatek_setup_macs()
{
local board="$1"
local lan_mac=""
+ local wan_mac=""
+ local label_mac=""
case $board in
ruijie,rg-ew3200gx-pro)
lan_mac=$(macaddr_add $(get_mac_label) 1)
;;
+ xiaomi,redmi-router-ax6s)
+ wan_mac=$(mtd_get_mac_ascii bdata ethaddr_wan)
+ label_mac=$wan_mac
+ ;;
esac
[ -n "$lan_mac" ] && ucidef_set_interface_macaddr "lan" $lan_mac
+ [ -n "$wan_mac" ] && ucidef_set_interface_macaddr "wan" $wan_mac
+ [ -n "$label_mac" ] && ucidef_set_label_macaddr $label_mac
}
board_config_update
diff --git a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
index fbca6ef0f7..f54665dfa1 100755
--- a/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh
@@ -45,7 +45,8 @@ platform_do_upgrade() {
default_do_upgrade "$1"
;;
mediatek,mt7622-rfb1-ubi|\
- totolink,a8000ru)
+ totolink,a8000ru|\
+ xiaomi,redmi-router-ax6s)
nand_do_upgrade "$1"
;;
*)
@@ -67,7 +68,8 @@ platform_check_image() {
buffalo_check_image "$board" "$magic" "$1" || return 1
;;
mediatek,mt7622-rfb1-ubi|\
- totolink,a8000ru)
+ totolink,a8000ru|\
+ xiaomi,redmi-router-ax6s)
nand_do_platform_check "$board" "$1"
;;
*)