* [PATCH v2 0/3] Add Genio 510 and 700 BootROM download agents
@ 2026-09-23 21:17 Carlo Caione
2026-09-23 21:17 ` [PATCH v2 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 Carlo Caione
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Carlo Caione @ 2026-09-23 21:17 UTC (permalink / raw)
To: GSS_MTK_Uboot_upstream, u-boot
Cc: Carlo Caione, Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao,
Chunfeng Yun, Igor Belwon, David Lechner, Julien Stephan,
Julien Masson, Johan Jonker, Macpaul Lin, Chris-QJ Chen,
Neil Armstrong, Bastien Curutchet, Alexey Charkov,
Vitor Sato Eschholz, Pablo Sun (孫毓翔),
Arnaud Ferraris, Suhrid Subramaniam, Marek Vasut, Casey Connolly,
Michael Srba
Genio 510 and 700 need a way to provision blank eMMC and recover boards
with unusable boot firmware. Add RAM-based fastboot download agents that
can be loaded through the MediaTek BootROM download protocol without
relying on the installed bootloader.
Fastboot in U-Boot proper is preferred when the complete download agent
fits the platform's BootROM payload limit. It provides U-Boot's shell and
boot facilities as well as flashing. The SPL variant offers a smaller
executable payload when including BL31 and U-Boot proper would exceed
that limit. Both require an external DDR loader and run fastboot from
DRAM after DDR initialization.
The two paths start USB fastboot at different stages:
Fastboot in SPL Fastboot in U-Boot proper
--------------- -------------------------
BootROM USB download BootROM USB download
(host -> SRAM) (host -> SRAM)
| |
v v
DDR loader DDR loader
| Initialize DRAM | Initialize DRAM
| Copy SPL to DRAM | Copy SPL + FIT to DRAM
v v
SPL SPL
| USB fastboot <-> host | Load BL31 + U-Boot from RAM
v v
eMMC provisioning BL31
|
v
U-Boot proper
| USB fastboot <-> host
v
eMMC provisioning
This series is based on upstream/next plus generic SPL fastboot V6,
now applied to u-boot-dfu-next [1]. Genio SPL support is already in
upstream/next.
[1] https://lore.kernel.org/all/179015047421.246261.8241758059641679018.b4-ty@kernel.org/
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
Changes in v2:
- Rebase onto upstream/next, which now includes Genio SPL support.
- Align shared DA filenames with the mt8370 Genio naming.
- Use fixed USB peripheral mode instead of the private force-vbus DT
property, with corresponding MTU3 driver support.
- Limit RAM boot to the U-Boot DA and use phase-specific MMC settings.
- Separate shared and per-agent configuration, and make DA and normal
storage-image configurations mutually exclusive.
- Build the SPL DA entry only in SPL and simplify FIT key handling.
- Keep the SPL allocation limit large enough for sparse image writes.
- Select the eMMC user area when resuming boot with SPL fastboot continue.
- Explain the preferred U-Boot DA and the SPL alternative for tighter
BootROM payload limits; clarify DT requirements and continue behavior.
- Link to v1: https://patch.msgid.link/20260914-ccaione-upstream-mt8390-da-v1-0-b76f9e30ac38@baylibre.com
To: GSS_MTK_Uboot_upstream <GSS_MTK_Uboot_upstream@mediatek.com>
To: u-boot@lists.u-boot-project.org
Cc: Tom Rini <trini@konsulko.com>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Ryder Lee <ryder.lee@mediatek.com>
Cc: Weijie Gao <weijie.gao@mediatek.com>
Cc: Chunfeng Yun <chunfeng.yun@mediatek.com>
Cc: Igor Belwon <igor.belwon@mentallysanemainliners.org>
Cc: David Lechner <dlechner@baylibre.com>
Cc: Julien Stephan <jstephan@baylibre.com>
Cc: Julien Masson <jmasson@baylibre.com>
Cc: Johan Jonker <jbx6244@gmail.com>
Cc: Macpaul Lin <macpaul.lin@mediatek.com>
Cc: Chris-QJ Chen <chris-qj.chen@mediatek.com>
Cc: Neil Armstrong <neil.armstrong@linaro.org>
Cc: Bastien Curutchet <bastien.curutchet@bootlin.com>
Cc: Alexey Charkov <alchark@gmail.com>
Cc: Vitor Sato Eschholz <vsatoes@baylibre.com>
Cc: "Pablo Sun (孫毓翔)" <pablo.sun@mediatek.com>
Cc: Arnaud Ferraris <arnaud.ferraris@collabora.com>
Cc: Suhrid Subramaniam <Suhrid.Subramaniam@mediatek.com>
Cc: Marek Vasut <marek.vasut+usb@mailbox.org>
Cc: Carlo Caione <ccaione@baylibre.com>
Cc: Casey Connolly <casey.connolly@linaro.org>
Cc: Michael Srba <Michael.Srba@seznam.cz>
---
Carlo Caione (2):
arm: mediatek: enable U-Boot fastboot DAs on Genio 510 and 700
doc: board: mediatek: document Genio download agents
Julien Masson (1):
arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700
arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi | 8 ++
arch/arm/dts/mt8370-genio-da-u-boot.dtsi | 64 ++++++++++
arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi | 8 ++
arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi | 17 +++
arch/arm/dts/mtk-genio-da-fit-binman-u-boot.dtsi | 62 ++++++++++
.../dts/mtk-genio-loader-spl-binman-u-boot.dtsi | 2 +-
arch/arm/mach-mediatek/Kconfig | 58 +++++++++
arch/arm/mach-mediatek/Makefile | 3 +
arch/arm/mach-mediatek/spl.c | 22 ++--
arch/arm/mach-mediatek/spl_fastboot.c | 68 +++++++++++
board/mediatek/MAINTAINERS | 8 ++
common/spl/Kconfig | 2 +-
configs/mt8370-genio-da-spl-fastboot.config | 21 ++++
configs/mt8370-genio-da-uboot-fastboot.config | 28 +++++
configs/mt8370-genio-da.config | 12 ++
configs/mt8370_genio_510_evk_da_spl_defconfig | 2 +
configs/mt8370_genio_510_evk_da_uboot_defconfig | 2 +
configs/mt8390_genio_700_evk_da_spl_defconfig | 2 +
configs/mt8390_genio_700_evk_da_uboot_defconfig | 2 +
doc/board/mediatek/mt8188-genio-evk.rst | 135 +++++++++++++++++++++
drivers/usb/mtu3/mtu3_core.c | 5 +-
21 files changed, 518 insertions(+), 13 deletions(-)
---
base-commit: 9e002445cd0d47d3965312f12e97a18e1ed8bd53
change-id: 20260910-ccaione-upstream-mt8390-da-f2f8416ab2a8
prerequisite-message-id: 20260913-ccaione-upstream-spl-fastboot-v6-0-dd3ba81a7ed2@baylibre.com
prerequisite-patch-id: ebe0842a87ef1a27c9882d7c45823b37ef84e5a8
prerequisite-patch-id: 7df6bdcd4e7a655d86db0447593b2bf36050b049
prerequisite-patch-id: e98c322def69bb8ecec30dd41c05aa62040b1008
prerequisite-patch-id: 553ddc59d4de9ff9f1949875939979cbeab2eaac
prerequisite-patch-id: 8d8c1917bfcee87fecf6077a117c8a11cc402cdd
Best regards,
--
Carlo Caione <ccaione@baylibre.com>
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v2 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 2026-09-23 21:17 [PATCH v2 0/3] Add Genio 510 and 700 BootROM download agents Carlo Caione @ 2026-09-23 21:17 ` Carlo Caione 2026-09-28 22:43 ` David Lechner 2026-09-23 21:17 ` [PATCH v2 2/3] arm: mediatek: enable U-Boot " Carlo Caione 2026-09-23 21:17 ` [PATCH v2 3/3] doc: board: mediatek: document Genio download agents Carlo Caione 2 siblings, 1 reply; 8+ messages in thread From: Carlo Caione @ 2026-09-23 21:17 UTC (permalink / raw) To: GSS_MTK_Uboot_upstream, u-boot Cc: Carlo Caione, Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, David Lechner, Julien Stephan, Julien Masson, Johan Jonker, Macpaul Lin, Chris-QJ Chen, Neil Armstrong, Bastien Curutchet, Alexey Charkov, Vitor Sato Eschholz, Pablo Sun (孫毓翔), Arnaud Ferraris, Suhrid Subramaniam, Marek Vasut, Casey Connolly, Michael Srba From: Julien Masson <jmasson@baylibre.com> Genio 510 and 700 need a way to provision blank eMMC and recover from unusable boot firmware without relying on the installed bootloader. Add a BootROM-loaded fastboot agent that also prepares the eMMC boot settings so newly flashed firmware can boot. U-Boot proper is preferred when the complete agent fits BootROM's SRAM download area before DRAM initialization. Provide the SPL alternative for tighter payload budgets, avoiding the space required by BL31 and U-Boot proper. An external DDR loader is still required. Signed-off-by: Julien Masson <jmasson@baylibre.com> Signed-off-by: Carlo Caione <ccaione@baylibre.com> --- arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi | 4 ++ arch/arm/dts/mt8370-genio-da-u-boot.dtsi | 61 +++++++++++++++++++ arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi | 4 ++ arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi | 17 ++++++ .../dts/mtk-genio-loader-spl-binman-u-boot.dtsi | 2 +- arch/arm/mach-mediatek/Kconfig | 28 +++++++++ arch/arm/mach-mediatek/Makefile | 3 + arch/arm/mach-mediatek/spl_fastboot.c | 68 ++++++++++++++++++++++ board/mediatek/MAINTAINERS | 5 ++ common/spl/Kconfig | 2 +- configs/mt8370-genio-da-spl-fastboot.config | 21 +++++++ configs/mt8370-genio-da.config | 12 ++++ configs/mt8370_genio_510_evk_da_spl_defconfig | 2 + configs/mt8390_genio_700_evk_da_spl_defconfig | 2 + drivers/usb/mtu3/mtu3_core.c | 5 +- 15 files changed, 233 insertions(+), 3 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 10b9a142f37..2ee7fb1f40c 100644 --- a/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi +++ b/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi @@ -14,3 +14,7 @@ #include "mtk-genio-mtk-boot-binman-u-boot.dtsi" #include "mtk-genio-bootloaders-binman-u-boot.dtsi" #endif + +#ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT +#include "mt8370-genio-da-u-boot.dtsi" +#endif diff --git a/arch/arm/dts/mt8370-genio-da-u-boot.dtsi b/arch/arm/dts/mt8370-genio-da-u-boot.dtsi new file mode 100644 index 00000000000..9d0d057cfc9 --- /dev/null +++ b/arch/arm/dts/mt8370-genio-da-u-boot.dtsi @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR MIT) +/* + * Copyright (c) 2026 BayLibre, SAS. + * Author: Carlo Caione <ccaione@baylibre.com> + */ + +/* + * Download agents (DAs) run from RAM to provision or recover eMMC. + * Both variants expose USB0 as a peripheral and leave unused USB + * controllers disabled, independently of the normal boot USB setup. + */ + +#include "mtk-genio-binman-u-boot.dtsi" +#include "mtk-genio-da-binman-u-boot.dtsi" + +&ssusb0 { + dr_mode = "peripheral"; +}; + +&ssusb1 { + status = "disabled"; +}; + +&ssusb2 { + status = "disabled"; +}; + +/* Only the SPL fastboot variant needs these USB dependencies in SPL. */ +#ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT +&pericfg_ao { + bootph-pre-ram; +}; + +&ssusb0 { + bootph-pre-ram; +}; + +&u3phy0 { + bootph-pre-ram; +}; + +&u2port0 { + bootph-pre-ram; +}; + +&usb_default_pins { + bootph-pre-ram; + + pins-iddig { + bootph-pre-ram; + }; + + pins-valid { + bootph-pre-ram; + }; + + pins-vbus { + bootph-pre-ram; + }; +}; +#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 6230b016ca0..4fedbda9b3f 100644 --- a/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi +++ b/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi @@ -14,3 +14,7 @@ #include "mtk-genio-mtk-boot-binman-u-boot.dtsi" #include "mtk-genio-bootloaders-binman-u-boot.dtsi" #endif + +#ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT +#include "mt8370-genio-da-u-boot.dtsi" +#endif diff --git a/arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi b/arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi new file mode 100644 index 00000000000..9627785cc56 --- /dev/null +++ b/arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: (GPL-2.0-only OR MIT) +/* + * Copyright (c) 2026 BayLibre, SAS. + * Author: Carlo Caione <ccaione@baylibre.com> + */ + +&binman { + da: da { + filename = "da.bin"; + pad-byte = <0>; + +/* DA authentication is handled by the BootROM download tooling. */ +#define MTK_GENIO_SPL_NO_FIT_KEYS +#include "mtk-genio-loader-spl-binman-u-boot.dtsi" +#undef MTK_GENIO_SPL_NO_FIT_KEYS + }; +}; diff --git a/arch/arm/dts/mtk-genio-loader-spl-binman-u-boot.dtsi b/arch/arm/dts/mtk-genio-loader-spl-binman-u-boot.dtsi index 2dd13d261a0..6c99d0926c4 100644 --- a/arch/arm/dts/mtk-genio-loader-spl-binman-u-boot.dtsi +++ b/arch/arm/dts/mtk-genio-loader-spl-binman-u-boot.dtsi @@ -12,7 +12,7 @@ ddr-loader { size = <CONFIG_MTK_GENIO_DDR_LOADER_SIZE>; }; -#ifdef CONFIG_SPL_FIT_SIGNATURE +#if defined(CONFIG_SPL_FIT_SIGNATURE) && !defined(MTK_GENIO_SPL_NO_FIT_KEYS) u-boot-spl { type = "section"; size = <CONFIG_SPL_MAX_SIZE>; diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig index e572cfe8571..eece6456e43 100644 --- a/arch/arm/mach-mediatek/Kconfig +++ b/arch/arm/mach-mediatek/Kconfig @@ -249,6 +249,34 @@ config MTK_GENIO_BL31_LOAD_ADDR endif +config MTK_BROM_DOWNLOAD_AGENT + bool + depends on TARGET_MT8188 && SPL + select BINMAN + select MTK_GENIO_IMAGE_CONTRACT + +choice + prompt "MediaTek BootROM download agent" + optional + depends on TARGET_MT8188 && SPL && SUPPORT_EMMC_BOOT + depends on !MTK_GENIO_BOOT_IMAGES + help + Select where to run fastboot after the BootROM downloads the agent + into RAM. Leave this disabled for normal storage boot. + Download agents cannot also build the normal storage-boot images. + +config MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT + bool "Run download-agent fastboot from SPL" + depends on SPL_FASTBOOT_FLASH_MMC + select MTK_BROM_DOWNLOAD_AGENT + select SPL_BOARD_INIT + help + Build an SPL which enters USB fastboot after the MediaTek BootROM + downloads it into RAM. The download agent also configures the eMMC + boot partition so that a newly flashed board can boot normally. + +endchoice + config MTK_TZ_MOVABLE select ARCH_MISC_INIT select OF_SYSTEM_SETUP diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile index 35f748a70d6..2a371664d1d 100644 --- a/arch/arm/mach-mediatek/Makefile +++ b/arch/arm/mach-mediatek/Makefile @@ -4,6 +4,9 @@ obj-$(CONFIG_ARM64) += armv8-mem-map.o obj-y += cpu.o obj-$(CONFIG_MTK_TZ_MOVABLE) += tzcfg.o obj-$(CONFIG_XPL_BUILD) += spl.o +ifdef CONFIG_XPL_BUILD +obj-$(CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT) += spl_fastboot.o +endif obj-$(CONFIG_TARGET_MT7622) += mt7622/ obj-$(CONFIG_TARGET_MT7623) += mt7623/ diff --git a/arch/arm/mach-mediatek/spl_fastboot.c b/arch/arm/mach-mediatek/spl_fastboot.c new file mode 100644 index 00000000000..73744946314 --- /dev/null +++ b/arch/arm/mach-mediatek/spl_fastboot.c @@ -0,0 +1,68 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright (c) 2026 BayLibre, SAS. + * Author: Julien Masson <jmasson@baylibre.com> + */ + +#include <dm/uclass.h> +#include <fastboot.h> +#include <mmc.h> +#include <stdio.h> +#include <linux/errno.h> + +static int mtk_mmc_boot_prepare(void) +{ + struct udevice *dev; + struct mmc *mmc; + int ret; + + /* No storage loader has run yet, so probe the device here. */ + ret = uclass_get_device_by_seq(UCLASS_MMC, + CONFIG_VAL(FASTBOOT_FLASH_MMC_DEV), &dev); + if (ret) { + printf("Cannot load MMC device: %d\n", ret); + return ret; + } + + mmc = mmc_get_mmc_dev(dev); + if (!mmc) + return -ENODEV; + + ret = mmc_init(mmc); + if (ret) { + printf("MMC init failed: %d\n", ret); + return ret; + } + + /* Enable BOOT1 and boot acknowledgment for normal BootROM startup. */ + ret = mmc_set_part_conf(mmc, 1, 1, 0); + if (ret) + printf("Cannot configure the eMMC boot partition: %d\n", ret); + + /* Reset to x1 SDR, backward-compatible timing for each boot. */ + ret = mmc_set_boot_bus_width(mmc, 0, 0, 0); + if (ret) + printf("Cannot configure the eMMC boot bus: %d\n", ret); + + if (!mmc->ext_csd[EXT_CSD_RST_N_FUNCTION]) { + ret = mmc_set_rst_n_function(mmc, 1); + if (ret) + printf("Cannot enable the eMMC reset function: %d\n", ret); + } + + return 0; +} + +void spl_board_init(void) +{ + int ret; + + ret = mtk_mmc_boot_prepare(); + if (ret) + printf("MMC boot preparation failed: %d\n", ret); + + puts("Waiting for fastboot commands...\n"); + ret = fastboot_usb_run(0, NULL, 0); + if (ret) + printf("Fastboot failed: %d\n", ret); +} diff --git a/board/mediatek/MAINTAINERS b/board/mediatek/MAINTAINERS index 20befdba0e2..61fefcf9a34 100644 --- a/board/mediatek/MAINTAINERS +++ b/board/mediatek/MAINTAINERS @@ -18,13 +18,18 @@ MT8188/MT8370/MT8390 M: Macpaul Lin <Macpaul.Lin@mediatek.com> M: Julien Stephan <jstephan@baylibre.com> S: Maintained +F: arch/arm/dts/mt8370-genio-da-u-boot.dtsi F: arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi F: arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi 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.config F: configs/mt8188.config +F: configs/mt8370_genio_510_evk_da_spl_defconfig F: configs/mt8370_genio_510_evk_defconfig +F: configs/mt8390_genio_700_evk_da_spl_defconfig F: configs/mt8390_genio_700_evk_defconfig F: doc/board/mediatek/mt8188-genio-evk.rst diff --git a/common/spl/Kconfig b/common/spl/Kconfig index 9bce4ab3955..c6fa647670b 100644 --- a/common/spl/Kconfig +++ b/common/spl/Kconfig @@ -194,7 +194,7 @@ config SPL_SHOW_ERRORS config SPL_BINMAN_SYMBOLS bool "Declare binman symbols in SPL" depends on SPL_FRAMEWORK && BINMAN - default n if MTK_GENIO_BOOT_IMAGES + default n if MTK_GENIO_IMAGE_CONTRACT default y help This enables use of symbols in SPL which refer to other entries in diff --git a/configs/mt8370-genio-da-spl-fastboot.config b/configs/mt8370-genio-da-spl-fastboot.config new file mode 100644 index 00000000000..6ba12f7d282 --- /dev/null +++ b/configs/mt8370-genio-da-spl-fastboot.config @@ -0,0 +1,21 @@ +#include <configs/mt8370-genio-da.config> + +CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT=y +# Sparse writes need an 8 MiB DMA buffer in addition to the fastboot state. +CONFIG_SPL_SYS_MALLOC_SIZE=0x1000000 +# dlmalloc also caps individual SPL allocations at SYS_MALLOC_LEN. +CONFIG_SYS_MALLOC_LEN=0x1000000 +# Resume from the user-area FIT after fastboot continue. +CONFIG_SUPPORT_EMMC_BOOT_OVERRIDE_PART_CONFIG=y +CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION=0 +CONFIG_SPL_MMC_WRITE=y +CONFIG_SPL_PHY=y +CONFIG_SPL_DM_USB_GADGET=y +CONFIG_SPL_USB_GADGET=y +CONFIG_SPL_USB_MTU3=y +CONFIG_SPL_FASTBOOT=y +CONFIG_SPL_FASTBOOT_REBOOT=y +CONFIG_SPL_FASTBOOT_FLASH_MMC=y +CONFIG_SPL_FASTBOOT_FLASH_MMC_DEV=0 +CONFIG_SPL_FASTBOOT_MMC_BOOT_SUPPORT=y +CONFIG_SPL_FASTBOOT_MMC_USER_SUPPORT=y diff --git a/configs/mt8370-genio-da.config b/configs/mt8370-genio-da.config new file mode 100644 index 00000000000..46cb42b37ba --- /dev/null +++ b/configs/mt8370-genio-da.config @@ -0,0 +1,12 @@ +# USB identity and transfer buffer shared by both download-agent modes. +CONFIG_SUPPORT_EMMC_BOOT=y +CONFIG_PHY=y +CONFIG_PHY_MTK_TPHY=y +CONFIG_USB=y +CONFIG_DM_USB_GADGET=y +CONFIG_USB_MTU3=y +CONFIG_USB_GADGET=y +CONFIG_USB_GADGET_VENDOR_NUM=0x0e8d +CONFIG_USB_GADGET_PRODUCT_NUM=0x201c +CONFIG_FASTBOOT_BUF_ADDR=0x65000000 +CONFIG_FASTBOOT_BUF_SIZE=0x15000000 diff --git a/configs/mt8370_genio_510_evk_da_spl_defconfig b/configs/mt8370_genio_510_evk_da_spl_defconfig new file mode 100644 index 00000000000..bb537616b53 --- /dev/null +++ b/configs/mt8370_genio_510_evk_da_spl_defconfig @@ -0,0 +1,2 @@ +#include <configs/mt8370_genio_510_evk_defconfig> +#include <configs/mt8370-genio-da-spl-fastboot.config> diff --git a/configs/mt8390_genio_700_evk_da_spl_defconfig b/configs/mt8390_genio_700_evk_da_spl_defconfig new file mode 100644 index 00000000000..7f1ba02c6e7 --- /dev/null +++ b/configs/mt8390_genio_700_evk_da_spl_defconfig @@ -0,0 +1,2 @@ +#include <configs/mt8390_genio_700_evk_defconfig> +#include <configs/mt8370-genio-da-spl-fastboot.config> diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c index f296a72cf18..d8ef6e6afba 100644 --- a/drivers/usb/mtu3/mtu3_core.c +++ b/drivers/usb/mtu3/mtu3_core.c @@ -843,7 +843,10 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb) mtu->mac_base = ssusb->mac_base; mtu->ssusb = ssusb; mtu->max_speed = usb_get_maximum_speed(dev_ofnode(ssusb->dev)); - mtu->force_vbus = dev_read_bool(ssusb->dev, "mediatek,force-vbus"); + /* Fixed peripheral mode must not depend on OTG session detection. */ + mtu->force_vbus = + usb_get_dr_mode(dev_ofnode(ssusb->dev)) == USB_DR_MODE_PERIPHERAL || + dev_read_bool(ssusb->dev, "mediatek,force-vbus"); ret = mtu3_hw_init(mtu); if (ret) { -- 2.55.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 2026-09-23 21:17 ` [PATCH v2 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 Carlo Caione @ 2026-09-28 22:43 ` David Lechner 2026-09-29 7:39 ` Carlo Caione 0 siblings, 1 reply; 8+ messages in thread From: David Lechner @ 2026-09-28 22:43 UTC (permalink / raw) To: Carlo Caione, GSS_MTK_Uboot_upstream, u-boot Cc: Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan, Julien Masson, Johan Jonker, Macpaul Lin, Chris-QJ Chen, Neil Armstrong, Bastien Curutchet, Alexey Charkov, Vitor Sato Eschholz, Pablo Sun (孫毓翔), Arnaud Ferraris, Suhrid Subramaniam, Marek Vasut, Casey Connolly, Michael Srba On 9/23/26 4:17 PM, Carlo Caione wrote: > From: Julien Masson <jmasson@baylibre.com> > > Genio 510 and 700 need a way to provision blank eMMC and recover from > unusable boot firmware without relying on the installed bootloader. > Add a BootROM-loaded fastboot agent that also prepares the eMMC boot > settings so newly flashed firmware can boot. > > U-Boot proper is preferred when the complete agent fits BootROM's SRAM > download area before DRAM initialization. Provide the SPL alternative > for tighter payload budgets, avoiding the space required by BL31 and > U-Boot proper. An external DDR loader is still required. This is a bit short on details of why certain tecnical descisions are made in this patch. > > Signed-off-by: Julien Masson <jmasson@baylibre.com> > Signed-off-by: Carlo Caione <ccaione@baylibre.com> > --- > arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi | 4 ++ > arch/arm/dts/mt8370-genio-da-u-boot.dtsi | 61 +++++++++++++++++++ > arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi | 4 ++ > arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi | 17 ++++++ > .../dts/mtk-genio-loader-spl-binman-u-boot.dtsi | 2 +- > arch/arm/mach-mediatek/Kconfig | 28 +++++++++ > arch/arm/mach-mediatek/Makefile | 3 + > arch/arm/mach-mediatek/spl_fastboot.c | 68 ++++++++++++++++++++++ > board/mediatek/MAINTAINERS | 5 ++ > common/spl/Kconfig | 2 +- > configs/mt8370-genio-da-spl-fastboot.config | 21 +++++++ > configs/mt8370-genio-da.config | 12 ++++ > configs/mt8370_genio_510_evk_da_spl_defconfig | 2 + > configs/mt8390_genio_700_evk_da_spl_defconfig | 2 + > drivers/usb/mtu3/mtu3_core.c | 5 +- > 15 files changed, 233 insertions(+), 3 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 10b9a142f37..2ee7fb1f40c 100644 > --- a/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi > +++ b/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi > @@ -14,3 +14,7 @@ > #include "mtk-genio-mtk-boot-binman-u-boot.dtsi" > #include "mtk-genio-bootloaders-binman-u-boot.dtsi" > #endif > + > +#ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT > +#include "mt8370-genio-da-u-boot.dtsi" > +#endif > diff --git a/arch/arm/dts/mt8370-genio-da-u-boot.dtsi b/arch/arm/dts/mt8370-genio-da-u-boot.dtsi > new file mode 100644 > index 00000000000..9d0d057cfc9 > --- /dev/null > +++ b/arch/arm/dts/mt8370-genio-da-u-boot.dtsi > @@ -0,0 +1,61 @@ > +// SPDX-License-Identifier: (GPL-2.0-only OR MIT) > +/* > + * Copyright (c) 2026 BayLibre, SAS. > + * Author: Carlo Caione <ccaione@baylibre.com> > + */ > + > +/* > + * Download agents (DAs) run from RAM to provision or recover eMMC. > + * Both variants expose USB0 as a peripheral and leave unused USB > + * controllers disabled, independently of the normal boot USB setup. > + */ > + > +#include "mtk-genio-binman-u-boot.dtsi" > +#include "mtk-genio-da-binman-u-boot.dtsi" > + > +&ssusb0 { > + dr_mode = "peripheral"; > +}; > + > +&ssusb1 { > + status = "disabled"; > +}; > + > +&ssusb2 { > + status = "disabled"; > +}; > + > +/* Only the SPL fastboot variant needs these USB dependencies in SPL. */ > +#ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT > +&pericfg_ao { > + bootph-pre-ram; > +}; > + > +&ssusb0 { > + bootph-pre-ram; > +}; > + > +&u3phy0 { > + bootph-pre-ram; > +}; > + > +&u2port0 { > + bootph-pre-ram; > +}; > + > +&usb_default_pins { > + bootph-pre-ram; > + > + pins-iddig { > + bootph-pre-ram; > + }; > + > + pins-valid { > + bootph-pre-ram; > + }; > + > + pins-vbus { > + bootph-pre-ram; > + }; > +}; > +#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 6230b016ca0..4fedbda9b3f 100644 > --- a/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi > +++ b/arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi > @@ -14,3 +14,7 @@ > #include "mtk-genio-mtk-boot-binman-u-boot.dtsi" > #include "mtk-genio-bootloaders-binman-u-boot.dtsi" > #endif > + > +#ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT > +#include "mt8370-genio-da-u-boot.dtsi" > +#endif > diff --git a/arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi b/arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi > new file mode 100644 > index 00000000000..9627785cc56 > --- /dev/null > +++ b/arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi > @@ -0,0 +1,17 @@ > +// SPDX-License-Identifier: (GPL-2.0-only OR MIT) > +/* > + * Copyright (c) 2026 BayLibre, SAS. > + * Author: Carlo Caione <ccaione@baylibre.com> > + */ > + > +&binman { > + da: da { > + filename = "da.bin"; > + pad-byte = <0>; > + > +/* DA authentication is handled by the BootROM download tooling. */ > +#define MTK_GENIO_SPL_NO_FIT_KEYS > +#include "mtk-genio-loader-spl-binman-u-boot.dtsi" > +#undef MTK_GENIO_SPL_NO_FIT_KEYS > + }; > +}; > diff --git a/arch/arm/dts/mtk-genio-loader-spl-binman-u-boot.dtsi b/arch/arm/dts/mtk-genio-loader-spl-binman-u-boot.dtsi > index 2dd13d261a0..6c99d0926c4 100644 > --- a/arch/arm/dts/mtk-genio-loader-spl-binman-u-boot.dtsi > +++ b/arch/arm/dts/mtk-genio-loader-spl-binman-u-boot.dtsi > @@ -12,7 +12,7 @@ ddr-loader { > size = <CONFIG_MTK_GENIO_DDR_LOADER_SIZE>; > }; > > -#ifdef CONFIG_SPL_FIT_SIGNATURE > +#if defined(CONFIG_SPL_FIT_SIGNATURE) && !defined(MTK_GENIO_SPL_NO_FIT_KEYS) > u-boot-spl { > type = "section"; > size = <CONFIG_SPL_MAX_SIZE>; > diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig > index e572cfe8571..eece6456e43 100644 > --- a/arch/arm/mach-mediatek/Kconfig > +++ b/arch/arm/mach-mediatek/Kconfig > @@ -249,6 +249,34 @@ config MTK_GENIO_BL31_LOAD_ADDR > > endif > > +config MTK_BROM_DOWNLOAD_AGENT > + bool > + depends on TARGET_MT8188 && SPL > + select BINMAN > + select MTK_GENIO_IMAGE_CONTRACT > + > +choice > + prompt "MediaTek BootROM download agent" > + optional > + depends on TARGET_MT8188 && SPL && SUPPORT_EMMC_BOOT > + depends on !MTK_GENIO_BOOT_IMAGES > + help > + Select where to run fastboot after the BootROM downloads the agent > + into RAM. Leave this disabled for normal storage boot. > + Download agents cannot also build the normal storage-boot images. > + > +config MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT > + bool "Run download-agent fastboot from SPL" > + depends on SPL_FASTBOOT_FLASH_MMC > + select MTK_BROM_DOWNLOAD_AGENT > + select SPL_BOARD_INIT > + help > + Build an SPL which enters USB fastboot after the MediaTek BootROM > + downloads it into RAM. The download agent also configures the eMMC > + boot partition so that a newly flashed board can boot normally. > + > +endchoice > + > config MTK_TZ_MOVABLE > select ARCH_MISC_INIT > select OF_SYSTEM_SETUP > diff --git a/arch/arm/mach-mediatek/Makefile b/arch/arm/mach-mediatek/Makefile > index 35f748a70d6..2a371664d1d 100644 > --- a/arch/arm/mach-mediatek/Makefile > +++ b/arch/arm/mach-mediatek/Makefile > @@ -4,6 +4,9 @@ obj-$(CONFIG_ARM64) += armv8-mem-map.o > obj-y += cpu.o > obj-$(CONFIG_MTK_TZ_MOVABLE) += tzcfg.o > obj-$(CONFIG_XPL_BUILD) += spl.o > +ifdef CONFIG_XPL_BUILD > +obj-$(CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT) += spl_fastboot.o > +endif > > obj-$(CONFIG_TARGET_MT7622) += mt7622/ > obj-$(CONFIG_TARGET_MT7623) += mt7623/ > diff --git a/arch/arm/mach-mediatek/spl_fastboot.c b/arch/arm/mach-mediatek/spl_fastboot.c > new file mode 100644 > index 00000000000..73744946314 > --- /dev/null > +++ b/arch/arm/mach-mediatek/spl_fastboot.c > @@ -0,0 +1,68 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright (c) 2026 BayLibre, SAS. > + * Author: Julien Masson <jmasson@baylibre.com> > + */ > + > +#include <dm/uclass.h> > +#include <fastboot.h> > +#include <mmc.h> > +#include <stdio.h> > +#include <linux/errno.h> > + > +static int mtk_mmc_boot_prepare(void) > +{ > + struct udevice *dev; > + struct mmc *mmc; > + int ret; > + > + /* No storage loader has run yet, so probe the device here. */ > + ret = uclass_get_device_by_seq(UCLASS_MMC, > + CONFIG_VAL(FASTBOOT_FLASH_MMC_DEV), &dev); > + if (ret) { > + printf("Cannot load MMC device: %d\n", ret); > + return ret; > + } > + > + mmc = mmc_get_mmc_dev(dev); > + if (!mmc) > + return -ENODEV; > + > + ret = mmc_init(mmc); > + if (ret) { > + printf("MMC init failed: %d\n", ret); > + return ret; > + } > + > + /* Enable BOOT1 and boot acknowledgment for normal BootROM startup. */ > + ret = mmc_set_part_conf(mmc, 1, 1, 0); > + if (ret) > + printf("Cannot configure the eMMC boot partition: %d\n", ret); > + > + /* Reset to x1 SDR, backward-compatible timing for each boot. */ > + ret = mmc_set_boot_bus_width(mmc, 0, 0, 0); > + if (ret) > + printf("Cannot configure the eMMC boot bus: %d\n", ret); > + > + if (!mmc->ext_csd[EXT_CSD_RST_N_FUNCTION]) { > + ret = mmc_set_rst_n_function(mmc, 1); If I understand correctly, this makes a permanant change to the eMMC hardware. It is documented in patch 3, but I wonder if we should add a comment here too. And I wonder if anyone would not want that setting. > + if (ret) > + printf("Cannot enable the eMMC reset function: %d\n", ret); > + } > + > + return 0; > +} > + > +void spl_board_init(void) > +{ > + int ret; > + > + ret = mtk_mmc_boot_prepare(); > + if (ret) > + printf("MMC boot preparation failed: %d\n", ret); > + > + puts("Waiting for fastboot commands...\n"); > + ret = fastboot_usb_run(0, NULL, 0); > + if (ret) > + printf("Fastboot failed: %d\n", ret); > +} > diff --git a/board/mediatek/MAINTAINERS b/board/mediatek/MAINTAINERS > index 20befdba0e2..61fefcf9a34 100644 > --- a/board/mediatek/MAINTAINERS > +++ b/board/mediatek/MAINTAINERS > @@ -18,13 +18,18 @@ MT8188/MT8370/MT8390 > M: Macpaul Lin <Macpaul.Lin@mediatek.com> > M: Julien Stephan <jstephan@baylibre.com> > S: Maintained > +F: arch/arm/dts/mt8370-genio-da-u-boot.dtsi > F: arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi > F: arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi > 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.config These are not sorted in order. > F: configs/mt8188.config > +F: configs/mt8370_genio_510_evk_da_spl_defconfig > F: configs/mt8370_genio_510_evk_defconfig > +F: configs/mt8390_genio_700_evk_da_spl_defconfig > F: configs/mt8390_genio_700_evk_defconfig > F: doc/board/mediatek/mt8188-genio-evk.rst > > diff --git a/common/spl/Kconfig b/common/spl/Kconfig > index 9bce4ab3955..c6fa647670b 100644 > --- a/common/spl/Kconfig > +++ b/common/spl/Kconfig > @@ -194,7 +194,7 @@ config SPL_SHOW_ERRORS > config SPL_BINMAN_SYMBOLS > bool "Declare binman symbols in SPL" > depends on SPL_FRAMEWORK && BINMAN > - default n if MTK_GENIO_BOOT_IMAGES > + default n if MTK_GENIO_IMAGE_CONTRACT > default y > help > This enables use of symbols in SPL which refer to other entries in > diff --git a/configs/mt8370-genio-da-spl-fastboot.config b/configs/mt8370-genio-da-spl-fastboot.config > new file mode 100644 > index 00000000000..6ba12f7d282 > --- /dev/null > +++ b/configs/mt8370-genio-da-spl-fastboot.config > @@ -0,0 +1,21 @@ > +#include <configs/mt8370-genio-da.config> > + > +CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT=y > +# Sparse writes need an 8 MiB DMA buffer in addition to the fastboot state. > +CONFIG_SPL_SYS_MALLOC_SIZE=0x1000000 > +# dlmalloc also caps individual SPL allocations at SYS_MALLOC_LEN. > +CONFIG_SYS_MALLOC_LEN=0x1000000 > +# Resume from the user-area FIT after fastboot continue. > +CONFIG_SUPPORT_EMMC_BOOT_OVERRIDE_PART_CONFIG=y > +CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION=0 > +CONFIG_SPL_MMC_WRITE=y > +CONFIG_SPL_PHY=y > +CONFIG_SPL_DM_USB_GADGET=y > +CONFIG_SPL_USB_GADGET=y > +CONFIG_SPL_USB_MTU3=y > +CONFIG_SPL_FASTBOOT=y > +CONFIG_SPL_FASTBOOT_REBOOT=y > +CONFIG_SPL_FASTBOOT_FLASH_MMC=y > +CONFIG_SPL_FASTBOOT_FLASH_MMC_DEV=0 > +CONFIG_SPL_FASTBOOT_MMC_BOOT_SUPPORT=y > +CONFIG_SPL_FASTBOOT_MMC_USER_SUPPORT=y > diff --git a/configs/mt8370-genio-da.config b/configs/mt8370-genio-da.config > new file mode 100644 > index 00000000000..46cb42b37ba > --- /dev/null > +++ b/configs/mt8370-genio-da.config > @@ -0,0 +1,12 @@ > +# USB identity and transfer buffer shared by both download-agent modes. > +CONFIG_SUPPORT_EMMC_BOOT=y > +CONFIG_PHY=y > +CONFIG_PHY_MTK_TPHY=y > +CONFIG_USB=y > +CONFIG_DM_USB_GADGET=y > +CONFIG_USB_MTU3=y > +CONFIG_USB_GADGET=y > +CONFIG_USB_GADGET_VENDOR_NUM=0x0e8d > +CONFIG_USB_GADGET_PRODUCT_NUM=0x201c > +CONFIG_FASTBOOT_BUF_ADDR=0x65000000 > +CONFIG_FASTBOOT_BUF_SIZE=0x15000000 > diff --git a/configs/mt8370_genio_510_evk_da_spl_defconfig b/configs/mt8370_genio_510_evk_da_spl_defconfig > new file mode 100644 > index 00000000000..bb537616b53 > --- /dev/null > +++ b/configs/mt8370_genio_510_evk_da_spl_defconfig > @@ -0,0 +1,2 @@ > +#include <configs/mt8370_genio_510_evk_defconfig> > +#include <configs/mt8370-genio-da-spl-fastboot.config> > diff --git a/configs/mt8390_genio_700_evk_da_spl_defconfig b/configs/mt8390_genio_700_evk_da_spl_defconfig > new file mode 100644 > index 00000000000..7f1ba02c6e7 > --- /dev/null > +++ b/configs/mt8390_genio_700_evk_da_spl_defconfig > @@ -0,0 +1,2 @@ > +#include <configs/mt8390_genio_700_evk_defconfig> > +#include <configs/mt8370-genio-da-spl-fastboot.config> > diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c > index f296a72cf18..d8ef6e6afba 100644 > --- a/drivers/usb/mtu3/mtu3_core.c > +++ b/drivers/usb/mtu3/mtu3_core.c > @@ -843,7 +843,10 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb) > mtu->mac_base = ssusb->mac_base; > mtu->ssusb = ssusb; > mtu->max_speed = usb_get_maximum_speed(dev_ofnode(ssusb->dev)); > - mtu->force_vbus = dev_read_bool(ssusb->dev, "mediatek,force-vbus"); > + /* Fixed peripheral mode must not depend on OTG session detection. */ Why not? From what I am seeing in the Linux driver it doesn't do this. And I'm not sure why mt8183 has "mediatek,force-vbus" here in the U-boot devicetree. Maybe lack of proper pinmux for that target in U-boot? I feel like we should not be doing this for new boards. I would only expect to need to force vbus on a board where vbus wasn't wired up properly. That isn't the case here. Is fastboot broken without this change? > + mtu->force_vbus = > + usb_get_dr_mode(dev_ofnode(ssusb->dev)) == USB_DR_MODE_PERIPHERAL || > + dev_read_bool(ssusb->dev, "mediatek,force-vbus"); > > ret = mtu3_hw_init(mtu); > if (ret) { > ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 2026-09-28 22:43 ` David Lechner @ 2026-09-29 7:39 ` Carlo Caione 0 siblings, 0 replies; 8+ messages in thread From: Carlo Caione @ 2026-09-29 7:39 UTC (permalink / raw) To: David Lechner Cc: GSS_MTK_Uboot_upstream, u-boot, Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan, Julien Masson, Johan Jonker, Macpaul Lin, Chris-QJ Chen, Neil Armstrong, Bastien Curutchet, Alexey Charkov, Vitor Sato Eschholz, Pablo Sun (孫毓翔), Arnaud Ferraris, Suhrid Subramaniam, Marek Vasut, Casey Connolly, Michael Srba On Mon, Sep 28, 2026 at 17:43:22 +0100, David Lechner wrote: > On 9/23/26 4:17 PM, Carlo Caione wrote: > > From: Julien Masson <jmasson@baylibre.com> > > > > Genio 510 and 700 need a way to provision blank eMMC and recover from > > unusable boot firmware without relying on the installed bootloader. > > Add a BootROM-loaded fastboot agent that also prepares the eMMC boot > > settings so newly flashed firmware can boot. > > > > U-Boot proper is preferred when the complete agent fits BootROM's SRAM > > download area before DRAM initialization. Provide the SPL alternative > > for tighter payload budgets, avoiding the space required by BL31 and > > U-Boot proper. An external DDR loader is still required. > > This is a bit short on details of why certain tecnical descisions are made > in this patch. I'll try to improve it when possible. > > + /* Reset to x1 SDR, backward-compatible timing for each boot. */ > > + ret = mmc_set_boot_bus_width(mmc, 0, 0, 0); > > + if (ret) > > + printf("Cannot configure the eMMC boot bus: %d\n", ret); > > + > > + if (!mmc->ext_csd[EXT_CSD_RST_N_FUNCTION]) { > > + ret = mmc_set_rst_n_function(mmc, 1); > > If I understand correctly, this makes a permanant change to the eMMC hardware. > It is documented in patch 3, but I wonder if we should add a comment here too. > And I wonder if anyone would not want that setting. This was ported over from the downstream MTK code so I think that this is actually needed. I'll add a comment here. > > diff --git a/board/mediatek/MAINTAINERS b/board/mediatek/MAINTAINERS > > index 20befdba0e2..61fefcf9a34 100644 > > --- a/board/mediatek/MAINTAINERS > > +++ b/board/mediatek/MAINTAINERS > > @@ -18,13 +18,18 @@ MT8188/MT8370/MT8390 > > M: Macpaul Lin <Macpaul.Lin@mediatek.com> > > M: Julien Stephan <jstephan@baylibre.com> > > S: Maintained > > +F: arch/arm/dts/mt8370-genio-da-u-boot.dtsi > > F: arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi > > F: arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi > > 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.config > > These are not sorted in order. :( > > diff --git a/drivers/usb/mtu3/mtu3_core.c b/drivers/usb/mtu3/mtu3_core.c > > index f296a72cf18..d8ef6e6afba 100644 > > --- a/drivers/usb/mtu3/mtu3_core.c > > +++ b/drivers/usb/mtu3/mtu3_core.c > > @@ -843,7 +843,10 @@ int ssusb_gadget_init(struct ssusb_mtk *ssusb) > > mtu->mac_base = ssusb->mac_base; > > mtu->ssusb = ssusb; > > mtu->max_speed = usb_get_maximum_speed(dev_ofnode(ssusb->dev)); > > - mtu->force_vbus = dev_read_bool(ssusb->dev, "mediatek,force-vbus"); > > + /* Fixed peripheral mode must not depend on OTG session detection. */ > > Why not? From what I am seeing in the Linux driver it doesn't do this. > And I'm not sure why mt8183 has "mediatek,force-vbus" here in the U-boot > devicetree. Maybe lack of proper pinmux for that target in U-boot? > > I feel like we should not be doing this for new boards. I would only expect > to need to force vbus on a board where vbus wasn't wired up properly. That > isn't the case here. > > Is fastboot broken without this change? I tested it and it is not. So it looks like this change is actually not really needed. Thanks for the review, -- Carlo Caione ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] arm: mediatek: enable U-Boot fastboot DAs on Genio 510 and 700 2026-09-23 21:17 [PATCH v2 0/3] Add Genio 510 and 700 BootROM download agents Carlo Caione 2026-09-23 21:17 ` [PATCH v2 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 Carlo Caione @ 2026-09-23 21:17 ` Carlo Caione 2026-09-28 22:43 ` David Lechner 2026-09-23 21:17 ` [PATCH v2 3/3] doc: board: mediatek: document Genio download agents Carlo Caione 2 siblings, 1 reply; 8+ messages in thread From: Carlo Caione @ 2026-09-23 21:17 UTC (permalink / raw) To: GSS_MTK_Uboot_upstream, u-boot Cc: Carlo Caione, Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, David Lechner, Julien Stephan, Julien Masson, Johan Jonker, Macpaul Lin, Chris-QJ Chen, Neil Armstrong, Bastien Curutchet, Alexey Charkov, Vitor Sato Eschholz, Pablo Sun (孫毓翔), Arnaud Ferraris, Suhrid Subramaniam, Marek Vasut, Casey Connolly, Michael Srba 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 <ccaione@baylibre.com> --- 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 <ccaione@baylibre.com> + */ + +&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 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] arm: mediatek: enable U-Boot fastboot DAs on Genio 510 and 700 2026-09-23 21:17 ` [PATCH v2 2/3] arm: mediatek: enable U-Boot " Carlo Caione @ 2026-09-28 22:43 ` David Lechner 2026-09-29 7:43 ` Carlo Caione 0 siblings, 1 reply; 8+ messages in thread From: David Lechner @ 2026-09-28 22:43 UTC (permalink / raw) To: Carlo Caione, GSS_MTK_Uboot_upstream, u-boot Cc: Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan, Julien Masson, Johan Jonker, Macpaul Lin, Chris-QJ Chen, Neil Armstrong, Bastien Curutchet, Alexey Charkov, Vitor Sato Eschholz, Pablo Sun (孫毓翔), Arnaud Ferraris, Suhrid Subramaniam, Marek Vasut, Casey Connolly, Michael Srba On 9/23/26 4:17 PM, Carlo Caione wrote: > 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. > ... > 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 > } Could be nice to do the CONFIG_IS_ENABLED() conversion as a separate patch so it is easier to see what is added here. > 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 What is driving the need for such large allocations? > +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 Do we need to enable FASTBOOT_CMD_OEM_PARTCONF and FASTBOOT_CMD_OEM_BOOTBUS to allow flashing a blank eMMC? > +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 ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] arm: mediatek: enable U-Boot fastboot DAs on Genio 510 and 700 2026-09-28 22:43 ` David Lechner @ 2026-09-29 7:43 ` Carlo Caione 0 siblings, 0 replies; 8+ messages in thread From: Carlo Caione @ 2026-09-29 7:43 UTC (permalink / raw) To: David Lechner Cc: GSS_MTK_Uboot_upstream, u-boot, Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, Julien Stephan, Julien Masson, Johan Jonker, Macpaul Lin, Chris-QJ Chen, Neil Armstrong, Bastien Curutchet, Alexey Charkov, Vitor Sato Eschholz, Pablo Sun (孫毓翔), Arnaud Ferraris, Suhrid Subramaniam, Marek Vasut, Casey Connolly, Michael Srba On Mon, Sep 28, 2026 at 17:43:26 +0100, David Lechner wrote: > On 9/23/26 4:17 PM, Carlo Caione wrote: > > 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. > > > > ... > > > 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 > > } > > Could be nice to do the CONFIG_IS_ENABLED() conversion as a separate patch > so it is easier to see what is added here. Ok, I'll split it. > > 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 > > What is driving the need for such large allocations? Yeah, this was actually fixed in the previous SPL patchset but not in this one. 8MB are enough, I'll fix this. > > +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 > > Do we need to enable FASTBOOT_CMD_OEM_PARTCONF and FASTBOOT_CMD_OEM_BOOTBUS > to allow flashing a blank eMMC? This is actually a very, very good point. Now, we have two ways of doing this: either we add the fastboot commands and let the host issue these commands or we just do this in the code. The first solution would imply modifying the genio-flash tools to issue the command during provisioning and this is something I'd like to avoid, so I'm going to do this programmatically the same way we do for the SPL DA version. Cheers, -- Carlo Caione ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] doc: board: mediatek: document Genio download agents 2026-09-23 21:17 [PATCH v2 0/3] Add Genio 510 and 700 BootROM download agents Carlo Caione 2026-09-23 21:17 ` [PATCH v2 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 Carlo Caione 2026-09-23 21:17 ` [PATCH v2 2/3] arm: mediatek: enable U-Boot " Carlo Caione @ 2026-09-23 21:17 ` Carlo Caione 2 siblings, 0 replies; 8+ messages in thread From: Carlo Caione @ 2026-09-23 21:17 UTC (permalink / raw) To: GSS_MTK_Uboot_upstream, u-boot Cc: Carlo Caione, Tom Rini, Ilias Apalodimas, Ryder Lee, Weijie Gao, Chunfeng Yun, Igor Belwon, David Lechner, Julien Stephan, Julien Masson, Johan Jonker, Macpaul Lin, Chris-QJ Chen, Neil Armstrong, Bastien Curutchet, Alexey Charkov, Vitor Sato Eschholz, Pablo Sun (孫毓翔), Arnaud Ferraris, Suhrid Subramaniam, Marek Vasut, Casey Connolly, Michael Srba Download agents have different firmware and eMMC provisioning requirements from normal storage boot. Document them so users can build compatible images and understand which persistent eMMC settings each agent changes. Signed-off-by: Carlo Caione <ccaione@baylibre.com> --- doc/board/mediatek/mt8188-genio-evk.rst | 135 ++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) diff --git a/doc/board/mediatek/mt8188-genio-evk.rst b/doc/board/mediatek/mt8188-genio-evk.rst index e36e8faeb48..70d9b8b84b3 100644 --- a/doc/board/mediatek/mt8188-genio-evk.rst +++ b/doc/board/mediatek/mt8188-genio-evk.rst @@ -279,3 +279,138 @@ Genio Tools uses the default bootstrap from the image directory. Keep ``bootloaders_b`` unchanged until the new images have been tested. Add ``--dry-run`` to check the selected files and partitions without accessing the board. + +BootROM download agents +----------------------- + +A download agent (DA) runs from RAM and exposes eMMC through USB fastboot for +provisioning or recovery. The BootROM downloads ``da.bin`` into SRAM; the +external DDR loader initializes DRAM and enters SPL using the same execution +contract as normal boot. The DA itself is not installed in an eMMC partition. + +Prefer fastboot in U-Boot proper when the complete DA fits the platform's +BootROM download limit. It provides U-Boot's shell and boot facilities in +addition to flashing. The complete image must fit in the SRAM download area +before the DDR loader can initialize DRAM. Fastboot in SPL offers a smaller +executable payload for configurations where including BL31 and U-Boot proper +would exceed that limit. Both variants run fastboot from DRAM. + +Two mutually exclusive modes are available: + +* ``CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT`` runs fastboot directly in + SPL. This keeps the provisioning agent small and independent of BL31, + OP-TEE and U-Boot proper. It needs the matching external DDR loader. +* ``CONFIG_MTK_BROM_DOWNLOAD_AGENT_UBOOT_FASTBOOT`` uses SPL to load BL31 and + U-Boot from a FIT in RAM. U-Boot then runs ``fastboot usb 0``. This mode needs + a matching BL31 built without an OP-TEE dependency, and a DDR loader which + implements the additional FIT copy described below. It provides + U-Boot's shell and boot facilities for provisioning flows which need + more than the SPL agent's flash and erase commands. + +The two paths start USB fastboot at different stages:: + + Fastboot in SPL Fastboot in U-Boot proper + --------------- ------------------------- + BootROM USB download BootROM USB download + (host -> SRAM) (host -> SRAM) + | | + v v + DDR loader DDR loader + | Initialize DRAM | Initialize DRAM + | Copy SPL to DRAM | Copy SPL + FIT to DRAM + v v + SPL SPL + | USB fastboot <-> host | Load BL31 + U-Boot from RAM + v v + eMMC provisioning BL31 + | + v + U-Boot proper + | USB fastboot <-> host + v + eMMC provisioning + +Build download agents separately from normal boot images; do not enable +``CONFIG_MTK_GENIO_BOOT_IMAGES`` in a DA configuration. + +For Genio 700, build the SPL fastboot mode with:: + + $ export CROSS_COMPILE=aarch64-linux-gnu- + $ make O=build-da-spl mt8390_genio_700_evk_da_spl_defconfig + $ make O=build-da-spl BINMAN_INDIRS=/path/to/firmware + +For fastboot in U-Boot proper:: + + $ make O=build-da-uboot mt8390_genio_700_evk_da_uboot_defconfig + $ make O=build-da-uboot BL31=/path/to/da-bl31.bin \ + BINMAN_INDIRS=/path/to/firmware + +Use the corresponding ``mt8370_genio_510_evk_da_spl_defconfig`` or +``mt8370_genio_510_evk_da_uboot_defconfig`` for Genio 510. Each build produces +``da.bin`` and ``da.map`` in its output directory. Use board- and mode-matched +firmware inputs; do not set ``TEE`` for these builds. + +Image and loader contract +~~~~~~~~~~~~~~~~~~~~~~~~~ + +The default ``da.bin`` layouts are shown below. Offsets are relative to the +start of the image, and region sizes include padding:: + + Fastboot in SPL Fastboot in U-Boot proper + + 0x00000 +----------------------+ 0x00000 +----------------------+ + | DDR loader | | DDR loader | + | 300 KiB | | 300 KiB | + 0x4b000 +----------------------+ 0x4b000 +----------------------+ + | SPL + USB fastboot | | SPL | + | 700 KiB | | 148 KiB | + | | 0x70000 +----------------------+ + | | | FIT: BL31 + U-Boot | + | | | 572 KiB | + 0xfa000 +----------------------+ 0xff000 +----------------------+ + +Both DA modes use the shared ``mtk-genio-*-binman-u-boot.dtsi`` templates and +``CONFIG_MTK_GENIO_IMAGE_CONTRACT`` settings. The image starts with the DDR +loader padded to ``CONFIG_MTK_GENIO_DDR_LOADER_SIZE``, followed by SPL padded +to ``CONFIG_SPL_MAX_SIZE``. The loader copies that SPL region to +``CONFIG_SPL_TEXT_BASE`` before entering it. SPL fastboot reserves a 16 MiB +heap, including space for the sparse writer's 8 MiB buffer. + +The full-U-Boot DA appends a FIT at ``CONFIG_MTK_GENIO_DA_FIT_OFFSET``, in a +fixed region of ``CONFIG_MTK_GENIO_DA_FIT_MAX_SIZE`` bytes. The external +loader must copy this complete region to ``CONFIG_SPL_LOAD_FIT_ADDRESS`` +before entering SPL. Its ``DA_FIT_OFFSET`` and ``DA_FIT_SIZE`` must match the +U-Boot settings. The FIT container is directly parseable; only its BL31 and +U-Boot payloads are gzip-compressed. SPL decompresses them to +``CONFIG_MTK_GENIO_BL31_LOAD_ADDR`` and ``CONFIG_TEXT_BASE`` respectively, +then enters BL31, which starts U-Boot. + +The default padded images are 1000 KiB for the SPL DA and 1020 KiB for the +U-Boot DA. The latter fits the Genio 700 BootROM download area. Selecting SPL +alone does not remove the fixed padding; a tighter download budget also +requires smaller reserved regions, with matching changes to the DDR loader. + +These fixed regions are part of the external loader ABI. Changing the image +sizes or addresses requires corresponding loader changes. Binman rejects +payloads which exceed their reserved regions. The generated DA is a raw +payload for the platform download tooling; it has no eMMC BootROM wrapper. +Its FIT hashes do not authenticate it. Platforms requiring authenticated +DAs must use their external signing and BootROM download tooling. + +Using the download agent +~~~~~~~~~~~~~~~~~~~~~~~~ + +Select the generated agent with ``genio-flash --bootstrap /path/to/da.bin``. +``genio-flash`` reboots the board after flashing. + +For manual fastboot sessions, use ``fastboot reboot`` to start the installed +boot chain. ``fastboot continue`` boots firmware from eMMC with the SPL DA, +or returns to the command prompt with the U-Boot DA, without resetting. + +Use raw images for ``mmc0boot0`` and ``mmc0boot1``. Android sparse images are +supported for GPT partitions and the eMMC user-area alias. + +The SPL DA prepares eMMC boot settings and permanently enables the hardware +reset pin if its policy is still unconfigured. The U-Boot DA does not perform +this preparation; provisioning a blank eMMC with it requires configuring +the boot settings separately. -- 2.55.0 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2026-09-29 7:43 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-09-23 21:17 [PATCH v2 0/3] Add Genio 510 and 700 BootROM download agents Carlo Caione 2026-09-23 21:17 ` [PATCH v2 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 Carlo Caione 2026-09-28 22:43 ` David Lechner 2026-09-29 7:39 ` Carlo Caione 2026-09-23 21:17 ` [PATCH v2 2/3] arm: mediatek: enable U-Boot " Carlo Caione 2026-09-28 22:43 ` David Lechner 2026-09-29 7:43 ` Carlo Caione 2026-09-23 21:17 ` [PATCH v2 3/3] doc: board: mediatek: document Genio download agents Carlo Caione
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.