Some provisioning flows need U-Boot's command support in addition to fastboot. Provide a U-Boot-based download agent for Genio 510 and 700 so these flows can run without relying on firmware already stored on the board.
Signed-off-by: Carlo Caione <[email protected]> --- arch/arm/dts/mt8188-genio-da-u-boot.dtsi | 3 ++ arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi | 4 ++ 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 | 3 ++ board/mediatek/MAINTAINERS | 3 ++ configs/mt8188-genio-da-uboot-fastboot.config | 20 ++++++++ configs/mt8370_genio_510_evk_da_uboot_defconfig | 2 + configs/mt8390_genio_700_evk_da_uboot_defconfig | 2 + 10 files changed, 133 insertions(+) diff --git a/arch/arm/dts/mt8188-genio-da-u-boot.dtsi b/arch/arm/dts/mt8188-genio-da-u-boot.dtsi index e9078f37157..2bbe9f2b8f4 100644 --- a/arch/arm/dts/mt8188-genio-da-u-boot.dtsi +++ b/arch/arm/dts/mt8188-genio-da-u-boot.dtsi @@ -6,6 +6,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/mt8370-genio-510-evk-u-boot.dtsi b/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi index 608987ca6d7..8b665d59a5f 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 "mt8188-genio-da-u-boot.dtsi" +#undef MTK_DA_FIT_DESCRIPTION +#undef MTK_DA_DESCRIPTION #endif 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 6c6c85e8767..f52cc820d90 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 "mt8188-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 59489c0fe65..5614cf70cd9 100644 --- a/arch/arm/mach-mediatek/Kconfig +++ b/arch/arm/mach-mediatek/Kconfig @@ -273,8 +273,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..75b51f4986e 100644 --- a/arch/arm/mach-mediatek/spl.c +++ b/arch/arm/mach-mediatek/spl.c @@ -33,6 +33,9 @@ void board_init_f(ulong dummy) u32 spl_boot_device(void) { + if (CONFIG_IS_ENABLED(RAM_DEVICE)) + return BOOT_DEVICE_RAM; + #if defined(CONFIG_SPL_SPI) return BOOT_DEVICE_SPI; #elif defined(CONFIG_SPL_MMC) diff --git a/board/mediatek/MAINTAINERS b/board/mediatek/MAINTAINERS index 27aeb4dff07..73d7873b8a3 100644 --- a/board/mediatek/MAINTAINERS +++ b/board/mediatek/MAINTAINERS @@ -29,11 +29,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/mt8188-genio-da-spl-fastboot.config +F: configs/mt8188-genio-da-uboot-fastboot.config F: configs/mt8188-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/mt8188-genio-da-uboot-fastboot.config b/configs/mt8188-genio-da-uboot-fastboot.config new file mode 100644 index 00000000000..5e493726c7c --- /dev/null +++ b/configs/mt8188-genio-da-uboot-fastboot.config @@ -0,0 +1,20 @@ +#include <configs/mt8188-genio-da.config> + +CONFIG_MTK_BROM_DOWNLOAD_AGENT_UBOOT_FASTBOOT=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..282ec12bacf --- /dev/null +++ b/configs/mt8370_genio_510_evk_da_uboot_defconfig @@ -0,0 +1,2 @@ +#include <configs/mt8370_genio_510_evk_defconfig> +#include <configs/mt8188-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..0302fb5e8c2 --- /dev/null +++ b/configs/mt8390_genio_700_evk_da_uboot_defconfig @@ -0,0 +1,2 @@ +#include <configs/mt8390_genio_700_evk_defconfig> +#include <configs/mt8188-genio-da-uboot-fastboot.config> -- 2.55.0
