Prefer fastboot in U-Boot proper when the complete download agent fits the BootROM SRAM limit. Its shell and boot commands support provisioning and recovery beyond the SPL agent's flashing operations, without relying on the installed firmware.
This variant requires BL31 and an external DDR loader. Signed-off-by: Carlo Caione <[email protected]> --- arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi | 4 ++ arch/arm/dts/mt8370-genio-da-u-boot.dtsi | 3 ++ arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi | 4 ++ arch/arm/dts/mtk-genio-da-fit-binman-u-boot.dtsi | 62 ++++++++++++++++++++++++ arch/arm/mach-mediatek/Kconfig | 30 ++++++++++++ arch/arm/mach-mediatek/spl.c | 22 +++++---- board/mediatek/MAINTAINERS | 3 ++ configs/mt8370-genio-da-uboot-fastboot.config | 28 +++++++++++ configs/mt8370_genio_510_evk_da_uboot_defconfig | 2 + configs/mt8390_genio_700_evk_da_uboot_defconfig | 2 + 10 files changed, 150 insertions(+), 10 deletions(-) diff --git a/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi b/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi index 2ee7fb1f40c..86b38b0e484 100644 --- a/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi +++ b/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi @@ -16,5 +16,9 @@ #endif #ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT +#define MTK_DA_DESCRIPTION "MediaTek Genio 510 download agent" +#define MTK_DA_FIT_DESCRIPTION "MediaTek Genio 510 DA bootloaders" #include "mt8370-genio-da-u-boot.dtsi" +#undef MTK_DA_FIT_DESCRIPTION +#undef MTK_DA_DESCRIPTION #endif diff --git a/arch/arm/dts/mt8370-genio-da-u-boot.dtsi b/arch/arm/dts/mt8370-genio-da-u-boot.dtsi index 9d0d057cfc9..4ca46bbe2e2 100644 --- a/arch/arm/dts/mt8370-genio-da-u-boot.dtsi +++ b/arch/arm/dts/mt8370-genio-da-u-boot.dtsi @@ -12,6 +12,9 @@ #include "mtk-genio-binman-u-boot.dtsi" #include "mtk-genio-da-binman-u-boot.dtsi" +#ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT_UBOOT_FASTBOOT +#include "mtk-genio-da-fit-binman-u-boot.dtsi" +#endif &ssusb0 { dr_mode = "peripheral"; diff --git a/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi b/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi index 4fedbda9b3f..648cd0703f5 100644 --- a/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi +++ b/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi @@ -16,5 +16,9 @@ #endif #ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT +#define MTK_DA_DESCRIPTION "MediaTek Genio 700 download agent" +#define MTK_DA_FIT_DESCRIPTION "MediaTek Genio 700 DA bootloaders" #include "mt8370-genio-da-u-boot.dtsi" +#undef MTK_DA_FIT_DESCRIPTION +#undef MTK_DA_DESCRIPTION #endif diff --git a/arch/arm/dts/mtk-genio-da-fit-binman-u-boot.dtsi b/arch/arm/dts/mtk-genio-da-fit-binman-u-boot.dtsi new file mode 100644 index 00000000000..a605ad2504a --- /dev/null +++ b/arch/arm/dts/mtk-genio-da-fit-binman-u-boot.dtsi @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR MIT) +/* + * Copyright (c) 2026 BayLibre, SAS. + * Author: Carlo Caione <[email protected]> + */ + +&da { + fit { + description = MTK_DA_FIT_DESCRIPTION; + offset = <CONFIG_MTK_GENIO_DA_FIT_OFFSET>; + size = <CONFIG_MTK_GENIO_DA_FIT_MAX_SIZE>; + #address-cells = <1>; + + images { + uboot { + description = "U-Boot fastboot download agent"; + type = "firmware"; + os = "u-boot"; + arch = "arm64"; + compression = "gzip"; + compress = "gzip"; + load = <CONFIG_TEXT_BASE>; + entry = <CONFIG_TEXT_BASE>; + + u-boot { + }; + + hash { + algo = "sha256"; + }; + }; + + atf { + description = "ARM Trusted Firmware BL31"; + type = "firmware"; + os = "arm-trusted-firmware"; + arch = "arm64"; + compression = "gzip"; + compress = "gzip"; + load = <CONFIG_MTK_GENIO_BL31_LOAD_ADDR>; + entry = <CONFIG_MTK_GENIO_BL31_LOAD_ADDR>; + + atf-bl31 { + }; + + hash { + algo = "sha256"; + }; + }; + }; + + configurations { + default = "conf"; + + conf { + description = MTK_DA_DESCRIPTION; + firmware = "atf"; + loadables = "uboot"; + }; + }; + }; +}; diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig index eece6456e43..c24b1935e2e 100644 --- a/arch/arm/mach-mediatek/Kconfig +++ b/arch/arm/mach-mediatek/Kconfig @@ -275,8 +275,38 @@ config MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT downloads it into RAM. The download agent also configures the eMMC boot partition so that a newly flashed board can boot normally. +config MTK_BROM_DOWNLOAD_AGENT_UBOOT_FASTBOOT + bool "Run download-agent fastboot from U-Boot" + depends on SPL_RAM_DEVICE + depends on USB_FUNCTION_FASTBOOT + depends on FASTBOOT_FLASH_MMC + select MTK_BROM_DOWNLOAD_AGENT + help + Build a small SPL which loads BL31 and U-Boot from a FIT already + copied to DRAM by the external DDR loader. U-Boot proper then + provides the USB fastboot download agent. + endchoice +if MTK_BROM_DOWNLOAD_AGENT_UBOOT_FASTBOOT + +config MTK_GENIO_DA_FIT_OFFSET + hex "Download-agent FIT offset" + default 0x70000 if TARGET_MT8188 + help + Offset of the directly parseable FIT in the BootROM-loaded download + agent. This must match the external loader's DA_FIT_OFFSET value. + +config MTK_GENIO_DA_FIT_MAX_SIZE + hex "Maximum download-agent FIT size" + default 0x8f000 if TARGET_MT8188 + help + Fixed region reserved for the download-agent FIT and the maximum FIT + size accepted by this image layout. This must match the external + loader's DA_FIT_SIZE value while the loader copies the complete region. + +endif + config MTK_TZ_MOVABLE select ARCH_MISC_INIT select OF_SYSTEM_SETUP diff --git a/arch/arm/mach-mediatek/spl.c b/arch/arm/mach-mediatek/spl.c index 6f1ec052b95..120a94c6598 100644 --- a/arch/arm/mach-mediatek/spl.c +++ b/arch/arm/mach-mediatek/spl.c @@ -33,15 +33,17 @@ void board_init_f(ulong dummy) u32 spl_boot_device(void) { -#if defined(CONFIG_SPL_SPI) - return BOOT_DEVICE_SPI; -#elif defined(CONFIG_SPL_MMC) - return BOOT_DEVICE_MMC1; -#elif defined(CONFIG_SPL_NAND_SUPPORT) - return BOOT_DEVICE_NAND; -#elif defined(CONFIG_SPL_NOR_SUPPORT) - return BOOT_DEVICE_NOR; -#else + if (IS_ENABLED(CONFIG_MTK_BROM_DOWNLOAD_AGENT_UBOOT_FASTBOOT)) + return BOOT_DEVICE_RAM; + + if (CONFIG_IS_ENABLED(SPI)) + return BOOT_DEVICE_SPI; + if (CONFIG_IS_ENABLED(MMC)) + return BOOT_DEVICE_MMC1; + if (CONFIG_IS_ENABLED(NAND_SUPPORT)) + return BOOT_DEVICE_NAND; + if (CONFIG_IS_ENABLED(NOR_SUPPORT)) + return BOOT_DEVICE_NOR; + return BOOT_DEVICE_NONE; -#endif } diff --git a/board/mediatek/MAINTAINERS b/board/mediatek/MAINTAINERS index 61fefcf9a34..29b59852e45 100644 --- a/board/mediatek/MAINTAINERS +++ b/board/mediatek/MAINTAINERS @@ -25,11 +25,14 @@ F: arch/arm/dts/mt8390-genio-common-u-boot.dtsi F: arch/arm/dts/mtk-genio-*-binman-u-boot.dtsi F: arch/arm/dts/mtk-genio-binman-u-boot.dtsi F: configs/mt8370-genio-da-spl-fastboot.config +F: configs/mt8370-genio-da-uboot-fastboot.config F: configs/mt8370-genio-da.config F: configs/mt8188.config F: configs/mt8370_genio_510_evk_da_spl_defconfig +F: configs/mt8370_genio_510_evk_da_uboot_defconfig F: configs/mt8370_genio_510_evk_defconfig F: configs/mt8390_genio_700_evk_da_spl_defconfig +F: configs/mt8390_genio_700_evk_da_uboot_defconfig F: configs/mt8390_genio_700_evk_defconfig F: doc/board/mediatek/mt8188-genio-evk.rst diff --git a/configs/mt8370-genio-da-uboot-fastboot.config b/configs/mt8370-genio-da-uboot-fastboot.config new file mode 100644 index 00000000000..5a85b26df0d --- /dev/null +++ b/configs/mt8370-genio-da-uboot-fastboot.config @@ -0,0 +1,28 @@ +#include <configs/mt8370-genio-da.config> + +CONFIG_MTK_BROM_DOWNLOAD_AGENT_UBOOT_FASTBOOT=y +CONFIG_SYS_MALLOC_LEN=0x9000000 +CONFIG_CMD_FASTBOOT=y +CONFIG_USB_FUNCTION_FASTBOOT=y +CONFIG_FASTBOOT_FLASH=y +CONFIG_FASTBOOT_FLASH_MMC=y +CONFIG_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_FASTBOOT_MMC_BOOT_SUPPORT=y +CONFIG_FASTBOOT_MMC_USER_SUPPORT=y +CONFIG_SPL_RAM_DEVICE=y +CONFIG_SPL_LOAD_FIT_ADDRESS=0x41000000 +CONFIG_SPL_MAX_SIZE=0x25000 +CONFIG_SPL_CRC32=y +CONFIG_SPL_GZIP=y +# CONFIG_SPL_MMC is not set +# CONFIG_SPL_LIBDISK_SUPPORT is not set +# CONFIG_SPL_EFI_PARTITION is not set +# CONFIG_SPL_SYS_MMCSD_RAW_MODE is not set +CONFIG_BOOTDELAY=0 +CONFIG_USE_BOOTCOMMAND=y +CONFIG_BOOTCOMMAND="fastboot usb 0" +CONFIG_ENV_IS_NOWHERE=y +# CONFIG_ENV_IS_IN_MMC is not set +# CONFIG_BOOTSTD_FULL is not set +# CONFIG_CMD_BOOTFLOW is not set +# CONFIG_EFI_LOADER is not set diff --git a/configs/mt8370_genio_510_evk_da_uboot_defconfig b/configs/mt8370_genio_510_evk_da_uboot_defconfig new file mode 100644 index 00000000000..c696e89c892 --- /dev/null +++ b/configs/mt8370_genio_510_evk_da_uboot_defconfig @@ -0,0 +1,2 @@ +#include <configs/mt8370_genio_510_evk_defconfig> +#include <configs/mt8370-genio-da-uboot-fastboot.config> diff --git a/configs/mt8390_genio_700_evk_da_uboot_defconfig b/configs/mt8390_genio_700_evk_da_uboot_defconfig new file mode 100644 index 00000000000..102f61a3afc --- /dev/null +++ b/configs/mt8390_genio_700_evk_da_uboot_defconfig @@ -0,0 +1,2 @@ +#include <configs/mt8390_genio_700_evk_defconfig> +#include <configs/mt8370-genio-da-uboot-fastboot.config> -- 2.55.0
