[PATCH] mediatek: filogic: add support for GatoNetworks GDSP

Enrico Mioso mrkiko.rs at gmail.com
Sun Nov 3 08:30:34 PST 2024


The GatoNetworks GDSP is a re-branded version of the R5000 5G Industrial
router from Yinghua technologies.
The re-branded device comes with OpenWrt preinstalled, and an OpenWrt-based
U-Boot bootloader version. The flash layout has been kept compatible with the
OpenWrt version found on the stock device, making sysupgrade possible.

Specifications:
SOC: Mediatek MT7981BA
RAM: 256MB
Flash: SPI-NOR 32 MiB (Winbond W25Q256)
WLAN: MT7976CN DBDC AX Wi-Fi
Switch: MT7531AE (4x LAN Gigabit ports, 1x WAN Gigabit port)
5G: Quectel RM520N modem
Watchdog: an external WDT connected to GPIO 6 is present and always running;
          the builtin Mediatek watchdog is also present and effective, but
          not used at the moment.

This porting has been tested only with 1x 5G modems installed (the device
supports up to two).

Installation:
Installation is possible via sysupgrade both in the stock device and
re-branded version (requiring -F and -n in the former case).

OpenWrt-based U-Boot Bootloader installation
--------------------------------------------

The firmware flashed at manifacturing time in the re-branded device will
flash an OpenWrt-based U-Boot bootloader with some extra recovery features
(see [1]).
To update the bootloader, you need to install the mtd-rw module and
insmod it:

insmod mtd-rw i_want_a_brick=1

Then update relevant flash partitions:

mtd erase u-boot-env
mtd erase BL2
mtd erase FIP
mtd write openwrt-mediatek-filogic-gatonetworks_gdsp-preloader.bin BL2
mtd write openwrt-mediatek-filogic-gatonetworks_gdsp-bl31-uboot.fip FIP

And reboot, making sure all previous commands ran succesfully.
If something goes wrong, you can recover your device via the mtk_uartboot
tool.
In my testing, it was possible to start the process even without (un)-plugging
the device, may be handy for remote recovery.

U-Boot Recovery
---------------

This procedure has been tested only with the OpenWrt-based U-boot bootloader.
Assign your system static IP address 192.168.1.1 and start a TFTP server. The
device will look for an initramfs image named
openwrt-mediatek-filogic-gatonetworks_gdsp-initramfs-kernel.bin
(so you may use openwrt/bin/targets/mediatek/filogic as root dir for your
TFTP server).
Power on the device while keeping the reset button pressed, until you see
a TFTP request from 192.168.1.10. Your environment will be restored to it's
default state.

Notes
-----
[1]: the OpenWrt-based U-Boot bootloader you will find installed in the
device is configured to request for the initramfs image via TFTP for
$gdsp_tftp_tries times before trying normal boot from NOR flash.
Setting this U-Boot environment variable to 0x0 will disable the feature,
which is not implemented in this patch.
[2]: the exposed UART port is connected to ttyS1; the ttyS0 console port s not
exposed.
[3]: the provided bootloader environment has no provision for operating on
BL2 and the FIP partitions. This is an intentional choice to make it
(slightly) more difficult to brick the device.

Signed-off-by: Enrico Mioso <mrkiko.rs at gmail.com>
---
 .../uboot-envtools/files/mediatek_filogic     |   3 +
 package/boot/uboot-mediatek/Makefile          |  14 +
 ...ialized-the-watchdog-subsystem-later.patch |  59 +++
 .../patches/458-add-GatoNetworks-GDSP.patch   | 418 ++++++++++++++++++
 .../dts/mt7981b-gatonetworks-gdsp.dts         | 377 ++++++++++++++++
 .../filogic/base-files/etc/board.d/02_network |   4 +
 .../etc/hotplug.d/ieee80211/11_fix_wifi_mac   |   5 +
 .../base-files/lib/upgrade/platform.sh        |   1 +
 target/linux/mediatek/image/filogic.mk        |  16 +
 9 files changed, 897 insertions(+)
 create mode 100644 package/boot/uboot-mediatek/patches/457-initialized-the-watchdog-subsystem-later.patch
 create mode 100644 package/boot/uboot-mediatek/patches/458-add-GatoNetworks-GDSP.patch
 create mode 100644 target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp.dts

diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic
index a38024de65..9de1a4d75d 100644
--- a/package/boot/uboot-envtools/files/mediatek_filogic
+++ b/package/boot/uboot-envtools/files/mediatek_filogic
@@ -86,6 +86,9 @@ zbtlink,zbt-z8103ax)
 dlink,aquila-pro-ai-m30-a1)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x40000"
 	;;
+gatonetworks,gdsp)
+	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
+	;;
 glinet,gl-x3000|\
 glinet,gl-xe3000|\
 glinet,gl-mt2500|\
diff --git a/package/boot/uboot-mediatek/Makefile b/package/boot/uboot-mediatek/Makefile
index ab08126b51..bb7ad0edef 100644
--- a/package/boot/uboot-mediatek/Makefile
+++ b/package/boot/uboot-mediatek/Makefile
@@ -364,6 +364,19 @@ define U-Boot/mt7981_rfb-emmc
   DEPENDS:=+trusted-firmware-a-mt7981-emmc-ddr3
 endef
 
+define U-Boot/mt7981_gatonetworks_gdsp
+  NAME:=GatoNetworks GDSP
+  BUILD_SUBTARGET:=filogic
+  BUILD_DEVICES:=gatonetworks_gdsp
+  UBOOT_CONFIG:=mt7981_gatonetworks_gdsp
+  UBOOT_IMAGE:=u-boot.fip
+  BL2_BOOTDEV:=nor
+  BL2_SOC:=mt7981
+  BL2_DDRTYPE:=ddr3
+  DEPENDS:=+trusted-firmware-a-mt7981-nor-ddr3
+  FIP_COMPRESS:=1
+endef
+
 define U-Boot/mt7981_rfb-nor
   NAME:=MT7981 Reference Board
   BUILD_SUBTARGET:=filogic
@@ -797,6 +810,7 @@ UBOOT_TARGETS := \
 	mt7981_abt_asr3000 \
 	mt7981_cmcc_rax3000m-emmc \
 	mt7981_cmcc_rax3000m-nand \
+	mt7981_gatonetworks_gdsp \
 	mt7981_glinet_gl-x3000 \
 	mt7981_glinet_gl-xe3000 \
 	mt7981_h3c_magic-nx30-pro \
diff --git a/package/boot/uboot-mediatek/patches/457-initialized-the-watchdog-subsystem-later.patch b/package/boot/uboot-mediatek/patches/457-initialized-the-watchdog-subsystem-later.patch
new file mode 100644
index 0000000000..652452c1dd
--- /dev/null
+++ b/package/boot/uboot-mediatek/patches/457-initialized-the-watchdog-subsystem-later.patch
@@ -0,0 +1,59 @@
+From 9c1ad8a18ac1a20aee7a617964bcae3e90dac700 Mon Sep 17 00:00:00 2001
+From: Enrico Mioso <mrkiko.rs at gmail.com>
+Date: Wed, 23 Oct 2024 17:46:35 +0200
+Subject: [PATCH] uboot-mediatek: initialized the watchdog subsystem later
+
+Initialize the watchdog subsystem later during initialization, to allow for
+the gpio-wdt driver to work.
+
+Signed-off-by: Enrico Mioso <mrkiko.rs at gmail.com>
+---
+ common/board_r.c | 11 ++++-------
+ 1 file changed, 4 insertions(+), 7 deletions(-)
+
+diff --git a/common/board_r.c b/common/board_r.c
+index e6eab553e5..d5fe9a0d43 100644
+--- a/common/board_r.c
++++ b/common/board_r.c
+@@ -651,19 +651,13 @@ static init_fnc_t init_sequence_r[] = {
+ 	serial_initialize,
+ 	initr_announce,
+ 	dm_announce,
+-#if CONFIG_IS_ENABLED(WDT)
+-	initr_watchdog,
+-#endif
+-	INIT_FUNC_WATCHDOG_RESET
+ 	arch_initr_trap,
+ #if defined(CONFIG_BOARD_EARLY_INIT_R)
+ 	board_early_init_r,
+ #endif
+-	INIT_FUNC_WATCHDOG_RESET
+ #ifdef CONFIG_POST
+ 	post_output_backlog,
+ #endif
+-	INIT_FUNC_WATCHDOG_RESET
+ #if defined(CONFIG_PCI_INIT_R) && defined(CONFIG_SYS_EARLY_PCI_INIT)
+ 	/*
+ 	 * Do early PCI configuration _before_ the flash gets initialised,
+@@ -678,7 +672,6 @@ static init_fnc_t init_sequence_r[] = {
+ #ifdef CONFIG_MTD_NOR_FLASH
+ 	initr_flash,
+ #endif
+-	INIT_FUNC_WATCHDOG_RESET
+ #if defined(CONFIG_PPC) || defined(CONFIG_M68K) || defined(CONFIG_X86)
+ 	/* initialize higher level parts of CPU like time base and timers */
+ 	cpu_init_r,
+@@ -707,6 +700,10 @@ static init_fnc_t init_sequence_r[] = {
+ #ifdef CONFIG_PVBLOCK
+ 	initr_pvblock,
+ #endif
++#if CONFIG_IS_ENABLED(WDT)
++	initr_watchdog,
++#endif
++	INIT_FUNC_WATCHDOG_RESET
+ 	initr_env,
+ #ifdef CONFIG_SYS_MALLOC_BOOTPARAMS
+ 	initr_malloc_bootparams,
+-- 
+2.46.2
+
diff --git a/package/boot/uboot-mediatek/patches/458-add-GatoNetworks-GDSP.patch b/package/boot/uboot-mediatek/patches/458-add-GatoNetworks-GDSP.patch
new file mode 100644
index 0000000000..da53d741a7
--- /dev/null
+++ b/package/boot/uboot-mediatek/patches/458-add-GatoNetworks-GDSP.patch
@@ -0,0 +1,418 @@
+From 57d0f608d925cb688b5c9b71512fca7d228f07f6 Mon Sep 17 00:00:00 2001
+From: Enrico Mioso <mrkiko.rs at gmail.com>
+Date: Wed, 23 Oct 2024 20:39:28 +0200
+Subject: [PATCH] add GatoNetworks GDSP
+
+Signed-off-by: Enrico Mioso <mrkiko.rs at gmail.com>
+---
+ arch/arm/dts/mt7981-gatonetworks_gdsp.dts  | 200 +++++++++++++++++++++
+ configs/mt7981_gatonetworks_gdsp_defconfig | 144 +++++++++++++++
+ gatonetworks_gdsp_env                      |  38 ++++
+ 3 files changed, 382 insertions(+)
+ create mode 100644 arch/arm/dts/mt7981-gatonetworks_gdsp.dts
+ create mode 100644 configs/mt7981_gatonetworks_gdsp_defconfig
+ create mode 100644 gatonetworks_gdsp_env
+
+diff --git a/arch/arm/dts/mt7981-gatonetworks_gdsp.dts b/arch/arm/dts/mt7981-gatonetworks_gdsp.dts
+new file mode 100644
+index 0000000000..8cb5547943
+--- /dev/null
++++ b/arch/arm/dts/mt7981-gatonetworks_gdsp.dts
+@@ -0,0 +1,200 @@
++// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
++
++/dts-v1/;
++#include "mt7981.dtsi"
++#include <dt-bindings/gpio/gpio.h>
++#include <dt-bindings/input/linux-event-codes.h>
++
++/ {
++	#address-cells = <1>;
++	#size-cells = <1>;
++	model = "GatoNetworks GDSP";
++	compatible = "gatonetworks,gdsp", "mediatek,mt7981";
++  chosen {
++		stdout-path = &uart0;
++		tick-timer = &timer0;
++  };
++
++	memory {
++		device_type = "memory";
++		reg = <0x40000000 0x10000000>;
++	};
++
++	keys {
++		compatible = "gpio-keys";
++
++		reset {
++			label = "reset";
++			linux,code = <KEY_RESTART>;
++			gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
++		};
++	};
++
++	leds {
++		compatible = "gpio-leds";
++
++		sim1 {
++			label = "sim1";
++			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
++		};
++
++		sim2 {
++			label = "sim2";
++			gpios = <&gpio 0 GPIO_ACTIVE_LOW>;
++		};
++
++		sg1 {
++			label = "sg1";
++			gpios = <&gpio 10 GPIO_ACTIVE_LOW>;
++		};
++
++		sg2 {
++			label = "sg2";
++			gpios = <&gpio 11 GPIO_ACTIVE_LOW>;
++		};
++
++		sg3 {
++			label = "sg3";
++			gpios = <&gpio 12 GPIO_ACTIVE_LOW>;
++		};
++
++		sg4 {
++			label = "sg4";
++			gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
++		};
++
++		sg5 {
++			label = "sg5";
++			gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
++		};
++
++		sg6 {
++			label = "sg6";
++			gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
++		};
++	};
++	gpio-watchdog {
++		compatible = "linux,wdt-gpio";
++		gpios = <&gpio 6 GPIO_ACTIVE_LOW>;
++		hw_algo = "toggle";
++		hw_margin_ms = <25000>;
++		always-running;
++		u-boot,autostart;
++	};
++};
++
++&eth {
++	status = "okay";
++	mediatek,gmac-id = <0>;
++	phy-mode = "2500base-x";
++	mediatek,switch = "mt7531";
++	reset-gpios = <&gpio 39 GPIO_ACTIVE_HIGH>;
++
++	fixed-link {
++		speed = <2500>;
++		full-duplex;
++	};
++};
++
++&spi2 {
++	pinctrl-names = "default";
++	pinctrl-0 = <&spi2_flash_pins>;
++	status = "okay";
++	must_tx;
++	enhance_timing;
++	dma_ext;
++	ipm_design;
++	support_quad;
++	tick_dly = <2>;
++	sample_sel = <0>;
++
++	flash at 0 {
++		compatible = "jedec,spi-nor";
++		reg = <0>;
++		spi-max-frequency = <52000000>;
++
++		partitions {
++			compatible = "fixed-partitions";
++			#address-cells = <1>;
++			#size-cells = <1>;
++
++			partition at 00000 {
++				label = "BL2";
++				reg = <0x00000 0x0040000>;
++				read-only;
++			};
++
++			partition at 40000 {
++				label = "u-boot-env";
++				reg = <0x40000 0x0010000>;
++			};
++
++			partition at 50000 {
++				label = "Factory";
++				reg = <0x50000 0x00B0000>;
++				read-only;
++			};
++
++			partition at 100000 {
++				label = "FIP";
++				reg = <0x100000 0x0080000>;
++			};
++
++			partition at 180000 {
++				label = "firmware";
++				reg = <0x180000 0x1E80000>;
++			};
++		};
++	};
++};
++
++&pinctrl {
++	uart1_pins: uart1-pins {
++		mux {
++			function = "uart";
++			groups = "uart1_0";
++		};
++	};
++
++	uart2_pins: uart2-pins {
++		mux {
++			function = "uart";
++			groups = "uart2_0_tx_rx";
++		};
++	};
++
++	spi2_flash_pins: spi2-pins {
++		mux {
++			function = "spi";
++			groups = "spi2", "spi2_wp_hold";
++		};
++
++		conf-pu {
++			pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
++			drive-strength = <MTK_DRIVE_8mA>;
++			bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
++		};
++
++		conf-pd {
++			pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
++			drive-strength = <MTK_DRIVE_8mA>;
++			bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
++		};
++	};
++};
++
++&uart0 {
++	status = "okay";
++};
++
++&uart1 {
++	pinctrl-names = "default";
++	pinctrl-0 = <&uart1_pins>;
++	status = "okay";
++};
++
++&uart2 {
++	pinctrl-names = "default";
++	pinctrl-0 = <&uart2_pins>;
++	status = "okay";
++};
+diff --git a/configs/mt7981_gatonetworks_gdsp_defconfig b/configs/mt7981_gatonetworks_gdsp_defconfig
+new file mode 100644
+index 0000000000..f357e5b327
+--- /dev/null
++++ b/configs/mt7981_gatonetworks_gdsp_defconfig
+@@ -0,0 +1,144 @@
++CONFIG_ARM=y
++CONFIG_SYS_HAS_NONCACHED_MEMORY=y
++CONFIG_POSITION_INDEPENDENT=y
++CONFIG_ARCH_MEDIATEK=y
++CONFIG_TEXT_BASE=0x41e00000
++CONFIG_SYS_MALLOC_F_LEN=0x4000
++CONFIG_NR_DRAM_BANKS=1
++CONFIG_ENV_SIZE=0x10000
++CONFIG_ENV_OFFSET=0x0
++CONFIG_DEFAULT_DEVICE_TREE="mt7981-gatonetworks_gdsp"
++CONFIG_OF_LIBFDT_OVERLAY=y
++CONFIG_TARGET_MT7981=y
++CONFIG_WATCHDOG_TIMEOUT_MSECS=25000
++CONFIG_DEBUG_UART_BASE=0x11002000
++CONFIG_DEBUG_UART_CLOCK=40000000
++CONFIG_SYS_LOAD_ADDR=0x46000000
++CONFIG_DEBUG_UART=y
++CONFIG_FIT=y
++CONFIG_SPI_BOOT=y
++CONFIG_AUTOBOOT_MENU_SHOW=y
++CONFIG_USE_PREBOOT=y
++CONFIG_DEFAULT_FDT_FILE="mt7981-gatonetworks_gdsp"
++CONFIG_SYS_CBSIZE=512
++CONFIG_SYS_PBSIZE=1049
++CONFIG_LOGLEVEL=7
++CONFIG_CONSOLE_MUX=y
++CONFIG_LOG=y
++CONFIG_BOARD_LATE_INIT=y
++CONFIG_HUSH_PARSER=y
++CONFIG_SYS_PROMPT="GDSP> "
++CONFIG_SYS_MAXARGS=16
++CONFIG_CMD_BDINFO_EXTRA=y
++CONFIG_CMD_CPU=y
++CONFIG_CMD_HISTORY=y
++CONFIG_CMD_LICENSE=y
++# CONFIG_BOOTM_NETBSD is not set
++# CONFIG_BOOTM_PLAN9 is not set
++# CONFIG_BOOTM_RTEMS is not set
++# CONFIG_BOOTM_VXWORKS is not set
++# CONFIG_CMD_BOOTEFI_BOOTMGR is not set
++CONFIG_CMD_BOOTMENU=y
++CONFIG_CMD_ASKENV=y
++CONFIG_CMD_ERASEENV=y
++CONFIG_CMD_ENV_CALLBACK=y
++CONFIG_CMD_ENV_FLAGS=y
++CONFIG_CRC32_VERIFY=y
++CONFIG_LOOPW=y
++CONFIG_CMD_MEMINFO=y
++CONFIG_CMD_MEMTEST=y
++CONFIG_CMD_STRINGS=y
++# CONFIG_CMD_UNLZ4 is not set
++# CONFIG_CMD_UNZIP is not set
++CONFIG_CMD_DM=y
++CONFIG_CMD_GPIO=y
++CONFIG_CMD_GPIO_READ=y
++CONFIG_CMD_PWM=y
++CONFIG_CMD_MTD=y
++# CONFIG_CMD_NAND_EXT is not set
++CONFIG_CMD_SF_TEST=y
++CONFIG_CMD_CAT=y
++CONFIG_CMD_SETEXPR_FMT=y
++CONFIG_CMD_XXD=y
++CONFIG_CMD_DHCP=y
++CONFIG_CMD_TFTPPUT=y
++CONFIG_CMD_TFTPSRV=y
++CONFIG_CMD_RARP=y
++CONFIG_CMD_PING=y
++CONFIG_CMD_CDP=y
++CONFIG_CMD_SNTP=y
++CONFIG_CMD_DNS=y
++CONFIG_CMD_LINK_LOCAL=y
++CONFIG_CMD_PXE=y
++CONFIG_CMD_CACHE=y
++# CONFIG_CMD_EFICONFIG is not set
++CONFIG_CMD_PSTORE=y
++CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000
++CONFIG_CMD_UUID=y
++CONFIG_CMD_HASH=y
++CONFIG_CMD_SMC=y
++CONFIG_CMD_FAT=y
++CONFIG_CMD_FS_GENERIC=y
++CONFIG_CMD_FS_UUID=y
++CONFIG_ENV_OVERWRITE=y
++CONFIG_ENV_IS_IN_MTD=y
++CONFIG_ENV_MTD_NAME="u-boot-env"
++CONFIG_ENV_SIZE_REDUND=0x0
++CONFIG_SYS_RELOC_GD_ENV_ADDR=y
++CONFIG_USE_DEFAULT_ENV_FILE=y
++CONFIG_DEFAULT_ENV_FILE="gatonetworks_gdsp_env"
++CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y
++CONFIG_VERSION_VARIABLE=y
++CONFIG_NET_RANDOM_ETHADDR=y
++CONFIG_NETCONSOLE=y
++CONFIG_REGMAP=y
++CONFIG_SYSCON=y
++CONFIG_BUTTON=y
++CONFIG_BUTTON_GPIO=y
++CONFIG_CLK=y
++CONFIG_GPIO_HOG=y
++CONFIG_LED=y
++CONFIG_LED_BLINK=y
++CONFIG_LED_GPIO=y
++# CONFIG_MMC is not set
++CONFIG_MTD=y
++CONFIG_DM_MTD=y
++CONFIG_MTD_SPI_NAND=y
++CONFIG_DM_SPI_FLASH=y
++CONFIG_SPI_FLASH_SFDP_SUPPORT=y
++CONFIG_SPI_FLASH_EON=y
++CONFIG_SPI_FLASH_GIGADEVICE=y
++CONFIG_SPI_FLASH_ISSI=y
++CONFIG_SPI_FLASH_MACRONIX=y
++CONFIG_SPI_FLASH_SPANSION=y
++CONFIG_SPI_FLASH_STMICRO=y
++CONFIG_SPI_FLASH_WINBOND=y
++CONFIG_SPI_FLASH_XMC=y
++CONFIG_SPI_FLASH_XTX=y
++CONFIG_SPI_FLASH_MTD=y
++CONFIG_UBI_SILENCE_MSG=y
++CONFIG_PHY_FIXED=y
++CONFIG_MEDIATEK_ETH=y
++CONFIG_PHY=y
++CONFIG_PHY_MTK_TPHY=y
++CONFIG_PINCTRL=y
++CONFIG_PINCONF=y
++CONFIG_PINCTRL_MT7981=y
++CONFIG_POWER_DOMAIN=y
++CONFIG_MTK_POWER_DOMAIN=y
++CONFIG_DM_PWM=y
++CONFIG_PWM_MTK=y
++CONFIG_DM_SERIAL=y
++CONFIG_MTK_SERIAL=y
++CONFIG_SPI=y
++CONFIG_DM_SPI=y
++CONFIG_MTK_SPIM=y
++CONFIG_USB=y
++CONFIG_USB_XHCI_HCD=y
++CONFIG_USB_XHCI_MTK=y
++CONFIG_USB_STORAGE=y
++CONFIG_WDT=y
++CONFIG_WDT_GPIO=y
++CONFIG_UBIFS_SILENCE_MSG=y
++CONFIG_HEXDUMP=y
++CONFIG_LMB_MAX_REGIONS=64
+diff --git a/gatonetworks_gdsp_env b/gatonetworks_gdsp_env
+new file mode 100644
+index 0000000000..5af8d5b039
+--- /dev/null
++++ b/gatonetworks_gdsp_env
+@@ -0,0 +1,38 @@
++load_factory_data=if env exists factory_data_present ; then else mtd read Factory $loadaddr 0x0 0x1000 ; setenv factory_data_present 1 ; fi
++lan_mac_factory=run load_factory_data ; setexpr macoffs $loadaddr + 0x2a ; env readmem -b lan_mac $macoffs 0x6 ; setenv lan_mac_factory ; setenv macoffs
++wan_mac_factory=run load_factory_data ; setexpr macoffs $loadaddr + 0x24 ; env readmem -b wan_mac $macoffs 0x6 ; setenv wan_mac_factory ; setenv macoffs
++label_mac_factory=run load_factory_data ; setexpr macoffs $loadaddr + 0x4 ; env readmem -b label_mac $macoffs 0x6 ; setenv label_mac_factory ; setenv macoffs
++ethaddr_factory=setenv ethaddr $lan_mac ; setenv ethaddr_factory
++wifi_mac_factory=setenv wifi_mac $label_mac ; setenv wifi_mac_factory
++env_cleanup=setenv load_factory_data ; setenv factory_data_present ; setenv env_cleanup
++ipaddr=192.168.1.1
++serverip=192.168.1.10
++loadaddr=0x46000000
++bootcmd=run boot_nor
++bootdelay=0
++bootfile=openwrt-mediatek-filogic-gatonetworks_gdsp-initramfs-kernel.bin
++bootfile_upg=openwrt-mediatek-filogic-gatonetworks_gdsp-squashfs-sysupgrade.bin
++bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60
++bootmenu_default=0
++bootmenu_delay=0
++bootmenu_title=      ( ( ( OpenWrt ) ) )
++bootmenu_0=Initialize environment.=run _firstboot
++bootmenu_0d=Run default boot command.=run boot_default
++bootmenu_1=Boot system via TFTP.=run boot_tftp ; run bootmenu_confirm_return
++bootmenu_2=Boot system from flash.=run boot_nor ; run bootmenu_confirm_return
++bootmenu_3=Load system via TFTP then write to flash.=run boot_tftp_sysupgrade ; run bootmenu_confirm_return
++bootmenu_4=Reset all settings to factory defaults.=run reset_factory ; reset
++bootmenu_5=Reboot.=reset
++boot_first=if button reset ; then run boot_tftp ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu
++boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_tftp_forever
++boot_nor=mtd read firmware ${loadaddr} ; bootm $loadaddr
++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr
++boot_tftp_forever=while true ; do run boot_tftp ; sleep 1 ; done
++boot_tftp_sysupgrade=tftpboot $loadaddr $bootfile_upg && iminfo $loadaddr && run nor_write_production
++reset_factory=env default -a && saveenv && reset
++nor_pad_size=setexpr image_eb $filesize / 0x1000 ; setexpr tmp1 image_size % 0x1000 ; test 0x$tmp1 -gt 0 && setexpr image_eb $image_eb + 1 ; setexpr image_eb $image_eb * 0x1000
++nor_write_production=run nor_pad_size ; test 0x$image_eb -le 0x1e80000 && mtd erase firmware 0x0 0x$image_eb && mtd write firmware $loadaddr 0x0 $filesize
++_init_env=setenv _init_env ; saveenv
++_firstboot=setenv _firstboot ; run _switch_to_menu ; run lan_mac_factory ; run wan_mac_factory ; run label_mac_factory ; run env_cleanup ; run ethaddr_factory ; run wifi_mac_factory ; run _init_env ; run boot_first
++_switch_to_menu=setenv _switch_to_menu ; setenv bootdelay 3 ; setenv bootmenu_delay 3 ; setenv bootmenu_0 $bootmenu_0d ; setenv bootmenu_0d ; run _bootmenu_update_title
++_bootmenu_update_title=setenv _bootmenu_update_title ; setenv bootmenu_title "$bootmenu_title       $ver"
+-- 
+2.46.2
+
diff --git a/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp.dts b/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp.dts
new file mode 100644
index 0000000000..1c85167e25
--- /dev/null
+++ b/target/linux/mediatek/dts/mt7981b-gatonetworks-gdsp.dts
@@ -0,0 +1,377 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+
+/dts-v1/;
+#include "mt7981.dtsi"
+
+/ {
+	model = "GatoNetworks GDSP";
+	compatible = "gatonetworks,gdsp", "mediatek,mt7981";
+
+	aliases {
+		serial0 = &uart0;
+		label-mac-device = &wifi;
+		led-boot = &sg1;
+		led-failsafe = &sg1;
+		led-running = &sg1;
+		led-upgrade = &sg1;
+	};
+
+  chosen {
+		stdout-path = "serial0:115200n8";
+		bootargs = "console=ttyS0,115200n1 earlycon=uart8250,mmio32,0x11002000";
+  };
+
+	memory {
+		reg = <0 0x40000000 0 0x10000000>;
+	};
+
+	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;
+	};
+
+	reg_5v: regulator-5v {
+		compatible = "regulator-fixed";
+		regulator-name = "fixed-5V";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		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";
+
+		modem1 {
+			gpio-export,name = "modem1";
+			gpio-export,output = <0>;
+			gpios = <&pio 2 GPIO_ACTIVE_LOW>;
+		};
+
+		modem2 {
+			gpio-export,name = "modem2";
+			gpio-export,output = <0>;
+			gpios = <&pio 14 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		sim1 {
+			label = "green:sim1";
+			gpios = <&pio 13 GPIO_ACTIVE_LOW>;
+		};
+
+		sim2 {
+			label = "green:sim2";
+			gpios = <&pio 0 GPIO_ACTIVE_LOW>;
+		};
+
+		sg1: sg1 {
+			label = "green:sg1";
+			gpios = <&pio 10 GPIO_ACTIVE_LOW>;
+		};
+
+		sg2 {
+			label = "green:sg2";
+			gpios = <&pio 11 GPIO_ACTIVE_LOW>;
+		};
+
+		sg3 {
+			label = "green:sg3";
+			gpios = <&pio 12 GPIO_ACTIVE_LOW>;
+		};
+
+		sg4 {
+			label = "green:sg4";
+			gpios = <&pio 7 GPIO_ACTIVE_LOW>;
+		};
+
+		sg5 {
+			label = "green:sg5";
+			gpios = <&pio 8 GPIO_ACTIVE_LOW>;
+		};
+
+		sg6 {
+			label = "green:sg6";
+			gpios = <&pio 9 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	gpio-watchdog {
+		compatible = "linux,wdt-gpio";
+		gpios = <&pio 6 GPIO_ACTIVE_LOW>;
+		hw_algo = "toggle";
+		hw_margin_ms = <25000>;
+		always-running;
+	};
+};
+
+&watchdog {
+	status = "okay";
+};
+
+&eth {
+	status = "okay";
+
+	gmac0: mac at 0 {
+		compatible = "mediatek,eth-mac";
+		reg = <0>;
+		phy-mode = "2500base-x";
+
+		nvmem-cells = <&macaddr_lan>;
+		nvmem-cell-names = "mac-address";
+
+		fixed-link {
+			speed = <2500>;
+			full-duplex;
+			pause;
+		};
+	};
+
+	mdio: mdio-bus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		switch at 1f {
+			compatible = "mediatek,mt7531";
+			reg = <31>;
+			reset-gpios = <&pio 39 0>;
+			interrupt-controller;
+			#interrupt-cells = <1>;
+			interrupt-parent = <&pio>;
+			interrupts = <38 IRQ_TYPE_LEVEL_HIGH>;
+
+			mdio {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				swphy0: phy at 0 {
+					reg = <0>;
+				};
+
+				swphy1: phy at 1 {
+					reg = <1>;
+				};
+
+				swphy2: phy at 2 {
+					reg = <2>;
+				};
+
+				swphy3: phy at 3 {
+					reg = <3>;
+				};
+
+				swphy4: phy at 4 {
+					reg = <4>;
+				};
+			};
+
+			ports {
+				#address-cells = <1>;
+				#size-cells = <0>;
+
+				port at 0 {
+					reg = <0>;
+					label = "lan1";
+					phy-handle = <&swphy0>;
+				};
+
+				port at 1 {
+					reg = <1>;
+					label = "lan2";
+					phy-handle = <&swphy1>;
+				};
+
+				port at 2 {
+					reg = <2>;
+					label = "lan3";
+					phy-handle = <&swphy2>;
+				};
+
+				port at 3 {
+					reg = <3>;
+					label = "lan4";
+					phy-handle = <&swphy3>;
+				};
+
+				port at 4 {
+					reg = <4>;
+					label = "wan";
+					nvmem-cells = <&macaddr_wan>;
+					nvmem-cell-names = "mac-address";
+					phy-handle = <&swphy4>;
+				};
+
+				port at 6 {
+					reg = <6>;
+					ethernet = <&gmac0>;
+					phy-mode = "2500base-x";
+
+					fixed-link {
+						speed = <2500>;
+						full-duplex;
+						pause;
+					};
+				};
+			};
+		};
+	};
+};
+
+&crypto {
+	status = "okay";
+};
+
+&wifi {
+	status = "okay";
+
+	mediatek,mtd-eeprom = <&factory 0x0>;
+	nvmem-cells = <&macaddr_wifi 0>;
+	nvmem-cell-names = "mac-address";
+};
+
+&spi2 {
+	pinctrl-names = "default";
+	pinctrl-0 = <&spi2_flash_pins>;
+	status = "okay";
+
+	flash at 0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "jedec,spi-nor";
+		reg = <0>;
+		spi-max-frequency = <52000000>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			partition at 00000 {
+				label = "BL2";
+				reg = <0x00000 0x0040000>;
+				read-only;
+			};
+
+			partition at 40000 {
+				label = "u-boot-env";
+				reg = <0x40000 0x0010000>;
+			};
+
+			factory: partition at 50000 {
+				label = "Factory";
+				reg = <0x50000 0x00B0000>;
+				read-only;
+
+				nvmem-layout {
+					compatible = "fixed-layout";
+					#address-cells = <1>;
+					#size-cells = <1>;
+
+					macaddr_wifi: macaddr at 4 {
+						reg = <0x4 0x6>;
+					};
+
+					macaddr_wan: macaddr at 24 {
+						reg = <0x24 0x6>;
+					};
+
+					macaddr_lan: macaddr at 2a {
+						reg = <0x2a 0x6>;
+					};
+				};
+			};
+
+			partition at 100000 {
+				label = "FIP";
+				reg = <0x100000 0x0080000>;
+				read-only;
+			};
+
+			partition at 180000 {
+				label = "firmware";
+				reg = <0x180000 0x1E80000>;
+			};
+		};
+	};
+};
+
+&pio {
+	uart1_pins: uart1-pins {
+		mux {
+			function = "uart";
+			groups = "uart1_0";
+		};
+	};
+
+	uart2_pins: uart2-pins {
+		mux {
+			function = "uart";
+			groups = "uart2_0_tx_rx";
+		};
+	};
+
+	spi2_flash_pins: spi2-pins {
+		mux {
+			function = "spi";
+			groups = "spi2", "spi2_wp_hold";
+		};
+
+		conf-pu {
+			pins = "SPI2_CS", "SPI2_HOLD", "SPI2_WP";
+			drive-strength = <MTK_DRIVE_8mA>;
+			bias-pull-up = <MTK_PUPD_SET_R1R0_11>;
+		};
+
+		conf-pd {
+			pins = "SPI2_CLK", "SPI2_MOSI", "SPI2_MISO";
+			drive-strength = <MTK_DRIVE_8mA>;
+			bias-pull-down = <MTK_PUPD_SET_R1R0_11>;
+		};
+	};
+};
+
+&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";
+};
+
+&xhci {
+	mediatek,u3p-dis-msk = <0x0>;
+	phys = <&u2port0 PHY_TYPE_USB2>,
+	       <&u3port0 PHY_TYPE_USB3>;
+	status = "okay";
+	vusb33-supply = <&reg_3p3v>;
+	vbus-supply = <&reg_5v>;
+};
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 fff39006da..e1c0315fab 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
@@ -137,6 +137,10 @@ mediatek_setup_macs()
 	bananapi,bpi-r4)
 		wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1)
 		;;
+	gatonetworks,gdsp)
+		local factory_dev="/dev/mtd$(find_mtd_index "Factory")"
+		label_mac=$(get_mac_binary $factory_dev 0x4)
+		;;
 	h3c,magic-nx30-pro)
 		wan_mac=$(mtd_get_mac_ascii pdt_data_1 ethaddr)
 		lan_mac=$(macaddr_add "$wan_mac" 1)
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 3042858353..e94eb8880b 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
@@ -89,6 +89,11 @@ case "$board" in
 		addr=$(mtd_get_mac_binary "Odm" 0x81)
 		[ "$PHYNBR" = "1" ] && macaddr_add $addr 3 > /sys${DEVPATH}/macaddress
 		;;
+	gatonetworks,gdsp)
+		addr=$(get_mac_label)
+		[ "$PHYNBR" = "0" ] && echo "$addr" > /sys${DEVPATH}/macaddress
+		[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 1) > /sys${DEVPATH}/macaddress
+		;;
 	glinet,gl-mt6000|\
 	glinet,gl-x3000|\
 	glinet,gl-xe3000)
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 7fe2d29d31..fa4faf151b 100755
--- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
@@ -111,6 +111,7 @@ platform_do_upgrade() {
 		;;
 	cudy,re3000-v1|\
 	cudy,wr3000-v1|\
+	gatonetworks,gdsp|\
 	yuncore,ax835)
 		default_do_upgrade "$1"
 		;;
diff --git a/target/linux/mediatek/image/filogic.mk b/target/linux/mediatek/image/filogic.mk
index 5dfde755a0..97837cf9c3 100644
--- a/target/linux/mediatek/image/filogic.mk
+++ b/target/linux/mediatek/image/filogic.mk
@@ -670,6 +670,22 @@ define Device/edgecore_eap111
 endef
 TARGET_DEVICES += edgecore_eap111
 
+define Device/gatonetworks_gdsp
+  DEVICE_VENDOR := GatoNetworks
+  DEVICE_MODEL := gdsp
+  DEVICE_DTS := mt7981b-gatonetworks-gdsp
+  DEVICE_DTS_DIR := ../dts
+  IMAGES := sysupgrade.bin
+  IMAGE_SIZE := 32768k
+  DEVICE_PACKAGES := kmod-mt7915e kmod-mt7981-firmware mt7981-wo-firmware \
+    kmod-usb-net-qmi-wwan uqmi kmod-usb3 kmod-usb-serial-option \
+    -kmod-phy-aquantia
+  ARTIFACTS := preloader.bin bl31-uboot.fip
+  ARTIFACT/preloader.bin := mt7981-bl2 nor-ddr3
+  ARTIFACT/bl31-uboot.fip := mt7981-bl31-uboot gatonetworks_gdsp
+endef
+TARGET_DEVICES += gatonetworks_gdsp
+
 define Device/glinet_gl-mt2500
   DEVICE_VENDOR := GL.iNet
   DEVICE_MODEL := GL-MT2500
-- 
2.47.0




More information about the openwrt-devel mailing list