Skip to contentSkip to conversation

uefi: support USB boot in distro boot

PATCH Superseded AKASHI Takahiro 3 participants 10 messages Oct 12, 2018 – Oct 18, 2018

lore
Share & tools
lore
#0 lore raw

cover uefi: support USB boot in distro boot

I think that it will be nice if we can install a distro linux from, say, USB memory with ISO image, to a hard disk off the shelf. Even with the current u-boot, we can do this by having two *scsi* disks, but using an USB device looks more realistic, doesn't it?

This patch set give us a base for this; I was able to successfully start a familiar "install" screen on qemu, using an ubuntu server ISO image for arm64. CUI of course.

Thanks,
-Takahiro Akashi

AKASHI Takahiro (3):
efi_loader: support USB boot in distro boot script
ARM: qemu-arm: enable usb mass storage in default configuration
ARM: qemu-arm: enable USB boot in distro boot with UEFI

 configs/qemu_arm64_defconfig    | 1 +
 configs/qemu_arm_defconfig      | 1 +
 include/config_distro_bootcmd.h | 7 ++++++-
 include/configs/qemu-arm.h      | 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)
Signature · 1 line
2.19.0
#1 lore raw

PATCH 1/3 efi_loader: support USB boot in distro boot script

With this patch, a removable USB mass storage device attached to the system will also be scanned to find and boot an EFI binary (that is BOOTEFI_NAME, see config_distro_bootcmd.h).

---
 include/config_distro_bootcmd.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
include/config_distro_bootcmd.h +6 -1
index 76e12b7bf4ee..dd47e27d6835 100644
@@ -26,7 +26,12 @@
  */
 
 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
-		"if " #devtypel " dev ${devnum}; then " \
+		"if test " #devtypel " = usb ; then " \
+			"if " #devtypel " info ${devnum}; then " \
+				"setenv devtype " #devtypel "; " \
+				"run scan_dev_for_boot_part; " \
+			"fi;" \
+		"elif " #devtypel " dev ${devnum}; then " \
 			"setenv devtype " #devtypel "; " \
 			"run scan_dev_for_boot_part; " \
 		"fi\0"
Signature · 1 line
2.19.0
#2 lore raw

PATCH 1/3 efi_loader: support USB boot in distro boot script

Hi Takahiro,

Quoted 17 lines · On Fri, 12 Oct 2018 14:09:07 +0900 AKASHI Takahiro…

With this patch, a removable USB mass storage device attached to the system will also be scanned to find and boot an EFI binary (that is BOOTEFI_NAME, see config_distro_bootcmd.h).

---
 include/config_distro_bootcmd.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/include/config_distro_bootcmd.h index 76e12b7bf4ee..dd47e27d6835 100644 --- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h

include/config_distro_bootcmd.h +0 -0
@@ -26,7 +26,12 @@
  */
 
 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \

include/config_distro_bootcmd.h line 37

Quoted 10 lines
include/config_distro_bootcmd.h +6 -1
-		"if " #devtypel " dev ${devnum}; then " \
+		"if test " #devtypel " = usb ; then " \
+			"if " #devtypel " info ${devnum}; then " \
+				"setenv devtype " #devtypel "; " \
+				"run scan_dev_for_boot_part; " \
+			"fi;" \
+		"elif " #devtypel " dev ${devnum}; then " \
 			"setenv devtype " #devtypel "; " \
 			"run scan_dev_for_boot_part; " \
 		"fi\0"

I can't see how this patch is needed - "usb dev" is a valid command (via do_usb() -> blk_common_cmd()) as long as CONFIG_USB_STORAGE is set.

#3 lore raw

PATCH 1/3 efi_loader: support USB boot in distro boot script

Quoted 21 lines · Tuomas Tynkkynen

Hi Takahiro,

Quoted 16 lines · On Fri, 12 Oct 2018 14:09:07 +0900 AKASHI Takahiro…

With this patch, a removable USB mass storage device attached to the system will also be scanned to find and boot an EFI binary (that is BOOTEFI_NAME, see config_distro_bootcmd.h).

---
 include/config_distro_bootcmd.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/include/config_distro_bootcmd.h index 76e12b7bf4ee..dd47e27d6835 100644 --- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h

(quoted diff) +0 -0
@@ -26,7 +26,12 @@
  */
 
Quoted 14 lines

include/config_distro_bootcmd.h line 37

Quoted 11 lines
include/config_distro_bootcmd.h +6 -1
 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
-		"if " #devtypel " dev ${devnum}; then " \
+		"if test " #devtypel " = usb ; then " \
+			"if " #devtypel " info ${devnum}; then " \
+				"setenv devtype " #devtypel "; " \
+				"run scan_dev_for_boot_part; " \
+			"fi;" \
+		"elif " #devtypel " dev ${devnum}; then " \
 			"setenv devtype " #devtypel "; " \
 			"run scan_dev_for_boot_part; " \
 		"fi\0"

I can't see how this patch is needed - "usb dev" is a valid command (via do_usb() -> blk_common_cmd()) as long as CONFIG_USB_STORAGE is set.

Right.
I didn't notice this sub-command, dev, because I first consulted "help usb" with default qemu_arm64_defconfig which doesn't have CONFIG_USB_STORAGE. Since then I've believed it was not available.

Yet my patch #2&#3 should work.

-Takahiro Akashi

#4 lore raw

PATCH 1/3 efi_loader: support USB boot in distro boot script

Quoted 37 lines · AKASHI Takahiro
Quoted 21 lines · Tuomas Tynkkynen

Hi Takahiro,

Quoted 16 lines · On Fri, 12 Oct 2018 14:09:07 +0900 AKASHI Takahiro…

With this patch, a removable USB mass storage device attached to the system will also be scanned to find and boot an EFI binary (that is BOOTEFI_NAME, see config_distro_bootcmd.h).

---
 include/config_distro_bootcmd.h | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/include/config_distro_bootcmd.h index 76e12b7bf4ee..dd47e27d6835 100644 --- a/include/config_distro_bootcmd.h
+++ b/include/config_distro_bootcmd.h

(quoted diff) +0 -0
@@ -26,7 +26,12 @@
  */
 
Quoted 14 lines

include/config_distro_bootcmd.h line 37

Quoted 11 lines
include/config_distro_bootcmd.h +6 -1
 #define BOOTENV_SHARED_BLKDEV_BODY(devtypel) \
-		"if " #devtypel " dev ${devnum}; then " \
+		"if test " #devtypel " = usb ; then " \
+			"if " #devtypel " info ${devnum}; then " \
+				"setenv devtype " #devtypel "; " \
+				"run scan_dev_for_boot_part; " \
+			"fi;" \
+		"elif " #devtypel " dev ${devnum}; then " \
 			"setenv devtype " #devtypel "; " \
 			"run scan_dev_for_boot_part; " \
 		"fi\0"

I can't see how this patch is needed - "usb dev" is a valid command (via do_usb() -> blk_common_cmd()) as long as CONFIG_USB_STORAGE is set.

Quoted 6 lines

Right.
I didn't notice this sub-command, dev, because I first consulted "help usb" with default qemu_arm64_defconfig which doesn't have CONFIG_USB_STORAGE. Since then I've believed it was not available.

Yet my patch #2&#3 should work.

Yes, distro boot already supports USB booting just fine. All you need to do is what you did in patch 3 to enable it on a particular target board.

Alex

#5 lore raw

PATCH 2/3 ARM: qemu-arm: enable usb mass storage in default configuration

In reply to AKASHI Takahiro

This is a preparatory patch so that USB boot will be supported in distro boot script by default.

---
 configs/qemu_arm64_defconfig | 1 +
 configs/qemu_arm_defconfig   | 1 +
 2 files changed, 2 insertions(+)
configs/qemu_arm64_defconfig +1 -0
index 7fd726fdda35..91c97181ab9f 100644
@@ -32,3 +32,4 @@ CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_PCI=y
+CONFIG_USB_STORAGE=y
configs/qemu_arm_defconfig +1 -0
index fbceaf3c52f3..4f4f9b791415 100644
@@ -32,3 +32,4 @@ CONFIG_USB=y
 CONFIG_DM_USB=y
 CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_EHCI_PCI=y
+CONFIG_USB_STORAGE=y
Signature · 1 line
2.19.0
#6 lore raw

PATCH 2/3 ARM: qemu-arm: enable usb mass storage in default configuration

Quoted 4 lines · AKASHI Takahiro

This is a preparatory patch so that USB boot will be supported in distro boot script by default.

How about something like this instead?

Alex

Kconfig +1 -0
index 1aadf5dd2d..8d515fe18c 100644
@@ -86,6 +86,7 @@ config DISTRO_DEFAULTS
 	select SUPPORT_RAW_INITRD
 	select SYS_LONGHELP
 	imply CMD_MII if NET
+	imply USB_STORAGE if USB
 	imply USE_BOOTCOMMAND
 	help
 	  Select this to enable various options and commands which are suitable
#7 lore raw

PATCH 2/3 ARM: qemu-arm: enable usb mass storage in default configuration

Quoted 9 lines · Alexander Graf
Quoted 4 lines · AKASHI Takahiro

This is a preparatory patch so that USB boot will be supported in distro boot script by default.

How about something like this instead?

Looks smart.

Thanks,
-Takahiro Akashi

Quoted 15 lines

Alex

Kconfig +1 -0
index 1aadf5dd2d..8d515fe18c 100644
@@ -86,6 +86,7 @@ config DISTRO_DEFAULTS
 	select SUPPORT_RAW_INITRD
 	select SYS_LONGHELP
 	imply CMD_MII if NET
+	imply USB_STORAGE if USB
 	imply USE_BOOTCOMMAND
 	help
 	  Select this to enable various options and commands which are suitable
#8 lore raw

PATCH 3/3 ARM: qemu-arm: enable USB boot in distro boot with UEFI

In reply to AKASHI Takahiro

With this patch which adds a removable USB mass storage to a list of bootable devices, USB boot is supported in distro boot if UEFI is configured.

---
 include/configs/qemu-arm.h | 1 +
 1 file changed, 1 insertion(+)
include/configs/qemu-arm.h +1 -0
index 0e66f946dde5..395cb911f5fe 100644
@@ -45,6 +45,7 @@
 #define CONFIG_ENV_SECT_SIZE		SZ_1M
 
 #define BOOT_TARGET_DEVICES(func) \
+	func(USB, usb, 0) \
 	func(SCSI, scsi, 0) \
 	func(DHCP, dhcp, na)
 
Signature · 1 line
2.19.0