[PATCH] mediatek: filogic: add support for GL.iNet GL-MT2500
Enrico Mioso
mrkiko.rs at gmail.com
Sun Nov 26 10:51:41 PST 2023
On Sun, Nov 26, 2023 at 03:35:09PM +0000, Daniel Golle wrote:
> Hi Enrico,
>
> thank you for advancing with support for this device!
>
> See comments inline, mostly about left-overs from earlier draft
> implementations of nvmem-on-MMC.
>
> On Sun, Nov 26, 2023 at 04:11:13PM +0100, Enrico Mioso wrote:
> > 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 <daniel at makrotopia.org>
> > Signed-off-by: Enrico Mioso <mrkiko.rs at gmail.com>
> > ---
> > .../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 = <KEY_RESTART>;
> > + 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 at 0 {
> > + label = "vpn";
> > + gpios = <&pio 31 GPIO_ACTIVE_LOW>;
> > + };
> > +
> > + led_white: led at 1 {
> > + label = "white:system";
> > + gpios = <&pio 30 GPIO_ACTIVE_LOW>;
> > + };
> > +
> > + led_blue: led at 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 at 0 {
>
> Please remove card at 0 from DT, it is not needed not and was for testing
> future support of NVMEM on MMC (which I'd like to first get approved
> upstream before starting to use it in OpenWrt).
>
> In case you are interested, the WIP patches for that are here:
>
> https://github.com/dangowrt/linux/commit/296ecde1da4d83e24c81dcc50a71d0db27e41088
> https://github.com/dangowrt/linux/commit/fb68168efaeab49202c36e38e7771bfc53bb5067
> https://github.com/dangowrt/linux/commit/d83b29b7d8a722b82f17bcdbf2d9b778460f12d4
> https://github.com/dangowrt/linux/commit/109053c04b366dca1e0e006b60714e4a07ba441f
> https://github.com/dangowrt/linux/commit/65122ec7c436254f1f72958be0272c54a5022b83
> https://github.com/dangowrt/linux/commit/70e6bdcb818157b6261c3905edee94e0c1d39b9d
> https://github.com/dangowrt/linux/commit/bfea727f2d27d9131417c619d449b67673308381
>
>
> > + compatible = "mmc-card";
> > + reg = <0>;
> > +
> > + block {
> > + partitions {
> > + #address-cells = <1>;
> > + #size-cells = <0>;
> > +
> > + partition at 2 {
> > + reg = <2>;
> > + partname = "u-boot-env";
> > + compatible = "nvmem-cells";
> > + };
> > +
> > + partition at 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 at a {
> > + compatible = "mac-base";
> > + reg = <0xa 0x6>;
> > + #nvmem-cell-cells = <1>;
> > + };
> > +
> > + ddns at 10 {
> > + reg = <0x10 0x10>;
> > + };
> > +
> > + sn-bak at 20 {
> > + reg = <0x20 0x10>;
> > + };
> > +
> > + sn at 30 {
> > + reg = <0x30 0x10>;
> > + };
> > +
> > + country-code at 88 {
> > + reg = <0x88 0x10>;
> > + };
> > + };
> > + };
> > + };
> > +};
> > +
> > +ð {
> > + pinctrl-names = "default";
> > + pinctrl-0 = <&mdio_pins>;
> > +
> > + status = "okay";
> > +
> > + gmac0: mac at 0 {
> > + compatible = "mediatek,eth-mac";
> > + reg = <0>;
> > + phy-mode = "2500base-x";
> > + phy-handle = <&phy0>;
> > +// nvmem-cells = <&macaddr 0>;
> > +// nvmem-cell-names = "mac-address";
>
> Also the commented-out lines here and below referencing nvmem-cells
> should be removed for now. Once NVMEM-on-MMC is supported, we should
> re-add them.
>
> > + };
> > +
> > + gmac1: mac at 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 at 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
> > --
> > 2.42.1
> >
Hi Daniel,
thanks a lot for the help and time reviewing this.
I am going to submit a new version shortly.
BTW - how should we proceed with the VPN led name? May we leave it as it is or should we include a colour spec?
Thanks,
Enrico
More information about the openwrt-devel
mailing list