]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
mediatek: filogic: add support for TP-Link Festa FR365 19203/head
authorYonghyu Ban <yhban@silicon.moe>
Wed, 19 Mar 2025 08:29:04 +0000 (17:29 +0900)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 12 Jul 2025 18:21:43 +0000 (20:21 +0200)
Hardware
--------
SOC     : MediaTek MT7981B 2x A53
RAM     : NT5AD256M16E4-JR 512MiB
Flash   : ESMT F50L1G41LB 128MB
ETH     : 5x 1GbE (1x WAN, 4x LAN)
          1x SFP+ (2.5 GbE)
Switch  : MediaTek MT7531AE
WiFi    : MediaTek MT7976D
Buttons : Reset
Power   : DC 12V 2A

Installation
------------
1. Disassemble the device
2. Create solder bridge on R85, R86, Solder 4-pin header on J4.
3. Connect UART console.
4. In U-Boot shell, enter the following commands to prepare flashing
```
enable_phy
extra_para set extra-para score 100
extra_para set extra-para fwFlag good
```
5. Use `mtkupgrade` command to TFTP flash openwrt-mediatek-filogic-tplink_fr365-v1-squashfs-factory.bin
6. Reboot the device

Signed-off-by: Yonghyu Ban <yhban@silicon.moe>
Link: https://github.com/openwrt/openwrt/pull/19203
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
target/linux/mediatek/dts/mt7981b-tplink-fr365v1.dts [new file with mode: 0644]
target/linux/mediatek/filogic/base-files/etc/board.d/01_leds
target/linux/mediatek/filogic/base-files/etc/board.d/02_network
target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
target/linux/mediatek/filogic/base-files/lib/preinit/09_mount_cfg_part
target/linux/mediatek/filogic/base-files/lib/preinit/10_fix_eth_mac.sh
target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
target/linux/mediatek/image/filogic.mk

diff --git a/target/linux/mediatek/dts/mt7981b-tplink-fr365v1.dts b/target/linux/mediatek/dts/mt7981b-tplink-fr365v1.dts
new file mode 100644 (file)
index 0000000..af6fa90
--- /dev/null
@@ -0,0 +1,406 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/leds/common.h>
+
+#include "mt7981b.dtsi"
+
+/ {
+       model = "TP-Link FR365 v1";
+       compatible = "tplink,fr365-v1", "mediatek,mt7981";
+
+       aliases {
+               serial0 = &uart0;
+               led-boot = &led_status;
+               led-failsafe = &led_status;
+               led-running = &led_status;
+               led-upgrade = &led_status;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       memory {
+               reg = <0 0x40000000 0 0x20000000>;
+       };
+
+       gpio-keys {
+               compatible = "gpio-keys";
+
+               reset {
+                       label = "reset";
+                       linux,code = <KEY_RESTART>;
+                       gpios = <&pio 1 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               led_status: led_status {
+                       function = LED_FUNCTION_STATUS;
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&pio 4 GPIO_ACTIVE_LOW>;
+               };
+
+               led_usb: led_usb {
+                       function = LED_FUNCTION_USB;
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&pio 9 GPIO_ACTIVE_LOW>;
+               };
+
+               led_sfp: led_sfp {
+                       label = "green:sfp";
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&pio 5 GPIO_ACTIVE_LOW>;
+               };
+
+               led_wlan: led_wlan {
+                       function = LED_FUNCTION_WLAN;
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&pio 34 GPIO_ACTIVE_LOW>;
+               };
+
+               led_port2_act: led_port2_act {
+                       label = "green:port2_act";
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&pio 8 GPIO_ACTIVE_LOW>;
+               };
+
+               led_port2_linespeed: led_port2_linespeed {
+                       label = "green:port2_linespeed";
+                       color = <LED_COLOR_ID_GREEN>;
+                       gpios = <&pio 13 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       usb_vbus: regulator-usb-vbus {
+               compatible = "regulator-fixed";
+               regulator-name = "usb_vbus";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               gpios = <&pio 12 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+               regulator-boot-on;
+       };
+
+       sfp1: sfp-1 {
+               compatible = "sff,sfp";
+               i2c-bus = <&i2c0>;
+               los-gpios = <&pio 11 GPIO_ACTIVE_HIGH>;
+               mod-def0-gpios = <&pio 0 GPIO_ACTIVE_LOW>;
+               maximum-power-milliwatt = <3000>;
+               tx-disable-gpios = <&pio 10 GPIO_ACTIVE_HIGH>;
+       };
+};
+
+&eth {
+       status = "okay";
+
+       gmac0: mac@0 {
+               compatible = "mediatek,eth-mac";
+               reg = <0>;
+               phy-mode = "2500base-x";
+
+               fixed-link {
+                       speed = <2500>;
+                       full-duplex;
+               };
+       };
+
+       gmac1: mac@1 {
+               compatible = "mediatek,eth-mac";
+               reg = <1>;
+               phy-mode = "gmii";
+               phy-handle = <&int_gbe_phy>;
+               label = "port2";
+       };
+};
+
+&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>;
+       };
+};
+
+&spi0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&spi0_flash_pins>;
+       status = "okay";
+
+       spi_nand@0 {
+               compatible = "spi-nand";
+               #address-cells = <1>;
+               #size-cells = <1>;
+               reg = <0>;
+
+               spi-max-frequency = <52000000>;
+               spi-tx-bus-width = <4>;
+               spi-rx-bus-width = <4>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "bl2";
+                               reg = <0x0000000 0x0100000>;
+                               read-only;
+                       };
+
+                       partition@100000 {
+                               label = "u-boot-env";
+                               reg = <0x0100000 0x0080000>;
+                       };
+
+                       partition@180000 {
+                               label = "Factory";
+                               reg = <0x0180000 0x0200000>;
+                               read-only;
+                       };
+
+                       partition@380000 {
+                               label = "fip";
+                               reg = <0x0380000 0x0200000>;
+                               read-only;
+                       };
+
+                       partition@580000 {
+                               label = "ubi";
+                               reg = <0x0580000 0x2400000>;
+                               compatible = "linux,ubi";
+
+                               volumes {
+                                       ubi_rootdisk: ubi-volume-fit {
+                                               volname = "kernel";
+                                       };
+                               };
+                       };
+
+                       partition@2980000 {
+                               label = "ubi.b";
+                               reg = <0x2980000 0x2400000>;
+
+                               volumes {
+                                       ubi_rootdisk_2: ubi-volume-fit {
+                                               volname = "kernel";
+                                       };
+                               };
+                       };
+
+                       partition@4d80000 {
+                               label = "support-list";
+                               reg = <0x4d80000 0x0020000>;
+                               read-only;
+                       };
+
+                       partition@4da0000 {
+                               label = "user-config";
+                               reg = <0x4da0000 0x0a00000>;
+                               read-only;
+                       };
+
+                       partition@57a0000 {
+                               label = "partition-table";
+                               reg = <0x57a0000 0x0020000>;
+                               read-only;
+                       };
+
+                       partition@57c0000 {
+                               label = "device-info";
+                               reg = <0x57c0000 0x0020000>;
+                               read-only;
+                       };
+
+                       partition@57e0000 {
+                               label = "device-info.b";
+                               reg = <0x57e0000 0x0020000>;
+                               read-only;
+                       };
+
+                       partition@5800000 {
+                               label = "tddp";
+                               reg = <0x5800000 0x0020000>;
+                               read-only;
+                       };
+
+                       partition@5820000 {
+                               label = "tddp.b";
+                               reg = <0x5820000 0x0020000>;
+                               read-only;
+                       };
+
+                       partition@5840000 {
+                               label = "extra-para-ubi";
+                               reg = <0x5840000 0x0200000>;
+                       };
+
+                       partition@5a40000 {
+                               label = "firmware-info";
+                               reg = <0x5a40000 0x0020000>;
+                               read-only;
+                       };
+
+                       partition@5a60000 {
+                               label = "firmware-info.b";
+                               reg = <0x5a60000 0x0020000>;
+                               read-only;
+                       };
+
+                       partition@5a80000 {
+                               label = "log";
+                               reg = <0x5a80000 0x0200000>;
+                               read-only;
+                       };
+
+                       partition@5c80000 {
+                               label = "log.b";
+                               reg = <0x5c80000 0x0200000>;
+                               read-only;
+                       };
+
+                       partition@5e80000 {
+                               label = "wlan";
+                               reg = <0x5e80000 0x0500000>;
+                               read-only;
+                       };
+
+                       partition@6380000 {
+                               label = "wlan.b";
+                               reg = <0x6380000 0x0500000>;
+                               read-only;
+                       };
+
+                       partition@6880000 {
+                               label = "database";
+                               reg = <0x6880000 0x1100000>;
+                               read-only;
+                       };
+
+                       partition@7980000 {
+                               label = "log_recovery";
+                               reg = <0x7980000 0x0080000>;
+                               read-only;
+                       };
+
+                       partition@7a00000 {
+                               label = "panic-oops";
+                               reg = <0x7a00000 0x0080000>;
+                               read-only;
+                       };
+               };
+       };
+};
+
+&switch {
+       ports {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               port@0 {
+                       reg = <0>;
+                       label = "port3";
+               };
+
+               port@1 {
+                       reg = <1>;
+                       label = "port4";
+               };
+
+               port@2 {
+                       reg = <2>;
+                       label = "port5";
+               };
+
+               port@3 {
+                       reg = <3>;
+                       label = "port6";
+               };
+
+               port@5 {
+                       reg = <5>;
+                       label = "port1";
+                       phy-mode = "2500base-x";
+                       managed = "in-band-status";
+                       sfp = <&sfp1>;
+               };
+
+               port@6 {
+                       reg = <6>;
+                       ethernet = <&gmac0>;
+                       phy-mode = "2500base-x";
+
+                       fixed-link {
+                               speed = <2500>;
+                               full-duplex;
+                       };
+               };
+       };
+};
+
+&pio {
+       i2c0_pins: i2c0-pins {
+               mux {
+                       function = "i2c";
+                       groups = "i2c0_1";
+               };
+       };
+
+       spi0_flash_pins: spi0-pins {
+               mux {
+                       function = "spi";
+                       groups = "spi0", "spi0_wp_hold";
+               };
+
+               conf-pu {
+                       pins = "SPI0_CS", "SPI0_HOLD", "SPI0_WP";
+                       drive-strength = <8>;
+                       mediatek,pull-up-adv = <0>; /* bias-disable */
+               };
+
+               conf-pd {
+                       pins = "SPI0_CLK", "SPI0_MOSI", "SPI0_MISO";
+                       drive-strength = <8>;
+                       mediatek,pull-up-adv = <0>; /* bias-disable */
+               };
+       };
+};
+
+&i2c0 {
+       pinctrl-names = "default";
+       clock-frequency = <400000>;
+       pinctrl-0 = <&i2c0_pins>;
+       status = "okay";
+};
+
+&uart0 {
+       status = "okay";
+};
+
+&watchdog {
+       status = "okay";
+};
+
+&xhci {
+       status = "okay";
+       vbus-supply = <&usb_vbus>;
+       mediatek,u3p-dis-msk = <0x01>;
+};
+
+&usb_phy {
+       status = "okay";
+};
+
+&wifi {
+       status = "okay";
+};
index 19e815b415a62a633b2d536b4c3cb957fe74f1ea..53df9106f2d9cfe6fc8758aa82343301737ec5ba 100644 (file)
@@ -184,6 +184,11 @@ smartrg,sdg-8733a)
        ucidef_set_led_netdev "wan-orange" "WAN" "mdio-bus:08:orange:wan" "wan" "link_100 link_1000"
        ucidef_set_led_netdev "wan-white" "WAN" "mdio-bus:08:white:wan" "wan" "link_10000"
        ;;
+tplink,fr365-v1)
+       ucidef_set_led_netdev "port2-green-act" "port-2" "green:port2_act" "port2" "link tx rx"
+       ucidef_set_led_netdev "port1-green-act" "port-1" "green:sfp" "port1" "link tx rx"
+       ucidef_set_led_netdev "wlan" "wlan" "green:wlan" "phy1-ap0"
+       ;;
 tplink,re6000xd)
        ucidef_set_led_netdev "lan-1" "lan-1" "blue:lan-0" "lan1" "link tx rx"
        ucidef_set_led_netdev "lan-2" "lan-2" "blue:lan-1" "lan2" "link tx rx"
index 17fb2bddd1c9e70516aafbaf75784ea5e987f625..453594c5e05bcc5cc5f3b62b690a9c51df8a78f0 100644 (file)
@@ -133,6 +133,9 @@ mediatek_setup_interfaces()
        mercusys,mr90x-v1-ubi)
                ucidef_set_interfaces_lan_wan "lan0 lan1 lan2" eth1
                ;;
+       tplink,fr365-v1)
+               ucidef_set_interfaces_lan_wan "port1 port3 port4 port5 port6" "port2"
+               ;;
        tplink,tl-xdr6086|\
        wavlink,wl-wn586x3)
                ucidef_set_interfaces_lan_wan "lan1 lan2" eth1
@@ -212,6 +215,10 @@ mediatek_setup_macs()
                wan_mac=$label_mac
                lan_mac=$(macaddr_add "$label_mac" 1)
                ;;
+       tplink,fr365-v1)
+               lan_mac=$(strings /dev/mtd11 | grep 'option macaddr' | awk -F"'" '{print $2}')
+               wan_mac="$(macaddr_add $lan_mac 1)"
+               ;;
        xiaomi,mi-router-ax3000t|\
        xiaomi,mi-router-ax3000t-ubootmod|\
        xiaomi,mi-router-wr30u-stock|\
index 1d9db845db68602bf53c15d7ff1efe2314b4dca6..bfc051116441c3675a0a6f334c3dd2650a4a4eb0 100644 (file)
@@ -13,6 +13,9 @@ case "$FIRMWARE" in
                ln -sf /tmp/tp_data/MT7981_EEPROM.bin \
                        /lib/firmware/$FIRMWARE
                ;;
+       tplink,fr365-v1)
+               ln -sf /tmp/wlan/radio /lib/firmware/$FIRMWARE
+               ;;
        ubnt,unifi-6-plus)
                caldata_extract_mmc "factory" 0x0 0x1000
                ;;
index b447dbdfe3ec69170b3537a9357d8975504a445a..04ec47ee140239b6efd71bd52582ed7f1acd589a 100644 (file)
@@ -170,6 +170,11 @@ case "$board" in
                [ "$PHYNBR" = "0" ] && macaddr_add $addr 2 > /sys${DEVPATH}/macaddress
                [ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
                ;;
+       tplink,fr365-v1)
+               addr=$(strings /dev/mtd11 | grep 'option macaddr' | awk -F"'" '{print $2}')
+               [ "$PHYNBR" = "0" ] && echo $addr > /sys${DEVPATH}/macaddress
+               [ "$PHYNBR" = "1" ] && macaddr_add $addr 1 > /sys${DEVPATH}/macaddress
+               ;;
        tplink,tl-xdr4288|\
        tplink,tl-xdr6086|\
        tplink,tl-xdr6088)
index ddbb1d129370d919147d326eb79907b769d29fcc..1ef2c7c267c86ccf50adf4acf955252021bfec69 100644 (file)
@@ -19,6 +19,9 @@ preinit_mount_cfg_part() {
        tplink,re6000xd)
                mount_ubi_part "tp_data" "tp_data"
                ;;
+       tplink,fr365-v1)
+               mount_ubi_part "wlan" "ubi_wlan_factory_data"
+               ;;
        *)
                ;;
        esac
index 936ed44ff9667c38a81064acce25bbba835cdec5..5b9e5bd7ad79bdd5dda732a8a74527b977219692 100644 (file)
@@ -33,6 +33,16 @@ preinit_set_mac_address() {
                addr=$(get_mac_binary "/tmp/tp_data/default-mac" 0)
                ip link set dev eth1 address "$(macaddr_add $addr 1)"
                ;;
+       tplink,fr365-v1)
+               lan_mac=$(strings /dev/mtd11 | grep 'option macaddr' | awk -F"'" '{print $2}')
+               wan_mac="$(macaddr_add $lan_mac 1)"
+               ip link set dev port2 address "$wan_mac"
+               ip link set dev port1 address "$lan_mac"
+               ip link set dev port3 address "$lan_mac"
+               ip link set dev port4 address "$lan_mac"
+               ip link set dev port5 address "$lan_mac"
+               ip link set dev port6 address "$lan_mac"
+               ;;
        *)
                ;;
        esac
index 2a05b9b10c9db3ba8acf9f6c91dde503a5710d37..e08e265ab323e84d27f3a004353d1690d98bf3cf 100755 (executable)
@@ -153,6 +153,12 @@ platform_do_upgrade() {
                CI_UBIPART="ubi0"
                nand_do_upgrade "$1"
                ;;
+       tplink,fr365-v1)
+               CI_UBIPART="ubi"
+               CI_KERNPART="kernel"
+               CI_ROOTPART="rootfs"
+               nand_do_upgrade "$1"
+               ;;
        nradio,c8-668gl)
                CI_DATAPART="rootfs_data"
                CI_KERNPART="kernel_2nd"
index 653046321315080039dc32fe22a905eeb40f312b..97092e36e91a8d478bbde3fe472970f5c4a7ff01 100644 (file)
@@ -1760,6 +1760,26 @@ define Device/tplink_re6000xd
 endef
 TARGET_DEVICES += tplink_re6000xd
 
+define Device/tplink_fr365-v1
+  DEVICE_VENDOR := TP-Link
+  DEVICE_MODEL := FR365
+  DEVICE_VARIANT := v1
+  DEVICE_DTS := mt7981b-tplink-fr365v1
+  DEVICE_DTS_DIR := ../dts
+  UBINIZE_OPTS := -E 5
+  BLOCKSIZE := 128k
+  PAGESIZE := 2048
+  IMAGE_SIZE := 32768k
+  KERNEL_IN_UBI := 1
+  IMAGES += factory.bin
+  KERNEL_INITRAMFS := kernel-bin | lzma | \
+        fit lzma $$(KDIR)/image-$$(firstword $$(DEVICE_DTS)).dtb with-initrd | pad-to 64k
+  IMAGE/factory.ubi := append-ubi | check-size $$$$(IMAGE_SIZE)
+  IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata
+  DEVICE_PACKAGES := fitblk kmod-sfp kmod-usb3 kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware
+endef
+TARGET_DEVICES += tplink_fr365-v1
+
 define Device/tplink_tl-xdr-common
   DEVICE_VENDOR := TP-Link
   DEVICE_DTS_DIR := ../dts