From 5cc1918a7a0bed42eaf8a26afff6091336c62af5 Mon Sep 17 00:00:00 2001 From: David Bauer Date: Thu, 28 Dec 2023 23:16:02 +0100 Subject: [PATCH 1/7] dropbear: increase default receive window size Increasing the receive window size improves throughout on higher-latency links such as WAN connections. The current default of 24KB caps out at around 500 KB/s. Increasing the receive buffer to 256KB increases the throughput to at least 11 MB/s. Signed-off-by: David Bauer (cherry picked from commit f95eecfb21ff08662e022accd30e8254028ff63b) --- package/network/services/dropbear/files/dropbear.init | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package/network/services/dropbear/files/dropbear.init b/package/network/services/dropbear/files/dropbear.init index b82e967cbc..a40b5f7bae 100755 --- a/package/network/services/dropbear/files/dropbear.init +++ b/package/network/services/dropbear/files/dropbear.init @@ -155,6 +155,12 @@ dropbear_instance() PIDCOUNT="$(( ${PIDCOUNT} + 1))" local pid_file="/var/run/${NAME}.${PIDCOUNT}.pid" + # Increase default receive window size to increase + # throughput on high latency links + if [ "${RecvWindowSize}" -eq "0" ]; then + RecvWindowSize="262144" + fi + procd_open_instance procd_set_param command "$PROG" -F -P "$pid_file" [ "${PasswordAuth}" -eq 0 ] && procd_append_param command -s From b0fc8b47e0d808c57fcb82ef6eb965668c640c50 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Thu, 4 Jan 2024 13:46:34 +0100 Subject: [PATCH 2/7] netifd: update to Git openwrt-23.05 (2024-01-04) c739dee0a37b system-linux: refresh MAC address on DSA port conduit change 8587c074f1eb interface-ip: fix IPv4 route target masking 33d6c261aacb system-linux: fix bogus debug error messages on adding bridge members 0832e8f04778 wireless: add bridge_isolate option 5ca7a9058e98 bridge: fix reload on bridge vlan changes be4ffb3b78bc bridge: rework config change pvid handling 923c4370a1d4 system-linux: set master early on apply settings b9442415c785 system-linux: skip refreshing MAC on master change if custom MAC b635a09cdadf system-linux: set pending to 0 on ifindex found or error for if_get_master 2bbe49c36224 device: Log error message if device initialization failed 2703f740a23e Revert "system-linux: set pending to 0 on ifindex found or error for if_get_master" 9cb0cb418303 system-linux: fix race condition in netlink socket error handing c18cc79d5000 device: restore cleared flags on device down Signed-off-by: Felix Fietkau --- package/network/config/netifd/Makefile | 8 ++--- ...ace-ip-fix-IPv4-route-target-masking.patch | 32 ------------------- 2 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 package/network/config/netifd/patches/0001-interface-ip-fix-IPv4-route-target-masking.patch diff --git a/package/network/config/netifd/Makefile b/package/network/config/netifd/Makefile index d237ed181f..b9f0e692d5 100644 --- a/package/network/config/netifd/Makefile +++ b/package/network/config/netifd/Makefile @@ -1,13 +1,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=netifd -PKG_RELEASE:=1.1 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git -PKG_SOURCE_DATE:=2023-11-10 -PKG_SOURCE_VERSION:=35facc8306f590a7330789ab6d5785c0d43073ef -PKG_MIRROR_HASH:=4f73591ae1873e18df235349e478f2196ca0d3123c313a04149dc9d5e2bfb403 +PKG_SOURCE_DATE:=2024-01-04 +PKG_SOURCE_VERSION:=c18cc79d50002ab8529c21184aceb016c61ac61c +PKG_MIRROR_HASH:=0a1080ade51dc4a55249c8899d4d384f665e0d21075adab24ea23a2808165e05 PKG_MAINTAINER:=Felix Fietkau PKG_LICENSE:=GPL-2.0 diff --git a/package/network/config/netifd/patches/0001-interface-ip-fix-IPv4-route-target-masking.patch b/package/network/config/netifd/patches/0001-interface-ip-fix-IPv4-route-target-masking.patch deleted file mode 100644 index dd9374a83c..0000000000 --- a/package/network/config/netifd/patches/0001-interface-ip-fix-IPv4-route-target-masking.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 8587c074f1eb2064c42adb0a6aa5073f695ab89d Mon Sep 17 00:00:00 2001 -From: Jo-Philipp Wich -Date: Tue, 14 Nov 2023 14:01:44 +0100 -Subject: [PATCH] interface-ip: fix IPv4 route target masking - -A previous commit supposed to mask out excess host bits in route targets -failed to correctly calculate the mask value, causing it to produce -improper results for certain mask lengths. - -Fixes: #17 -Fixes: 76eb342 ("interface-ip: mask out host bits in IPv4 route targets") -Signed-off-by: Jo-Philipp Wich ---- - interface-ip.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/interface-ip.c b/interface-ip.c -index d2fe385..28e7106 100644 ---- a/interface-ip.c -+++ b/interface-ip.c -@@ -448,7 +448,7 @@ interface_ip_add_route(struct interface *iface, struct blob_attr *attr, bool v6) - - /* Mask out IPv4 host bits to avoid "Invalid prefix for given prefix length" */ - if (af == AF_INET && route->mask < 32) -- route->addr.in.s_addr &= ((1u << route->mask) - 1); -+ clear_if_addr(&route->addr, route->mask); - } - - if ((cur = tb[ROUTE_GATEWAY]) != NULL) { --- -2.39.1 - From 9325da80ab5dbd7caf91b2f98117c5f6ae6fc7c2 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Wed, 3 Jan 2024 15:13:32 +0100 Subject: [PATCH 3/7] mac80211: fix a race condition related to enabling fast-xmit fast-xmit must only be enabled after the sta has been uploaded to the driver, otherwise it could end up passing the not-yet-uploaded sta via drv_tx calls to the driver, leading to potential crashes because of uninitialized drv_priv data. Add a missing sta->uploaded check and re-check fast xmit after inserting a sta. Signed-off-by: Felix Fietkau (cherry picked from commit 438a97fab69b41387e25cbec45271e7fe159a330) --- ...x-race-condition-on-enabling-fast-xm.patch | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 package/kernel/mac80211/patches/subsys/337-wifi-mac80211-fix-race-condition-on-enabling-fast-xm.patch diff --git a/package/kernel/mac80211/patches/subsys/337-wifi-mac80211-fix-race-condition-on-enabling-fast-xm.patch b/package/kernel/mac80211/patches/subsys/337-wifi-mac80211-fix-race-condition-on-enabling-fast-xm.patch new file mode 100644 index 0000000000..0ef0aa2ef7 --- /dev/null +++ b/package/kernel/mac80211/patches/subsys/337-wifi-mac80211-fix-race-condition-on-enabling-fast-xm.patch @@ -0,0 +1,34 @@ +From: Felix Fietkau +Date: Wed, 3 Jan 2024 15:10:18 +0100 +Subject: [PATCH] wifi: mac80211: fix race condition on enabling fast-xmit + +fast-xmit must only be enabled after the sta has been uploaded to the driver, +otherwise it could end up passing the not-yet-uploaded sta via drv_tx calls +to the driver, leading to potential crashes because of uninitialized drv_priv +data. +Add a missing sta->uploaded check and re-check fast xmit after inserting a sta. + +Signed-off-by: Felix Fietkau +--- + +--- a/net/mac80211/sta_info.c ++++ b/net/mac80211/sta_info.c +@@ -886,6 +886,7 @@ static int sta_info_insert_finish(struct + + if (ieee80211_vif_is_mesh(&sdata->vif)) + mesh_accept_plinks_update(sdata); ++ ieee80211_check_fast_xmit(sta); + + return 0; + out_remove: +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -3041,7 +3041,7 @@ void ieee80211_check_fast_xmit(struct st + sdata->vif.type == NL80211_IFTYPE_STATION) + goto out; + +- if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED)) ++ if (!test_sta_flag(sta, WLAN_STA_AUTHORIZED) || !sta->uploaded) + goto out; + + if (test_sta_flag(sta, WLAN_STA_PS_STA) || From 9a7b14dcfeb211fb55fe64b9a7a0d76e17676a61 Mon Sep 17 00:00:00 2001 From: Robert Senderek Date: Sun, 10 Dec 2023 13:49:10 +0100 Subject: [PATCH 4/7] mediatek: enable mt7981-wo-firmware package by default Add support for wireless offload package in default configuration for -Cudy WR3000 -Confiabits MT7981 For some reason those ware missing. I confirm this work for my Cudy WR3000 Signed-off-by: Robert Senderek (cherry picked from commit b42eea0c2f68ea4903e952287a08511dd0a03072) --- target/linux/mediatek/image/filogic.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 2a9449f3bb..95bc760d36 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -284,7 +284,7 @@ define Device/confiabits_mt7981 IMAGE_SIZE := 65536k KERNEL_IN_UBI := 1 IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata - DEVICE_PACKAGES := kmod-usb3 kmod-mt7981-firmware + DEVICE_PACKAGES := kmod-usb3 kmod-mt7981-firmware mt7981-wo-firmware endef TARGET_DEVICES += confiabits_mt7981 @@ -303,7 +303,7 @@ define Device/cudy_wr3000-v1 KERNEL_INITRAMFS := kernel-bin | lzma | \ fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k IMAGE/sysupgrade.bin := append-kernel | pad-to 128k | append-rootfs | pad-rootfs | check-size | append-metadata - DEVICE_PACKAGES := kmod-mt7981-firmware + DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware endef TARGET_DEVICES += cudy_wr3000-v1 From f6fb6bb2ba67d0c6e43b1f8ee649ae6550661e79 Mon Sep 17 00:00:00 2001 From: Szabolcs Hubai Date: Wed, 8 Nov 2023 13:50:55 +0100 Subject: [PATCH 5/7] ramips: mt7621: use lzma-loader for Sercomm NA502 This fixes a well known "LZMA ERROR 1" error on Sercomm NA502, reported on the OpenWrt forum. [1] [1]: https://forum.openwrt.org/t/176942 Signed-off-by: Szabolcs Hubai (cherry picked from commit d41b8a570f209c352571f209c2c8f2b52b8d27af) --- target/linux/ramips/image/mt7621.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index d456176a01..e20a3e99aa 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1973,6 +1973,7 @@ TARGET_DEVICES += samknows_whitebox-v8 define Device/sercomm_na502 $(Device/nand) + $(Device/uimage-lzma-loader) IMAGE_SIZE := 20480k DEVICE_VENDOR := SERCOMM DEVICE_MODEL := NA502 From 18d7962f7b130ac9b873d6bb2c00c3ea6e2fa95f Mon Sep 17 00:00:00 2001 From: Mikhail Zhilkin Date: Sat, 25 Nov 2023 12:14:57 +0000 Subject: [PATCH 6/7] ramips: add support for Rostelecom RT-FE-1A Rostelecom RT-FE-1A is a wireless WiFi 5 router manufactured by Sercomm company. Device specification -------------------- SoC Type: MediaTek MT7621AT RAM: 256 MiB Flash: 128 MiB Wireless 2.4 GHz (MT7603EN): b/g/n, 2x2 Wireless 5 GHz (MT7615E): a/n/ac, 4x4 Ethernet: 5x GbE (WAN, LAN1, LAN2, LAN3, LAN4) USB ports: No Button: 2 buttons (Reset & WPS) LEDs: - 1x Power (green, unmanaged) - 1x Status (green, gpio) - 1x 2.4G (green, hardware, mt76-phy0) - 1x 2.4G (blue, gpio) - 1x 5G (green, hardware, mt76-phy1) - 1x 5G (blue, gpio) - 5x Ethernet (green, hardware, 4x LAN & WAN) Power: 12 VDC, 1.5 A Connector type: barrel Bootloader: U-Boot Installation ----------------- 1. Login to the router web interface (default http://192.168.0.1/) under "admin" account 2. Navigate to Settings -> Configuration -> Save to Computer 3. Decode the configuration. For example, using cfgtool.py tool (see related section): cfgtool.py -u configurationBackup.cfg 4. Open configurationBackup.xml and find the following block: 5. Replace by a new superadmin password and add a line which enabling superadmin login after. For example, the block after the changes: 6. Encode the configuration. For example, using cfgtool.py tool: cfgtool.py -p configurationBackup.xml 7. Upload the changed configuration (configurationBackup_changed.cfg) to the router 8. Login to the router web interface (superadmin:xxxxxxxxxx, where xxxxxxxxxx is a new password from the p.5) 9. Enable SSH access to the router (Settings -> Access control -> SSH) 10. Connect to the router using SSH shell using superadmin account 11. Run in SSH shell: sh 12. Make a mtd backup (optional, see related section) 13. Change bootflag to Sercomm1 and reboot: printf 1 | dd bs=1 seek=7 count=1 of=/dev/mtdblock3 reboot 14. Login to the router web interface under admin account 15. Remove dots from the OpenWrt factory image filename 16. Update firmware via web using OpenWrt factory image Revert to stock --------------- Change bootflag to Sercomm1 in OpenWrt CLI and then reboot: printf 1 | dd bs=1 seek=7 count=1 of=/dev/mtdblock3 mtd backup ---------- 1. Set up a tftp server (e.g. tftpd64 for windows) 2. Connect to a router using SSH shell and run the following commands: cd /tmp for i in 0 1 2 3 4 5 6 7 8 9; do nanddump -f mtd$i /dev/mtd$i; \ tftp -l mtd$i -p 192.168.0.2; md5sum mtd$i >> mtd.md5; rm mtd$i; done tftp -l mtd.md5 -p 192.168.0.2 MAC Addresses ------------- +-----+------------+---------+ | use | address | example | +-----+------------+---------+ | LAN | label | f4:*:66 | | WAN | label + 11 | f4:*:71 | | 2g | label + 2 | f4:*:68 | | 5g | label + 3 | f4:*:69 | +-----+------------+---------+ The label MAC address was found in Factory, 0x21000 cfgtool.py ---------- A tool for decoding and encoding Sercomm configs. Link: https://github.com/r3d5ky/sercomm_cfg_unpacker Signed-off-by: Mikhail Zhilkin (cherry picked from commit f3cdc9f9881796794c06f784a2e4790f5ed75d1f) --- package/boot/uboot-envtools/files/ramips | 1 + .../ramips/dts/mt7621_rostelecom_rt-fe-1a.dts | 266 ++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 14 + .../mt7621/base-files/lib/upgrade/platform.sh | 1 + 4 files changed, 282 insertions(+) create mode 100644 target/linux/ramips/dts/mt7621_rostelecom_rt-fe-1a.dts diff --git a/package/boot/uboot-envtools/files/ramips b/package/boot/uboot-envtools/files/ramips index 83b54388e3..1df42c22ef 100644 --- a/package/boot/uboot-envtools/files/ramips +++ b/package/boot/uboot-envtools/files/ramips @@ -43,6 +43,7 @@ beeline,smartbox-giga|\ beeline,smartbox-turbo|\ beeline,smartbox-turbo-plus|\ etisalat,s3|\ +rostelecom,rt-fe-1a|\ rostelecom,rt-sf-1) ubootenv_add_uci_config "/dev/mtd0" "0x80000" "0x1000" "0x20000" ;; diff --git a/target/linux/ramips/dts/mt7621_rostelecom_rt-fe-1a.dts b/target/linux/ramips/dts/mt7621_rostelecom_rt-fe-1a.dts new file mode 100644 index 0000000000..8afe5f5485 --- /dev/null +++ b/target/linux/ramips/dts/mt7621_rostelecom_rt-fe-1a.dts @@ -0,0 +1,266 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT + +#include "mt7621.dtsi" + +#include +#include +#include + +/ { + compatible = "rostelecom,rt-fe-1a", "mediatek,mt7621-soc"; + model = "Rostelecom RT-FE-1A"; + + aliases { + label-mac-device = &gmac0; + + led-boot = &led_status_green; + led-failsafe = &led_status_green; + led-running = &led_status_green; + led-upgrade = &led_status_green; + }; + + leds { + compatible = "gpio-leds"; + + led-0 { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <50>; + gpios = <&gpio 7 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy1tpt"; + }; + + led-1 { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <24>; + gpios = <&gpio 12 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "phy0tpt"; + }; + + led_status_green: led-2 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&gpio 18 GPIO_ACTIVE_LOW>; + }; + }; + + keys { + compatible = "gpio-keys"; + + button-0 { + label = "wps"; + gpios = <&gpio 11 GPIO_ACTIVE_HIGH>; + linux,code = ; + }; + + button-1 { + label = "reset"; + gpios = <&gpio 14 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + ubi-concat { + compatible = "mtd-concat"; + devices = <&ubiconcat0 &ubiconcat1 &ubiconcat2 \ + &ubiconcat3>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "ubi"; + reg = <0x0 0x5420000>; + }; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "sercomm,sc-partitions", "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "u-boot"; + reg = <0x0 0x100000>; + sercomm,scpart-id = <0>; + read-only; + }; + + partition@100000 { + label = "dynamic partition map"; + reg = <0x100000 0x100000>; + sercomm,scpart-id = <1>; + read-only; + }; + + partition@200000 { + label = "Factory"; + reg = <0x200000 0x100000>; + sercomm,scpart-id = <2>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + eeprom_2g: eeprom@0 { + reg = <0x0 0x400>; + }; + + eeprom_5g: eeprom@8000 { + reg = <0x8000 0x4da8>; + }; + + macaddr_label: macaddr@21000 { + compatible = "mac-base"; + reg = <0x21000 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition@300000 { + label = "Boot Flag"; + reg = <0x300000 0x100000>; + sercomm,scpart-id = <3>; + }; + + partition@400000 { + label = "kernel"; + reg = <0x400000 0x600000>; + sercomm,scpart-id = <4>; + }; + + partition@a00000 { + label = "Kernel 2"; + reg = <0xa00000 0x600000>; + sercomm,scpart-id = <5>; + read-only; + }; + + ubiconcat0: partition@1000000 { + label = "File System 1"; + reg = <0x1000000 0x1800000>; + sercomm,scpart-id = <6>; + }; + + partition@2800000 { + label = "File System 2"; + reg = <0x2800000 0x1800000>; + sercomm,scpart-id = <7>; + read-only; + }; + + ubiconcat1: partition@4000000 { + label = "Configuration/log"; + reg = <0x4000000 0x800000>; + sercomm,scpart-id = <8>; + }; + + ubiconcat2: partition@4800000 { + label = "application tmp buffer (Ftool)"; + reg = <0x4800000 0xc00000>; + sercomm,scpart-id = <9>; + }; + + ubiconcat3: partition@5400000 { + label = "free space (in stock firmware)"; + reg = <0x5400000 0x2820000>; + sercomm,scpart-id = <10>; + }; + }; +}; + +&pcie { + status = "okay"; +}; + +&pcie0 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + ieee80211-freq-limit = <5000000 6000000>; + + nvmem-cells = <&eeprom_5g>, <&macaddr_label 3>; + nvmem-cell-names = "eeprom", "mac-address"; + + led { + led-active-low; + }; + }; +}; + +&pcie1 { + wifi@0,0 { + compatible = "mediatek,mt76"; + reg = <0x0000 0 0 0 0>; + ieee80211-freq-limit = <2400000 2500000>; + + nvmem-cells = <&eeprom_2g>, <&macaddr_label 2>; + nvmem-cell-names = "eeprom", "mac-address"; + + led { + led-active-low; + }; + }; +}; + +&gmac0 { + nvmem-cells = <&macaddr_label 0>; + nvmem-cell-names = "mac-address"; +}; + +&gmac1 { + status = "okay"; + label = "wan"; + phy-handle = <ðphy0>; + + nvmem-cells = <&macaddr_label 11>; + nvmem-cell-names = "mac-address"; +}; + +&mdio { + ethphy0: ethernet-phy@0 { + reg = <0>; + }; +}; + +&switch0 { + ports { + port@1 { + status = "okay"; + label = "lan1"; + }; + + port@2 { + status = "okay"; + label = "lan2"; + }; + + port@3 { + status = "okay"; + label = "lan3"; + }; + + port@4 { + status = "okay"; + label = "lan4"; + }; + }; +}; + +&state_default { + gpio { + groups = "jtag", "uart2", "uart3", "wdt"; + function = "gpio"; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index e20a3e99aa..52968b482f 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -1947,6 +1947,20 @@ define Device/renkforce_ws-wn530hp3-a endef TARGET_DEVICES += renkforce_ws-wn530hp3-a +define Device/rostelecom_rt-fe-1a + $(Device/sercomm_dxx) + IMAGE_SIZE := 24576k + SERCOMM_HWID := CX4 + SERCOMM_HWVER := 11300 + SERCOMM_SWVER := 2010 + DEVICE_VENDOR := Rostelecom + DEVICE_MODEL := RT-FE-1A + DEVICE_ALT0_VENDOR := Sercomm + DEVICE_ALT0_MODEL := RT-FE-1A + DEVICE_PACKAGES := kmod-mt7603 kmod-mt7615-firmware +endef +TARGET_DEVICES += rostelecom_rt-fe-1a + define Device/rostelecom_rt-sf-1 $(Device/sercomm_dxx) IMAGE_SIZE := 32768k 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 5d8305b788..e212c688ec 100755 --- a/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/mt7621/base-files/lib/upgrade/platform.sh @@ -102,6 +102,7 @@ platform_do_upgrade() { netgear,wax202|\ netis,wf2881|\ raisecom,msg1500-x-00|\ + rostelecom,rt-fe-1a|\ rostelecom,rt-sf-1|\ sercomm,na502|\ sercomm,na502s|\ From 51881b2eb910d4adc6109b8d5abf0b23635a92ff Mon Sep 17 00:00:00 2001 From: Mikhail Zhilkin Date: Sat, 9 Dec 2023 17:17:02 +0000 Subject: [PATCH 7/7] mediatek: add support for Routerich AX3000 This PR is continuation of work under "mediatek: add support for Routerich AX3000" #13703 by the agreement with PR #13703 original author (Maximilian Weinmann ). All reviews from the previous PR were taken into into account. Routerich AX3000 is a wireless WiFi 6 router. Specification ------------- - SoC : MediaTek MT7981BA dual-core ARM Cortex-A53 1.3 GHz - RAM : DDR3 256 MiB (ESMT M15T2G16128A) - Flash : SPI-NAND 128 MiB (ESMT F50L1G41LB) - WLAN : MediaTek MT7976CN dual-band WiFi 6 - 2.4 GHz : b/g/n/ax, MIMO 2x2 - 5 GHz : a/n/ac/ax, MIMO 2x2 - Ethernet : 10/100/1000 Mbps x4 (MediaTek MT7531AE) - USB : 1x 2.0 - UART : through-hole on PCB - [J500] GND, TX, RX, 3.3V (115200n8) - Buttons : Mesh, Reset - LEDs : 1x Power (Blue) 1x WiFi 2.4 GHz (Blue) 1x WiFi 5 GHz (Red) 1x Mesh (Blue) 3x LAN activity (Blue) 1x WAN activity (Blue) 2x WAN no-internet (Red) - Power : 12 VDC, 1.5 A Installation ------------ Flash OpenWrt 'sysupgrade.bin' image using stock firmware web-interface (without keeping settings). Return to stock --------------- Install stock firmware image (without keeping settings) using OpenWrt sysupgrade method. Recovery -------- Connect uart, use u-boot menu to flash stock firmware image or boot OpenWrt initramfs image. MAC addresses ------------- +---------+-------------------+-----------+ | | MAC | Algorithm | +---------+-------------------+-----------+ | WAN | 24:0f:5e:xx:xx:b4 | label | | LAN | 24:0f:5e:xx:xx:b5 | label+1 | | WLAN 2g | 24:0f:5e:xx:xx:b6 | label+2 | | WLAN 5g | 24:0f:5e:xx:xx:b7 | label+3 | +---------+-------------------+-----------+ The WLAN 2g MAC was found in 'Factory', 0x4 Co-authored-by: Maximilian Weinmann Signed-off-by: Mikhail Zhilkin (cherry picked from commit 485adc9d3c436d31f9713a7d8d84adf266754e26) [Fix merge conflict in uboot-envtools] Signed-off-by: Mikhail Zhilkin --- .../uboot-envtools/files/mediatek_filogic | 3 +- .../mediatek/dts/mt7981b-routerich-ax3000.dts | 337 ++++++++++++++++++ .../filogic/base-files/etc/board.d/01_leds | 7 + .../filogic/base-files/etc/board.d/02_network | 3 +- .../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 1 + target/linux/mediatek/image/filogic.mk | 11 + 6 files changed, 360 insertions(+), 2 deletions(-) create mode 100644 target/linux/mediatek/dts/mt7981b-routerich-ax3000.dts diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic index 8c7c5a85c0..b3113d683c 100644 --- a/package/boot/uboot-envtools/files/mediatek_filogic +++ b/package/boot/uboot-envtools/files/mediatek_filogic @@ -61,7 +61,8 @@ glinet,gl-mt6000) local envdev=$(find_mmc_part "u-boot-env") ubootenv_add_uci_config "$envdev" "0x0" "0x80000" ;; -mercusys,mr90x-v1) +mercusys,mr90x-v1|\ +routerich,ax3000) local envdev=/dev/mtd$(find_mtd_index "u-boot-env") ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1" ;; diff --git a/target/linux/mediatek/dts/mt7981b-routerich-ax3000.dts b/target/linux/mediatek/dts/mt7981b-routerich-ax3000.dts new file mode 100644 index 0000000000..1dc4d380b8 --- /dev/null +++ b/target/linux/mediatek/dts/mt7981b-routerich-ax3000.dts @@ -0,0 +1,337 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +/dts-v1/; +#include +#include +#include + +#include "mt7981.dtsi" + +/ { + model = "Routerich AX3000"; + compatible = "routerich,ax3000", "mediatek,mt7981"; + + aliases { + label-mac-device = &wan; + + led-boot = &led_power_blue; + led-failsafe = &led_power_blue; + led-running = &led_power_blue; + led-upgrade = &led_power_blue; + + serial0 = &uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + gpio-keys { + compatible = "gpio-keys"; + + button-0 { + label = "mesh"; + linux,input-type = ; + linux,code = ; + gpios = <&pio 0 GPIO_ACTIVE_LOW>; + debounce-interval = <60>; + }; + + button-1 { + label = "reset"; + gpios = <&pio 1 GPIO_ACTIVE_LOW>; + linux,code = ; + debounce-interval = <60>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led-0 { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <50>; + gpios = <&pio 5 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + led-1 { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&pio 6 GPIO_ACTIVE_HIGH>; + }; + + led_power_blue: led-2 { + color = ; + function = LED_FUNCTION_POWER; + gpios = <&pio 7 GPIO_ACTIVE_LOW>; + }; + + led-3 { + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <1>; + gpios = <&pio 9 GPIO_ACTIVE_LOW>; + }; + + led-4 { + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <2>; + gpios = <&pio 10 GPIO_ACTIVE_LOW>; + }; + + led-5 { + color = ; + function = LED_FUNCTION_LAN; + function-enumerator = <3>; + gpios = <&pio 11 GPIO_ACTIVE_LOW>; + }; + + led-6 { + color = ; + function = LED_FUNCTION_WAN; + gpios = <&pio 12 GPIO_ACTIVE_LOW>; + }; + + led-7 { + color = ; + function = LED_FUNCTION_WLAN; + function-enumerator = <24>; + gpios = <&pio 34 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + led-8 { + color = ; + /* LED_FUNCTION_MESH isn't implemented yet */ + function = "mesh"; + gpios = <&pio 35 GPIO_ACTIVE_LOW>; + }; + }; + + memory { + reg = <0 0x40000000 0 0x10000000>; + }; +}; + +ð { + status = "okay"; + + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; + + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_factory_4 (-1)>; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; +}; + +&mdio_bus { + switch: switch@1f { + compatible = "mediatek,mt7531"; + reg = <0x1f>; + reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>; + interrupt-controller; + #interrupt-cells = <1>; + interrupt-parent = <&pio>; + interrupts = <38 IRQ_TYPE_LEVEL_HIGH>; + }; +}; + +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi0_flash_pins>; + status = "okay"; + + /* ESMT F50L1G41LB (128M) */ + spi_nand@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "spi-nand"; + reg = <0>; + + spi-max-frequency = <52000000>; + spi-tx-buswidth = <4>; + spi-rx-buswidth = <4>; + + spi-cal-enable; + spi-cal-mode = "read-data"; + spi-cal-datalen = <7>; + spi-cal-data = /bits/ 8 <0x53 0x50 0x49 0x4e 0x41 0x4e 0x44>; + spi-cal-addrlen = <5>; + spi-cal-addr = /bits/ 32 <0x0 0x0 0x0 0x0 0x0>; + + mediatek,nmbm; + mediatek,bmt-max-ratio = <1>; + mediatek,bmt-max-reserved-blocks = <64>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0_all { + label = "spi0.0"; + reg = <0x0 0x8000000>; + read-only; + }; + + partition@0 { + label = "BL2"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "u-boot-env"; + reg = <0x100000 0x80000>; + }; + + partition@180000 { + label = "Factory"; + reg = <0x180000 0x200000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + eeprom_factory_0: eeprom@0 { + reg = <0x0 0x1000>; + }; + + macaddr_factory_4: macaddr@4 { + compatible = "mac-base"; + reg = <0x4 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition@380000 { + label = "FIP"; + reg = <0x380000 0x200000>; + read-only; + }; + + partition@580000 { + label = "ubi"; + reg = <0x580000 0x4000000>; + }; + + partition@4580000 { + label = "firmware_backup"; + reg = <0x4580000 0x2000000>; + read-only; + }; + + partition@6580000 { + label = "zrsave"; + reg = <0x6580000 0x100000>; + read-only; + }; + + partition@6680000 { + label = "config2"; + reg = <0x6680000 0x100000>; + read-only; + }; + }; + }; +}; + +&switch { + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan1"; + }; + + port@2 { + reg = <2>; + label = "lan2"; + }; + + port@3 { + reg = <3>; + label = "lan3"; + }; + + wan: port@4 { + reg = <4>; + label = "wan"; + + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_factory_4 (-2)>; + }; + + port@6 { + reg = <6>; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; +}; + +&pio { + spi0_flash_pins: spi0-pins { + mux { + function = "spi"; + groups = "spi0", "spi0_wp_hold"; + }; + + conf-pu { + pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP"; + drive-strength = ; + bias-pull-up = ; + }; + + conf-pd { + pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO"; + drive-strength = ; + bias-pull-down = ; + }; + }; +}; + +&uart0 { + status = "okay"; +}; + +&usb_phy { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +&wifi { + status = "okay"; + nvmem-cell-names = "eeprom"; + nvmem-cells = <&eeprom_factory_0>; +}; + +&xhci { + status = "okay"; + mediatek,u3p-dis-msk = <0x1>; +}; diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds index 546b7f6cd7..cdeaa6c5c5 100644 --- a/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/01_leds @@ -26,6 +26,13 @@ netgear,wax220) ucidef_set_led_netdev "wlan2g" "WLAN2G" "blue:wlan2g" "phy0-ap0" ucidef_set_led_netdev "wlan5g" "WLAN5G" "blue:wlan5g" "phy1-ap0" ;; +routerich,ax3000) + ucidef_set_led_netdev "lan-1" "lan-1" "blue:lan-1" "lan1" "link tx rx" + ucidef_set_led_netdev "lan-2" "lan-2" "blue:lan-2" "lan2" "link tx rx" + ucidef_set_led_netdev "lan-3" "lan-3" "blue:lan-3" "lan3" "link tx rx" + ucidef_set_led_netdev "wan" "wan" "blue:wan" "wan" "link tx rx" + ucidef_set_led_netdev "wan-off" "wan-off" "red:wan" "wan" "link" + ;; xiaomi,mi-router-wr30u-112m-nmbm|\ xiaomi,mi-router-wr30u-stock|\ xiaomi,mi-router-wr30u-ubootmod) diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network index a53b66f7cb..20a78b7b4b 100644 --- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network +++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network @@ -29,7 +29,8 @@ mediatek_setup_interfaces() confiabits,mt7981|\ cudy,wr3000-v1|\ jcg,q30-pro|\ - qihoo,360t7) + qihoo,360t7|\ + routerich,ax3000) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" wan ;; cmcc,rax3000m|\ diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac index b2b4f377a6..4911d5e85e 100644 --- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac +++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac @@ -95,6 +95,7 @@ case "$board" in [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress ;; + routerich,ax3000|\ zbtlink,zbt-z8102ax|\ zyxel,ex5601-t0) addr=$(mtd_get_mac_binary "Factory" 0x4) diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 95bc760d36..add838c4bc 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -600,6 +600,17 @@ define Device/qihoo_360t7 endef TARGET_DEVICES += qihoo_360t7 +define Device/routerich_ax3000 + DEVICE_VENDOR := Routerich + DEVICE_MODEL := AX3000 + DEVICE_DTS := mt7981b-routerich-ax3000 + DEVICE_DTS_DIR := ../dts + DEVICE_PACKAGES := kmod-mt7981-firmware mt7981-wo-firmware kmod-usb3 + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + SUPPORTED_DEVICES += mediatek,mt7981-spim-snand-rfb +endef +TARGET_DEVICES += routerich_ax3000 + define Device/tplink_tl-xdr-common DEVICE_VENDOR := TP-Link DEVICE_DTS_DIR := ../dts