diff --git a/package/boot/uboot-mediatek/Makefile b/package/boot/uboot-mediatek/Makefile index 3776cf6e112..df0c8900ac0 100644 --- a/package/boot/uboot-mediatek/Makefile +++ b/package/boot/uboot-mediatek/Makefile @@ -6,6 +6,9 @@ PKG_RELEASE:=3 PKG_HASH:=78e8bfc382fe388f9b55aa1daf8c563522a037779b5d4c349d1415e381f1243e PKG_BUILD_DEPENDS:=!(TARGET_ramips||TARGET_mediatek_mt7623):arm-trusted-firmware-tools/host PKG_PARALLEL_VARIANTS:=1 +# Boards that drive the MT7987 built-in 2.5G PHY link its firmware into U-Boot, +# so the blobs linux-firmware stages have to exist before this package builds. +PKG_BUILD_DEPENDS+= PACKAGE_mt7987-2p5g-phy-firmware:linux-firmware ifdef CONFIG_TARGET_ramips UBOOT_USE_INTREE_DTC:=1 @@ -1157,6 +1160,18 @@ define U-Boot/mt7987_bananapi_bpi-r4-lite-nor FIP_COMPRESS:=1 endef +define U-Boot/mt7987_glinet_gl-be10000 + NAME:=GL.iNet GL-BE10000 + BUILD_SUBTARGET:=filogic + BUILD_DEVICES:=glinet_gl-be10000-ubootmod + UBOOT_CONFIG:=mt7987a_glinet_gl-be10000 + UBOOT_IMAGE:=u-boot.fip + BL2_BOOTDEV:=spim-nand2-4k-ubi + BL2_SOC:=mt7987 + BL2_DDRTYPE:=comb-be10000 + DEPENDS:=+trusted-firmware-a-mt7987-spim-nand2-4k-ubi-comb-be10000 +mt7987-2p5g-phy-firmware +endef + define U-Boot/mt7987_rfb-emmc NAME:=MT7987 Reference Board BUILD_SUBTARGET:=filogic @@ -1579,6 +1594,7 @@ UBOOT_TARGETS := \ mt7987_bananapi_bpi-r4-lite-sdmmc \ mt7987_bananapi_bpi-r4-lite-snand \ mt7987_bananapi_bpi-r4-lite-nor \ + mt7987_glinet_gl-be10000 \ mt7987_rfb-emmc \ mt7987_rfb-sd \ mt7987_rfb-spim-nand \ @@ -1640,6 +1656,17 @@ endif endef endif +# incbin'd by board/mediatek, so they must exist before the build +ifeq ($(BUILD_VARIANT),mt7987_glinet_gl-be10000) +define Build/Prepare + $(call Build/Prepare/Default) + $(CP) $(STAGING_DIR_IMAGE)/i2p5ge-phy-pmb.bin \ + $(STAGING_DIR_IMAGE)/i2p5ge-phy-DSPBitTb.bin \ + $(PKG_BUILD_DIR)/board/mediatek/mt7987/ + $(CP) ./files/openwrt_logo.bmp $(PKG_BUILD_DIR)/board/mediatek/common/ +endef +endif + define Build/Compile $(call Build/Compile/U-Boot) ifeq ($(UBOOT_IMAGE),u-boot.fip) diff --git a/package/boot/uboot-mediatek/files/openwrt_logo.bmp b/package/boot/uboot-mediatek/files/openwrt_logo.bmp new file mode 100644 index 00000000000..28b36662b29 Binary files /dev/null and b/package/boot/uboot-mediatek/files/openwrt_logo.bmp differ diff --git a/package/boot/uboot-mediatek/patches/481-add-glinet-be10000.patch b/package/boot/uboot-mediatek/patches/481-add-glinet-be10000.patch new file mode 100644 index 00000000000..1f8e734bb6e --- /dev/null +++ b/package/boot/uboot-mediatek/patches/481-add-glinet-be10000.patch @@ -0,0 +1,387 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: John Crispin +Subject: [PATCH] mt7987: add the GL.iNet GL-BE10000 + +MT7987 board that boots from SPI-NAND on SPI2 with the FIP inside UBI. +gmac1 drives the SoC built-in 2.5G PHY. + +--- a/arch/arm/dts/Makefile ++++ b/arch/arm/dts/Makefile +@@ -1118,6 +1118,7 @@ + mt7987a-bpi-r4-lite-emmc.dtb \ + mt7987a-bpi-r4-lite-sd.dtb \ + mt7987a-emmc-rfb.dtb \ ++ mt7987a-glinet-gl-be10000.dtb \ + mt7987a-rfb.dtb \ + mt7987a-routerich_be7200.dtb \ + mt7987a-sd-rfb.dtb \ +--- /dev/null ++++ b/arch/arm/dts/mt7987a-glinet-gl-be10000.dts +@@ -0,0 +1,25 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (c) 2026 GL.iNet ++ */ ++ ++/dts-v1/; ++#include "mt7987a.dtsi" ++#include ++ ++/ { ++ model = "GL.iNet GL-BE10000"; ++ compatible = "glinet,gl-be10000", ++ "mediatek,mt7987"; ++ ++ gpio-keys { ++ compatible = "gpio-keys"; ++ ++ button-reset { ++ label = "reset"; ++ linux,code = ; ++ gpios = <&pio 4 GPIO_ACTIVE_LOW>; ++ debounce-interval = <10>; ++ }; ++ }; ++}; +--- /dev/null ++++ b/arch/arm/dts/mt7987a-glinet-gl-be10000-u-boot.dtsi +@@ -0,0 +1,85 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (c) 2026 GL.iNet ++ */ ++ ++#include "mt7987a-u-boot.dtsi" ++#include "mt7987-netsys-u-boot.dtsi" ++ ++/ { ++ model = "GL.iNet GL-BE10000"; ++ compatible = "glinet,gl-be10000", ++ "mediatek,mt7987"; ++}; ++ ++/* ++ * LAN port, and the one to use. gmac1 drives the SoC built-in 2.5G PHY, which ++ * mtk-2p5ge supports on MT7987. Its firmware is linked into U-Boot by ++ * board/mediatek/mt7987/i2p5ge_fw.c, so it needs no storage and works before ++ * any UBI exists. ++ */ ++ð1 { ++ status = "okay"; ++ pinctrl-names = "default"; ++ pinctrl-0 = <&mdio0_pins>; ++ phy-mode = "internal"; ++ phy-handle = <&phy15>; ++ ++ phy15: eth-phy@15 { ++ compatible = "ethernet-phy-ieee802.3-c45"; ++ reg = <15>; ++ }; ++}; ++ ++/* ++ * pio 0 is the MDIO bus reset, active low. mtk_eth only releases it on the ++ * switch code path, which this board does not take, so hog it high. ++ */ ++&pio { ++ mdio-reset-hog { ++ gpio-hog; ++ gpios = <0 GPIO_ACTIVE_HIGH>; ++ output-high; ++ line-name = "mdio-reset"; ++ }; ++}; ++ ++&spi2 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&spi2_flash_pins>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ must_tx; ++ enhance_timing; ++ dma_ext; ++ ipm_design; ++ support_quad; ++ tick_dly = <2>; ++ sample_sel = <0>; ++ ++ spi_nand@0 { ++ compatible = "spi-nand"; ++ reg = <0>; ++ spi-max-frequency = <52000000>; ++ spi-rx-bus-width = <4>; ++ spi-tx-bus-width = <4>; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "bl2"; ++ reg = <0x0 0x200000>; ++ }; ++ ++ partition@200000 { ++ label = "ubi"; ++ reg = <0x200000 0x1fe00000>; ++ compatible = "linux,ubi"; ++ }; ++ }; ++ }; ++}; +--- /dev/null ++++ b/board/mediatek/mt7987/i2p5ge_fw.c +@@ -0,0 +1,47 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Firmware for the MT7987 built-in 2.5G ethernet PHY. ++ * ++ * mtk-2p5ge fetches the two blobs through a weak mt7987_i2p5ge_get_fw(), whose ++ * default implementation runs an environment script to read them out of ++ * storage. Link them into U-Boot instead: the PHY is the recovery path, so it ++ * has to come up before any UBI exists and while a broken UBI is being ++ * replaced. Returning 0 rather than a positive value tells the caller the ++ * buffers are static and must not be freed. ++ * ++ * The blobs are copied into this directory by the OpenWrt package before the ++ * build, from what linux-firmware stages. ++ */ ++ ++#include ++ ++asm( ++" .section .rodata\n" ++" .balign 16\n" ++" .globl i2p5ge_pmb_fw\n" ++"i2p5ge_pmb_fw:\n" ++" .incbin \"board/mediatek/mt7987/i2p5ge-phy-pmb.bin\"\n" ++" .globl i2p5ge_pmb_fw_end\n" ++"i2p5ge_pmb_fw_end:\n" ++" .balign 16\n" ++" .globl i2p5ge_dsp_fw\n" ++"i2p5ge_dsp_fw:\n" ++" .incbin \"board/mediatek/mt7987/i2p5ge-phy-DSPBitTb.bin\"\n" ++" .globl i2p5ge_dsp_fw_end\n" ++"i2p5ge_dsp_fw_end:\n" ++" .previous\n" ++); ++ ++extern const u8 i2p5ge_pmb_fw[], i2p5ge_pmb_fw_end[]; ++extern const u8 i2p5ge_dsp_fw[], i2p5ge_dsp_fw_end[]; ++ ++int mt7987_i2p5ge_get_fw(void **fw, size_t *fwsize, ++ void **dspfw, size_t *dspfwsize) ++{ ++ *fw = (void *)i2p5ge_pmb_fw; ++ *fwsize = i2p5ge_pmb_fw_end - i2p5ge_pmb_fw; ++ *dspfw = (void *)i2p5ge_dsp_fw; ++ *dspfwsize = i2p5ge_dsp_fw_end - i2p5ge_dsp_fw; ++ ++ return 0; ++} +--- a/board/mediatek/mt7987/Makefile ++++ b/board/mediatek/mt7987/Makefile +@@ -1,3 +1,4 @@ + # SPDX-License-Identifier: GPL-2.0 + + obj-y += mt7987_rfb.o ++obj-$(CONFIG_PHY_MEDIATEK_2P5GE) += i2p5ge_fw.o +--- /dev/null ++++ b/configs/mt7987a_glinet_gl-be10000_defconfig +@@ -0,0 +1,136 @@ ++CONFIG_ARM=y ++CONFIG_ARM_SMCCC=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_DEFAULT_DEVICE_TREE="mt7987a-glinet-gl-be10000" ++CONFIG_OF_LIBFDT_OVERLAY=y ++CONFIG_TARGET_MT7987=y ++CONFIG_CPU_ARMV8=y ++CONFIG_SYS_BOOTM_LEN=0x6000000 ++CONFIG_SYS_LOAD_ADDR=0x48000000 ++CONFIG_PRE_CON_BUF_ADDR=0x4007ef00 ++CONFIG_DEBUG_UART_BASE=0x11000000 ++CONFIG_DEBUG_UART_CLOCK=40000000 ++CONFIG_DEBUG_UART=y ++CONFIG_FIT=y ++CONFIG_AUTOBOOT_MENU_SHOW=y ++CONFIG_DEFAULT_FDT_FILE="mt7987a-glinet-gl-be10000" ++CONFIG_SYS_CBSIZE=512 ++CONFIG_SYS_PBSIZE=1049 ++CONFIG_LOGLEVEL=7 ++CONFIG_PRE_CONSOLE_BUFFER=y ++CONFIG_LOG=y ++# CONFIG_BOARD_INIT is not set ++CONFIG_BOARD_LATE_INIT=y ++CONFIG_HUSH_PARSER=y ++CONFIG_SYS_PROMPT="GL-BE10000> " ++# 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_LICENSE=y ++CONFIG_CMD_BOOTMENU=y ++CONFIG_CMD_ASKENV=y ++CONFIG_CMD_ERASEENV=y ++CONFIG_CMD_ENV_FLAGS=y ++CONFIG_CMD_RNG=y ++CONFIG_CMD_STRINGS=y ++CONFIG_CMD_CPU=y ++CONFIG_CMD_DM=y ++CONFIG_CMD_GPIO=y ++CONFIG_CMD_MDIO=y ++CONFIG_CMD_MII=y ++CONFIG_CMD_NET=y ++CONFIG_CMD_GPT=y ++CONFIG_CMD_I2C=y ++CONFIG_CMD_MTD=y ++CONFIG_CMD_PART=y ++CONFIG_CMD_PCI=y ++CONFIG_CMD_USB=y ++CONFIG_CMD_TFTPSRV=y ++CONFIG_CMD_RARP=y ++CONFIG_CMD_CDP=y ++CONFIG_CMD_SNTP=y ++CONFIG_CMD_LINK_LOCAL=y ++CONFIG_CMD_DHCP=y ++CONFIG_CMD_DNS=y ++CONFIG_CMD_PING=y ++CONFIG_CMD_PXE=y ++CONFIG_CMD_CACHE=y ++CONFIG_CMD_PSTORE=y ++CONFIG_CMD_PSTORE_MEM_ADDR=0x42ff0000 ++CONFIG_CMD_UUID=y ++CONFIG_CMD_HASH=y ++CONFIG_CMD_SMC=y ++CONFIG_CMD_EXT4=y ++CONFIG_CMD_FAT=y ++CONFIG_CMD_FS_GENERIC=y ++CONFIG_CMD_FS_UUID=y ++CONFIG_CMD_SF_TEST=y ++CONFIG_CMD_UBI=y ++CONFIG_CMD_UBI_RENAME=y ++# CONFIG_CMD_XIMG is not set ++CONFIG_ENV_OVERWRITE=y ++CONFIG_ENV_IS_IN_UBI=y ++CONFIG_ENV_REDUNDANT=y ++CONFIG_ENV_UBI_PART="ubi" ++CONFIG_ENV_UBI_VOLUME="ubootenv" ++CONFIG_ENV_UBI_VOLUME_REDUND="ubootenv2" ++CONFIG_ENV_RELOC_GD_ENV_ADDR=y ++CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE=y ++CONFIG_ENV_DEFAULT_ENV_TEXT_FILE="defenvs/glinet_gl-be10000_env" ++CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y ++CONFIG_VERSION_VARIABLE=y ++CONFIG_NETCONSOLE=y ++CONFIG_USE_IPADDR=y ++CONFIG_IPADDR="192.168.1.1" ++CONFIG_USE_NETMASK=y ++CONFIG_NETMASK="255.255.255.0" ++CONFIG_USE_SERVERIP=y ++CONFIG_SERVERIP="192.168.1.254" ++CONFIG_NET_RANDOM_ETHADDR=y ++CONFIG_BUTTON=y ++CONFIG_BUTTON_GPIO=y ++CONFIG_CLK=y ++CONFIG_GPIO_HOG=y ++CONFIG_DM_I2C=y ++CONFIG_SYS_I2C_MTK=y ++# CONFIG_MMC is not set ++CONFIG_MTD=y ++CONFIG_DM_MTD=y ++CONFIG_MTD_SPI_NAND=y ++CONFIG_MTD_UBI_FASTMAP=y ++CONFIG_PHY_ETHERNET_ID=y ++CONFIG_PHY_FIXED=y ++CONFIG_PHY_MEDIATEK_2P5GE=y ++CONFIG_MEDIATEK_ETH=y ++CONFIG_PHY=y ++CONFIG_PHY_MTK_TPHY=y ++CONFIG_PINCTRL=y ++CONFIG_PINCONF=y ++CONFIG_PINCTRL_MT7987=y ++CONFIG_POWER_DOMAIN=y ++CONFIG_MTK_POWER_DOMAIN=y ++CONFIG_DM_REGULATOR=y ++CONFIG_DM_REGULATOR_FIXED=y ++CONFIG_DM_REGULATOR_GPIO=y ++CONFIG_DM_RNG=y ++CONFIG_RNG_MTK_V2=y ++CONFIG_SCSI=y ++CONFIG_DM_SERIAL=y ++CONFIG_SERIAL_RX_BUFFER=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_ZSTD=y ++CONFIG_HEXDUMP=y +--- /dev/null ++++ b/defenvs/glinet_gl-be10000_env +@@ -0,0 +1,55 @@ ++ethaddr_factory=ubi read $fwaddr factory && setexpr.b maclow *0x46004005 + 1 && mw.b 0x46004005 $maclow && env readmem -b ethaddr 0x46004000 0x6 ; setenv maclow ; setenv ethaddr_factory ++ipaddr=192.168.1.1 ++serverip=192.168.1.254 ++loadaddr=0x48000000 ++fwaddr=0x46000000 ++bootargs=console=ttyS0,115200n1 earlycon=uart8250,mmio32,0x11000000 pci=pcie_bus_perf root=/dev/fit0 rootwait ubi.block=0,fit ++bootconf=config-1 ++bootcmd=if pstore check ; then run boot_recovery ; else run boot_ubi ; fi ++bootdelay=3 ++bootfile=openwrt-mediatek-filogic-glinet_gl-be10000-ubootmod-initramfs-recovery.itb ++bootfile_bl2=openwrt-mediatek-filogic-glinet_gl-be10000-ubootmod-preloader.bin ++bootfile_fip=openwrt-mediatek-filogic-glinet_gl-be10000-ubootmod-bl31-uboot.fip ++bootfile_upg=openwrt-mediatek-filogic-glinet_gl-be10000-ubootmod-squashfs-sysupgrade.itb ++bootmenu_confirm_return=askenv - Press ENTER to return to menu ; bootmenu 60 ++bootmenu_default=0 ++bootmenu_delay=3 ++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 production system from NAND.=run boot_production ; run bootmenu_confirm_return ++bootmenu_3=Boot recovery system from NAND.=run boot_recovery ; run bootmenu_confirm_return ++bootmenu_4=Load production system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_production ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_5=Load recovery system via TFTP then write to NAND.=setenv noboot 1 ; setenv replacevol 1 ; run boot_tftp_recovery ; setenv noboot ; setenv replacevol ; run bootmenu_confirm_return ++bootmenu_6=Load BL31+U-Boot FIP via TFTP then write to NAND.=run boot_tftp_write_fip ; run bootmenu_confirm_return ++bootmenu_7=Load BL2 preloader via TFTP then write to NAND.=run boot_tftp_write_bl2 ; run bootmenu_confirm_return ++bootmenu_8=Reboot.=reset ++bootmenu_9=Reset all settings to factory defaults.=run reset_factory ; reset ++boot_first=if button reset ; then run boot_tftp_recovery ; setenv flag_recover 1 ; run boot_default ; fi ; bootmenu ++boot_default=if env exists flag_recover ; then else run bootcmd ; fi ; run boot_recovery ; setenv replacevol 1 ; run boot_tftp_forever ++boot_production=run ubi_read_production && bootm $loadaddr#$bootconf ++boot_recovery=run ubi_read_recovery && bootm $loadaddr#$bootconf ++boot_ubi=run boot_production ; run boot_recovery ++boot_tftp_forever=while true ; do run boot_tftp_recovery ; sleep 1 ; done ++boot_tftp_production=tftpboot $loadaddr $bootfile_upg && env exists replacevol && iminfo $loadaddr && run ubi_write_production ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi ++boot_tftp_recovery=tftpboot $loadaddr $bootfile && env exists replacevol && iminfo $loadaddr && run ubi_write_recovery ; if env exists noboot ; then else bootm $loadaddr#$bootconf ; fi ++boot_tftp=tftpboot $loadaddr $bootfile && bootm $loadaddr#$bootconf ++boot_tftp_write_fip=tftpboot $loadaddr $bootfile_fip && run ubi_write_fip && run reset_factory ++boot_tftp_write_bl2=tftpboot $loadaddr $bootfile_bl2 && run snand_write_bl2 ++part_default=production ++part_recovery=recovery ++reset_factory=ubi part ubi ; mw $loadaddr 0x0 0x800 ; ubi write $loadaddr ubootenv 0x800 ; ubi write $loadaddr ubootenv2 0x800 ++snand_write_bl2=mtd erase bl2 && mtd write bl2 $loadaddr 0x0 0x80000 && mtd write bl2 $loadaddr 0x80000 0x80000 && mtd write bl2 $loadaddr 0x100000 0x80000 && mtd write bl2 $loadaddr 0x180000 0x80000 ++ubi_create_env=ubi check ubootenv || ubi create ubootenv 0x100000 dynamic ; ubi check ubootenv2 || ubi create ubootenv2 0x100000 dynamic ++ubi_prepare_rootfs=if ubi check rootfs_data ; then else if env exists rootfs_data_max ; then ubi create rootfs_data $rootfs_data_max dynamic || ubi create rootfs_data - dynamic ; else ubi create rootfs_data - dynamic ; fi ; fi ++ubi_read_production=ubi read $loadaddr fit && iminfo $loadaddr && run ubi_prepare_rootfs ++ubi_read_recovery=ubi check recovery && ubi read $loadaddr recovery ++ubi_remove_rootfs=ubi check rootfs_data && ubi remove rootfs_data ++ubi_write_fip=run ubi_remove_rootfs ; ubi check fip && ubi remove fip ; ubi create fip 0x200000 static ; ubi write $loadaddr fip 0x200000 ++ubi_write_production=ubi check fit && ubi remove fit ; run ubi_remove_rootfs ; ubi create fit $filesize dynamic && ubi write $loadaddr fit $filesize ++ubi_write_recovery=ubi check recovery && ubi remove recovery ; run ubi_remove_rootfs ; ubi create recovery $filesize dynamic && ubi write $loadaddr recovery $filesize ++_init_env=setenv _init_env ; run ubi_create_env ; saveenv ; saveenv ++_firstboot=setenv _firstboot ; run ethaddr_factory ; run _switch_to_menu ; 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" diff --git a/package/boot/uboot-mediatek/patches/482-glinet-be10000-show-openwrt-logo.patch b/package/boot/uboot-mediatek/patches/482-glinet-be10000-show-openwrt-logo.patch new file mode 100644 index 00000000000..25198aaadd0 --- /dev/null +++ b/package/boot/uboot-mediatek/patches/482-glinet-be10000-show-openwrt-logo.patch @@ -0,0 +1,293 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: John Crispin +Subject: [PATCH] mt7987: show the OpenWrt logo on the GL.iNet BE10000 + +BL2 draws the logo and leaves the panel running. Redraw it from U-Boot, +so the screen tracks the boot instead of holding one picture until +Linux. + +--- a/arch/arm/dts/mt7987a-glinet-gl-be10000-u-boot.dtsi ++++ b/arch/arm/dts/mt7987a-glinet-gl-be10000-u-boot.dtsi +@@ -31,11 +31,79 @@ + }; + }; + ++/* bootph-all throughout: the framebuffer is reserved before relocation */ ++&spi1 { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&spi1_pins>; ++ #address-cells = <1>; ++ #size-cells = <0>; ++ status = "okay"; ++ bootph-all; ++ must_tx; ++ enhance_timing; ++ dma_ext; ++ ipm_design; ++ support_quad; ++ tick_dly = <2>; ++ sample_sel = <0>; ++ ++ display@0 { ++ compatible = "sitronix,st7789p3"; ++ reg = <0>; ++ spi-max-frequency = <52000000>; ++ spi-cpol; ++ spi-cpha; ++ bootph-all; ++ ++ /* BL2 drew the splash and left the controller running */ ++ skip-init; ++ ++ rotation = <270>; ++ ++ dc-gpios = <&pio 22 GPIO_ACTIVE_HIGH>; ++ reset-gpios = <&pio 10 GPIO_ACTIVE_HIGH>; ++ backlight = <&backlight>; ++ }; ++}; ++ ++&pwm { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pwm2_pins>; ++ status = "okay"; ++ bootph-all; ++}; ++ ++/ { ++ backlight: backlight { ++ compatible = "pwm-backlight"; ++ pwms = <&pwm 2 50000>; ++ brightness-levels = <0 16 32 48 64 80 96 112 128 144 160 176 192 208 224 255>; ++ default-brightness-level = <12>; ++ bootph-all; ++ }; ++}; ++ + /* + * pio 0 is the MDIO bus reset, active low. mtk_eth only releases it on the + * switch code path, which this board does not take, so hog it high. + */ + &pio { ++ bootph-all; ++ ++ spi1_pins: spi1-pins { ++ mux { ++ function = "spi"; ++ groups = "spi1_1"; ++ }; ++ }; ++ ++ pwm2_pins: pwm2-pins { ++ mux { ++ function = "pwm"; ++ groups = "pwm2_0"; ++ }; ++ }; ++ + mdio-reset-hog { + gpio-hog; + gpios = <0 GPIO_ACTIVE_HIGH>; +--- /dev/null ++++ b/board/mediatek/common/panel_logo.c +@@ -0,0 +1,115 @@ ++// SPDX-License-Identifier: GPL-2.0 ++/* ++ * Copyright (C) 2026 OpenWrt.org ++ * ++ * Draws the OpenWrt logo and the stage name on an ST7789P3 front panel. The ++ * boards that carry one share the picture, the text position and the panel ++ * geometry, so only the calls into here belong in a board file. ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include "panel_logo.h" ++ ++/* openwrt_logo.bmp, incbin'd by the .bmp.o rule in Makefile.lib-u-boot */ ++extern u8 __splash_openwrt_logo_begin[]; ++ ++/* ++ * Only claimed when the panel actually came up under us. A static property ++ * would be a promise that U-Boot ran, which is false for netboot or recovery, ++ * and the panel is write-only so the kernel cannot check for itself. ++ */ ++void fdt_mark_panel_initialised(void *blob) ++{ ++ struct udevice *vid; ++ int node; ++ ++ vid = uclass_try_first_device(UCLASS_VIDEO); ++ if (!vid || !device_active(vid)) ++ return; ++ ++ node = fdt_node_offset_by_compatible(blob, -1, "panel-mipi-dbi-spi"); ++ if (node < 0) ++ return; ++ ++ if (fdt_setprop_empty(blob, node, "bootloader-initialized")) ++ printf("cannot mark the panel as initialised\n"); ++} ++ ++/* ++ * The first scanline clear of the centred 280x83 logo, rounded up to the 8x16 ++ * font cell. scripts/gen-boot-logos.py in the OpenWrt tree puts the BL2 text ++ * band at the same y with the same glyphs, so changing CONFIG_VIDEO_FONT_* here ++ * needs the BL2 blob regenerated too. ++ */ ++#define PANEL_TEXT_Y 176 ++ ++static void panel_text(struct udevice *vid, const char *text) ++{ ++ struct video_priv *vid_priv = dev_get_uclass_priv(vid); ++ struct vidconsole_priv *cons; ++ struct udevice *con; ++ int len = strlen(text); ++ int max, x; ++ ++ if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &con)) ++ return; ++ ++ cons = dev_get_uclass_priv(con); ++ max = vid_priv->xsize / cons->x_charsize; ++ x = len < max ? (vid_priv->xsize - len * cons->x_charsize) / 2 : 0; ++ ++ vidconsole_set_cursor_pos(con, x, PANEL_TEXT_Y); ++ vidconsole_put_stringn(con, text, max); ++} ++ ++/* ++ * Order matters. video_sync() runs the driver blit before it looks at its own ++ * rate limit, and CONFIG_CYCLIC is off here, so every call puts a whole 320x240 ++ * frame on the wire, which is 24 ms the eye can see. video_fill_part() and ++ * vidconsole_put_stringn() only touch the framebuffer. video_bmp_display() ends ++ * in video_sync(), so it goes last and its sync is the only blit of the frame. ++ * ++ * NO_FB_CLEAR keeps the BL2 picture on the panel through probe, so nothing has ++ * painted the framebuffer and the background is laid down here. ++ */ ++static void panel_draw(const char *text) ++{ ++ struct video_priv *priv; ++ struct udevice *vid; ++ ++ if (uclass_first_device_err(UCLASS_VIDEO, &vid)) ++ return; ++ ++ priv = dev_get_uclass_priv(vid); ++ video_fill_part(vid, 0, 0, priv->xsize, priv->ysize, priv->colour_bg); ++ ++ panel_text(vid, text); ++ video_bmp_display(vid, map_to_sysmem(__splash_openwrt_logo_begin), ++ BMP_ALIGN_CENTER, BMP_ALIGN_CENTER, true); ++} ++ ++void board_show_logo(void) ++{ ++ panel_draw(PLAIN_VERSION); ++} ++ ++/* The panel keeps this picture until Linux hands over to whatever draws next */ ++void board_preboot_os(void) ++{ ++ char *desc; ++ ++ if (!images.fit_hdr_os || ++ fit_get_desc(images.fit_hdr_os, images.fit_noffset_os, &desc)) ++ desc = "Booting Linux"; ++ ++ panel_draw(desc); ++} +--- /dev/null ++++ b/board/mediatek/common/panel_logo.h +@@ -0,0 +1,17 @@ ++/* SPDX-License-Identifier: GPL-2.0 */ ++/* ++ * Copyright (C) 2026 OpenWrt.org ++ */ ++ ++#ifndef _MEDIATEK_PANEL_LOGO_H ++#define _MEDIATEK_PANEL_LOGO_H ++ ++#if IS_ENABLED(CONFIG_VIDEO_ST7789P3) ++void board_show_logo(void); ++void fdt_mark_panel_initialised(void *blob); ++#else ++static inline void board_show_logo(void) { } ++static inline void fdt_mark_panel_initialised(void *blob) { } ++#endif ++ ++#endif /* _MEDIATEK_PANEL_LOGO_H */ +--- a/board/mediatek/mt7987/Makefile ++++ b/board/mediatek/mt7987/Makefile +@@ -2,3 +2,5 @@ + + obj-y += mt7987_rfb.o + obj-$(CONFIG_PHY_MEDIATEK_2P5GE) += i2p5ge_fw.o ++obj-$(CONFIG_VIDEO_ST7789P3) += ../common/panel_logo.o \ ++ ../common/openwrt_logo.bmp.o +--- a/board/mediatek/mt7987/mt7987_rfb.c ++++ b/board/mediatek/mt7987/mt7987_rfb.c +@@ -14,6 +14,8 @@ + #include + #include + ++#include "../common/panel_logo.h" ++ + #ifndef CONFIG_RESET_BUTTON_LABEL + #define CONFIG_RESET_BUTTON_LABEL "reset" + #endif +@@ -38,6 +40,9 @@ int board_late_init(void) + } + } + env_relocate(); ++ ++ board_show_logo(); ++ + return 0; + } + +@@ -72,6 +77,8 @@ int mtk_ft_system_setup(void *blob, stru + ;; + } + ++ fdt_mark_panel_initialised(blob); ++ + chosen = fdt_path_offset(blob, "/chosen"); + if (chosen <= 0) + return 0; +--- a/configs/mt7987a_glinet_gl-be10000_defconfig ++++ b/configs/mt7987a_glinet_gl-be10000_defconfig +@@ -43,6 +43,7 @@ CONFIG_CMD_STRINGS=y + CONFIG_CMD_CPU=y + CONFIG_CMD_DM=y + CONFIG_CMD_GPIO=y ++CONFIG_CMD_BMP=y + CONFIG_CMD_MDIO=y + CONFIG_CMD_MII=y + CONFIG_CMD_NET=y +@@ -116,6 +117,16 @@ CONFIG_PINCONF=y + CONFIG_PINCTRL_MT7987=y + CONFIG_POWER_DOMAIN=y + CONFIG_MTK_POWER_DOMAIN=y ++CONFIG_DM_PWM=y ++CONFIG_PWM_MTK=y ++CONFIG_VIDEO=y ++CONFIG_VIDEO_ST7789P3=y ++CONFIG_NO_FB_CLEAR=y ++CONFIG_BACKLIGHT=y ++CONFIG_BACKLIGHT_PWM=y ++# CONFIG_VIDEO_LOGO is not set ++# CONFIG_CYCLIC is not set ++# CONFIG_SYS_WHITE_ON_BLACK is not set + CONFIG_DM_REGULATOR=y + CONFIG_DM_REGULATOR_FIXED=y + CONFIG_DM_REGULATOR_GPIO=y