From 498c15376bae109bfe130cc5581f83e4cc52c0f9 Mon Sep 17 00:00:00 2001 From: Mikhail Zhilkin Date: Wed, 4 May 2022 15:16:38 +0000 Subject: [PATCH] ramips: add support for MTS WG430223 MTS WG430223 is a wireless AC1300 (WiFi 5) router manufactured by Arcadyan company. It's very similar to Beeline Smartbox Flash (Arcadyan WG443223). Device specification -------------------- SoC Type: MediaTek MT7621AT RAM: 128 MiB Flash: 128 MiB (Winbond W29N01HV) Wireless 2.4 GHz (MT7615DN): b/g/n, 2x2 Wireless 5 GHz (MT7615DN): a/n/ac, 2x2 Ethernet: 3xGbE (WAN, LAN1, LAN2) USB ports: No Button: 1 (Reset/WPS) LEDs: 2 (Red, Green) Power: 12 VDC, 1 A Connector type: Barrel Bootloader: U-Boot (Ralink UBoot Version: 5.0.0.2) OEM: Arcadyan WG430223 Installation ------------ 1. Login to the router web interface (superadmin:serial number) 2. Navigate to Administration -> Miscellaneous -> Access control lists & enable telnet & enable "Remote control from any IP address" 3. Connect to the router using telnet (default admin:admin) 4. Place *factory.trx on any web server (192.168.1.2 in this example) 5. Connect to the router using telnet shell (no password required) 6. Save MAC adresses to U-Boot environment: uboot_env --set --name eth2macaddr --value $(ifconfig | grep eth2 | \ awk '{print $5}') uboot_env --set --name eth3macaddr --value $(ifconfig | grep eth3 | \ awk '{print $5}') uboot_env --set --name ra0macaddr --value $(ifconfig | grep ra0 | \ awk '{print $5}') uboot_env --set --name rax0macaddr --value $(ifconfig | grep rax0 | \ awk '{print $5}') 7. Ensure that MACs were saved correctly: uboot_env --get --name eth2macaddr uboot_env --get --name eth3macaddr uboot_env --get --name ra0macaddr uboot_env --get --name rax0macaddr 8. Download and write the OpenWrt images: cd /tmp wget http://192.168.1.2/factory.trx mtd_write erase /dev/mtd4 mtd_write write factory.trx /dev/mtd4 9. Set 1st boot partition and reboot: uboot_env --set --name bootpartition --value 0 Back to Stock ------------- 1. Run in the OpenWrt shell: fw_setenv bootpartition 1 reboot 2. Optional step. Upgrade the stock firmware with any version to overwrite the OpenWrt in Slot 1. MAC addresses ------------- +-----------+-------------------+----------------+ | Interface | MAC | Source | +-----------+-------------------+----------------+ | label | A4:xx:xx:51:xx:F4 | No MACs was | | LAN | A4:xx:xx:51:xx:F6 | found on Flash | | WAN | A4:xx:xx:51:xx:F4 | [1] | | WLAN_2g | A4:xx:xx:51:xx:F5 | | | WLAN_5g | A6:xx:xx:21:xx:F5 | | +-----------+-------------------+----------------+ [1]: a. Label wasb't found neither in factory nor in other places. b. MAC addresses are stored in encrypted partition "glbcfg". Encryption key hasn't known yet. To ensure the correct MACs in OpenWrt, a hack with saving of the MACs to u-boot-env during the installation was applied. c. Default Ralink ethernet MAC address (00:0C:43:28:80:A0) was found in "Factory" 0xfff0. It's the same for all MTS WG430223 devices. OEM firmware also uses this MAC when initialazes ethernet driver. In OpenWrt we use it only as internal GMAC (eth0), all other MACs are unique. Therefore, there is no any barriers to the operation of several MTS WG430223 devices even within the same broadcast domain. Stock firmware image format --------------------------- The same as Beeline Smartbox Flash but with another trx magic +--------------+---------------+----------------------------------------+ | Offset | | Description | +==============+===============+========================================+ | 0x0 | 31 52 48 53 | TRX magic "1RHS" | +--------------+---------------+----------------------------------------+ Signed-off-by: Mikhail Zhilkin --- package/boot/uboot-envtools/files/ramips | 1 + .../linux/ramips/dts/mt7621_mts_wg430223.dts | 8 +++++++ target/linux/ramips/image/mt7621.mk | 21 +++++++++++++++++++ .../mt7621/base-files/etc/board.d/02_network | 4 +++- .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 3 ++- .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 6 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 target/linux/ramips/dts/mt7621_mts_wg430223.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index d97c8128811630..eebc08d65d352a 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -60,6 +60,7 @@ linksys,ea7300-v2|\ linksys,ea7500-v2|\ linksys,ea8100-v1|\ linksys,ea8100-v2|\ +mts,wg430223|\ xiaomi,mi-router-3g|\ xiaomi,mi-router-3-pro|\ xiaomi,mi-router-4|\ diff --git a/target/linux/ramips/dts/mt7621_mts_wg430223.dts b/target/linux/ramips/dts/mt7621_mts_wg430223.dts new file mode 100644 index 00000000000000..9ddb1d8dc545a9 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_mts_wg430223.dts @@ -0,0 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621_arcadyan_wg4xx223.dtsi" + +/ { + compatible = "mts,wg430223", "mediatek,mt7621-soc"; + model = "MTS WG430223"; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index 6ea827b41c7cd4..68d054f9602970 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1189,6 +1189,27 @@ define Device/mtc_wr1201 endef TARGET_DEVICES += mtc_wr1201 +define Device/mts_wg430223 + $(Device/dsa-migration) + $(Device/uimage-lzma-loader) + DEVICE_VENDOR := MTS + DEVICE_MODEL := WG430223 + IMAGE_SIZE := 32768k + KERNEL_SIZE := 4352k + UBINIZE_OPTS := -E 5 + BLOCKSIZE := 128k + PAGESIZE := 2048 + KERNEL := kernel-bin | append-dtb | lzma | loader-kernel | \ + uImage none | arcadyan-trx 0x53485231 | pad-to $$(KERNEL_SIZE) + KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-kernel | \ + uImage none + IMAGES += factory.trx + IMAGE/factory.trx := append-kernel | append-ubi | check-size + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + DEVICE_PACKAGES := kmod-mt7615e kmod-mt7615-firmware uboot-envtools +endef +TARGET_DEVICES += mts_wg430223 + define Device/netgear_ex6150 $(Device/dsa-migration) DEVICE_VENDOR := NETGEAR diff --git a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network index a8d8b8eef2b099..0a139e01131919 100644 --- a/target/linux/ramips/mt7621/base-files/etc/board.d/02_network +++ b/target/linux/ramips/mt7621/base-files/etc/board.d/02_network @@ -46,6 +46,7 @@ ramips_setup_interfaces() jcg,q20|\ lenovo,newifi-d1|\ mikrotik,routerboard-m33g|\ + mts,wg430223|\ oraybox,x3a|\ renkforce,ws-wn530hp3-a|\ xiaomi,mi-router-3g|\ @@ -127,7 +128,8 @@ ramips_setup_macs() wan_mac=$(mtd_get_mac_ascii u-boot-env et1macaddr) label_mac=$(mtd_get_mac_binary factory 0x4) ;; - beeline,smartbox-flash) + beeline,smartbox-flash|\ + mts,wg430223) lan_mac=$(mtd_get_mac_ascii u-boot-env eth2macaddr) wan_mac=$(mtd_get_mac_ascii u-boot-env eth3macaddr) label_mac=$lan_mac diff --git a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac index 5b12416872b1c3..3390104e8088ef 100644 --- a/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +++ b/target/linux/ramips/mt7621/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac @@ -10,7 +10,8 @@ PHYNBR=${DEVPATH##*/phy} board=$(board_name) case "$board" in - beeline,smartbox-flash) + beeline,smartbox-flash|\ + mts,wg430223) hw_mac_addr_ra0="$(mtd_get_mac_ascii u-boot-env ra0macaddr)" hw_mac_addr_rax0="$(mtd_get_mac_ascii u-boot-env rax0macaddr)" [ "$PHYNBR" = "0" ] && echo -n $hw_mac_addr_ra0 > /sys${DEVPATH}/macaddress diff --git a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh index 407611a6a2097d..9d5e7576ecd8dd 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -70,6 +70,7 @@ platform_do_upgrade() { linksys,ea7500-v2|\ linksys,ea8100-v1|\ linksys,ea8100-v2|\ + mts,wg430223|\ netgear,r6220|\ netgear,r6260|\ netgear,r6350|\