From a7f4155f54ac72c388a8b515865e496bfd6ec437 Mon Sep 17 00:00:00 2001 From: Jonas Jelonek Date: Wed, 18 Dec 2024 21:57:22 +0100 Subject: [PATCH 1/7] kernel: netdevices: add driver for Broadcom NetXtreme-C/E Package bnxt_en kernel module for Broadcom NetXtreme-C/E based Ethernet network chips like BCM573xx and BCM574xx. Signed-off-by: Jonas Jelonek Link: https://github.com/openwrt/openwrt/pull/17301 Signed-off-by: Hauke Mehrtens --- package/kernel/linux/modules/netdevices.mk | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/package/kernel/linux/modules/netdevices.mk b/package/kernel/linux/modules/netdevices.mk index cd24fb3ecbc..c72bc0e8e63 100644 --- a/package/kernel/linux/modules/netdevices.mk +++ b/package/kernel/linux/modules/netdevices.mk @@ -1525,6 +1525,28 @@ endef $(eval $(call KernelPackage,bnx2x)) +define KernelPackage/bnxt-en + SUBMENU:=$(NETWORK_DEVICES_MENU) + TITLE:=Broadcom NetXtreme-C/E network driver + DEPENDS:=@PCI_SUPPORT +kmod-hwmon-core +kmod-lib-crc32c +kmod-mdio +kmod-ptp + FILES:=$(LINUX_DIR)/drivers/net/ethernet/broadcom/bnxt/bnxt_en.ko + KCONFIG:= \ + CONFIG_BNXT \ + CONFIG_BNXT_SRIOV=y \ + CONFIG_BNXT_FLOWER_OFFLOAD=y \ + CONFIG_BNXT_DCB=n \ + CONFIG_BNXT_HWMON=y + AUTOLOAD:=$(call AutoProbe,bnxt_en) +endef + +define KernelPackage/bnxt-en/description + Supports Broadcom NetXtreme-C/E based Ethernet NICs including: + * BCM573xx + * BCM574xx +endef + +$(eval $(call KernelPackage,bnxt-en)) + define KernelPackage/be2net SUBMENU:=$(NETWORK_DEVICES_MENU) TITLE:=Broadcom Emulex OneConnect 10Gbps NIC From 9d434a8abf7cb50782aaae41fe2b011b3a9bf489 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Wed, 16 Oct 2024 16:05:40 +0800 Subject: [PATCH 2/7] kernel: crypto: add atmel i2c hw accelerator support Add support for Microchip / Atmel ECC/SHA/RNG hw accelerator. Signed-off-by: Tianling Shen Link: https://github.com/openwrt/openwrt/pull/17253 Signed-off-by: Hauke Mehrtens --- package/kernel/linux/modules/crypto.mk | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/package/kernel/linux/modules/crypto.mk b/package/kernel/linux/modules/crypto.mk index 2257a36c802..78c97121764 100644 --- a/package/kernel/linux/modules/crypto.mk +++ b/package/kernel/linux/modules/crypto.mk @@ -366,6 +366,26 @@ endef $(eval $(call KernelPackage,crypto-hmac)) +define KernelPackage/crypto-hw-atmel + TITLE:=Microchip / Atmel ECC/SHA/RNG hw accelerator + DEPENDS:=+kmod-i2c-core +kmod-crypto-ecdh +kmod-crypto-sha1 \ + +kmod-crypto-sha256 +kmod-lib-crc16 +kmod-random-core + KCONFIG:= \ + CONFIG_CRYPTO_HW=y \ + CONFIG_CRYPTO_DEV_ATMEL_I2C \ + CONFIG_CRYPTO_DEV_ATMEL_ECC \ + CONFIG_CRYPTO_DEV_ATMEL_SHA204A + FILES:= \ + $(LINUX_DIR)/drivers/crypto/atmel-i2c.ko \ + $(LINUX_DIR)/drivers/crypto/atmel-ecc.ko \ + $(LINUX_DIR)/drivers/crypto/atmel-sha204a.ko + AUTOLOAD:=$(call AutoLoad,09,atmel-i2c atmel-ecc atmel-sha204a) + $(call AddDepends/crypto) +endef + +$(eval $(call KernelPackage,crypto-hw-atmel)) + + define KernelPackage/crypto-hw-ccp TITLE:=AMD Cryptographic Coprocessor DEPENDS:= \ From 5a7fb834c7cb53cac7855759ca4165f596f1e4c8 Mon Sep 17 00:00:00 2001 From: Tianling Shen Date: Wed, 16 Oct 2024 16:05:40 +0800 Subject: [PATCH 3/7] mediatek: update openembed som7981 support The board has been redesigned due to previous hardware bugs (with other reasons maybe). Changes in new board: - Added a gpio beeper - Added a Atmel i2c eeprom - Added a Atmel i2c ECC accelerator - Added a Philips RTC module - Added two RS485 - Removed WPS button - Replaced USB3 port with M.2 B-key for LTE modules - Swapped GbE LEDs gpio Also assigned wifi mac with nvmem binding, added iface setup for failsafe, increased phy assert time for rtl8221b, and updated LED labels. Keeping compatibility for old version is not necessary here as only few samples were sent to those interested in it. Signed-off-by: Tianling Shen Link: https://github.com/openwrt/openwrt/pull/17253 Signed-off-by: Hauke Mehrtens --- .../lib/preinit/05_set_preinit_iface | 3 +- .../dts/mt7981b-openembed-som7981.dts | 111 ++++++++++++++---- .../filogic/base-files/etc/board.d/01_leds | 4 +- .../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 3 - target/linux/mediatek/image/filogic.mk | 5 +- 5 files changed, 99 insertions(+), 27 deletions(-) diff --git a/target/linux/mediatek/base-files/lib/preinit/05_set_preinit_iface b/target/linux/mediatek/base-files/lib/preinit/05_set_preinit_iface index 0deab424813..1025d1f1e13 100644 --- a/target/linux/mediatek/base-files/lib/preinit/05_set_preinit_iface +++ b/target/linux/mediatek/base-files/lib/preinit/05_set_preinit_iface @@ -2,7 +2,8 @@ set_preinit_iface() { case $(board_name) in cudy,m3000-v1|\ cudy,tr3000-v1|\ - glinet,gl-mt3000) + glinet,gl-mt3000|\ + openembed,som7981) ip link set eth1 up ifname=eth1 ;; diff --git a/target/linux/mediatek/dts/mt7981b-openembed-som7981.dts b/target/linux/mediatek/dts/mt7981b-openembed-som7981.dts index 0e9dea1ddb0..d5c868567bd 100644 --- a/target/linux/mediatek/dts/mt7981b-openembed-som7981.dts +++ b/target/linux/mediatek/dts/mt7981b-openembed-som7981.dts @@ -12,9 +12,10 @@ compatible = "openembed,som7981", "mediatek,mt7981"; aliases { - led-boot = &wlan2g_led; - led-failsafe = &wlan2g_led; - led-upgrade = &wlan2g_led; + led-boot = &act_led; + led-failsafe = &act_led; + led-running = &act_led; + led-upgrade = &act_led; serial0 = &uart0; }; @@ -26,6 +27,11 @@ reg = <0 0x40000000 0 0x40000000>; }; + beeper { + compatible = "gpio-beeper"; + gpios = <&pio 2 GPIO_ACTIVE_HIGH>; + }; + gpio-keys { compatible = "gpio-keys"; @@ -34,12 +40,6 @@ linux,code = ; gpios = <&pio 1 GPIO_ACTIVE_LOW>; }; - - button-wps { - label = "wps"; - linux,code = ; - gpios = <&pio 0 GPIO_ACTIVE_LOW>; - }; }; gpio-leds { @@ -47,28 +47,27 @@ led-0 { function = LED_FUNCTION_LAN; - color = ; + color = ; gpios = <&pio 8 GPIO_ACTIVE_LOW>; }; led-1 { function = LED_FUNCTION_LAN; - color = ; + color = ; gpios = <&pio 13 GPIO_ACTIVE_LOW>; }; - wlan2g_led: led-2 { - function = LED_FUNCTION_WLAN_2GHZ; - color = ; + led-2 { + function = LED_FUNCTION_PANIC; + color = ; gpios = <&pio 34 GPIO_ACTIVE_LOW>; - linux,default-trigger = "phy0tpt"; + panic-indicator; }; - led-3 { - function = LED_FUNCTION_WLAN_5GHZ; + act_led: led-3 { + function = LED_FUNCTION_ACTIVITY; color = ; gpios = <&pio 35 GPIO_ACTIVE_LOW>; - linux,default-trigger = "phy1tpt"; }; }; }; @@ -97,14 +96,38 @@ }; }; +&i2c0 { + clock-frequency = <400000>; + pinctrl-names = "default"; + pinctrl-0 = <&i2c0_pins>; + status = "okay"; + + eeprom@50 { + compatible = "atmel,24c64"; + reg = <0x50>; + page-size = <32>; + }; + + rtc@51 { + compatible = "nxp,pcf8563"; + reg = <0x51>; + #clock-cells = <0>; + }; + + crypto@60 { + compatible = "atmel,atecc508a"; + reg = <0x60>; + }; +}; + &mdio_bus { phy0: ethernet-phy@5 { reg = <5>; compatible = "ethernet-phy-ieee802.3-c45"; phy-mode = "2500base-x"; reset-gpios = <&pio 14 GPIO_ACTIVE_LOW>; - reset-assert-us = <10000>; - reset-deassert-us = <50000>; + reset-assert-us = <15000>; + reset-deassert-us = <68000>; realtek,aldps-enable; }; }; @@ -184,6 +207,13 @@ }; &pio { + i2c0_pins: i2c0-pins { + mux { + function = "i2c"; + groups = "i2c0_1"; + }; + }; + spi0_flash_pins: spi0-pins { mux { function = "spi"; @@ -202,12 +232,45 @@ mediatek,pull-down-adv = <0>; }; }; + + uart1_pins: uart1-pins { + mux { + function = "uart"; + groups = "uart1_3"; + }; + }; + + uart2_pins: uart2-pins { + mux { + function = "uart"; + groups = "uart2_0_tx_rx"; + }; + }; + + wwan_rst_h: wwan-rst-h { + pins = "GPIO_WPS"; + drive-strength = <8>; + mediatek,pull-down-adv = <0>; + output-low; + }; }; &uart0 { status = "okay"; }; +&uart1 { + pinctrl-names = "default"; + pinctrl-0 = <&uart1_pins>; + status = "okay"; +}; + +&uart2 { + pinctrl-names = "default"; + pinctrl-0 = <&uart2_pins>; + status = "okay"; +}; + &usb_phy { status = "okay"; }; @@ -220,8 +283,16 @@ nvmem-cells = <&eeprom_factory_0>; nvmem-cell-names = "eeprom"; status = "okay"; + + band@1 { + reg = <1>; + nvmem-cells = <&macaddr_factory_a 0>; + nvmem-cell-names = "mac-address"; + }; }; &xhci { + pinctrl-names = "default"; + pinctrl-0 = <&wwan_rst_h>; status = "okay"; }; 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 2496323d873..ca4961c6553 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 @@ -71,8 +71,8 @@ nradio,c8-668gl) ucidef_set_led_netdev "5g" "5G" "blue:indicator-0" "eth1" "link" ;; openembed,som7981) - ucidef_set_led_netdev "lanact" "LANACT" "green:lan" "eth1" "rx tx" - ucidef_set_led_netdev "lanlink" "LANLINK" "amber:lan" "eth1" "link" + ucidef_set_led_netdev "lanact" "LANACT" "amber:lan" "eth1" "rx tx" + ucidef_set_led_netdev "lanlink" "LANLINK" "green:lan" "eth1" "link" ;; openwrt,one) ucidef_set_led_netdev "wanact" "WANACT" "mdio-bus:0f:green:wan" "eth0" "rx tx" 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 41c425e5579..3f5554d269f 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 @@ -141,9 +141,6 @@ case "$board" in [ "$PHYNBR" = "0" ] && echo "$hw_mac_addr" > /sys${DEVPATH}/macaddress [ "$PHYNBR" = "1" ] && macaddr_setbit_la $hw_mac_addr > /sys${DEVPATH}/macaddress ;; - openembed,som7981) - [ "$PHYNBR" = "1" ] && cat /sys/class/net/eth0/address > /sys${DEVPATH}/macaddress - ;; qihoo,360t7) addr=$(mtd_get_mac_ascii factory lanMac) [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index abc6fc1e091..91706f8c73c 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -1215,7 +1215,10 @@ define Device/openembed_som7981 DEVICE_MODEL := SOM7981 DEVICE_DTS := mt7981b-openembed-som7981 DEVICE_DTS_DIR := ../dts - DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware kmod-usb3 + DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware \ + kmod-crypto-hw-atmel kmod-eeprom-at24 kmod-gpio-beeper kmod-rtc-pcf8563 \ + kmod-usb-net-cdc-mbim kmod-usb-net-qmi-wwan kmod-usb-serial-option \ + kmod-usb3 uqmi UBINIZE_OPTS := -E 5 BLOCKSIZE := 128k PAGESIZE := 2048 From dc655dcfca9a8e527cdea9eb395bea4aff276b30 Mon Sep 17 00:00:00 2001 From: Rani Hod Date: Sun, 22 Dec 2024 02:53:51 +0200 Subject: [PATCH 4/7] linux-firmware: package MediaTek MT7925 Bluetooth firmware `btusb` fails to start on MT7925 hardware without the appropriate firmware being loaded first: ``` bluetooth hci0: Direct firmware load for mediatek/mt7925/BT_RAM_CODE_MT7925_1_1_hdr.bin failed with error -2 bluetooth hci0: Falling back to sysfs fallback for: mediatek/mt7925/BT_RAM_CODE_MT7925_1_1_hdr.bin ``` Package firmware for MediaTek MT7925 Bluetooth from `linux-firmware`. Signed-off-by: Rani Hod Link: https://github.com/openwrt/openwrt/pull/17331 Signed-off-by: Hauke Mehrtens --- package/firmware/linux-firmware/mediatek.mk | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/package/firmware/linux-firmware/mediatek.mk b/package/firmware/linux-firmware/mediatek.mk index d520557196d..cbc1c70d81f 100644 --- a/package/firmware/linux-firmware/mediatek.mk +++ b/package/firmware/linux-firmware/mediatek.mk @@ -69,6 +69,15 @@ define Package/mt7922bt-firmware/install endef $(eval $(call BuildPackage,mt7922bt-firmware)) +Package/mt7925bt-firmware = $(call Package/firmware-default,mt7925bt firmware,,LICENCE.mediatek) +define Package/mt7925bt-firmware/install + $(INSTALL_DIR) $(1)/lib/firmware/mediatek/mt7925 + $(INSTALL_DATA) \ + $(PKG_BUILD_DIR)/mediatek/mt7925/BT_RAM_CODE_MT7925_1_1_hdr.bin \ + $(1)/lib/firmware/mediatek/mt7925 +endef +$(eval $(call BuildPackage,mt7925bt-firmware)) + Package/mt7981-wo-firmware = $(call Package/firmware-default,MT7981 offload firmware,,LICENCE.mediatek) define Package/mt7981-wo-firmware/install $(INSTALL_DIR) $(1)/lib/firmware/mediatek From 6992d6e51af34603de099d7bbe9d7e848f109e22 Mon Sep 17 00:00:00 2001 From: Maxim Anisimov Date: Tue, 10 Dec 2024 16:37:02 +0300 Subject: [PATCH 5/7] mediatek/filogic: add support for Cudy AP3000 v1 Hardware: SoC: MT7981b RAM: 512 MB Flash: 256 MB SPI NAND Ethernet: 1x2.5Gbps (rtl8221b) WiFi: 2x2 MT7981 Button: Reset LED: 1x multicolor Installation ------------ At the moment, firmware installation is only possible via a transition firmware. It's can be requested from the manufacturer by email to support@cudy.com Signed-off-by: Maxim Anisimov Link: https://github.com/openwrt/openwrt/pull/17225 Signed-off-by: Hauke Mehrtens --- .../mediatek/dts/mt7981b-cudy-ap3000-v1.dts | 218 ++++++++++++++++++ .../filogic/base-files/etc/board.d/02_network | 1 + .../etc/hotplug.d/ieee80211/11_fix_wifi_mac | 9 +- target/linux/mediatek/image/filogic.mk | 17 ++ 4 files changed, 239 insertions(+), 6 deletions(-) create mode 100644 target/linux/mediatek/dts/mt7981b-cudy-ap3000-v1.dts diff --git a/target/linux/mediatek/dts/mt7981b-cudy-ap3000-v1.dts b/target/linux/mediatek/dts/mt7981b-cudy-ap3000-v1.dts new file mode 100644 index 00000000000..bd6c15225b4 --- /dev/null +++ b/target/linux/mediatek/dts/mt7981b-cudy-ap3000-v1.dts @@ -0,0 +1,218 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT + +/dts-v1/; + +#include "mt7981.dtsi" + +/ { + model = "Cudy AP3000 v1"; + compatible = "cudy,ap3000-v1", "mediatek,mt7981"; + + aliases { + label-mac-device = &gmac0; + led-boot = &status_led; + led-failsafe = &status_led; + led-running = &status_led; + led-upgrade = &status_led; + serial0 = &uart0; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + gpio-keys { + compatible = "gpio-keys"; + + button-reset { + label = "reset"; + linux,code = ; + gpios = <&pio 1 GPIO_ACTIVE_LOW>; + }; + }; + + gpio-leds { + compatible = "gpio-leds"; + + led-0 { + color = ; + function = LED_FUNCTION_WLAN_2GHZ; + gpios = <&pio 4 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy0tpt"; + }; + + led-1 { + color = ; + function = LED_FUNCTION_WLAN_5GHZ; + gpios = <&pio 10 GPIO_ACTIVE_LOW>; + linux,default-trigger = "phy1tpt"; + }; + + status_led: led-2 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&pio 11 GPIO_ACTIVE_LOW>; + }; + }; + + watchdog { + compatible = "linux,wdt-gpio"; + gpios = <&pio 6 GPIO_ACTIVE_HIGH>; + hw_algo = "level"; + hw_margin_ms = <10000>; + always-running; + }; +}; + +&uart0 { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +ð { + pinctrl-names = "default"; + pinctrl-0 = <&mdio_pins>; + status = "okay"; + + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-handle = <&phy1>; + phy-mode = "2500base-x"; + + nvmem-cell-names = "mac-address"; + nvmem-cells = <&macaddr_bdinfo_de00 0>; + }; +}; + +&mdio_bus { + phy1: phy@1 { + reg = <1>; + interrupt-parent = <&pio>; + interrupts = <38 IRQ_TYPE_LEVEL_LOW>; + reset-gpios = <&pio 39 GPIO_ACTIVE_LOW>; + reset-assert-us = <100000>; + reset-deassert-us = <100000>; + }; +}; + +&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 = ; + }; + }; +}; + +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi0_flash_pins>; + status = "okay"; + + /* ESMT F50L2G41XA (256M) */ + 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 { + 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>; + }; + }; + }; + + partition@380000 { + label = "bdinfo"; + reg = <0x380000 0x40000>; + read-only; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr_bdinfo_de00: macaddr@de00 { + compatible = "mac-base"; + reg = <0xde00 0x6>; + #nvmem-cell-cells = <1>; + }; + }; + }; + + partition@3C0000 { + label = "fip"; + reg = <0x3C0000 0x200000>; + read-only; + }; + + partition@5C0000 { + label = "ubi"; + reg = <0x5C0000 0x4000000>; + }; + }; + }; +}; + +&wifi { + nvmem-cell-names = "eeprom"; + nvmem-cells = <&eeprom_factory_0>; + status = "okay"; +}; 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 12dca517127..d58a450a9d4 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 @@ -75,6 +75,7 @@ mediatek_setup_interfaces() ucidef_set_interfaces_lan_wan "lan1" eth1 ;; cudy,ap3000outdoor-v1|\ + cudy,ap3000-v1|\ cudy,re3000-v1|\ netgear,wax220|\ ubnt,unifi-6-plus|\ 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 3f5554d269f..3188fe71d5a 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 @@ -73,14 +73,11 @@ case "$board" in addr=$(mtd_get_mac_binary "Factory" 0x8000) [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress ;; - cudy,tr3000-v1|\ - cudy,re3000-v1) - addr=$(mtd_get_mac_binary bdinfo 0xde00) - [ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress - [ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress - ;; cudy,ap3000outdoor-v1|\ + cudy,ap3000-v1|\ cudy,m3000-v1|\ + cudy,re3000-v1|\ + cudy,tr3000-v1|\ cudy,wr3000s-v1|\ cudy,wr3000-v1) addr=$(mtd_get_mac_binary bdinfo 0xde00) diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 91706f8c73c..9815c8ce184 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -594,6 +594,23 @@ define Device/cudy_ap3000outdoor-v1 endef TARGET_DEVICES += cudy_ap3000outdoor-v1 +define Device/cudy_ap3000-v1 + DEVICE_VENDOR := Cudy + DEVICE_MODEL := AP3000 + DEVICE_VARIANT := v1 + DEVICE_DTS := mt7981b-cudy-ap3000-v1 + DEVICE_DTS_DIR := ../dts + SUPPORTED_DEVICES += R49 + UBINIZE_OPTS := -E 5 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 65536k + KERNEL_IN_UBI := 1 + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware +endef +TARGET_DEVICES += cudy_ap3000-v1 + define Device/cudy_m3000-v1 DEVICE_VENDOR := Cudy DEVICE_MODEL := M3000 From e0813dc071db32e848ba86ef9ae57510a54cd96f Mon Sep 17 00:00:00 2001 From: Jianyu Zhuang Date: Tue, 10 Dec 2024 15:38:20 +0800 Subject: [PATCH 6/7] mediatek: filogic: add support for Tenbay WR3000K MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tenbay WR3000K is an 802.11ax (Wi-Fi 6) router, based on MediaTek MT7981B. - SoC: MetiaTek MT7981B - RAM: Hynex H5TQ2G863GFR 512MiB - Flash: Winbond W25N01GVZEIG 128MiB - Wi-Fi: MediaTek MT7976C (2.4GHz/5GHz, 802.11ax, 2x2 MIMO, AX3000) - MediaTek MT7915E: 2.4GHz and 5GHz - Ethernet: 1x 10/100/1000 Mbps WAN + 3x 10/100/1000 Mbps LAN - Switch: MediaTek MT7531AE - UART: J4 (115200 baud) - LEDs: Power - Buttons: Reset, WPS - PWR: 12V/1A DC, 5.5×2.1 connector | Vendor | OpenWrt Interface | Address | Notes | |---------|-------------------|---------------|------------------------------------------------| | WAN | wan | Label MAC | Stored MAC in factory + offset 4, label MAC is Stored MAC - 2 | | LAN | br-lan | Label MAC+1 | | | 2.4GHz | phy0-ap0 | Label MAC + 2 | | | 5GHz | phy1-ap0 | Label MAC + 3 | | - 0x000000000000-0x000000100000 : "BL2" - 0x000000100000-0x000000180000 : "u-boot-env" - 0x000000180000-0x000000380000 : "Factory" - 0x000000380000-0x000000580000 : "FIP" - 0x000000580000-0x000003580000 : "ubi" - 0x000003580000-0x000006580000 : "ubi1" - 0x000006580000-0x0000065a0000 : "Product" - 0x0000065a0000-0x000007580000 : "Custom" - The original partition-Ubi partition-Ubi1 is an AB dual system, and Openwrt only uses Ubi. So flash requires modifying the uboot variable `boot_from=ubi` to ensure that it only starts from Ubi. - The Product and Custom partitions are original and only exist to align with the original layout; they are not used by OpenWrt. - id: 0, kernel - id: 1, rootfs - id: 2, rootfs_data - **USB-to-TTL Serial Adapter** (e.g., CH340 or CP2102). - **Dupont Wires** (male-to-male, 3 wires). - **PC/Laptop** with a serial communication tool. - Screwdriver (to open the router case). 1. **OpenWrt Firmware**: - Download the appropriate `wr3000k--mediatek-filogic-tenbay_wr3000k-squashfs-sysupgrade.bin` firmware file for your router from the [OpenWrt website](https://openwrt.org/). 2. **Serial Communication Tool**: - Windows: PuTTY, Tera Term. - Linux/Mac: Minicom, screen. 3. (Optional) **TFTP Server**: - Install a TFTP server like Tftpd64 or tftp-hpa. --- 1. Open the router casing and locate the **TX, RX, and GND** pins. 2. Connect the router pins to the USB-to-TTL adapter as follows: - **TX (router)** → **RX (adapter)** - **RX (router)** → **TX (adapter)** - **GND (router)** → **GND (adapter)** 3. Do **not** connect the VCC pin to avoid damage. - **Baud rate**: 115200 - **Data bits**: 8 - **Stop bits**: 1 - **Parity**: None - **Flow control**: None --- 1. Power on the router and observe the serial terminal output. 2. When prompted (e.g., `Hit any key to stop autoboot: 3`), press the '/' key quickly to interrupt the boot process. 3. You will see the U-Boot Boot Menu: ```plaintext *** U-Boot Boot Menu *** 1. Factory mode 2. Startup system (Default) 3. Upgrade firmware 4. Upgrade ATF BL2 5. Upgrade ATF FIP 6. Upgrade single image 7. Load image 0. U-Boot console Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit ``` 4. Select Option 0 by typing 0 and pressing Enter. 5. Input into ```plaintext MT7981> setenv boot_from ubi MT7981> saveenv Saving Environment to MTD... Erasing on MTD device 'nmbm0'... OK Writing to MTD device 'nmbm0'... OK OK MT7981> printenv baudrate=115200 boot_from=ubi ... ``` the above indicates system will start from *ubi*. and then type ```plaintext MT7981> reset ``` will boot from *ubi* 1. Power on the router and observe the serial terminal output. 2. When prompted (e.g., `Hit any key to stop autoboot: 3`), press the '/' key quickly to interrupt the boot process. 3. You will see the U-Boot Boot Menu: ```plaintext *** U-Boot Boot Menu *** 1. Factory mode 2. Startup system (Default) 3. Upgrade firmware 4. Upgrade ATF BL2 5. Upgrade ATF FIP 6. Upgrade single image 7. Load image 0. U-Boot console Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit ``` 4. Choose Option 3: Upgrade Firmware Enter Upgrade Mode Select Option 3 by typing 3 and pressing Enter. Upgrade Methods You will be prompted to choose between: ```plaintext *** Upgrading Firmware *** Run image after upgrading? (Y/n): y Available load methods: 0 - TFTP client (Default) 1 - Xmodem 2 - Ymodem 3 - Kermit 4 - S-Record 5 - RAM Select (enter for default): 0 Input U-Boot's IP address: 192.168.1.1 Input TFTP server's IP address: 192.168.1.10 Input IP netmask: 255.255.255.0 Input file name: wr3000k--mediatek-filogic-tenbay_wr3000k-squashfs-sysupgrade.bin ``` Type Enter to proceed. The router will erase the old firmware and write the new one. Signed-off-by: Jianyu Zhuang Link: https://github.com/openwrt/openwrt/pull/17172 Signed-off-by: Hauke Mehrtens --- .../uboot-envtools/files/mediatek_filogic | 1 + .../mediatek/dts/mt7981b-tenbay-wr3000k.dts | 249 ++++++++++++++++++ .../filogic/base-files/etc/board.d/02_network | 3 +- target/linux/mediatek/image/filogic.mk | 21 ++ 4 files changed, 273 insertions(+), 1 deletion(-) create mode 100644 target/linux/mediatek/dts/mt7981b-tenbay-wr3000k.dts diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic index d0a15e34736..9d7c5a1527b 100644 --- a/package/boot/uboot-envtools/files/mediatek_filogic +++ b/package/boot/uboot-envtools/files/mediatek_filogic @@ -107,6 +107,7 @@ glinet,gl-mt3000) ;; mercusys,mr90x-v1|\ routerich,ax3000|\ +tenbay,wr3000k|\ tplink,re6000xd) 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-tenbay-wr3000k.dts b/target/linux/mediatek/dts/mt7981b-tenbay-wr3000k.dts new file mode 100644 index 00000000000..2ae16673afa --- /dev/null +++ b/target/linux/mediatek/dts/mt7981b-tenbay-wr3000k.dts @@ -0,0 +1,249 @@ +// SPDX-License-Identifier: (GPL-2.0 OR MIT) + +/dts-v1/; +#include "mt7981.dtsi" + +/ { + model = "Tenbay WR3000K"; + compatible = "tenbay,wr3000k", "mediatek,mt7981"; + + aliases { + led-boot = &led_run; + led-failsafe = &led_blue; + led-running = &led_green; + led-upgrade = &led_blue; + serial0 = &uart0; + label-mac-device = &wan; + }; + + chosen { + stdout-path = "serial0:115200n8"; + }; + + gpio-keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&pio 1 GPIO_ACTIVE_LOW>; + }; + + wps { + label = "wps"; + linux,code = ; + gpios = <&pio 0 GPIO_ACTIVE_LOW>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led_run: led-0 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&pio 10 GPIO_ACTIVE_LOW>; + }; + + led_green: led-1 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&pio 11 GPIO_ACTIVE_LOW>; + }; + + led_blue: led-2 { + color = ; + function = LED_FUNCTION_STATUS; + gpios = <&pio 12 GPIO_ACTIVE_LOW>; + }; + }; +}; + +&uart0 { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +ð { + pinctrl-names = "default"; + pinctrl-0 = <&mdio_pins>; + status = "okay"; + + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; + nvmem-cells = <&macaddr_factory_4 (-1)>; + nvmem-cell-names = "mac-address"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; +}; + +&mdio_bus { + switch: switch@1f { + compatible = "mediatek,mt7531"; + reg = <31>; + reset-gpios = <&pio 39 GPIO_ACTIVE_HIGH>; + interrupt-controller; + #interrupt-cells = <1>; + interrupt-parent = <&pio>; + interrupts = <38 IRQ_TYPE_LEVEL_HIGH>; + }; +}; + +&switch { + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan1"; + }; + + port@1 { + reg = <1>; + label = "lan2"; + }; + + port@2 { + reg = <2>; + label = "lan3"; + }; + + wan: port@3 { + reg = <3>; + label = "wan"; + nvmem-cells = <&macaddr_factory_4 (-2)>; + nvmem-cell-names = "mac-address"; + }; + + port@6 { + reg = <6>; + ethernet = <&gmac0>; + phy-mode = "2500base-x"; + + fixed-link { + speed = <2500>; + full-duplex; + pause; + }; + }; + }; +}; + +&spi0 { + pinctrl-names = "default"; + pinctrl-0 = <&spi0_flash_pins>; + status = "okay"; + + flash@0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "spi-nand"; + reg = <0>; + spi-max-frequency = <52000000>; + + 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>; + + spi-tx-bus-width = <4>; + spi-rx-bus-width = <4>; + 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 { + label = "BL2"; + reg = <0x00000 0x0100000>; + read-only; + }; + + partition@100000 { + label = "u-boot-env"; + reg = <0x0100000 0x0080000>; + }; + + factory: partition@180000 { + label = "Factory"; + reg = <0x180000 0x0200000>; + 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 0x0200000>; + read-only; + }; + + partition@580000 { + label = "ubi"; + compatible = "linux,ubi"; + reg = <0x580000 0x3000000>; + }; + + partition@3580000 { + label = "ubi1"; + reg = <0x3580000 0x3000000>; + }; + + partition@6580000 { + label = "Product"; + reg = <0x6580000 0x0020000>; // 128 KB + }; + + partition@65a0000 { + label = "Custom"; + reg = <0x65a0000 0x1000000>; // 16 MB + }; + }; + }; +}; + +&pio { + spi0_flash_pins: spi0-pins { + mux { + function = "spi"; + groups = "spi0", "spi0_wp_hold"; + }; + }; +}; + +&wifi { + nvmem-cells = <&eeprom_factory_0>; + nvmem-cell-names = "eeprom"; + status = "okay"; +}; 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 d58a450a9d4..0d0ee526178 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 @@ -36,7 +36,8 @@ mediatek_setup_interfaces() keenetic,kn-3811|\ qihoo,360t7|\ routerich,ax3000|\ - routerich,ax3000-ubootmod) + routerich,ax3000-ubootmod|\ + tenbay,wr3000k) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" wan ;; asus,tuf-ax4200|\ diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 9815c8ce184..235971d1942 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -1368,6 +1368,27 @@ define Device/ruijie_rg-x60-pro endef TARGET_DEVICES += ruijie_rg-x60-pro +define Device/tenbay_wr3000k + DEVICE_VENDOR := Tenbay + DEVICE_MODEL := WR3000K + DEVICE_DTS := mt7981b-tenbay-wr3000k + DEVICE_DTS_DIR := ../dts + DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware + UBINIZE_OPTS := -E 5 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 49152k + KERNEL_IN_UBI := 1 + IMAGES += factory.bin + IMAGE/factory.bin := append-ubi | check-size $$$$(IMAGE_SIZE) + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + KERNEL = kernel-bin | lzma | \ + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb + KERNEL_INITRAMFS = kernel-bin | lzma | \ + fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd +endef +TARGET_DEVICES += tenbay_wr3000k + define Device/tplink_re6000xd DEVICE_VENDOR := TP-Link DEVICE_MODEL := RE6000XD From 4585d5abd9b77fa9ef794407c5dedcbc4001c869 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Sun, 22 Dec 2024 16:41:11 +0100 Subject: [PATCH 7/7] kernel: generic: netfilter: nft_set_hash: unaligned atomic read on struct nft_set_ext Fix kernel panic on some 64 bit architectures. This patch is pending upstream. https://patchwork.ozlabs.org/project/netfilter-devel/patch/20241222100239.336289-1-pablo@netfilter.org/ Fixes: https://github.com/openwrt/openwrt/issues/17336 Link: https://github.com/openwrt/openwrt/pull/17340 Signed-off-by: Hauke Mehrtens --- ...t_hash-unaligned-atomic-read-on-stru.patch | 87 +++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 target/linux/generic/pending-6.6/605-netfilter-nft_set_hash-unaligned-atomic-read-on-stru.patch diff --git a/target/linux/generic/pending-6.6/605-netfilter-nft_set_hash-unaligned-atomic-read-on-stru.patch b/target/linux/generic/pending-6.6/605-netfilter-nft_set_hash-unaligned-atomic-read-on-stru.patch new file mode 100644 index 00000000000..61e163293e2 --- /dev/null +++ b/target/linux/generic/pending-6.6/605-netfilter-nft_set_hash-unaligned-atomic-read-on-stru.patch @@ -0,0 +1,87 @@ +From 113fb8a8d1f27156f58b27ce0fc02af9b3705bf7 Mon Sep 17 00:00:00 2001 +From: Pablo Neira Ayuso +Date: Sun, 22 Dec 2024 11:02:39 +0100 +Subject: [PATCH] netfilter: nft_set_hash: unaligned atomic read on struct + nft_set_ext + +Access to genmask field in struct nft_set_ext results in unaligned +atomic read: + +[ 72.130109] Unable to handle kernel paging request at virtual address ffff0000c2bb708c +[ 72.131036] Mem abort info: +[ 72.131213] ESR = 0x0000000096000021 +[ 72.131446] EC = 0x25: DABT (current EL), IL = 32 bits +[ 72.132209] SET = 0, FnV = 0 +[ 72.133216] EA = 0, S1PTW = 0 +[ 72.134080] FSC = 0x21: alignment fault +[ 72.135593] Data abort info: +[ 72.137194] ISV = 0, ISS = 0x00000021, ISS2 = 0x00000000 +[ 72.142351] CM = 0, WnR = 0, TnD = 0, TagAccess = 0 +[ 72.145989] GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0 +[ 72.150115] swapper pgtable: 4k pages, 48-bit VAs, pgdp=0000000237d27000 +[ 72.154893] [ffff0000c2bb708c] pgd=0000000000000000, p4d=180000023ffff403, pud=180000023f84b403, pmd=180000023f835403, ++pte=0068000102bb7707 +[ 72.163021] Internal error: Oops: 0000000096000021 [#1] SMP +[...] +[ 72.170041] CPU: 7 UID: 0 PID: 54 Comm: kworker/7:0 Tainted: G E 6.13.0-rc3+ #2 +[ 72.170509] Tainted: [E]=UNSIGNED_MODULE +[ 72.170720] Hardware name: QEMU QEMU Virtual Machine, BIOS edk2-stable202302-for-qemu 03/01/2023 +[ 72.171192] Workqueue: events_power_efficient nft_rhash_gc [nf_tables] +[ 72.171552] pstate: 21400005 (nzCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--) +[ 72.171915] pc : nft_rhash_gc+0x200/0x2d8 [nf_tables] +[ 72.172166] lr : nft_rhash_gc+0x128/0x2d8 [nf_tables] +[ 72.172546] sp : ffff800081f2bce0 +[ 72.172724] x29: ffff800081f2bd40 x28: ffff0000c2bb708c x27: 0000000000000038 +[ 72.173078] x26: ffff0000c6780ef0 x25: ffff0000c643df00 x24: ffff0000c6778f78 +[ 72.173431] x23: 000000000000001a x22: ffff0000c4b1f000 x21: ffff0000c6780f78 +[ 72.173782] x20: ffff0000c2bb70dc x19: ffff0000c2bb7080 x18: 0000000000000000 +[ 72.174135] x17: ffff0000c0a4e1c0 x16: 0000000000003000 x15: 0000ac26d173b978 +[ 72.174485] x14: ffffffffffffffff x13: 0000000000000030 x12: ffff0000c6780ef0 +[ 72.174841] x11: 0000000000000000 x10: ffff800081f2bcf8 x9 : ffff0000c3000000 +[ 72.175193] x8 : 00000000000004be x7 : 0000000000000000 x6 : 0000000000000000 +[ 72.175544] x5 : 0000000000000040 x4 : ffff0000c3000010 x3 : 0000000000000000 +[ 72.175871] x2 : 0000000000003a98 x1 : ffff0000c2bb708c x0 : 0000000000000004 +[ 72.176207] Call trace: +[ 72.176316] nft_rhash_gc+0x200/0x2d8 [nf_tables] (P) +[ 72.176653] process_one_work+0x178/0x3d0 +[ 72.176831] worker_thread+0x200/0x3f0 +[ 72.176995] kthread+0xe8/0xf8 +[ 72.177130] ret_from_fork+0x10/0x20 +[ 72.177289] Code: 54fff984 d503201f d2800080 91003261 (f820303f) +[ 72.177557] ---[ end trace 0000000000000000 ]--- + +Align struct nft_set_ext to word size to address this and +documentation it. + +pahole reports that this increases the size of elements for rhash and +pipapo in 8 bytes on x86_64. + +Fixes: 7ffc7481153b ("netfilter: nft_set_hash: skip duplicated elements pending gc run") +Signed-off-by: Pablo Neira Ayuso +--- + include/net/netfilter/nf_tables.h | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +--- a/include/net/netfilter/nf_tables.h ++++ b/include/net/netfilter/nf_tables.h +@@ -721,15 +721,18 @@ struct nft_set_ext_tmpl { + /** + * struct nft_set_ext - set extensions + * +- * @genmask: generation mask ++ * @genmask: generation mask, but also flags (see NFT_SET_ELEM_DEAD_BIT) + * @offset: offsets of individual extension types + * @data: beginning of extension data ++ * ++ * This structure must be aligned to word size, otherwise atomic bitops ++ * on genmask field can cause aligment failure on some archs. + */ + struct nft_set_ext { + u8 genmask; + u8 offset[NFT_SET_EXT_NUM]; + char data[]; +-}; ++} __aligned(BITS_PER_LONG / 8); + + static inline void nft_set_ext_prepare(struct nft_set_ext_tmpl *tmpl) + {