[U-Boot] [PATCH 0/3] 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(-)

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).
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org --- include/config_distro_bootcmd.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 76e12b7bf4ee..dd47e27d6835 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -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"

Hi Takahiro,
On Fri, 12 Oct 2018 14:09:07 +0900 AKASHI Takahiro takahiro.akashi@linaro.org wrote:
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).
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org
include/config_distro_bootcmd.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 76e12b7bf4ee..dd47e27d6835 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -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;" \
"fi\0""elif " #devtypel " dev ${devnum}; then " \ "setenv devtype " #devtypel "; " \ "run scan_dev_for_boot_part; " \
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.

On Sun, Oct 14, 2018 at 02:21:11AM +0300, Tuomas Tynkkynen wrote:
Hi Takahiro,
On Fri, 12 Oct 2018 14:09:07 +0900 AKASHI Takahiro takahiro.akashi@linaro.org wrote:
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).
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org
include/config_distro_bootcmd.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 76e12b7bf4ee..dd47e27d6835 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -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;" \
"fi\0""elif " #devtypel " dev ${devnum}; then " \ "setenv devtype " #devtypel "; " \ "run scan_dev_for_boot_part; " \
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 should work.
-Takahiro Akashi

On 15.10.18 06:53, AKASHI Takahiro wrote:
On Sun, Oct 14, 2018 at 02:21:11AM +0300, Tuomas Tynkkynen wrote:
Hi Takahiro,
On Fri, 12 Oct 2018 14:09:07 +0900 AKASHI Takahiro takahiro.akashi@linaro.org wrote:
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).
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org
include/config_distro_bootcmd.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h index 76e12b7bf4ee..dd47e27d6835 100644 --- a/include/config_distro_bootcmd.h +++ b/include/config_distro_bootcmd.h @@ -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;" \
"fi\0""elif " #devtypel " dev ${devnum}; then " \ "setenv devtype " #devtypel "; " \ "run scan_dev_for_boot_part; " \
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 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

This is a preparatory patch so that USB boot will be supported in distro boot script by default.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org --- configs/qemu_arm64_defconfig | 1 + configs/qemu_arm_defconfig | 1 + 2 files changed, 2 insertions(+)
diff --git a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig index 7fd726fdda35..91c97181ab9f 100644 --- a/configs/qemu_arm64_defconfig +++ b/configs/qemu_arm64_defconfig @@ -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 diff --git a/configs/qemu_arm_defconfig b/configs/qemu_arm_defconfig index fbceaf3c52f3..4f4f9b791415 100644 --- a/configs/qemu_arm_defconfig +++ b/configs/qemu_arm_defconfig @@ -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

On 12.10.18 07:09, AKASHI Takahiro wrote:
This is a preparatory patch so that USB boot will be supported in distro boot script by default.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org
How about something like this instead?
Alex
diff --git a/Kconfig b/Kconfig index 1aadf5dd2d..8d515fe18c 100644 --- a/Kconfig +++ b/Kconfig @@ -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

On Tue, Oct 16, 2018 at 03:21:10PM +0200, Alexander Graf wrote:
On 12.10.18 07:09, AKASHI Takahiro wrote:
This is a preparatory patch so that USB boot will be supported in distro boot script by default.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org
How about something like this instead?
Looks smart.
Thanks, -Takahiro Akashi
Alex
diff --git a/Kconfig b/Kconfig index 1aadf5dd2d..8d515fe18c 100644 --- a/Kconfig +++ b/Kconfig @@ -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

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.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org --- include/configs/qemu-arm.h | 1 + 1 file changed, 1 insertion(+)
diff --git a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h index 0e66f946dde5..395cb911f5fe 100644 --- a/include/configs/qemu-arm.h +++ b/include/configs/qemu-arm.h @@ -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)

On 12.10.18 07:09, AKASHI Takahiro wrote:
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.
Signed-off-by: AKASHI Takahiro takahiro.akashi@linaro.org
Reviewed-by: Alexander Graf agraf@suse.de
Alex
participants (3)
-
AKASHI Takahiro
-
Alexander Graf
-
Tuomas Tynkkynen