All of lore.kernel.org
 help / color / mirror / Atom feed
From: Neil Armstrong <neil.armstrong@linaro.org>
To: Christian Hewitt <christianshewitt@gmail.com>,
	 Vyacheslav Bocharov <adeep@lexina.in>,
	 Beniamino Galvani <b.galvani@gmail.com>
Cc: u-boot-amlogic@groups.io, u-boot@lists.denx.de,
	 Neil Armstrong <neil.armstrong@linaro.org>,
	 Neil Armstrong <neil.armstrong@linaro.org>
Subject: [PATCH 3/4] configs: meson64: add alternate USB DFU boot target
Date: Mon, 23 Oct 2023 14:41:36 +0200	[thread overview]
Message-ID: <20231023-usb-dfu-boot-v1-3-df9d121c67c1@linaro.org> (raw)
In-Reply-To: <20231023-usb-dfu-boot-v1-0-df9d121c67c1@linaro.org>

Add boot over DFU RAM as an alternate to running script at
a fixed address like done today.

The main culprit is that it's not possible to do that
on G12A/Sm1 platforms due to changes in the USB boot protocol.

With this, U-Boot will present a DFU device with a ram slot where
the Host could write a fitImage or legacy U-Boot image, then with the
detach command boot will continue trying to boot the uploaded image.

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 include/configs/meson64.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/include/configs/meson64.h b/include/configs/meson64.h
index a64817ec9b..efab9a624d 100644
--- a/include/configs/meson64.h
+++ b/include/configs/meson64.h
@@ -53,6 +53,30 @@
 #define BOOTENV_DEV_NAME_ROMUSB(devtypeu, devtypel, instance)	\
 		"romusb "
 
+/*
+ * Fallback to "USB DFU" boot if script is not at scriptaddr
+ *
+ * DFU will expose the kernel_addr_r memory range as DFU entry,
+ * then with `dfu-util --detach`, booting the uploaded image
+ * will be attempted:
+ * $ dfu-util -a 0 -D fitImage
+ * $ dfu-util -a 0 -e
+ */
+#if CONFIG_IS_ENABLED(USB_GADGET) && CONFIG_IS_ENABLED(DFU_RAM)
+	#define BOOTENV_DEV_USB_DFU(devtypeu, devtypel, instance) \
+		"bootcmd_usbdfu=" \
+			"if test \"${boot_source}\" = \"usb\"; then " \
+				"dfu 0 ram 0 60;" \
+				"bootm ${kernel_addr_r};" \
+			"fi\0"
+
+	#define BOOTENV_DEV_NAME_USB_DFU(devtypeu, devtypel, instance) \
+		"usbdfu "
+#else
+	#define BOOTENV_DEV_USB_DFU(devtypeu, devtypel, instance)
+	#define BOOTENV_DEV_NAME_USB_DFU(devtypeu, devtypel, instance)
+#endif
+
 #ifdef CONFIG_CMD_USB
 #define BOOT_TARGET_DEVICES_USB(func) func(USB, usb, 0)
 #else
@@ -74,6 +98,7 @@
 #ifndef BOOT_TARGET_DEVICES
 #define BOOT_TARGET_DEVICES(func) \
 	func(ROMUSB, romusb, na)  \
+	func(USB_DFU, usbdfu, na)  \
 	func(MMC, mmc, 0) \
 	func(MMC, mmc, 1) \
 	func(MMC, mmc, 2) \
@@ -109,6 +134,7 @@
 	"fdtoverlay_addr_r=" FDTOVERLAY_ADDR_R "\0" \
 	"ramdisk_addr_r=" RAMDISK_ADDR_R "\0" \
 	"fdtfile=amlogic/" CONFIG_DEFAULT_DEVICE_TREE ".dtb\0" \
+	"dfu_alt_info=fitimage ram " KERNEL_ADDR_R " 0x4000000 \0" \
 	BOOTENV
 #endif
 

-- 
2.34.1


  parent reply	other threads:[~2023-10-23 12:42 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-23 12:41 [PATCH 0/4] ARM: meson: Add boot over DFU RAM as an USB boot step Neil Armstrong
2023-10-23 12:41 ` [PATCH 1/4] ARM: meson: enable FIT with LEGACY_IMAGE_FORMAT on all configs Neil Armstrong
2023-10-23 12:41 ` [PATCH 2/4] configs: meson64: declare addr out of EXTRA_ENV_SETTINGS Neil Armstrong
2023-10-23 12:41 ` Neil Armstrong [this message]
2023-10-23 12:41 ` [PATCH 4/4] ARM: meson: enable USB DFU + RAM on Amlogic boards with USB Gadget Neil Armstrong
2023-10-24  7:05 ` [PATCH 0/4] ARM: meson: Add boot over DFU RAM as an USB boot step Mattijs Korpershoek
2023-10-26 15:39 ` Neil Armstrong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231023-usb-dfu-boot-v1-3-df9d121c67c1@linaro.org \
    --to=neil.armstrong@linaro.org \
    --cc=adeep@lexina.in \
    --cc=b.galvani@gmail.com \
    --cc=christianshewitt@gmail.com \
    --cc=u-boot-amlogic@groups.io \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.