All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Add Genio 510 and 700 BootROM download agents
@ 2026-09-14 13:35 Carlo Caione
  2026-09-14 13:35 ` [PATCH 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 Carlo Caione
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Carlo Caione @ 2026-09-14 13:35 UTC (permalink / raw)
  To: GSS_MTK_Uboot_upstream, u-boot
  Cc: 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, Carlo Caione

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.

The series provides both an SPL agent for provisioning without BL31 or
U-Boot proper, and a U-Boot agent for flows needing its command support.
Both require an external DDR loader.

This series depends on Genio SPL V7 [1] and generic SPL fastboot V6 [2],
applied in that order.

[1] https://lore.kernel.org/all/20260910-ccaione-upstream-mt8390-spl-v7-0-0a5cf09c5761@baylibre.com/
[2] https://lore.kernel.org/all/20260913-ccaione-upstream-spl-fastboot-v6-0-dd3ba81a7ed2@baylibre.com/

Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
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/mt8188-genio-da-u-boot.dtsi           | 58 ++++++++++++++++
 arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi      |  8 +++
 arch/arm/dts/mt8390-genio-700-evk-u-boot.dtsi      |  8 +++
 arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi       | 16 +++++
 arch/arm/dts/mtk-genio-da-fit-binman-u-boot.dtsi   | 62 +++++++++++++++++
 .../dts/mtk-genio-loader-spl-binman-u-boot.dtsi    |  6 ++
 arch/arm/mach-mediatek/Kconfig                     | 56 +++++++++++++++
 arch/arm/mach-mediatek/Makefile                    |  1 +
 arch/arm/mach-mediatek/spl.c                       |  3 +
 arch/arm/mach-mediatek/spl_fastboot.c              | 65 +++++++++++++++++
 board/mediatek/MAINTAINERS                         |  8 +++
 common/spl/Kconfig                                 |  2 +-
 configs/mt8188-genio-da-spl-fastboot.config        | 15 ++++
 configs/mt8188-genio-da-uboot-fastboot.config      | 20 ++++++
 configs/mt8188-genio-da.config                     | 19 +++++
 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            | 81 ++++++++++++++++++++++
 20 files changed, 435 insertions(+), 1 deletion(-)
---
base-commit: 527115ef6783cec49e5610c523c124b399011361
change-id: 20260910-ccaione-upstream-mt8390-da-f2f8416ab2a8
prerequisite-message-id: 20260910-ccaione-upstream-mt8390-spl-v7-0-0a5cf09c5761@baylibre.com
prerequisite-patch-id: 2cf6c90272cb885eea020b339a7ae76fc13e96d3
prerequisite-patch-id: d125fe2e446f3662de925b608d4b6c6299f8759c
prerequisite-patch-id: 7b41f296adc7e1549b64c590134c3ec56d226b4c
prerequisite-patch-id: cfd62f5e9d74fad11e1a9525f5047f47ccc15763
prerequisite-patch-id: 20b9d94c25eebe6010672c3a075f1a7adddfebd2
prerequisite-patch-id: 9e9a4d81113ef179e2ae6599ee525a1a8e0fe248
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] 10+ messages in thread

* [PATCH 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700
  2026-09-14 13:35 [PATCH 0/3] Add Genio 510 and 700 BootROM download agents Carlo Caione
@ 2026-09-14 13:35 ` Carlo Caione
  2026-09-22 16:27   ` David Lechner
  2026-09-14 13:35 ` [PATCH 2/3] arm: mediatek: enable U-Boot " Carlo Caione
  2026-09-14 13:35 ` [PATCH 3/3] doc: board: mediatek: document Genio download agents Carlo Caione
  2 siblings, 1 reply; 10+ messages in thread
From: Carlo Caione @ 2026-09-14 13:35 UTC (permalink / raw)
  To: GSS_MTK_Uboot_upstream, u-boot
  Cc: 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, Carlo Caione

From: Julien Masson <jmasson@baylibre.com>

Genio 510 and 700 need a provisioning and recovery path that remains
usable when eMMC is blank or its boot firmware is unusable. Add a RAM-
based fastboot download agent so boards can be flashed through the
MediaTek BootROM download protocol without a working on-device
bootloader.

Running the agent in SPL avoids a dependency on BL31 and U-Boot proper
during provisioning.

Signed-off-by: Julien Masson <jmasson@baylibre.com>
Signed-off-by: Carlo Caione <ccaione@baylibre.com>
---
 arch/arm/dts/mt8188-genio-da-u-boot.dtsi           | 55 ++++++++++++++++++
 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-binman-u-boot.dtsi       | 16 ++++++
 .../dts/mtk-genio-loader-spl-binman-u-boot.dtsi    |  6 ++
 arch/arm/mach-mediatek/Kconfig                     | 26 +++++++++
 arch/arm/mach-mediatek/Makefile                    |  1 +
 arch/arm/mach-mediatek/spl_fastboot.c              | 65 ++++++++++++++++++++++
 board/mediatek/MAINTAINERS                         |  5 ++
 common/spl/Kconfig                                 |  2 +-
 configs/mt8188-genio-da-spl-fastboot.config        | 15 +++++
 configs/mt8188-genio-da.config                     | 19 +++++++
 configs/mt8370_genio_510_evk_da_spl_defconfig      |  2 +
 configs/mt8390_genio_700_evk_da_spl_defconfig      |  2 +
 14 files changed, 221 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/mt8188-genio-da-u-boot.dtsi b/arch/arm/dts/mt8188-genio-da-u-boot.dtsi
new file mode 100644
index 00000000000..e9078f37157
--- /dev/null
+++ b/arch/arm/dts/mt8188-genio-da-u-boot.dtsi
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
+/*
+ * Copyright (c) 2026 BayLibre, SAS.
+ * Author: Carlo Caione <ccaione@baylibre.com>
+ */
+
+#include "mtk-genio-binman-u-boot.dtsi"
+#include "mtk-genio-da-binman-u-boot.dtsi"
+
+&ssusb0 {
+	dr_mode = "peripheral";
+	mediatek,force-vbus;
+};
+
+&ssusb1 {
+	status = "disabled";
+};
+
+&ssusb2 {
+	status = "disabled";
+};
+
+#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/mt8370-genio-510-evk-u-boot.dtsi b/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi
index 10b9a142f37..608987ca6d7 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 "mt8188-genio-da-u-boot.dtsi"
+#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..6c6c85e8767 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 "mt8188-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..ad337bf1784
--- /dev/null
+++ b/arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi
@@ -0,0 +1,16 @@
+// 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>;
+
+#define MTK_GENIO_SIMPLE_SPL
+#include "mtk-genio-loader-spl-binman-u-boot.dtsi"
+#undef MTK_GENIO_SIMPLE_SPL
+	};
+};
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..503ae06da34 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,6 +12,11 @@ ddr-loader {
 	size = <CONFIG_MTK_GENIO_DDR_LOADER_SIZE>;
 };
 
+#ifdef MTK_GENIO_SIMPLE_SPL
+u-boot-spl {
+	size = <CONFIG_SPL_MAX_SIZE>;
+};
+#else
 #ifdef CONFIG_SPL_FIT_SIGNATURE
 u-boot-spl {
 	type = "section";
@@ -31,3 +36,4 @@ u-boot-spl {
 	size = <CONFIG_SPL_MAX_SIZE>;
 };
 #endif
+#endif
diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
index e572cfe8571..59489c0fe65 100644
--- a/arch/arm/mach-mediatek/Kconfig
+++ b/arch/arm/mach-mediatek/Kconfig
@@ -249,6 +249,32 @@ 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
+	help
+	  Select where to run fastboot after the BootROM downloads the agent
+	  into RAM. Leave this disabled for normal storage boot.
+
+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..42b83b82f77 100644
--- a/arch/arm/mach-mediatek/Makefile
+++ b/arch/arm/mach-mediatek/Makefile
@@ -4,6 +4,7 @@ obj-$(CONFIG_ARM64) += armv8-mem-map.o
 obj-y	+= cpu.o
 obj-$(CONFIG_MTK_TZ_MOVABLE)	+= tzcfg.o
 obj-$(CONFIG_XPL_BUILD)	+= spl.o
+obj-$(CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT)	+= spl_fastboot.o
 
 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..0ba76d47dfb
--- /dev/null
+++ b/arch/arm/mach-mediatek/spl_fastboot.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2024 BayLibre, SAS.
+ * Author: Julien Masson <jmasson@baylibre.com>
+ */
+
+#include <dm/uclass.h>
+#include <fastboot.h>
+#include <mmc.h>
+
+static int mtk_mmc_boot_prepare(void)
+{
+	struct udevice *dev;
+	struct mmc *mmc;
+	int ret;
+
+	ret = uclass_get_device_by_seq(UCLASS_MMC,
+				       CONFIG_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(CONFIG_FASTBOOT_USB_DEV, NULL, 0);
+	if (ret)
+		printf("Fastboot failed: %d\n", ret);
+}
diff --git a/board/mediatek/MAINTAINERS b/board/mediatek/MAINTAINERS
index 5b0d79320bd..27aeb4dff07 100644
--- a/board/mediatek/MAINTAINERS
+++ b/board/mediatek/MAINTAINERS
@@ -21,14 +21,19 @@ MT8188/MT8370/MT8390
 M:	Macpaul Lin <Macpaul.Lin@mediatek.com>
 M:	Julien Stephan <jstephan@baylibre.com>
 S:	Maintained
+F:	arch/arm/dts/mt8188-genio-da-u-boot.dtsi
 F:	arch/arm/dts/mt8188-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/mt8188-genio-da-spl-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_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 f9b453df766..77da2f4c8aa 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/mt8188-genio-da-spl-fastboot.config b/configs/mt8188-genio-da-spl-fastboot.config
new file mode 100644
index 00000000000..01b35f1144e
--- /dev/null
+++ b/configs/mt8188-genio-da-spl-fastboot.config
@@ -0,0 +1,15 @@
+#include <configs/mt8188-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
+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_MMC_BOOT_SUPPORT=y
+CONFIG_SPL_FASTBOOT_MMC_USER_SUPPORT=y
diff --git a/configs/mt8188-genio-da.config b/configs/mt8188-genio-da.config
new file mode 100644
index 00000000000..d47bce044a7
--- /dev/null
+++ b/configs/mt8188-genio-da.config
@@ -0,0 +1,19 @@
+CONFIG_SYS_MALLOC_LEN=0x9000000
+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_CMD_FASTBOOT=y
+CONFIG_USB_FUNCTION_FASTBOOT=y
+CONFIG_FASTBOOT_BUF_ADDR=0x65000000
+CONFIG_FASTBOOT_BUF_SIZE=0x15000000
+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
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..42ca29dfe1c
--- /dev/null
+++ b/configs/mt8370_genio_510_evk_da_spl_defconfig
@@ -0,0 +1,2 @@
+#include <configs/mt8370_genio_510_evk_defconfig>
+#include <configs/mt8188-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..ca58b131ed6
--- /dev/null
+++ b/configs/mt8390_genio_700_evk_da_spl_defconfig
@@ -0,0 +1,2 @@
+#include <configs/mt8390_genio_700_evk_defconfig>
+#include <configs/mt8188-genio-da-spl-fastboot.config>

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] arm: mediatek: enable U-Boot fastboot DAs on Genio 510 and 700
  2026-09-14 13:35 [PATCH 0/3] Add Genio 510 and 700 BootROM download agents Carlo Caione
  2026-09-14 13:35 ` [PATCH 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 Carlo Caione
@ 2026-09-14 13:35 ` Carlo Caione
  2026-09-22 16:27   ` David Lechner
  2026-09-14 13:35 ` [PATCH 3/3] doc: board: mediatek: document Genio download agents Carlo Caione
  2 siblings, 1 reply; 10+ messages in thread
From: Carlo Caione @ 2026-09-14 13:35 UTC (permalink / raw)
  To: GSS_MTK_Uboot_upstream, u-boot
  Cc: 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, Carlo Caione

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 <ccaione@baylibre.com>
---
 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 <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 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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] doc: board: mediatek: document Genio download agents
  2026-09-14 13:35 [PATCH 0/3] Add Genio 510 and 700 BootROM download agents Carlo Caione
  2026-09-14 13:35 ` [PATCH 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 Carlo Caione
  2026-09-14 13:35 ` [PATCH 2/3] arm: mediatek: enable U-Boot " Carlo Caione
@ 2026-09-14 13:35 ` Carlo Caione
  2 siblings, 0 replies; 10+ messages in thread
From: Carlo Caione @ 2026-09-14 13:35 UTC (permalink / raw)
  To: GSS_MTK_Uboot_upstream, u-boot
  Cc: 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, Carlo Caione

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 | 81 +++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)

diff --git a/doc/board/mediatek/mt8188-genio-evk.rst b/doc/board/mediatek/mt8188-genio-evk.rst
index e36e8faeb48..43948bb4365 100644
--- a/doc/board/mediatek/mt8188-genio-evk.rst
+++ b/doc/board/mediatek/mt8188-genio-evk.rst
@@ -279,3 +279,84 @@ 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.
+
+Two mutually exclusive modes are available:
+
+* ``CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT`` runs fastboot directly in
+  SPL. It needs the matching external DDR loader, but no BL31 or OP-TEE.
+* ``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.
+
+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
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+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.
+
+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.
+
+Provisioning behavior
+~~~~~~~~~~~~~~~~~~~~~
+
+Before entering fastboot, the SPL DA selects eMMC boot0 (BOOT1 in the eMMC
+register encoding), enables boot acknowledgment and sets the boot bus to
+x1 SDR. If ``RST_N_FUNCTION`` is still zero, it permanently enables the eMMC
+reset pin. That field is write-once. A previously programmed reset policy is
+left unchanged. Preparation errors are printed and fastboot remains available
+for recovery.
+
+The full-U-Boot DA does not perform that automatic eMMC boot preparation.
+Its provisioning flow must configure the target's boot settings separately
+when needed, particularly on a blank device. Neither mode changes the GPT or
+writes firmware partitions until commanded by the host. Use the platform
+provisioning tools with the matching DA and partition metadata.
+
+Use raw images with the eMMC boot-area aliases ``mmc0boot0`` and
+``mmc0boot1``: these aliases write the downloaded bytes without expanding
+Android sparse images. Sparse flashing is supported for GPT partitions and
+the eMMC user-area alias.

-- 
2.55.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700
  2026-09-14 13:35 ` [PATCH 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 Carlo Caione
@ 2026-09-22 16:27   ` David Lechner
  2026-09-23 14:15     ` Carlo Caione
  0 siblings, 1 reply; 10+ messages in thread
From: David Lechner @ 2026-09-22 16:27 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

On 9/14/26 8:35 AM, Carlo Caione wrote:
> From: Julien Masson <jmasson@baylibre.com>
> 
> Genio 510 and 700 need a provisioning and recovery path that remains
> usable when eMMC is blank or its boot firmware is unusable. Add a RAM-
> based fastboot download agent so boards can be flashed through the
> MediaTek BootROM download protocol without a working on-device
> bootloader.
> 
> Running the agent in SPL avoids a dependency on BL31 and U-Boot proper
> during provisioning.

It would be helpful to have some more explanation here about why the
different parts of this patch are doing what they are doing.

> 
> Signed-off-by: Julien Masson <jmasson@baylibre.com>
> Signed-off-by: Carlo Caione <ccaione@baylibre.com>
> ---
>  arch/arm/dts/mt8188-genio-da-u-boot.dtsi           | 55 ++++++++++++++++++
>  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-binman-u-boot.dtsi       | 16 ++++++
>  .../dts/mtk-genio-loader-spl-binman-u-boot.dtsi    |  6 ++
>  arch/arm/mach-mediatek/Kconfig                     | 26 +++++++++
>  arch/arm/mach-mediatek/Makefile                    |  1 +
>  arch/arm/mach-mediatek/spl_fastboot.c              | 65 ++++++++++++++++++++++
>  board/mediatek/MAINTAINERS                         |  5 ++
>  common/spl/Kconfig                                 |  2 +-
>  configs/mt8188-genio-da-spl-fastboot.config        | 15 +++++
>  configs/mt8188-genio-da.config                     | 19 +++++++

I think these should use mt8370 prefix like the other common genio 510/700
stuff. mt8188 is for chromebooks, so I don't think it would make sense to
use that number with genio-specific configs.

>  configs/mt8370_genio_510_evk_da_spl_defconfig      |  2 +
>  configs/mt8390_genio_700_evk_da_spl_defconfig      |  2 +
>  14 files changed, 221 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/dts/mt8188-genio-da-u-boot.dtsi b/arch/arm/dts/mt8188-genio-da-u-boot.dtsi
> new file mode 100644
> index 00000000000..e9078f37157
> --- /dev/null
> +++ b/arch/arm/dts/mt8188-genio-da-u-boot.dtsi
> @@ -0,0 +1,55 @@
> +// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
> +/*
> + * Copyright (c) 2026 BayLibre, SAS.
> + * Author: Carlo Caione <ccaione@baylibre.com>
> + */

I would add a comment here explaining that da is download agent and why we
have this special devicetree that is different from the normal one.

> +
> +#include "mtk-genio-binman-u-boot.dtsi"
> +#include "mtk-genio-da-binman-u-boot.dtsi"
> +
> +&ssusb0 {
> +	dr_mode = "peripheral";

> +	mediatek,force-vbus;

This is not an upstream DT property.

It seems like dr_mode = "peripheral" should already imply this anyway. So
hopefully we can just modify the USB driver and leave this property out.

> +};
> +
> +&ssusb1 {
> +	status = "disabled";
> +};
> +
> +&ssusb2 {
> +	status = "disabled";
> +};
> +
> +#ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT

Why do these matter for fastboot but not the ones above?

> +&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/mt8370-genio-510-evk-u-boot.dtsi b/arch/arm/dts/mt8370-genio-510-evk-u-boot.dtsi
> index 10b9a142f37..608987ca6d7 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 "mt8188-genio-da-u-boot.dtsi"
> +#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..6c6c85e8767 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 "mt8188-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..ad337bf1784
> --- /dev/null
> +++ b/arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi
> @@ -0,0 +1,16 @@
> +// 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>;
> +
> +#define MTK_GENIO_SIMPLE_SPL

Could we pick a name that describe more precicly what this does? SIMPLE
is vague.

> +#include "mtk-genio-loader-spl-binman-u-boot.dtsi"
> +#undef MTK_GENIO_SIMPLE_SPL
> +	};
> +};
> 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..503ae06da34 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,6 +12,11 @@ ddr-loader {
>  	size = <CONFIG_MTK_GENIO_DDR_LOADER_SIZE>;
>  };
>  
> +#ifdef MTK_GENIO_SIMPLE_SPL
> +u-boot-spl {
> +	size = <CONFIG_SPL_MAX_SIZE>;
> +};
> +#else
>  #ifdef CONFIG_SPL_FIT_SIGNATURE
>  u-boot-spl {
>  	type = "section";
> @@ -31,3 +36,4 @@ u-boot-spl {
>  	size = <CONFIG_SPL_MAX_SIZE>;
>  };
>  #endif
> +#endif
> diff --git a/arch/arm/mach-mediatek/Kconfig b/arch/arm/mach-mediatek/Kconfig
> index e572cfe8571..59489c0fe65 100644
> --- a/arch/arm/mach-mediatek/Kconfig
> +++ b/arch/arm/mach-mediatek/Kconfig
> @@ -249,6 +249,32 @@ 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
> +	help
> +	  Select where to run fastboot after the BootROM downloads the agent
> +	  into RAM. Leave this disabled for normal storage boot.
> +
> +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..42b83b82f77 100644
> --- a/arch/arm/mach-mediatek/Makefile
> +++ b/arch/arm/mach-mediatek/Makefile
> @@ -4,6 +4,7 @@ obj-$(CONFIG_ARM64) += armv8-mem-map.o
>  obj-y	+= cpu.o
>  obj-$(CONFIG_MTK_TZ_MOVABLE)	+= tzcfg.o
>  obj-$(CONFIG_XPL_BUILD)	+= spl.o
> +obj-$(CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT)	+= spl_fastboot.o
>  
>  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..0ba76d47dfb
> --- /dev/null
> +++ b/arch/arm/mach-mediatek/spl_fastboot.c
> @@ -0,0 +1,65 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (c) 2024 BayLibre, SAS.

2026

> + * Author: Julien Masson <jmasson@baylibre.com>
> + */
> +
> +#include <dm/uclass.h>
> +#include <fastboot.h>
> +#include <mmc.h>

Suggest also <stdio.h> for printf and <linux/errno.h> for ENODEV.

> +
> +static int mtk_mmc_boot_prepare(void)
> +{
> +	struct udevice *dev;
> +	struct mmc *mmc;
> +	int ret;
> +
> +	ret = uclass_get_device_by_seq(UCLASS_MMC,
> +				       CONFIG_FASTBOOT_FLASH_MMC_DEV, &dev);

Should this be find_mmc_device(CONFIG_VAL(FASTBOOT_FLASH_MMC_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(CONFIG_FASTBOOT_USB_DEV, NULL, 0);
> +	if (ret)
> +		printf("Fastboot failed: %d\n", ret);
> +}
> diff --git a/board/mediatek/MAINTAINERS b/board/mediatek/MAINTAINERS
> index 5b0d79320bd..27aeb4dff07 100644
> --- a/board/mediatek/MAINTAINERS
> +++ b/board/mediatek/MAINTAINERS
> @@ -21,14 +21,19 @@ MT8188/MT8370/MT8390
>  M:	Macpaul Lin <Macpaul.Lin@mediatek.com>
>  M:	Julien Stephan <jstephan@baylibre.com>
>  S:	Maintained
> +F:	arch/arm/dts/mt8188-genio-da-u-boot.dtsi
>  F:	arch/arm/dts/mt8188-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/mt8188-genio-da-spl-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_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 f9b453df766..77da2f4c8aa 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

Should we do something to make sure we don't select MTK_GENIO_BOOT_IMAGES
and MTK_BROM_DOWNLOAD_AGENT at the same time?

>  	default y
>  	help
>  	  This enables use of symbols in SPL which refer to other entries in
> diff --git a/configs/mt8188-genio-da-spl-fastboot.config b/configs/mt8188-genio-da-spl-fastboot.config
> new file mode 100644
> index 00000000000..01b35f1144e
> --- /dev/null
> +++ b/configs/mt8188-genio-da-spl-fastboot.config
> @@ -0,0 +1,15 @@
> +#include <configs/mt8188-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
> +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_MMC_BOOT_SUPPORT=y
> +CONFIG_SPL_FASTBOOT_MMC_USER_SUPPORT=y
> diff --git a/configs/mt8188-genio-da.config b/configs/mt8188-genio-da.config

Do these really need to be two separate files? As mentioned above, there
isn't really such thing as a mt8188-genio seprate from a mt8370-genio-common.
mt8188.config already contains things that really are genio-specific that
would be more "correct" to move to a separate file. But that is a bigger
cleanup that affects all MediaTek Genio boards that we can look at later.

> new file mode 100644
> index 00000000000..d47bce044a7
> --- /dev/null
> +++ b/configs/mt8188-genio-da.config
> @@ -0,0 +1,19 @@
> +CONFIG_SYS_MALLOC_LEN=0x9000000
> +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_CMD_FASTBOOT=y
> +CONFIG_USB_FUNCTION_FASTBOOT=y
> +CONFIG_FASTBOOT_BUF_ADDR=0x65000000
> +CONFIG_FASTBOOT_BUF_SIZE=0x15000000
> +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
> 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..42ca29dfe1c
> --- /dev/null
> +++ b/configs/mt8370_genio_510_evk_da_spl_defconfig
> @@ -0,0 +1,2 @@
> +#include <configs/mt8370_genio_510_evk_defconfig>
> +#include <configs/mt8188-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..ca58b131ed6
> --- /dev/null
> +++ b/configs/mt8390_genio_700_evk_da_spl_defconfig
> @@ -0,0 +1,2 @@
> +#include <configs/mt8390_genio_700_evk_defconfig>
> +#include <configs/mt8188-genio-da-spl-fastboot.config>
> 


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] arm: mediatek: enable U-Boot fastboot DAs on Genio 510 and 700
  2026-09-14 13:35 ` [PATCH 2/3] arm: mediatek: enable U-Boot " Carlo Caione
@ 2026-09-22 16:27   ` David Lechner
  2026-09-23 14:25     ` Carlo Caione
  0 siblings, 1 reply; 10+ messages in thread
From: David Lechner @ 2026-09-22 16:27 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

On 9/14/26 8:35 AM, Carlo Caione wrote:
> 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.

So this is providing the same utility as in the previous patch, but also
uses U-Boot proper? Why do we need both?


> 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;
> +

It seems like this could unintentionally affect other MediaTek targets since
they all share this code. Should we also check one of the FASTBOOT config
options here?

>  #if defined(CONFIG_SPL_SPI)
>  	return BOOT_DEVICE_SPI;
>  #elif defined(CONFIG_SPL_MMC)
Should we have a precursor patch to clean up the existing entries to also
use CONFIG_IS_ENABLED() to keep this consistent?

(And I assume in the config from the first patch, this would fall though to
BOOT_DEVICE_NONE since there is no u-boot proper in that case?)


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700
  2026-09-22 16:27   ` David Lechner
@ 2026-09-23 14:15     ` Carlo Caione
  0 siblings, 0 replies; 10+ messages in thread
From: Carlo Caione @ 2026-09-23 14:15 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

On Tue, Sep 22, 2026 at 11:27:32 +0100, David Lechner wrote:
> On 9/14/26 8:35 AM, Carlo Caione wrote:
> > From: Julien Masson <jmasson@baylibre.com>
> > 
> > Genio 510 and 700 need a provisioning and recovery path that remains
> > usable when eMMC is blank or its boot firmware is unusable. Add a RAM-
> > based fastboot download agent so boards can be flashed through the
> > MediaTek BootROM download protocol without a working on-device
> > bootloader.
> > 
> > Running the agent in SPL avoids a dependency on BL31 and U-Boot proper
> > during provisioning.
> 
> It would be helpful to have some more explanation here about why the
> different parts of this patch are doing what they are doing.

Yeah, I agree. I'll add the explanation of the why in the commit
message.
 
> > 
> > Signed-off-by: Julien Masson <jmasson@baylibre.com>
> > Signed-off-by: Carlo Caione <ccaione@baylibre.com>
> > ---
> >  arch/arm/dts/mt8188-genio-da-u-boot.dtsi           | 55 ++++++++++++++++++
> >  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-binman-u-boot.dtsi       | 16 ++++++
> >  .../dts/mtk-genio-loader-spl-binman-u-boot.dtsi    |  6 ++
> >  arch/arm/mach-mediatek/Kconfig                     | 26 +++++++++
> >  arch/arm/mach-mediatek/Makefile                    |  1 +
> >  arch/arm/mach-mediatek/spl_fastboot.c              | 65 ++++++++++++++++++++++
> >  board/mediatek/MAINTAINERS                         |  5 ++
> >  common/spl/Kconfig                                 |  2 +-
> >  configs/mt8188-genio-da-spl-fastboot.config        | 15 +++++
> >  configs/mt8188-genio-da.config                     | 19 +++++++
> 
> I think these should use mt8370 prefix like the other common genio 510/700
> stuff. mt8188 is for chromebooks, so I don't think it would make sense to
> use that number with genio-specific configs.

:( yup, makes sense.

> >  configs/mt8370_genio_510_evk_da_spl_defconfig      |  2 +
> >  configs/mt8390_genio_700_evk_da_spl_defconfig      |  2 +
> >  14 files changed, 221 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/arm/dts/mt8188-genio-da-u-boot.dtsi b/arch/arm/dts/mt8188-genio-da-u-boot.dtsi
> > new file mode 100644
> > index 00000000000..e9078f37157
> > --- /dev/null
> > +++ b/arch/arm/dts/mt8188-genio-da-u-boot.dtsi
> > @@ -0,0 +1,55 @@
> > +// SPDX-License-Identifier: (GPL-2.0-only OR MIT)
> > +/*
> > + * Copyright (c) 2026 BayLibre, SAS.
> > + * Author: Carlo Caione <ccaione@baylibre.com>
> > + */
> 
> I would add a comment here explaining that da is download agent and why we
> have this special devicetree that is different from the normal one.

I'll add a comment.

> > +
> > +#include "mtk-genio-binman-u-boot.dtsi"
> > +#include "mtk-genio-da-binman-u-boot.dtsi"
> > +
> > +&ssusb0 {
> > +	dr_mode = "peripheral";
> 
> > +	mediatek,force-vbus;
> 
> This is not an upstream DT property.
> 
> It seems like dr_mode = "peripheral" should already imply this anyway. So
> hopefully we can just modify the USB driver and leave this property out.

Good point. I'll make the change to the MTU3 driver.

> > +};
> > +
> > +&ssusb1 {
> > +	status = "disabled";
> > +};
> > +
> > +&ssusb2 {
> > +	status = "disabled";
> > +};
> > +
> > +#ifdef CONFIG_MTK_BROM_DOWNLOAD_AGENT_SPL_FASTBOOT
> 
> Why do these matter for fastboot but not the ones above?

Because only the fastboot-in-SPL variant uses USB during SPL execution,
in the fastboot-in-U-Boot-proper case these nodes are already in the
regular U-Boot DT (no need for 'bootph-pre-ram').

> > +&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

[...]
> > --- /dev/null
> > +++ b/arch/arm/dts/mtk-genio-da-binman-u-boot.dtsi
> > @@ -0,0 +1,16 @@
> > +// 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>;
> > +
> > +#define MTK_GENIO_SIMPLE_SPL
> 
> Could we pick a name that describe more precicly what this does? SIMPLE
> is vague.

Fair enough.

[...]
> >  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..0ba76d47dfb
> > --- /dev/null
> > +++ b/arch/arm/mach-mediatek/spl_fastboot.c
> > @@ -0,0 +1,65 @@
> > +// SPDX-License-Identifier: GPL-2.0-only
> > +/*
> > + * Copyright (c) 2024 BayLibre, SAS.
> 
> 2026

uh, time flies.

> > + * Author: Julien Masson <jmasson@baylibre.com>
> > + */
> > +
> > +#include <dm/uclass.h>
> > +#include <fastboot.h>
> > +#include <mmc.h>
> 
> Suggest also <stdio.h> for printf and <linux/errno.h> for ENODEV.

Ok

> > +
> > +static int mtk_mmc_boot_prepare(void)
> > +{
> > +	struct udevice *dev;
> > +	struct mmc *mmc;
> > +	int ret;
> > +
> > +	ret = uclass_get_device_by_seq(UCLASS_MMC,
> > +				       CONFIG_FASTBOOT_FLASH_MMC_DEV, &dev);
> 
> Should this be find_mmc_device(CONFIG_VAL(FASTBOOT_FLASH_MMC_DEV))?

No, we need this because we need to actually probe the device.

[...]
> > diff --git a/common/spl/Kconfig b/common/spl/Kconfig
> > index f9b453df766..77da2f4c8aa 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
> 
> Should we do something to make sure we don't select MTK_GENIO_BOOT_IMAGES
> and MTK_BROM_DOWNLOAD_AGENT at the same time?

I'll add a depends on !MTK_GENIO_BOOT_IMAGES

> >  	default y
> >  	help
> >  	  This enables use of symbols in SPL which refer to other entries in
> > diff --git a/configs/mt8188-genio-da-spl-fastboot.config b/configs/mt8188-genio-da-spl-fastboot.config
> > new file mode 100644
> > index 00000000000..01b35f1144e
> > --- /dev/null
> > +++ b/configs/mt8188-genio-da-spl-fastboot.config
> > @@ -0,0 +1,15 @@
> > +#include <configs/mt8188-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
> > +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_MMC_BOOT_SUPPORT=y
> > +CONFIG_SPL_FASTBOOT_MMC_USER_SUPPORT=y
> > diff --git a/configs/mt8188-genio-da.config b/configs/mt8188-genio-da.config
> 
> Do these really need to be two separate files? As mentioned above, there
> isn't really such thing as a mt8188-genio seprate from a mt8370-genio-common.
> mt8188.config already contains things that really are genio-specific that
> would be more "correct" to move to a separate file. But that is a bigger
> cleanup that affects all MediaTek Genio boards that we can look at later.

ok, I can slightly make this better by splitting:

- mt8370-genio-da.config: settings shared by both DA variants
- mt8370-genio-da-spl-fastboot.config: SPL fastboot settings
- mt8370-genio-da-uboot-fastboot.config: U-Boot-proper fastboot settings

Thanks!

--
Carlo Caione

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] arm: mediatek: enable U-Boot fastboot DAs on Genio 510 and 700
  2026-09-22 16:27   ` David Lechner
@ 2026-09-23 14:25     ` Carlo Caione
  2026-09-23 14:55       ` David Lechner
  0 siblings, 1 reply; 10+ messages in thread
From: Carlo Caione @ 2026-09-23 14:25 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

On Tue, Sep 22, 2026 at 11:27:35 +0100, David Lechner wrote:
> On 9/14/26 8:35 AM, Carlo Caione wrote:
> > 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.
> 
> So this is providing the same utility as in the previous patch, but also
> uses U-Boot proper? Why do we need both?

I'll explain that better in the next respin but basically U-Boot proper
is preferred when the complete agent fits BootROM's SRAM download area
before DRAM initialization (it is preferred because well, you have the
full U-Boot at your disposal).

The SPL alternative is useful for tighter payload budgets, because it
avoids the space required by BL31 and U-Boot proper (an external DDR
loader is still required).
 
So it is just matter of space really: if you have enough SRAM usable as
download area it is better to go with proper U-Boot, if space is tight
SPL is your only option.

> > 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;
> > +
> 
> It seems like this could unintentionally affect other MediaTek targets since
> they all share this code. Should we also check one of the FASTBOOT config
> options here?

Uh, good eye. Thanks for spotting this.

> >  #if defined(CONFIG_SPL_SPI)
> >  	return BOOT_DEVICE_SPI;
> >  #elif defined(CONFIG_SPL_MMC)
> Should we have a precursor patch to clean up the existing entries to also
> use CONFIG_IS_ENABLED() to keep this consistent?

I'll clean it up in this set, no need to have a precursor patch.

> (And I assume in the config from the first patch, this would fall though to
> BOOT_DEVICE_NONE since there is no u-boot proper in that case?)

mmh no, spl_boot_device() returns BOOT_DEVICE_MMC1, not
BOOT_DEVICE_NONE. The point is that there is no U-Boot proper inside the
SPL DA, but SPL can load it from eMMC.

Thank you for the review,

--
Carlo Caione

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] arm: mediatek: enable U-Boot fastboot DAs on Genio 510 and 700
  2026-09-23 14:25     ` Carlo Caione
@ 2026-09-23 14:55       ` David Lechner
  2026-09-23 16:14         ` Carlo Caione
  0 siblings, 1 reply; 10+ messages in thread
From: David Lechner @ 2026-09-23 14:55 UTC (permalink / raw)
  To: Carlo Caione
  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

On 9/23/26 9:25 AM, Carlo Caione wrote:
> On Tue, Sep 22, 2026 at 11:27:35 +0100, David Lechner wrote:
>> On 9/14/26 8:35 AM, Carlo Caione wrote:
>>> 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.
>>

...

>>>  #if defined(CONFIG_SPL_SPI)
>>>  	return BOOT_DEVICE_SPI;
>>>  #elif defined(CONFIG_SPL_MMC)
>> Should we have a precursor patch to clean up the existing entries to also
>> use CONFIG_IS_ENABLED() to keep this consistent?
> 
> I'll clean it up in this set, no need to have a precursor patch.
> 
>> (And I assume in the config from the first patch, this would fall though to
>> BOOT_DEVICE_NONE since there is no u-boot proper in that case?)
> 
> mmh no, spl_boot_device() returns BOOT_DEVICE_MMC1, not
> BOOT_DEVICE_NONE. The point is that there is no U-Boot proper inside the
> SPL DA, but SPL can load it from eMMC.

I might not have written this down in the review. When I was looking over
this, I was wondering if running the download agent should always end with
a reset/reboot or if it is supposed to be able to jump to u-boot proper or
linux without rebooting first. 

> 
> Thank you for the review,
> 
> --
> Carlo Caione


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] arm: mediatek: enable U-Boot fastboot DAs on Genio 510 and 700
  2026-09-23 14:55       ` David Lechner
@ 2026-09-23 16:14         ` Carlo Caione
  0 siblings, 0 replies; 10+ messages in thread
From: Carlo Caione @ 2026-09-23 16:14 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

On Wed, Sep 23, 2026 at 09:55:01 +0100, David Lechner wrote:
[...]
> > mmh no, spl_boot_device() returns BOOT_DEVICE_MMC1, not
> > BOOT_DEVICE_NONE. The point is that there is no U-Boot proper inside the
> > SPL DA, but SPL can load it from eMMC.
> 
> I might not have written this down in the review. When I was looking over
> this, I was wondering if running the download agent should always end with
> a reset/reboot or if it is supposed to be able to jump to u-boot proper or
> linux without rebooting first. 

Very interesting question.

So, we should always issue a 'fastboot reboot' command (and this is
exactly what genio-flash does at the end of the provisioning process)
because a reboot is needed to excercise the complete newly installed
boot chain (including the new DDR loader and the new SPL just downloaded
into the eMMC during provisioning).

Just for the sake of curiosity I also tried to check what happens with
`fastboot continue`: SPL DA chainload the proper U-Boot just flashed
into the eMMC, U-Boot DA does nothing, it just stops.

Someone off-list asked me to support `fastboot boot` from SPL but I'll
be pushing that as a separate submission.

Cheers,

--
Carlo Caione

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-09-23 16:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-14 13:35 [PATCH 0/3] Add Genio 510 and 700 BootROM download agents Carlo Caione
2026-09-14 13:35 ` [PATCH 1/3] arm: mediatek: enable SPL fastboot DAs on Genio 510 and 700 Carlo Caione
2026-09-22 16:27   ` David Lechner
2026-09-23 14:15     ` Carlo Caione
2026-09-14 13:35 ` [PATCH 2/3] arm: mediatek: enable U-Boot " Carlo Caione
2026-09-22 16:27   ` David Lechner
2026-09-23 14:25     ` Carlo Caione
2026-09-23 14:55       ` David Lechner
2026-09-23 16:14         ` Carlo Caione
2026-09-14 13:35 ` [PATCH 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.