From patchwork Sun Nov 26 15:11:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enrico Mioso X-Patchwork-Id: 1868538 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=uD+LNZWJ; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=BvTXb2Vn; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4SdXQ90cR3z1ySK for ; Mon, 27 Nov 2023 02:17:20 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jbzHMgTcUzMlUnhnjXz7Dxo7rkO/ABdjBCTTG6mh938=; b=uD+LNZWJE1ZAuc ikQDXbNWjPUn6Vtm9FQOtj6DoL+y4NMzfI9peOGlEayIv9jJKTx6iLD5vM1qlMsGmfE22H75FTzB8 if1R4H80CxT8JzdtmaYbVzKJIbnD3rHYdbV2kbahMb4kbO/ditxdUsvRJAO2r3K+LxCDzHwb+FX4j Fn+k0X7Gb7Kq9hUCtneqk0q1OwdVFBMl3QG46cHxgxUWO0jKk1Z5+GUSDSBZuYPk5IdxzHKQ93M7L wEdRR0QOGoIdPoq0JOJv3hXgPpheK4OSylTcxFhcoJf3n8nuU5O7jV5oWN7HFvOQzRwxBazi0mFre OC05F0r3ZhBfNypB50bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1r7GpP-00CBtq-0F; Sun, 26 Nov 2023 15:13:47 +0000 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1r7GpJ-00CBpy-2F for openwrt-devel@lists.openwrt.org; Sun, 26 Nov 2023 15:13:43 +0000 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a00cbb83c82so486753066b.2 for ; Sun, 26 Nov 2023 07:13:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701011618; x=1701616418; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=TS0Ql7NYL6If1YFjSA/xp9lnxeL3a+nBHufd4kU8kmQ=; b=BvTXb2Vn5/VY99Jsc4b/tWWn4+6yRaqZ58FqqwkUfLadgs5OFWVwFgg4sz6kK7Ubbq Pbv9F2RWyNU0ackyezJB6LRlO+6m6aGYfh+oVz0wyFuJAptOjpCq/c+cXffXHAjN6R7O zKsxl9eD3pHSuszagaq+qpVn/RLkv/m44ZrZbx69Z+4h+VA0yRQUPnhEcJbMg4tzNIv2 LSNP7/8yrU9lKPyrvjMV4zhkqWdycMLwsMyLBLwMNQHrvndK9dlRU7s8k/IU7vcqOUHz nl7dBQQsHwRy8B7kCRzlHjM7FwI/TZs7jYDY3WfNuhR8Tks+DCxMDWHAEFDiYgi847wy dlxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701011618; x=1701616418; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=TS0Ql7NYL6If1YFjSA/xp9lnxeL3a+nBHufd4kU8kmQ=; b=eBGOy80mZ9qMAA5TrioRqkY6uvvc8fg+LFKZp3oj1X74brsqxe+Ar6cBIVA5HlPvGf 9+U5ULRivdxtpz3K3NDEVD3jv8E5K9L86cWEvTp3Viz2aIoaU42xZup2/kTjgfhv8NTI p7ekqvdMAGI9sENyFkVVJwWelxx2qufGQ1EhQ3LtQFEkrCHlYNLxwkyMOTeSaEG9+Eq8 KMxRlGEgIZ2sqV52EfuNLu1Gq7AdpBJLgtQ8Xqr3saL3dorAMLAHxaHEnpFii8hGjUk/ pfbZFSZcWqz+4KBfoNAXmXWr05SvnIPs+v0JEbZCf/VeeUGYOWoSo7Oq+KnIFrqOMPW9 X/Xw== X-Gm-Message-State: AOJu0Yxz4kpqbezkVyA+F6kcVKHiidQkV58AEktvQuA4KEn4snW6Jrqk Rh9gs7nAiAomijqDUuk75ReaeODPu+4dEA== X-Google-Smtp-Source: AGHT+IGX40XuLP5L4bp4mU7wMENyKlzxzDzSeRTwZoXmWK8Z9Wf4ICtpmw7jwtEbiVuGtjac9g8GiQ== X-Received: by 2002:a17:906:27d9:b0:9e3:f97b:239e with SMTP id k25-20020a17090627d900b009e3f97b239emr6759476ejc.29.1701011617567; Sun, 26 Nov 2023 07:13:37 -0800 (PST) Received: from localhost.localdomain (h17-ipv4-77-240-224.mynet.it. [77.240.224.17]) by smtp.gmail.com with ESMTPSA id me22-20020a170906aed600b009dd8473559dsm4594399ejb.110.2023.11.26.07.13.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 Nov 2023 07:13:37 -0800 (PST) From: Enrico Mioso To: openwrt-devel@lists.openwrt.org Cc: Enrico Mioso , Daniel Golle Subject: [PATCH] mediatek: filogic: add support for GL.iNet GL-MT2500 Date: Sun, 26 Nov 2023 16:11:13 +0100 Message-ID: <20231126151232.2244760-1-mrkiko.rs@gmail.com> X-Mailer: git-send-email 2.42.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231126_071341_760415_A526A0F3 X-CRM114-Status: GOOD ( 20.44 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: The GL-MT2500 is a Security Gateway based on MediaTek MT7981. It comes in two variants: one with a plastic case, the other with an alluminium one. Both variants run the same firmware. Hardware specifications: - SoC: MediaTek MT7981B - CPU: 2x 1.3 GHz Cortex-A53 - Flash: 8GB EMMC - RAM: 1 GB - Ethernet: - 1x 10/100/1000 Mbps built-in PHY (LAN) - 1x 10/100/1000/2500 Mbps MaxLinear GP [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:634 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [mrkiko.rs[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org The GL-MT2500 is a Security Gateway based on MediaTek MT7981. It comes in two variants: one with a plastic case, the other with an alluminium one. Both variants run the same firmware. Hardware specifications: - SoC: MediaTek MT7981B - CPU: 2x 1.3 GHz Cortex-A53 - Flash: 8GB EMMC - RAM: 1 GB - Ethernet: - 1x 10/100/1000 Mbps built-in PHY (LAN) - 1x 10/100/1000/2500 Mbps MaxLinear GPY211 PHY (WAN) - USB 3.0 port - Buttons: RESET button - LEDs: 1x light-blue, 1x warm-white, 1x VPN - Serial console: internal 4-pin header, 115200 8n1 - Power: 5 VDC, 3 A (USB Type-C) MAC addresses assignment: The label on the back of the device reports WAN (eth0) interface MAC address. LAN interface (eth1) has WAN MAC address incremented by 1. Installation: ------------- Method 1 - via GL.iNet bootloader web failsafe UI 1. Connect to the LAN interface of the device (the one that's farther from USB-C power supply connector). 2. Assign static IP 192.168.1.2/24 to the host. 3. Hold the reset button for at least 5 seconds while powering on the device. If all went well, the bootloader should be responding to ICMP ping packets and listening for web connections at 192.168.1.1. Upload the *sysupgrade-squashfs image, then press the Update button. The device should restart to OpenWrt. Method 2 - via UART connection 1. Connect to device serial port. 2. Interrupt the boot process typing "gl". 3. Connect your host to the LAN port of the device and assign it static IP 192.168.1.2/24. 4. Start a TFTP server in your artifacts folder (e.g.: openwrt/bin/targets/mediatek/filogic). 5. In the bootloader, issue these commands: tftpboot openwrt-mediatek-filogic-glinet_gl-mt2500-initramfs-kernel.bin && bootm this should bring you to the OpenWrt prompt where you can transfer a sysupgrade image and proceed with the usual sysupgrade process. Notes ----- 1. This port might not work on all hardware samples: in some cases, the unit might just hang when probing EMMC. 2. The U-Boot environment might not be populated (empty EMMC partition) until a "saveenv" command is issued. Do not initialize the environment from within OpenWrt as this might cause problems due to the fact fw_printenv's default env will not match the vendor's U-Boot one. Untested features ----------------- Flashing from stock web UI wasn't tested, but is expected to work, being stock firmware shipped as a sysupgrade tar image as well. Furthermore, going back to stock firmware wasn't tested, but should be possible via U-Boot failsafe web UI. CREDITS ------ Daniel Golle did the hard part of this port, so thank you! Signed-off-by: Daniel Golle Signed-off-by: Enrico Mioso --- .../uboot-envtools/files/mediatek_filogic | 1 + .../mediatek/dts/mt7981b-glinet-gl-mt2500.dts | 209 ++++++++++++++++++ .../filogic/base-files/etc/board.d/02_network | 6 + .../base-files/lib/upgrade/platform.sh | 2 + target/linux/mediatek/image/filogic.mk | 11 + 5 files changed, 229 insertions(+) create mode 100644 target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic index ae8e1589a0..d678e1fcbd 100644 --- a/package/boot/uboot-envtools/files/mediatek_filogic +++ b/package/boot/uboot-envtools/files/mediatek_filogic @@ -77,6 +77,7 @@ xiaomi,redmi-router-ax6000-ubootmod) glinet,gl-mt3000) ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x80000" "0x20000" ;; +glinet,gl-mt2500|\ glinet,gl-mt6000) local envdev=$(find_mmc_part "u-boot-env") ubootenv_add_uci_config "$envdev" "0x0" "0x80000" diff --git a/target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts b/target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts new file mode 100644 index 0000000000..58d4200d6c --- /dev/null +++ b/target/linux/mediatek/dts/mt7981b-glinet-gl-mt2500.dts @@ -0,0 +1,209 @@ +/dts-v1/; +#include "mt7981.dtsi" +/ { + model = "GL.iNet GL-MT2500"; + compatible = "glinet,gl-mt2500", "mediatek,mt7981"; + + chosen { + stdout-path = "serial0:115200n8"; + bootargs-append = " root=PARTLABEL=rootfs rootwait"; + }; + + aliases { + led-boot = &led_blue; + led-failsafe = &led_blue; + led-running = &led_white; + led-upgrade = &led_blue; + serial0 = &uart0; + }; + + reg_3p3v: regulator-3p3v { + compatible = "regulator-fixed"; + regulator-name = "fixed-3.3V"; + regulator-min-microvolt = <3300000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + regulator-always-on; + }; + + gpio-keys { + compatible = "gpio-keys"; + + reset { + label = "reset"; + linux,code = ; + gpios = <&pio 1 GPIO_ACTIVE_LOW>; + }; + }; + + gpio-export { + compatible = "gpio-export"; + + usb_power { + gpio-export,name = "usb_power"; + gpio-export,output = <1>; + gpios = <&pio 12 GPIO_ACTIVE_HIGH>; + }; + }; + + leds { + compatible = "gpio-leds"; + + led@0 { + label = "vpn"; + gpios = <&pio 31 GPIO_ACTIVE_LOW>; + }; + + led_white: led@1 { + label = "white:system"; + gpios = <&pio 30 GPIO_ACTIVE_LOW>; + }; + + led_blue: led@2 { + label = "blue:system"; + gpios = <&pio 29 GPIO_ACTIVE_LOW>; + default-state = "on"; + }; + }; +}; + +&uart0 { + status = "okay"; +}; + +&watchdog { + status = "okay"; +}; + +&mmc0 { + pinctrl-names = "default", "state_uhs"; + pinctrl-0 = <&mmc0_pins_default>; + pinctrl-1 = <&mmc0_pins_uhs>; + bus-width = <8>; + max-frequency = <52000000>; + cap-mmc-highspeed; + vmmc-supply = <®_3p3v>; + non-removable; + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + card@0 { + compatible = "mmc-card"; + reg = <0>; + + block { + partitions { + #address-cells = <1>; + #size-cells = <0>; + + partition@2 { + reg = <2>; + partname = "u-boot-env"; + compatible = "nvmem-cells"; + }; + + partition@3 { + reg = <3>; + partname = "rf"; + compatible = "nvmem-cells"; + }; + }; + }; + + boot1 { + compatible = "nvmem-cells"; + + nvmem-layout { + compatible = "fixed-layout"; + #address-cells = <1>; + #size-cells = <1>; + + macaddr: macaddr@a { + compatible = "mac-base"; + reg = <0xa 0x6>; + #nvmem-cell-cells = <1>; + }; + + ddns@10 { + reg = <0x10 0x10>; + }; + + sn-bak@20 { + reg = <0x20 0x10>; + }; + + sn@30 { + reg = <0x30 0x10>; + }; + + country-code@88 { + reg = <0x88 0x10>; + }; + }; + }; + }; +}; + +ð { + pinctrl-names = "default"; + pinctrl-0 = <&mdio_pins>; + + status = "okay"; + + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "2500base-x"; + phy-handle = <&phy0>; +// nvmem-cells = <&macaddr 0>; +// nvmem-cell-names = "mac-address"; + }; + + gmac1: mac@1 { + compatible = "mediatek,eth-mac"; + reg = <1>; + phy-mode = "gmii"; + phy-handle = <&int_gbe_phy>; +// nvmem-cells = <&macaddr 1>; +// nvmem-cell-names = "mac-address"; + }; +}; + +&mdio_bus { + reset-gpios = <&pio 14 GPIO_ACTIVE_LOW>; + reset-delay-us = <600>; + reset-post-delay-us = <20000>; + + phy0: ethernet-phy@5 { + reg = <5>; + compatible = "ethernet-phy-ieee802.3-c45"; + phy-mode = "2500base-x"; + }; +}; + +&pio { + mmc0_pins_default: mmc0-pins-default { + mux { + function = "flash"; + groups = "emmc_45"; + }; + }; + mmc0_pins_uhs: mmc0-pins-uhs { + mux { + function = "flash"; + groups = "emmc_45"; + }; + }; +}; + +&usb_phy { + status = "okay"; +}; + +&xhci { + mediatek,u3p-dis-msk = <0x0>; + phys = <&u2port0 PHY_TYPE_USB2>, + <&u3port0 PHY_TYPE_USB3>; + 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 5153c156f6..ef0dab38d0 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 @@ -32,6 +32,7 @@ mediatek_setup_interfaces() h3c,magic-nx30-pro) ucidef_set_interfaces_lan_wan "lan1 lan2 lan3" eth1 ;; + glinet,gl-mt2500|\ glinet,gl-mt3000) ucidef_set_interfaces_lan_wan eth1 eth0 ;; @@ -109,6 +110,11 @@ mediatek_setup_macs() ;; esac ;; + glinet,gl-mt2500) + label_mac=$(get_mac_binary /dev/mmcblk0boot1 0xa) + wan_mac=$label_mac + lan_mac=$(macaddr_add "$label_mac" 1) + ;; glinet,gl-mt6000) label_mac=$(mmc_get_mac_binary factory 0x0a) wan_mac=$label_mac diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh index 3c278d5faf..6130768cb4 100755 --- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh +++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh @@ -97,6 +97,7 @@ platform_do_upgrade() { cudy,wr3000-v1) default_do_upgrade "$1" ;; + glinet,gl-mt2500|\ glinet,gl-mt6000) CI_KERNPART="kernel" CI_ROOTPART="rootfs" @@ -176,6 +177,7 @@ platform_copy_config() { ;; esac ;; + glinet,gl-mt2500|\ glinet,gl-mt6000|\ ubnt,unifi-6-plus) emmc_copy_config diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk index 4886db1141..2adad62962 100644 --- a/target/linux/mediatek/image/filogic.mk +++ b/target/linux/mediatek/image/filogic.mk @@ -274,6 +274,17 @@ define Device/cudy_wr3000-v1 endef TARGET_DEVICES += cudy_wr3000-v1 +define Device/glinet_gl-mt2500 + DEVICE_VENDOR := GL.iNet + DEVICE_MODEL := GL-MT2500 + DEVICE_DTS := mt7981b-glinet-gl-mt2500 + DEVICE_DTS_DIR := ../dts + SUPPORTED_DEVICES += glinet,mt2500-emmc + DEVICE_PACKAGES := e2fsprogs f2fsck mkf2fs kmod-usb3 -kmod-mt7915e -wpad-basic-mbedtls + IMAGE/sysupgrade.bin := sysupgrade-tar | append-gl-metadata +endef +TARGET_DEVICES += glinet_gl-mt2500 + define Device/glinet_gl-mt3000 DEVICE_VENDOR := GL.iNet DEVICE_MODEL := GL-MT3000