Initial implementation of standard boot
Subsystems (7)
v2 cover Initial implementation of standard boot
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by
U-Boot)
- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
With this we can boot on a Raspberry Pi 3 with just one command:
bootflow scan -lb
which means to scan, listing (-l) each bootflow and trying to boot each one (-b). The final patch shows this.
With a standard way to identify boot devices, booting become easier. It also should be possible to support U-Boot scripts, for backwards compatibility only.
This series relies on the PXE clean-up series, posted here:
https://patchwork.ozlabs.org/project/uboot/list/?series=267078
For documentation, see the 'doc' patch.
For version 2, a new naming scheme is used as above:
- bootdev is used instead of bootdevice, because 'device' is overused, is everywhere in U-Boot, can be confused with udevice
- bootmeth - because 'method' is too vanilla, appears 1300 times in U-Boot
Also in version 2, drivers are introduced for the boot methods, to make it more extensible. Booting a custom OS is simply a matter of creating a bootmeth for it and implementing the read_file() and boot() methods.
The design is described in these two documents:
https://drive.google.com/file/d/1ggW0KJpUOR__vBkj3l61L2dav4ZkNC12/view?usp=sharing
https://drive.google.com/file/d/1kTrflO9vvGlKp-ZH_jlgb9TY3WYG6FF9/view?usp=sharing
The series is available at u-boot-dm/bme-working
Sample log on rpi_3_32b:
U-Boot 2021.10-rc2-00043-gccd453aa918-dirty (Aug 28 2021 - 13:58:46 -0600)
DRAM: 992 MiB
RPI 3 Model B (0xa22082)
MMC: mmc@7e202000: 0, sdhci@7e300000: 1
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... In: serial
Out: vidconsole Err: vidconsole Net: No ethernet found.
starting USB...
Bus usb@7e980000: USB DWC2
scanning bus usb@7e980000 for devices... usb_kbd usb_kbd: Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000
4 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot: 0
Scanning for bootflows in all bootmethods
Seq Type State Uclass Part Name Filename --- ----------- ------ -------- ---- ------------------------ ----------------
Scanning bootmethod '[email protected]':
0 efi-loader loaded mmc 1 [email protected] efi/boot/bootarm.efi
** Booting bootflow '[email protected]_1' Scanning disk [email protected]...
** Unrecognized filesystem type **
Card did not respond to voltage select! : -110 Scanning disk [email protected]...
Disk [email protected] not ready
Found 4 disks
No EFI system partition
Booting /efi\boot
Waiting for Ethernet connection... done.
Fedora (5.11.12-300.fc34.armv7hl) 34 (Workstation Edition) UEFI Firmware Settings
Use the ▲ and ▼ keys to change the selection.
Press 'e' to edit the selected item, or 'c' for a command prompt. Press Escape to return to the previous menu.
The selected entry will be started automatically in 0s.
Changes in v2:
- Free the memory buffer, to avoid running out of memory
- Unmap the file
- Reorder struct sandbox_mmc_priv
Simon Glass (41):
lib: Add a way to find the postiion of a trailing number
Makefile: Allow LTO to be disabled for a build test/py: Allow passing input to a program
sandbox: Support unmapping a file
sandbox: mmc: Support a backing file
mmc: Allow for children other than the block device
mbr: Correct verification check
disk: part_dos: Fix a NULL pointer error
common: Allow a smaller console-recording pre-reloc
dm: core: Add tests for stringlist functions
dm: core: Fix handling of uclass pre_unbind method
dm: core: Fix up string-function documentation
dm: core: Add a way to obtain a string list
dm: core: Allow finding children / uclasses by partial name
dm: core: Add a way to count the devices in a uclass
sandbox: Enable HEXDUMP for sandbox_flattree test/py: Relax the naming rules for unit tests test/py: Raise a ValueError if a command fails
bootstd: Add the concept of a bootflow
bootstd: Add the bootstd uclass and core implementation
bootstd: Add the bootdev uclass
bootstd: Add the bootmeth uclass and helpers
bootstd: Add support for bootflows
bootstd: Add a bootdev command
bootstd: Add a bootflow ommand
bootstd: Add a bootmeth command
bootstd: Add an implementation of distro boot
bootstd: mmc: Add a bootdev driver
bootstd: ethernet: Add a bootdev driver
bootstd: Add an implementation of distro PXE boot
bootstd: Add an implementation of EFI boot
bootstd: Add a system bootdev for strange boot methods
bootstd: Add an implementation of EFI bootmgr
bootstd: Add a sandbox bootmeth driver
bootstd: usb: Add a bootdev driver
test: fastboot: Avoid using mmc1
test: dm: Restart USB before assuming it is stopped
bootstd: Add tests for bootstd including all uclasses
bootstd: Add setup for the bootflow tests
bootstd: doc: Add documentation
RFC: Switch rpi over to use bootstd
MAINTAINERS | 21 + Makefile | 18 +- arch/arm/config.mk | 4 +- arch/arm/include/asm/global_data.h | 2 +- arch/sandbox/cpu/os.c | 10 + arch/sandbox/dts/test.dts | 19 + boot/Kconfig | 77 ++- boot/Makefile | 14 + boot/bootdev-uclass.c | 439 ++++++++++++++ boot/bootflow.c | 576 ++++++++++++++++++ boot/bootmeth-uclass.c | 59 ++ boot/bootmeth_distro.c | 217 +++++++ boot/bootmeth_efi.c | 263 ++++++++ boot/bootmeth_efi_mgr.c | 84 +++ boot/bootmeth_pxe.c | 183 ++++++ boot/bootmeth_sandbox.c | 67 +++ boot/bootstd-uclass.c | 176 ++++++ boot/system_bootdev.c | 64 ++ cmd/Kconfig | 15 + cmd/Makefile | 1 + cmd/bootdev.c | 120 ++++ cmd/bootflow.c | 386 ++++++++++++ cmd/bootmeth.c | 158 +++++ cmd/mbr.c | 8 +- common/Kconfig | 10 + common/console.c | 4 +- common/usb_storage.c | 12 + configs/amcore_defconfig | 1 + configs/rcar3_salvator-x_defconfig | 1 + configs/sandbox_defconfig | 3 +- configs/sandbox_flattree_defconfig | 4 +- configs/tbs2910_defconfig | 1 + disk/part_dos.c | 10 +- doc/build/gcc.rst | 17 + doc/develop/bootstd.rst | 600 +++++++++++++++++++ doc/develop/distro.rst | 3 + doc/develop/index.rst | 1 + doc/device-tree-bindings/bootdev.txt | 26 + doc/device-tree-bindings/bootmeth.txt | 31 + doc/device-tree-bindings/bootstd.txt | 36 ++ doc/device-tree-bindings/mmc/sandbox,mmc.txt | 18 + doc/usage/bootdev.rst | 135 +++++ doc/usage/bootflow.rst | 427 +++++++++++++ doc/usage/bootmeth.rst | 106 ++++ doc/usage/index.rst | 3 + drivers/core/device-remove.c | 9 +- drivers/core/device.c | 13 +- drivers/core/of_access.c | 3 +- drivers/core/ofnode.c | 26 + drivers/core/read.c | 6 + drivers/core/uclass.c | 29 +- drivers/mmc/Makefile | 5 + drivers/mmc/mmc-uclass.c | 27 +- drivers/mmc/mmc_bootdev.c | 62 ++ drivers/mmc/sandbox_mmc.c | 60 +- drivers/usb/host/Makefile | 4 + drivers/usb/host/usb_bootdev.c | 61 ++ include/bootdev.h | 258 ++++++++ include/bootflow.h | 304 ++++++++++ include/bootmeth.h | 156 +++++ include/bootstd.h | 80 +++ include/configs/rpi.h | 41 +- include/distro.h | 24 + include/dm/device.h | 12 + include/dm/ofnode.h | 24 +- include/dm/read.h | 28 + include/dm/uclass-id.h | 3 + include/dm/uclass-internal.h | 14 +- include/dm/uclass.h | 17 + include/mmc.h | 12 +- include/os.h | 9 + include/test/suites.h | 2 + include/vsprintf.h | 18 + lib/strto.c | 14 +- net/Kconfig | 9 + net/Makefile | 1 + net/eth-uclass.c | 8 + net/eth_bootdev.c | 101 ++++ test/Makefile | 1 + test/boot/Makefile | 5 + test/boot/bootdev.c | 200 +++++++ test/boot/bootflow.c | 398 ++++++++++++ test/boot/bootmeth.c | 90 +++ test/boot/bootstd_common.c | 35 ++ test/boot/bootstd_common.h | 27 + test/cmd_ut.c | 7 + test/dm/blk.c | 6 + test/dm/fastboot.c | 4 +- test/dm/ofnode.c | 96 +++ test/py/conftest.py | 2 +- test/py/multiplexed_log.py | 10 +- test/py/tests/bootstd/mmc1.img.xz | Bin 0 -> 4448 bytes test/py/tests/test_ut.py | 103 ++++ test/py/u_boot_utils.py | 5 +- 94 files changed, 6765 insertions(+), 94 deletions(-) create mode 100644 boot/bootdev-uclass.c create mode 100644 boot/bootflow.c create mode 100644 boot/bootmeth-uclass.c create mode 100644 boot/bootmeth_distro.c create mode 100644 boot/bootmeth_efi.c create mode 100644 boot/bootmeth_efi_mgr.c create mode 100644 boot/bootmeth_pxe.c create mode 100644 boot/bootmeth_sandbox.c create mode 100644 boot/bootstd-uclass.c create mode 100644 boot/system_bootdev.c create mode 100644 cmd/bootdev.c create mode 100644 cmd/bootflow.c create mode 100644 cmd/bootmeth.c create mode 100644 doc/develop/bootstd.rst create mode 100644 doc/device-tree-bindings/bootdev.txt create mode 100644 doc/device-tree-bindings/bootmeth.txt create mode 100644 doc/device-tree-bindings/bootstd.txt create mode 100644 doc/device-tree-bindings/mmc/sandbox,mmc.txt create mode 100644 doc/usage/bootdev.rst create mode 100644 doc/usage/bootflow.rst create mode 100644 doc/usage/bootmeth.rst create mode 100644 drivers/mmc/mmc_bootdev.c create mode 100644 drivers/usb/host/usb_bootdev.c create mode 100644 include/bootdev.h create mode 100644 include/bootflow.h create mode 100644 include/bootmeth.h create mode 100644 include/bootstd.h create mode 100644 include/distro.h create mode 100644 net/eth_bootdev.c create mode 100644 test/boot/Makefile create mode 100644 test/boot/bootdev.c create mode 100644 test/boot/bootflow.c create mode 100644 test/boot/bootmeth.c create mode 100644 test/boot/bootstd_common.c create mode 100644 test/boot/bootstd_common.h create mode 100644 test/py/tests/bootstd/mmc1.img.xz
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 1/41 lib: Add a way to find the postiion of a trailing number
At present it is not possible to find out which part of the string is the number part and which is before it. Add a new variant which provides this feature, so we can separate the two in the caller.
---
(no changes since v1)
include/vsprintf.h | 18 ++++++++++++++++++ lib/strto.c | 14 ++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-)
include/vsprintf.h +18 -0
@@ -118,6 +118,24 @@ long trailing_strtol(const char *str);*/ long trailing_strtoln (const char *str,const char *end); +/** +* trailing_strtoln() - extract a trailing integer from a fixed-length string +* +* Given a fixed-length string this finds a trailing number on the string +* and returns it. For example, "abc123" would return 123. Only the +* characters between @str and @end - 1 are examined. If @end is NULL, it is +* set to str + strlen(str). +* +* @str: String to exxamine +* @end: Pointer to end of string to examine, or NULL to use the +* whole string +* @lenp: If non-NULL, this is set to the number of characters before the +* number starts, e.g. for "mmc0" this would be 3; if no trailing number is +* found, it is set to the length of the whole string +* @return training number if found, else -1 +*/ +long trailing_strtoln_len (const char *str,const char *end,int *lenp); +/** * panic() - Print a message and reset/hang *
lib/strto.c +12 -2
@@ -183,7 +183,7 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base)return simple_strtoull (cp, endp, base); } -long trailing_strtoln (const char *str,const char *end) +long trailing_strtoln_len (const char *str,const char *end,int *lenp) {const char *p;
@@ -191,14 +191,24 @@ long trailing_strtoln(const char *str, const char *end) end = str +strlen (str);if (isdigit (end[-1 ])) {for (p = end -1 ; p > str; p--) { -if (!isdigit (*p)) +if (!isdigit (*p)) { +if (lenp) + *lenp = p - str +1 ;return dectoul (p +1 ,NULL ); + } } } +if (lenp) + *lenp = end - str;return -1 ; } +long trailing_strtoln (const char *str,const char *end) +{ +return trailing_strtoln_len (str, end,NULL ); +} +long trailing_strtol (const char *str) {return trailing_strtoln (str,NULL );
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 01/41] lib: Add a way to find the postiion of a trailing number
Quoted 18 lines · Simon Glass
At present it is not possible to find out which part of the string is the number part and which is before it. Add a new variant which provides this feature, so we can separate the two in the caller.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
include/vsprintf.h | 18 ++++++++++++++++++ lib/strto.c | 14 ++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-)include/vsprintf.h +0
-0
include/vsprintf.h long trailing_strtol(const char *str); · line 127
Quoted 10 lines
include/vsprintf.h +7
-0@@ -118,6 +118,24 @@ long trailing_strtol(const char *str);*/ long trailing_strtoln (const char *str,const char *end); +/** +* trailing_strtoln() - extract a trailing integer from a fixed-length string +* +* Given a fixed-length string this finds a trailing number on the string +* and returns it. For example, "abc123" would return 123. Only the +* characters between @str and @end - 1 are examined. If @end is NULL, it is +* set to str + strlen(str).
Please, provide a test with as string like 'abc123def456'.
include/vsprintf.h long trailing_strtol(const char *str); · line 137
Quoted 10 lines
include/vsprintf.h +10
-0+* +* @str: String to exxamine +* @end: Pointer to end of string to examine, or NULL to use the +* whole string +* @lenp: If non-NULL, this is set to the number of characters before the +* number starts, e.g. for "mmc0" this would be 3; if no trailing number is +* found, it is set to the length of the whole string +* @return training number if found, else -1 +*/ +long trailing_strtoln_len (const char *str,const char *end,int *lenp);
Usage in a caller would be easier if you would return a pointer to the first digit instead of a length.
Best regards
Heinrich
Quoted 44 lines
include/vsprintf.h +1
-0+/** * panic() - Print a message and reset/hang * lib/strto.c +12
-2@@ -183,7 +183,7 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base)return simple_strtoull (cp, endp, base); } -long trailing_strtoln (const char *str,const char *end) +long trailing_strtoln_len (const char *str,const char *end,int *lenp) {const char *p;@@ -191,14 +191,24 @@ long trailing_strtoln(const char *str, const char *end) end = str +strlen (str);if (isdigit (end[-1 ])) {for (p = end -1 ; p > str; p--) { -if (!isdigit (*p)) +if (!isdigit (*p)) { +if (lenp) + *lenp = p - str +1 ;return dectoul (p +1 ,NULL ); + } } } +if (lenp) + *lenp = end - str;return -1 ; } +long trailing_strtoln (const char *str,const char *end) +{ +return trailing_strtoln_len (str, end,NULL ); +} +long trailing_strtol (const char *str) {return trailing_strtoln (str,NULL );
PATCH v2 2/41 Makefile: Allow LTO to be disabled for a build
In reply to Simon GlassLTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)
Makefile +13 -5
@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS := +# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= y + ifeq ($(cc-name),clang) ifneq ($(CROSS_COMPILE),) CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))
@@ -641,6 +644,11 @@ export CFLAGS_EFI # Compiler flags to add when building EFI app export CFLAGS_NON_EFI # Compiler flags to remove when building EFI app export EFI_TARGET # binutils target if EFI is natively supported +export LTO_ENABLE + +# This is y if LTO is enabled for this build +LTO_ENABLE=$(if $(CONFIG_LTO),$(LTO_BUILD),) + # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use # that (or fail if absent). Otherwise, search for a linker script in a # standard location.
@@ -688,16 +696,16 @@ endif LTO_CFLAGS := LTO_FINAL_LDFLAGS := export LTO_CFLAGS LTO_FINAL_LDFLAGS -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) ifeq ($(cc-name),clang) - LTO_CFLAGS += -flto + LTO_CFLAGS += -DLTO_ENABLE -flto LTO_FINAL_LDFLAGS += -flto AR = $(shell $(CC) -print-prog-name=llvm-ar) NM = $(shell $(CC) -print-prog-name=llvm-nm) else NPROC := $(shell nproc 2>/dev/null || echo 1) - LTO_CFLAGS += -flto=$(NPROC) + LTO_CFLAGS += -DLTO_ENABLE -flto=$(NPROC) LTO_FINAL_LDFLAGS += -fuse-linker-plugin -flto=$(NPROC) # use plugin aware tools
@@ -1717,7 +1725,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink) # Generate linker list symbols references to force compiler to not optimize # them away when compiling with LTO -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) u-boot-keep-syms-lto := keep-syms-lto.o u-boot-keep-syms-lto_c := $(patsubst %.o,%.c,$(u-boot-keep-syms-lto))
@@ -1739,7 +1747,7 @@ endif # Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) quiet_cmd_u-boot__ ?= LTO $@ cmd_u-boot__ ?= \ $(CC) -nostdlib -nostartfiles \
arch/arm/config.mk +2 -2
@@ -15,11 +15,11 @@ CFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections \ -fstack-protector-strong CFLAGS_EFI := -fpic -fshort-wchar -ifneq ($(CONFIG_LTO)$(CONFIG_USE_PRIVATE_LIBGCC),yy) +ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy) LDFLAGS_FINAL += --gc-sections endif -ifndef CONFIG_LTO +ifneq ($(LTO_ENABLE),y) PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections endif
arch/arm/include/asm/global_data.h +1 -1
@@ -98,7 +98,7 @@ struct arch_global_data {#include <asm-generic/global_data.h> -#if defined(__clang__) || defined(CONFIG_LTO ) +#if defined(__clang__) || defined(LTO_ENABLE )#define DECLARE_GLOBAL_DATA_PTR #define gd get_gd()
doc/build/gcc.rst +17 -0
@@ -141,6 +141,23 @@ of dtc is new enough. It also makes sure that pylibfdt is present, if needed Note that the :doc:`tools` are always built with the included version of libfdt so it is not possible to build U-Boot tools with a system libfdt, at present. +Link-time optimisation (LTO) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +U-Boot supports link-time optimisation which can reduce the size of the final +U-Boot binaries, particularly with SPL. + +At present this can be enabled by ARM boards by adding `CONFIG_LTO=y` into the +defconfig file. Other architectures are not supported. LTO is enabled by default +for sandbox. + +This does incur a link-time penalty of several seconds. For faster incremental +builds during development, you can disable it by setting `LTO_BUILD` to `n`. + +.. code-block:: bash + + LTO_BUILD=n make + Other build targets ~~~~~~~~~~~~~~~~~~~
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
Hi Simon
How does this patch related to the standard boot series? Shouldn't this be a completely separate patch?
Thanks
/Ilias
Quoted 151 lines · Simon Glass
LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)Makefile +13
-5@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS := +# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= y + ifeq ($(cc-name),clang) ifneq ($(CROSS_COMPILE),) CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))@@ -641,6 +644,11 @@ export CFLAGS_EFI # Compiler flags to add when building EFI app export CFLAGS_NON_EFI # Compiler flags to remove when building EFI app export EFI_TARGET # binutils target if EFI is natively supported +export LTO_ENABLE + +# This is y if LTO is enabled for this build +LTO_ENABLE=$(if $(CONFIG_LTO),$(LTO_BUILD),) + # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use # that (or fail if absent). Otherwise, search for a linker script in a # standard location.@@ -688,16 +696,16 @@ endif LTO_CFLAGS := LTO_FINAL_LDFLAGS := export LTO_CFLAGS LTO_FINAL_LDFLAGS -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) ifeq ($(cc-name),clang) - LTO_CFLAGS += -flto + LTO_CFLAGS += -DLTO_ENABLE -flto LTO_FINAL_LDFLAGS += -flto AR = $(shell $(CC) -print-prog-name=llvm-ar) NM = $(shell $(CC) -print-prog-name=llvm-nm) else NPROC := $(shell nproc 2>/dev/null || echo 1) - LTO_CFLAGS += -flto=$(NPROC) + LTO_CFLAGS += -DLTO_ENABLE -flto=$(NPROC) LTO_FINAL_LDFLAGS += -fuse-linker-plugin -flto=$(NPROC) # use plugin aware tools@@ -1717,7 +1725,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink) # Generate linker list symbols references to force compiler to not optimize # them away when compiling with LTO -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) u-boot-keep-syms-lto := keep-syms-lto.o u-boot-keep-syms-lto_c := $(patsubst %.o,%.c,$(u-boot-keep-syms-lto))@@ -1739,7 +1747,7 @@ endif # Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) quiet_cmd_u-boot__ ?= LTO $@ cmd_u-boot__ ?= \ $(CC) -nostdlib -nostartfiles \arch/arm/config.mk +2
-2@@ -15,11 +15,11 @@ CFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections \ -fstack-protector-strong CFLAGS_EFI := -fpic -fshort-wchar -ifneq ($(CONFIG_LTO)$(CONFIG_USE_PRIVATE_LIBGCC),yy) +ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy) LDFLAGS_FINAL += --gc-sections endif -ifndef CONFIG_LTO +ifneq ($(LTO_ENABLE),y) PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections endifarch/arm/include/asm/global_data.h +1
-1@@ -98,7 +98,7 @@ struct arch_global_data {#include <asm-generic/global_data.h> -#if defined(__clang__) || defined(CONFIG_LTO ) +#if defined(__clang__) || defined(LTO_ENABLE )#define DECLARE_GLOBAL_DATA_PTR #define gd get_gd()doc/build/gcc.rst +17
-1@@ -141,6 +141,23 @@ of dtc is new enough. It also makes sure that pylibfdt is present, if needed Note that the :doc:`tools` are always built with the included version of libfdt so it is not possible to build U-Boot tools with a system libfdt, at present. +Link-time optimisation (LTO) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +U-Boot supports link-time optimisation which can reduce the size of the final +U-Boot binaries, particularly with SPL. + +At present this can be enabled by ARM boards by adding `CONFIG_LTO=y` into the +defconfig file. Other architectures are not supported. LTO is enabled by default +for sandbox. + +This does incur a link-time penalty of several seconds. For faster incremental +builds during development, you can disable it by setting `LTO_BUILD` to `n`. + +.. code-block:: bash + + LTO_BUILD=n make + Other build targets ~~~~~~~~~~~~~~~~~~~ --2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
Quoted 42 lines · Ilias Apalodimas
Hi Simon
How does this patch related to the standard boot series? Shouldn't this be a completely separate patch?
Thanks
/IliasQuoted 33 lines · Simon Glass
LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)Makefile +0
-0@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS :=
Quoted 2 lines
Makefile KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing · line 438
Quoted 2 lines
Makefile +2
-0+# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= y
This does not allow LTO_BUILD=y to enable LTO for CONFIG_LTO=n.
We should have something like
LTO_CONFIG ?= $CONFIG_LTO
Best regards
Heinrich
Quoted 116 lines
Quoted 116 lines
Makefile +11
-5+ ifeq ($(cc-name),clang) ifneq ($(CROSS_COMPILE),) CLANG_TARGET := --target=$(notdir $(CROSS_COMPILE:%-=%))@@ -641,6 +644,11 @@ export CFLAGS_EFI # Compiler flags to add when building EFI app export CFLAGS_NON_EFI # Compiler flags to remove when building EFI app export EFI_TARGET # binutils target if EFI is natively supported +export LTO_ENABLE + +# This is y if LTO is enabled for this build +LTO_ENABLE=$(if $(CONFIG_LTO),$(LTO_BUILD),) + # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use # that (or fail if absent). Otherwise, search for a linker script in a # standard location.@@ -688,16 +696,16 @@ endif LTO_CFLAGS := LTO_FINAL_LDFLAGS := export LTO_CFLAGS LTO_FINAL_LDFLAGS -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) ifeq ($(cc-name),clang) - LTO_CFLAGS += -flto + LTO_CFLAGS += -DLTO_ENABLE -flto LTO_FINAL_LDFLAGS += -flto AR = $(shell $(CC) -print-prog-name=llvm-ar) NM = $(shell $(CC) -print-prog-name=llvm-nm) else NPROC := $(shell nproc 2>/dev/null || echo 1) - LTO_CFLAGS += -flto=$(NPROC) + LTO_CFLAGS += -DLTO_ENABLE -flto=$(NPROC) LTO_FINAL_LDFLAGS += -fuse-linker-plugin -flto=$(NPROC) # use plugin aware tools@@ -1717,7 +1725,7 @@ ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink) # Generate linker list symbols references to force compiler to not optimize # them away when compiling with LTO -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) u-boot-keep-syms-lto := keep-syms-lto.o u-boot-keep-syms-lto_c := $(patsubst %.o,%.c,$(u-boot-keep-syms-lto))@@ -1739,7 +1747,7 @@ endif # Rule to link u-boot # May be overridden by arch/$(ARCH)/config.mk -ifdef CONFIG_LTO +ifeq ($(LTO_ENABLE),y) quiet_cmd_u-boot__ ?= LTO $@ cmd_u-boot__ ?= \ $(CC) -nostdlib -nostartfiles \arch/arm/config.mk +2
-2@@ -15,11 +15,11 @@ CFLAGS_NON_EFI := -fno-pic -ffixed-r9 -ffunction-sections -fdata-sections \ -fstack-protector-strong CFLAGS_EFI := -fpic -fshort-wchar -ifneq ($(CONFIG_LTO)$(CONFIG_USE_PRIVATE_LIBGCC),yy) +ifneq ($(LTO_ENABLE)$(CONFIG_USE_PRIVATE_LIBGCC),yy) LDFLAGS_FINAL += --gc-sections endif -ifndef CONFIG_LTO +ifneq ($(LTO_ENABLE),y) PLATFORM_RELFLAGS += -ffunction-sections -fdata-sections endifarch/arm/include/asm/global_data.h +1
-1@@ -98,7 +98,7 @@ struct arch_global_data {#include <asm-generic/global_data.h> -#if defined(__clang__) || defined(CONFIG_LTO ) +#if defined(__clang__) || defined(LTO_ENABLE )#define DECLARE_GLOBAL_DATA_PTR #define gd get_gd()doc/build/gcc.rst +17
-1@@ -141,6 +141,23 @@ of dtc is new enough. It also makes sure that pylibfdt is present, if needed Note that the :doc:`tools` are always built with the included version of libfdt so it is not possible to build U-Boot tools with a system libfdt, at present. +Link-time optimisation (LTO) +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +U-Boot supports link-time optimisation which can reduce the size of the final +U-Boot binaries, particularly with SPL. + +At present this can be enabled by ARM boards by adding `CONFIG_LTO=y` into the +defconfig file. Other architectures are not supported. LTO is enabled by default +for sandbox. + +This does incur a link-time penalty of several seconds. For faster incremental +builds during development, you can disable it by setting `LTO_BUILD` to `n`. + +.. code-block:: bash + + LTO_BUILD=n make + Other build targets ~~~~~~~~~~~~~~~~~~~ --2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
Quoted 45 lines · Heinrich Schuchardt
Quoted 42 lines · Ilias Apalodimas
Hi Simon
How does this patch related to the standard boot series? Shouldn't this be a completely separate patch?
Thanks
/IliasQuoted 33 lines · Simon Glass
LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)Makefile +0
-0@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS :=
Quoted 4 lines
Quoted 2 lines
Makefile KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing · line 438
Quoted 2 lines
Makefile +2
-0+# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= yThis does not allow LTO_BUILD=y to enable LTO for
CONFIG_LTO=n.
I don't understand why we need this patch at all. If you want to disable LTO, disable LTO. Yes, LTO makes linking take longer which can be annoying on iterative development. I have a few different "HACK: DO NOT PUSH: ..." things I git am at the start of a branch, depending on needs. You can just do that to drop "imply LTO" from the SANDBOX stanza in arch/Kconfig. We do not need a whole thing around a CONFIG option that can be disabled in the defconfig, or local .config file even.
Signature · 1 line
Tom
Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
Hi Tom,
Quoted 52 lines · Tom Rini
Quoted 45 lines · Heinrich Schuchardt
Quoted 42 lines · Ilias Apalodimas
Hi Simon
How does this patch related to the standard boot series? Shouldn't this be a completely separate patch?
Thanks
/IliasQuoted 33 lines · Simon Glass
LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)Makefile +0
-0@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS :=Quoted 4 lines
Quoted 2 lines
Makefile KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing · line 438
Quoted 2 lines
Makefile +2
-0+# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= yThis does not allow LTO_BUILD=y to enable LTO for
CONFIG_LTO=n.
Quoted 8 lines
I don't understand why we need this patch at all. If you want to disable LTO, disable LTO. Yes, LTO makes linking take longer which can be annoying on iterative development. I have a few different "HACK: DO NOT PUSH: ..." things I git am at the start of a branch, depending on needs. You can just do that to drop "imply LTO" from the SANDBOX stanza in
arch/Kconfig. We do not need a whole thing around a CONFIG option that can be disabled in the defconfig, or local .config file even.
Cranky time.
Of course we don't *need* it. I could just buy a slower build machine and type with two fingers. There are lots of ways to slow things down and LTO is one of them. I change branches at least a dozen times a day and am always trying things out from patchwork. I am sure others do too. LTO dramatically slows down builds. Having a way to easily do this from the build system saves time.
Regards,
Simon
Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
Quoted 64 lines · Simon Glass
Hi Tom,
Quoted 52 lines · Tom Rini
Quoted 45 lines · Heinrich Schuchardt
Quoted 42 lines · Ilias Apalodimas
Hi Simon
How does this patch related to the standard boot series? Shouldn't this be a completely separate patch?
Thanks
/IliasQuoted 33 lines · Simon Glass
LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)Makefile +0
-0@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS :=Quoted 4 lines
Quoted 2 lines
Makefile KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing · line 438
Quoted 2 lines
Makefile +2
-0+# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= yThis does not allow LTO_BUILD=y to enable LTO for
CONFIG_LTO=n.Quoted 8 lines
I don't understand why we need this patch at all. If you want to disable LTO, disable LTO. Yes, LTO makes linking take longer which can be annoying on iterative development. I have a few different "HACK: DO NOT PUSH: ..." things I git am at the start of a branch, depending on needs. You can just do that to drop "imply LTO" from the SANDBOX stanza in
arch/Kconfig. We do not need a whole thing around a CONFIG option that can be disabled in the defconfig, or local .config file even.
Quoted 8 lines
Cranky time.
Of course we don't *need* it. I could just buy a slower build machine and type with two fingers. There are lots of ways to slow things down and LTO is one of them. I change branches at least a dozen times a day and am always trying things out from patchwork. I am sure others do too. LTO dramatically slows down builds. Having a way to easily do this from the build system saves time.
Maybe the answer is that LTO just isn't appropriate for sandbox. We're not doing any specific tests for LTO anywhere (nor does that seem appropriate), and we do have platforms in CI that run tests other than building, with LTO.
Signature · 1 line
Tom
Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
Hi Tom,
Quoted 75 lines · Tom Rini
Quoted 64 lines · Simon Glass
Hi Tom,
Quoted 52 lines · Tom Rini
Quoted 45 lines · Heinrich Schuchardt
Quoted 42 lines · Ilias Apalodimas
Hi Simon
How does this patch related to the standard boot series? Shouldn't this be a completely separate patch?
Thanks
/IliasQuoted 33 lines · Simon Glass
LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)Makefile +0
-0@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS :=Quoted 4 lines
Quoted 2 lines
Makefile KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing · line 438
Quoted 2 lines
Makefile +2
-0+# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= yThis does not allow LTO_BUILD=y to enable LTO for
CONFIG_LTO=n.Quoted 8 lines
I don't understand why we need this patch at all. If you want to disable LTO, disable LTO. Yes, LTO makes linking take longer which can be annoying on iterative development. I have a few different "HACK: DO NOT PUSH: ..." things I git am at the start of a branch, depending on needs. You can just do that to drop "imply LTO" from the SANDBOX stanza in
arch/Kconfig. We do not need a whole thing around a CONFIG option that can be disabled in the defconfig, or local .config file even.Quoted 8 lines
Cranky time.
Of course we don't *need* it. I could just buy a slower build machine and type with two fingers. There are lots of ways to slow things down and LTO is one of them. I change branches at least a dozen times a day and am always trying things out from patchwork. I am sure others do too. LTO dramatically slows down builds. Having a way to easily do this from the build system saves time.
Quoted 4 lines
Maybe the answer is that LTO just isn't appropriate for sandbox. We're not doing any specific tests for LTO anywhere (nor does that seem appropriate), and we do have platforms in CI that run tests other than building, with LTO.
It has value as a test, I presume, and a demo of how it works. Also it runs most of the tests.
But I'm happy to disable it if that helps.
Still, it doesn't really solve the issue. The same thing happens when building real boards.
Regards,
Simon
Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
Quoted 83 lines · Simon Glass
Hi Tom,
Quoted 75 lines · Tom Rini
Quoted 64 lines · Simon Glass
Hi Tom,
Quoted 52 lines · Tom Rini
Quoted 45 lines · Heinrich Schuchardt
Quoted 42 lines · Ilias Apalodimas
Hi Simon
How does this patch related to the standard boot series? Shouldn't this be a completely separate patch?
Thanks
/IliasQuoted 33 lines · Simon Glass
LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)Makefile +0
-0@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS :=Quoted 4 lines
Quoted 2 lines
Makefile KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing · line 438
Quoted 2 lines
Makefile +2
-0+# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= yThis does not allow LTO_BUILD=y to enable LTO for
CONFIG_LTO=n.Quoted 8 lines
I don't understand why we need this patch at all. If you want to disable LTO, disable LTO. Yes, LTO makes linking take longer which can be annoying on iterative development. I have a few different "HACK: DO NOT PUSH: ..." things I git am at the start of a branch, depending on needs. You can just do that to drop "imply LTO" from the SANDBOX stanza in
arch/Kconfig. We do not need a whole thing around a CONFIG option that can be disabled in the defconfig, or local .config file even.Quoted 8 lines
Cranky time.
Of course we don't *need* it. I could just buy a slower build machine and type with two fingers. There are lots of ways to slow things down and LTO is one of them. I change branches at least a dozen times a day and am always trying things out from patchwork. I am sure others do too. LTO dramatically slows down builds. Having a way to easily do this from the build system saves time.
Quoted 4 lines
Maybe the answer is that LTO just isn't appropriate for sandbox. We're not doing any specific tests for LTO anywhere (nor does that seem appropriate), and we do have platforms in CI that run tests other than building, with LTO.
Quoted 7 lines
It has value as a test, I presume, and a demo of how it works. Also it runs most of the tests.
But I'm happy to disable it if that helps.
Still, it doesn't really solve the issue. The same thing happens when building real boards.
Well, a big part of the problem here is I strongly disagree with a make-line flag to override a CONFIG option. I also hear your use case of "I build this platform so frequently per development session it's a noticeable slowdown and a 'LOCAL:' commit will also screw up my workflow". So where do we go? LTO is a size versus speed trade-off (and -ffunction-sections/-fdata-sections/--gc-unused is a much smaller speed trade-off) that's more important on real hardware (and also not used as often as it might be, at least so far). On real boards, there's less of a "just turn it off" option because it's required to be small enough to use on the hardware. Since that's not the case on sandbox, maybe we just need to turn it on in more QEMU platforms (to get broader test coverage in CI) and off in sandbox.
Signature · 1 line
Tom
Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
Hi Tom,
Quoted 93 lines · Tom Rini
Quoted 83 lines · Simon Glass
Hi Tom,
Quoted 75 lines · Tom Rini
Quoted 64 lines · Simon Glass
Hi Tom,
Quoted 52 lines · Tom Rini
Quoted 45 lines · Heinrich Schuchardt
Quoted 42 lines · Ilias Apalodimas
Hi Simon
How does this patch related to the standard boot series? Shouldn't this be a completely separate patch?
Thanks
/IliasQuoted 33 lines · Simon Glass
LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)Makefile +0
-0@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS :=Quoted 4 lines
Quoted 2 lines
Makefile KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing · line 438
Quoted 2 lines
Makefile +2
-0+# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= yThis does not allow LTO_BUILD=y to enable LTO for
CONFIG_LTO=n.Quoted 8 lines
I don't understand why we need this patch at all. If you want to disable LTO, disable LTO. Yes, LTO makes linking take longer which can be annoying on iterative development. I have a few different "HACK: DO NOT PUSH: ..." things I git am at the start of a branch, depending on needs. You can just do that to drop "imply LTO" from the SANDBOX stanza in
arch/Kconfig. We do not need a whole thing around a CONFIG option that can be disabled in the defconfig, or local .config file even.Quoted 8 lines
Cranky time.
Of course we don't *need* it. I could just buy a slower build machine and type with two fingers. There are lots of ways to slow things down and LTO is one of them. I change branches at least a dozen times a day and am always trying things out from patchwork. I am sure others do too. LTO dramatically slows down builds. Having a way to easily do this from the build system saves time.
Quoted 4 lines
Maybe the answer is that LTO just isn't appropriate for sandbox. We're not doing any specific tests for LTO anywhere (nor does that seem appropriate), and we do have platforms in CI that run tests other than building, with LTO.
Quoted 7 lines
It has value as a test, I presume, and a demo of how it works. Also it runs most of the tests.
But I'm happy to disable it if that helps.
Still, it doesn't really solve the issue. The same thing happens when building real boards.
Quoted 12 lines
Well, a big part of the problem here is I strongly disagree with a make-line flag to override a CONFIG option. I also hear your use case of "I build this platform so frequently per development session it's a noticeable slowdown and a 'LOCAL:' commit will also screw up my workflow". So where do we go? LTO is a size versus speed trade-off (and -ffunction-sections/-fdata-sections/--gc-unused is a much smaller speed trade-off) that's more important on real hardware (and also not used as often as it might be, at least so far). On real boards, there's less of a "just turn it off" option because it's required to be small enough to use on the hardware. Since that's not the case on sandbox, maybe we just need to turn it on in more QEMU platforms (to get broader test coverage in CI) and off in sandbox.
This is all true...and certainly sandbox would solve the main issue I have. If we turn it off for sandbox we should perhaps have CI turn it on...
It is similar to the dtc thing, where we have a DTC variable to avoid pointlessly building dtc. I guess you are worried about having too many of these sorts of things?
Regards,
SImon
Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
Quoted 109 lines · Simon Glass
Hi Tom,
Quoted 93 lines · Tom Rini
Quoted 83 lines · Simon Glass
Hi Tom,
Quoted 75 lines · Tom Rini
Quoted 64 lines · Simon Glass
Hi Tom,
Quoted 52 lines · Tom Rini
Quoted 45 lines · Heinrich Schuchardt
Quoted 42 lines · Ilias Apalodimas
Hi Simon
How does this patch related to the standard boot series? Shouldn't this be a completely separate patch?
Thanks
/IliasQuoted 33 lines · Simon Glass
LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)Makefile +0
-0@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS :=Quoted 4 lines
Quoted 2 lines
Makefile KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing · line 438
Quoted 2 lines
Makefile +2
-0+# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= yThis does not allow LTO_BUILD=y to enable LTO for
CONFIG_LTO=n.Quoted 8 lines
I don't understand why we need this patch at all. If you want to disable LTO, disable LTO. Yes, LTO makes linking take longer which can be annoying on iterative development. I have a few different "HACK: DO NOT PUSH: ..." things I git am at the start of a branch, depending on needs. You can just do that to drop "imply LTO" from the SANDBOX stanza in
arch/Kconfig. We do not need a whole thing around a CONFIG option that can be disabled in the defconfig, or local .config file even.Quoted 8 lines
Cranky time.
Of course we don't *need* it. I could just buy a slower build machine and type with two fingers. There are lots of ways to slow things down and LTO is one of them. I change branches at least a dozen times a day and am always trying things out from patchwork. I am sure others do too. LTO dramatically slows down builds. Having a way to easily do this from the build system saves time.
Quoted 4 lines
Maybe the answer is that LTO just isn't appropriate for sandbox. We're not doing any specific tests for LTO anywhere (nor does that seem appropriate), and we do have platforms in CI that run tests other than building, with LTO.
Quoted 7 lines
It has value as a test, I presume, and a demo of how it works. Also it runs most of the tests.
But I'm happy to disable it if that helps.
Still, it doesn't really solve the issue. The same thing happens when building real boards.
Quoted 12 lines
Well, a big part of the problem here is I strongly disagree with a make-line flag to override a CONFIG option. I also hear your use case of "I build this platform so frequently per development session it's a noticeable slowdown and a 'LOCAL:' commit will also screw up my workflow". So where do we go? LTO is a size versus speed trade-off (and -ffunction-sections/-fdata-sections/--gc-unused is a much smaller speed trade-off) that's more important on real hardware (and also not used as often as it might be, at least so far). On real boards, there's less of a "just turn it off" option because it's required to be small enough to use on the hardware. Since that's not the case on sandbox, maybe we just need to turn it on in more QEMU platforms (to get broader test coverage in CI) and off in sandbox.
Quoted 7 lines
This is all true...and certainly sandbox would solve the main issue I have. If we turn it off for sandbox we should perhaps have CI turn it on...
It is similar to the dtc thing, where we have a DTC variable to avoid pointlessly building dtc. I guess you are worried about having too many of these sorts of things?
Well, the DTC thing to me is at least a case of "external tool exists, stop building it when it's already provided, versioning tools like this is bad". LTO is a thing that impact the build itself and can (so long as it fits in hardware still) be enabled/disabled by the user.
Signature · 1 line
Tom
Re: [PATCH v2 02/41] Makefile: Allow LTO to be disabled for a build
In reply to Heinrich SchuchardtHi Heinrich,
Quoted 8 lines · Heinrich Schuchardt
Quoted 4 lines · Ilias Apalodimas
Hi Simon
How does this patch related to the standard boot series? Shouldn't this be a completely separate patch?
Probably, but I lose track of all the branches in progress, particularly when things sit for a while.
Quoted 38 lines
Quoted 38 lines
Thanks
/IliasQuoted 33 lines · Simon Glass
LTO (Link-Time Optimisation) is an very useful feature which can significantly reduce the size of U-Boot binaries. So far it has been made available for selected ARM boards and sandbox.
However, incremental builds are much slower when LTO is used. For example, an incremental build of sandbox takes 2.1 seconds on my machine, but 6.7 seconds with LTO enabled.
Add a LTO_BUILD=n parameter to the build, so it can be disabled during development if needed, for faster builds.
Add some documentation about LTO while we are here.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Makefile | 18 +++++++++++++----- arch/arm/config.mk | 4 ++-- arch/arm/include/asm/global_data.h | 2 +- doc/build/gcc.rst | 17 +++++++++++++++++ 4 files changed, 33 insertions(+), 8 deletions(-)Makefile +0
-0@@ -434,6 +434,9 @@ KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing KBUILD_AFLAGS := -D__ASSEMBLY__ KBUILD_LDFLAGS :=
Quoted 8 lines
Quoted 2 lines
Makefile KBUILD_CFLAGS += -fshort-wchar -fno-strict-aliasing · line 438
Quoted 2 lines
Makefile +2
-0+# Set this to "n" use of LTO for this build, e.g. LTO_BUILD=n +LTO_BUILD ?= yThis does not allow LTO_BUILD=y to enable LTO for
CONFIG_LTO=n.We should have something like
LTO_CONFIG?= $CONFIG_LTO
The CONFIG indicates that LTO is supported, so if we want to do that, we could fix the problems with LTO for a board/arch and send a patch to enable it. I think we want it enabled by default.
[..]
Regards
Simon
PATCH v2 3/41 test/py: Allow passing input to a program
In reply to Simon GlassWhen running a program on the host, allow input to be passed in as stdin. This is needed for running sfdisk, for example.
---
(no changes since v1)
test/py/multiplexed_log.py | 8 +++++--- test/py/u_boot_utils.py | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-)
test/py/multiplexed_log.py +5 -3
@@ -109,7 +109,7 @@ class RunAndLog(object): """Clean up any resources managed by this object.""" pass - def run(self, cmd, cwd=None, ignore_errors=False): + def run(self, cmd, cwd=None, ignore_errors=False, stdin=None): """Run a command as a sub-process, and log the results. The output is available at self.output which can be useful if there is
@@ -123,6 +123,7 @@ class RunAndLog(object): function will simply return if the command cannot be executed or exits with an error code, otherwise an exception will be raised if such problems occur. + stdin: Input string to pass to the command as stdin (or None) Returns: The output as a string.
@@ -135,8 +136,9 @@ class RunAndLog(object): try: p = subprocess.Popen(cmd, cwd=cwd, - stdin=None, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - (stdout, stderr) = p.communicate() + stdin=subprocess.PIPE if stdin else None, + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + (stdout, stderr) = p.communicate(input=stdin) if stdout is not None: stdout = stdout.decode('utf-8') if stderr is not None:
test/py/u_boot_utils.py +3 -2
@@ -154,7 +154,7 @@ def wait_until_file_open_fails(fn, ignore_errors): return raise Exception('File can still be opened') -def run_and_log(u_boot_console, cmd, ignore_errors=False): +def run_and_log(u_boot_console, cmd, ignore_errors=False, stdin=None): """Run a command and log its output. Args:
@@ -166,6 +166,7 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False): will simply return if the command cannot be executed or exits with an error code, otherwise an exception will be raised if such problems occur. + stdin: Input string to pass to the command as stdin (or None) Returns: The output as a string.
@@ -173,7 +174,7 @@ def run_and_log(u_boot_console, cmd, ignore_errors=False): if isinstance(cmd, str): cmd = cmd.split() runner = u_boot_console.log.get_runner(cmd[0], sys.stdout) - output = runner.run(cmd, ignore_errors=ignore_errors) + output = runner.run(cmd, ignore_errors=ignore_errors, stdin=stdin) runner.close() return output
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 03/41] test/py: Allow passing input to a program
When running a program on the host, allow input to be passed in as stdin. This is needed for running sfdisk, for example.
---
(no changes since v1)
test/py/multiplexed_log.py | 8 +++++--- test/py/u_boot_utils.py | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 4/41 sandbox: Support unmapping a file
In reply to Simon GlassAdd the opposite of mapping, so that we can unmap and avoid running out of address space.
---
(no changes since v1)
arch/sandbox/cpu/os.c | 10 ++++++++++ include/os.h | 9 +++++++++ 2 files changed, 19 insertions(+)
arch/sandbox/cpu/os.c +10 -0
@@ -211,6 +211,16 @@ int os_map_file(const char *pathname, int os_flags, void **bufp, int *sizep)return 0 ; } +int os_unmap (void *buf,int size) +{ +if (munmap (buf, size)) { +printf ("Can't unmap %p %x\n" , buf, size); +return -EIO ; + } + +return 0 ; +} +/* Restore tty state when we exit */ static struct termios orig_term;static bool term_setup;
include/os.h +9 -0
@@ -419,6 +419,15 @@ int os_read_file(const char *name, void **bufp, int *sizep);*/ int os_map_file (const char *pathname,int os_flags,void **bufp,int *sizep); +/** +* os_unmap() - Unmap a file previously mapped +* +* @buf: Mapped address +* @size: Size in bytes +* Return: 0 if OK, -ve on error +*/ +int os_unmap (void *buf,int size); +/* * os_find_text_base() - Find the text section in this running process *
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 04/41] sandbox: Support unmapping a file
Add the opposite of mapping, so that we can unmap and avoid running out of address space.
---
(no changes since v1)
arch/sandbox/cpu/os.c | 10 ++++++++++ include/os.h | 9 +++++++++ 2 files changed, 19 insertions(+)
Applied to u-boot-dm/next, thanks!
PATCH v2 5/41 sandbox: mmc: Support a backing file
In reply to Simon GlassProvide a way for sandbox MMC to present data from a backing file. This allows a filesystem to be created on the host and easily served via an emulated mmc device.
---
Changes in v2:
- Free the memory buffer, to avoid running out of memory
- Unmap the file
- Reorder struct sandbox_mmc_priv
doc/device-tree-bindings/mmc/sandbox,mmc.txt | 18 ++++++ drivers/mmc/sandbox_mmc.c | 60 +++++++++++++++++--- 2 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 doc/device-tree-bindings/mmc/sandbox,mmc.txt
doc/device-tree-bindings/mmc/sandbox,mmc.txt new file +18 -0
@@ -0,0 +1,18 @@ +Sandbox MMC +=========== + +Required properties: +- compatible : "sandbox,mmc" + +Optional properties: +- filename : Name of backing file, if any. This is mapped into the MMC device + so can be used to provide a filesystem or other test data + + +Example +------- + +mmc2 { + compatible = "sandbox,mmc"; + non-removable; +};
drivers/mmc/sandbox_mmc.c +51 -9
104 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 05/41] sandbox: mmc: Support a backing file
Provide a way for sandbox MMC to present data from a backing file. This allows a filesystem to be created on the host and easily served via an emulated mmc device.
---
Changes in v2:
- Free the memory buffer, to avoid running out of memory
- Unmap the file
- Reorder struct sandbox_mmc_priv
doc/device-tree-bindings/mmc/sandbox,mmc.txt | 18 ++++++ drivers/mmc/sandbox_mmc.c | 60 +++++++++++++++++--- 2 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 doc/device-tree-bindings/mmc/sandbox,mmc.txt
Applied to u-boot-dm/next, thanks!
PATCH v2 6/41 mmc: Allow for children other than the block device
In reply to Simon GlassAt present the MMC uclass assumes that the only child it can have is a block device. Update this so we can add a bootmethod too.
---
(no changes since v1)
drivers/mmc/mmc-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/mmc/mmc-uclass.c +2 -2
@@ -320,7 +320,7 @@ struct blk_desc *mmc_get_blk_desc(struct mmc *mmc)struct blk_desc *desc;struct udevice *dev; -device_find_first_child (mmc->dev, &dev); +device_find_first_child_by_uclass (mmc->dev,UCLASS_BLK , &dev);if (!dev)return NULL ; desc =dev_get_uclass_plat (dev);
@@ -425,7 +425,7 @@ int mmc_unbind(struct udevice *dev) {struct udevice *bdev; -device_find_first_child (dev, &bdev); +device_find_first_child_by_uclass (dev,UCLASS_BLK , &bdev);if (bdev) {device_remove (bdev,DM_REMOVE_NORMAL );device_unbind (bdev);
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 06/41] mmc: Allow for children other than the block device
At present the MMC uclass assumes that the only child it can have is a block device. Update this so we can add a bootmethod too.
---
(no changes since v1)
drivers/mmc/mmc-uclass.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 7/41 mbr: Correct verification check
In reply to Simon GlassAt present this command considers the partitions to be identical if the start and size are smaller than expected. It should check that they are the same. Fix this and tidy up the code style a little.
---
(no changes since v1)
cmd/mbr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
cmd/mbr.c +4 -4
@@ -244,12 +244,12 @@ static int do_verify_mbr(struct blk_desc *dev, const char *str)for (i =0 ; i < count; i++) {struct disk_partition p; -if (part_get_info (dev, i+1 , &p)) +if (part_get_info (dev, i +1 , &p)) goto fail; -if ((partitions[i].size && p.size < partitions[i].size) || - (partitions[i].start && p.start < partitions[i].start) || - (p.sys_ind != partitions[i].sys_ind)) +if ((partitions[i].size && p.size != partitions[i].size) || + (partitions[i].start && p.start != partitions[i].start) || + p.sys_ind != partitions[i].sys_ind) goto fail; } ret =0 ;
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 07/41] mbr: Correct verification check
Hi Simon,
Quoted 36 lines · Simon Glass
At present this command considers the partitions to be identical if the start and size are smaller than expected. It should check that they are the same. Fix this and tidy up the code style a little.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
cmd/mbr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)cmd/mbr.c +4
-4@@ -244,12 +244,12 @@ static int do_verify_mbr(struct blk_desc *dev, const char *str)for (i =0 ; i < count; i++) {struct disk_partition p; -if (part_get_info (dev, i+1 , &p)) +if (part_get_info (dev, i +1 , &p)) goto fail; -if ((partitions[i].size && p.size < partitions[i].size) || - (partitions[i].start && p.start < partitions[i].start) || - (p.sys_ind != partitions[i].sys_ind)) +if ((partitions[i].size && p.size != partitions[i].size) || + (partitions[i].start && p.start != partitions[i].start) || + p.sys_ind != partitions[i].sys_ind) goto fail; } ret =0 ;Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
This seems irrelevant to the series and a general fix. Can you send it as such?
Re: [PATCH v2 07/41] mbr: Correct verification check
Hi Simon,
Quoted 4 lines · Simon Glass
At present this command considers the partitions to be identical if the start and size are smaller than expected. It should check that they are the same. Fix this and tidy up the code style a little.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
cmd/mbr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 8/41 disk: part_dos: Fix a NULL pointer error
In reply to Simon GlassWhen ext is NULL we cannot dereference it. Update the code flow to avoid this, so that layout_mbr_partitions() can be used with partition tables that do not include an extended partition.
---
(no changes since v1)
disk/part_dos.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
disk/part_dos.c +6 -4
@@ -459,10 +459,12 @@ int layout_mbr_partitions(struct disk_partition *p, int count, ext = &p[i]; } -if (i >=4 && !ext) { -printf ("%s: extended partition is needed for more than 4 partitions\n" , - __func__); -return -1 ; +if (count <4 ) +return 0 ; + +if (!ext) { +log_err ("extended partition is needed for more than 4 partitions\n" ); +return -EINVAL ; }/* calculate extended volumes start and size if needed */
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 08/41] disk: part_dos: Fix a NULL pointer error
When ext is NULL we cannot dereference it. Update the code flow to avoid this, so that layout_mbr_partitions() can be used with partition tables that do not include an extended partition.
---
(no changes since v1)
disk/part_dos.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 9/41 common: Allow a smaller console-recording pre-reloc
In reply to Simon GlassBefore relocation there is generally not as much available memory and not that much console output. At present the console-output buffer is the same side before and after relocation. Add a separate Kconfig option to remove this limitation.
---
(no changes since v1)
common/Kconfig | 10 ++++++++++ common/console.c | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-)
common/Kconfig +10 -0
@@ -32,6 +32,16 @@ config CONSOLE_RECORD_OUT_SIZE more data will be recorded until some is removed. The buffer is allocated immediately after the malloc() region is ready. +config CONSOLE_RECORD_OUT_SIZE_F + hex "Output buffer size before relocation" + depends on CONSOLE_RECORD + default 0x400 if CONSOLE_RECORD + help + Set the size of the console output buffer before relocation. When + this fills up, no more data will be recorded until some is removed. + The buffer is allocated immediately after the early malloc() region is + ready. + config CONSOLE_RECORD_IN_SIZE hex "Input buffer size" depends on CONSOLE_RECORD
common/console.c +3 -1
@@ -735,7 +735,9 @@ int console_record_init(void)int ret; ret =membuff_new ((struct membuff *)&gd->console_out, -CONFIG_CONSOLE_RECORD_OUT_SIZE ); + gd->flags &GD_FLG_RELOC ? +CONFIG_CONSOLE_RECORD_OUT_SIZE : +CONFIG_CONSOLE_RECORD_OUT_SIZE_F );if (ret)return ret; ret = membuff_new((struct membuff *)&gd->console_in,
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 09/41] common: Allow a smaller console-recording pre-reloc
Before relocation there is generally not as much available memory and not that much console output. At present the console-output buffer is the same side before and after relocation. Add a separate Kconfig option to remove this limitation.
---
(no changes since v1)
common/Kconfig | 10 ++++++++++ common/console.c | 4 +++- 2 files changed, 13 insertions(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 10/41 dm: core: Add tests for stringlist functions
In reply to Simon GlassThese functions currently lack tests so add some. The error handling differs betwee livetree and flattree at present, so only check the error codes with livetree.
---
(no changes since v1)
arch/sandbox/dts/test.dts | 1 + test/dm/ofnode.c | 76 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+)
arch/sandbox/dts/test.dts +1 -0
@@ -207,6 +207,7 @@ test4-gpios = <&gpio_a 14>, <&gpio_b 4 1 3 2 1>; test5-gpios = <&gpio_a 19>; + bool-value; int-value = <1234>; uint-value = <(-1234)>; int64-value = /bits/ 64 <0x1111222233334444>;
test/dm/ofnode.c +76 -0
79 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 10/41] dm: core: Add tests for stringlist functions
These functions currently lack tests so add some. The error handling differs betwee livetree and flattree at present, so only check the error codes with livetree.
---
(no changes since v1)
arch/sandbox/dts/test.dts | 1 + test/dm/ofnode.c | 76 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+)
Applied to u-boot-dm/next, thanks!
PATCH v2 11/41 dm: core: Fix handling of uclass pre_unbind method
In reply to Simon GlassThis method is currently called after the platform data has been freed. But the pre_unbind() method may wish to access this, e.g. to free some data structures stored there.
Split the unbinding of devices into two pieces, as is done with removal. This corrects the problem.
Also tidy a code-style issue in device_remove() while we are here.
---
(no changes since v1)
drivers/core/device-remove.c | 9 +++++---- drivers/core/uclass.c | 8 +++++++- include/dm/uclass-internal.h | 14 +++++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-)
drivers/core/device-remove.c +5 -4
@@ -95,6 +95,9 @@ int device_unbind(struct udevice *dev)if (ret)return log_msg_ret ("child unbind" , ret); + ret =uclass_pre_unbind_device (dev); +if (ret) +return log_msg_ret ("uc" , ret);if (dev_get_flags (dev) &DM_FLAG_ALLOC_PDATA ) {free (dev_get_plat (dev));dev_set_plat (dev,NULL );
@@ -142,10 +145,8 @@ void device_free(struct udevice *dev) }if (dev->parent) { size = dev->parent->driver->per_child_auto; -if (!size) { - size = dev->parent->uclass->uc_drv-> - per_child_auto; - } +if (!size) + size = dev->parent->uclass->uc_drv->per_child_auto;if (size) {free (dev_get_parent_priv (dev));dev_set_parent_priv (dev,NULL );
drivers/core/uclass.c +7 -1
@@ -682,7 +682,7 @@ err: }#if CONFIG_IS_ENABLED (DM_DEVICE_REMOVE ) -int uclass_unbind_device (struct udevice *dev) +int uclass_pre_unbind_device (struct udevice *dev) {struct uclass *uc;int ret;
@@ -694,7 +694,13 @@ int uclass_unbind_device(struct udevice *dev) return ret; } +return 0 ; +} + +int uclass_unbind_device (struct udevice *dev) +{list_del (&dev->uclass_node); +return 0 ; }#endif
include/dm/uclass-internal.h +13 -1
@@ -243,6 +243,17 @@ int uclass_find_device_by_phandle(enum uclass_id id, struct udevice *parent,*/ int uclass_bind_device (struct udevice *dev); +#if CONFIG_IS_ENABLED (DM_DEVICE_REMOVE ) +/** +* uclass_pre_unbind_device() - Prepare to deassociate device with a uclass +* +* Call any handled needed before uclass_unbind_device() is called +* +* @dev: Pointer to the device +* #return 0 on success, -ve on error +*/ +int uclass_pre_unbind_device (struct udevice *dev); +/** * uclass_unbind_device() - Deassociate device with a uclass *
@@ -251,9 +262,10 @@ int uclass_bind_device(struct udevice *dev);* @dev: Pointer to the device * #return 0 on success, -ve on error */ -#if CONFIG_IS_ENABLED (DM_DEVICE_REMOVE )int uclass_unbind_device (struct udevice *dev); +#else +static inline int uclass_pre_unbind_device (struct udevice *dev) {return 0 ; }static inline int uclass_unbind_device (struct udevice *dev) {return 0 ; }#endif
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 11/41] dm: core: Fix handling of uclass pre_unbind method
This method is currently called after the platform data has been freed. But the pre_unbind() method may wish to access this, e.g. to free some data structures stored there.
Split the unbinding of devices into two pieces, as is done with removal. This corrects the problem.
Also tidy a code-style issue in device_remove() while we are here.
---
(no changes since v1)
drivers/core/device-remove.c | 9 +++++---- drivers/core/uclass.c | 8 +++++++- include/dm/uclass-internal.h | 14 +++++++++++++- 3 files changed, 25 insertions(+), 6 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 12/41 dm: core: Fix up string-function documentation
In reply to Simon GlassThe details for of_property_read_string_helper() and ofnode_read_string_index() are a little inaccurate. Fix up the comments to avoid confusion.
---
(no changes since v1)
drivers/core/of_access.c | 3 ++- include/dm/ofnode.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
drivers/core/of_access.c +2 -1
@@ -581,7 +581,8 @@ int of_property_match_string(const struct device_node *np, const char *propname,* @propname: name of the property to be searched. * @out_strs: output array of string pointers. * @sz: number of array elements to read. -* @skip: Number of strings to skip over at beginning of list. +* @skip: Number of strings to skip over at beginning of list (cannot be +* negative) * * Don't call this function directly. It is a utility helper for the * of_property_read_string*() family of functions.
include/dm/ofnode.h +2 -2
@@ -590,11 +590,11 @@ int ofnode_stringlist_search(ofnode node, const char *propname,* * @node: node to check * @propname: name of the property containing the string list -* @index: index of the string to return +* @index: index of the string to return (cannot be negative) * @lenp: return location for the string length or an error code on failure * * @return: -* length of string, if found or -ve error value if not found +* 0 if found or -ve error value if not found */ int ofnode_read_string_index (ofnode node,const char *propname,int index,const char **outp);
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 12/41] dm: core: Fix up string-function documentation
The details for of_property_read_string_helper() and ofnode_read_string_index() are a little inaccurate. Fix up the comments to avoid confusion.
---
(no changes since v1)
drivers/core/of_access.c | 3 ++- include/dm/ofnode.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 13/41 dm: core: Add a way to obtain a string list
In reply to Simon GlassAt present we support reading a string list a string at a time. Apart from being inefficient, this makes it impossible to separate reading of the devicetree into the of_to_plat() method where it belongs, since any code which needs access to the string must read it from the devicetree.
Add a function which returns the string property as an array of pointers to the strings, which is easily used by clients.
---
(no changes since v1)
drivers/core/ofnode.c | 26 ++++++++++++++++++++++++++ drivers/core/read.c | 6 ++++++ include/dm/ofnode.h | 20 ++++++++++++++++++++ include/dm/read.h | 28 ++++++++++++++++++++++++++++ test/dm/ofnode.c | 20 ++++++++++++++++++++ 5 files changed, 100 insertions(+)
drivers/core/ofnode.c +26 -0
@@ -456,6 +456,32 @@ int ofnode_read_string_count(ofnode node, const char *property) } } +int ofnode_read_string_list (ofnode node,const char *property, +const char ***listp) +{ +const char **prop; +int count; +int i; + + *listp =NULL ; + count =ofnode_read_string_count (node, property); +if (count <0 ) +return count; +if (!count) +return 0 ; + + prop =calloc (count +1 ,sizeof (char *)); +if (!prop) +return -ENOMEM ; + +for (i =0 ; i < count; i++) +ofnode_read_string_index (node, property, i, &prop[i]); + prop[count] =NULL ; + *listp = prop; + +return count; +} +static void ofnode_from_fdtdec_phandle_args (struct fdtdec_phandle_args *in,struct ofnode_phandle_args *out) {
drivers/core/read.c +6 -0
@@ -205,6 +205,12 @@ int dev_read_string_count(const struct udevice *dev, const char *propname)return ofnode_read_string_count (dev_ofnode (dev), propname); } +int dev_read_string_list (const struct udevice *dev,const char *propname, +const char ***listp) +{ +return ofnode_read_string_list (dev_ofnode (dev), propname, listp); +} +int dev_read_phandle_with_args (const struct udevice *dev,const char *list_name,const char *cells_name,int cell_count,int index,struct ofnode_phandle_args *out_args)
include/dm/ofnode.h +20 -0
@@ -609,6 +609,26 @@ int ofnode_read_string_index(ofnode node, const char *propname, int index,*/ int ofnode_read_string_count (ofnode node,const char *property); +/** +* ofnode_read_string_list() - read a list of strings +* +* This produces a list of string pointers with each one pointing to a string +* in the string list. If the property does not exist, it returns {NULL}. +* +* The data is allocated and the caller is reponsible for freeing the return +* value (the list of string pointers). The strings themselves may not be +* changed as they point directly into the devicetree property. +* +* @node: node to check +* @listp: returns an allocated, NULL-terminated list of strings if the return +* value is > 0, else is set to NULL +* @return number of strings in list, 0 if none, -ENOMEM if out of memory, +* -EINVAL if no such property, -EENODATA if property is empty +* @return: NULL-terminated list of strings (NULL if no property or empty) +*/ +int ofnode_read_string_list (ofnode node,const char *property, +const char ***listp); +/** * ofnode_parse_phandle_with_args() - Find a node pointed by phandle in a list *
include/dm/read.h +28 -0
@@ -371,6 +371,27 @@ int dev_read_string_index(const struct udevice *dev, const char *propname,* number of strings in the list, or -ve error value if not found */ int dev_read_string_count (const struct udevice *dev,const char *propname); + +/** +* dev_read_string_list() - read a list of strings +* +* This produces a list of string pointers with each one pointing to a string +* in the string list. If the property does not exist, it returns {NULL}. +* +* The data is allocated and the caller is reponsible for freeing the return +* value (the list of string pointers). The strings themselves may not be +* changed as they point directly into the devicetree property. +* +* @dev: device to examine +* @propname: name of the property containing the string list +* @listp: returns an allocated, NULL-terminated list of strings if the return +* value is > 0, else is set to NULL +* @return number of strings in list, 0 if none, -ENOMEM if out of memory, +* -ENOENT if no such property +*/ +int dev_read_string_list (const struct udevice *dev,const char *propname, +const char ***listp); +/** * dev_read_phandle_with_args() - Find a node pointed by phandle in a list *
@@ -906,6 +927,13 @@ static inline int dev_read_string_count(const struct udevice *dev,return ofnode_read_string_count (dev_ofnode (dev), propname); } +static inline int dev_read_string_list (const struct udevice *dev, +const char *propname, +const char ***listp) +{ +return ofnode_read_string_list (dev_ofnode (dev), propname, listp); +} +static inline int dev_read_phandle_with_args (const struct udevice *dev,const char *list_name,const char *cells_name,int cell_count,int index,struct ofnode_phandle_args *out_args)
test/dm/ofnode.c +20 -0
@@ -336,6 +336,7 @@ DM_TEST(dm_test_ofnode_conf, 0);static int dm_test_ofnode_string (struct unit_test_state *uts) { +const char **val;const char *out;ofnode node;
@@ -348,6 +349,10 @@ static int dm_test_ofnode_string(struct unit_test_state *uts)ut_asserteq_str ("test string" , out);ut_asserteq (0 ,ofnode_stringlist_search (node,"str-value" ,"test string" )); +ut_asserteq (1 ,ofnode_read_string_list (node,"str-value" , &val)); +ut_asserteq_str ("test string" , val[0 ]); +ut_assertnull (val[1 ]); +free (val);/* list of strings */ ut_asserteq (5 ,ofnode_read_string_count (node,"mux-control-names" ));
@@ -356,6 +361,15 @@ static int dm_test_ofnode_string(struct unit_test_state *uts)ut_asserteq_str ("mux0" , out);ut_asserteq (0 ,ofnode_stringlist_search (node,"mux-control-names" ,"mux0" )); +ut_asserteq (5 ,ofnode_read_string_list (node,"mux-control-names" , + &val)); +ut_asserteq_str ("mux0" , val[0 ]); +ut_asserteq_str ("mux1" , val[1 ]); +ut_asserteq_str ("mux2" , val[2 ]); +ut_asserteq_str ("mux3" , val[3 ]); +ut_asserteq_str ("mux4" , val[4 ]); +ut_assertnull (val[5 ]); +free (val);ut_assertok (ofnode_read_string_index (node,"mux-control-names" ,4 , &out));
@@ -369,6 +383,7 @@ DM_TEST(dm_test_ofnode_string, 0);static int dm_test_ofnode_string_err (struct unit_test_state *uts) { +const char **val;const char *out;ofnode node;
@@ -383,16 +398,21 @@ static int dm_test_ofnode_string_err(struct unit_test_state *uts)ut_asserteq (-EINVAL ,ofnode_read_string_count (node,"missing" ));ut_asserteq (-EINVAL ,ofnode_read_string_index (node,"missing" ,0 , &out)); +ut_asserteq (-EINVAL ,ofnode_read_string_list (node,"missing" , &val));/* empty property */ ut_asserteq (-ENODATA ,ofnode_read_string_count (node,"bool-value" ));ut_asserteq (-ENODATA ,ofnode_read_string_index (node,"bool-value" ,0 , &out)); +ut_asserteq (-ENODATA ,ofnode_read_string_list (node,"bool-value" , + &val));/* badly formatted string list */ ut_asserteq (-EILSEQ ,ofnode_read_string_count (node,"int64-value" ));ut_asserteq (-EILSEQ ,ofnode_read_string_index (node,"int64-value" ,0 , &out)); +ut_asserteq (-EILSEQ ,ofnode_read_string_list (node,"int64-value" , + &val));/* out of range / not found */ ut_asserteq(-ENODATA, ofnode_read_string_index(node, "str-value", 1,
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 13/41] dm: core: Add a way to obtain a string list
Quoted 32 lines · Simon Glass
At present we support reading a string list a string at a time. Apart from being inefficient, this makes it impossible to separate reading of the devicetree into the
of_to_plat()method where it belongs, since any code which needs access to the string must read it from the devicetree.Add a function which returns the string property as an array of pointers to the strings, which is easily used by clients.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
drivers/core/ofnode.c | 26 ++++++++++++++++++++++++++ drivers/core/read.c | 6 ++++++ include/dm/ofnode.h | 20 ++++++++++++++++++++ include/dm/read.h | 28 ++++++++++++++++++++++++++++ test/dm/ofnode.c | 20 ++++++++++++++++++++ 5 files changed, 100 insertions(+)drivers/core/ofnode.c +3
-0@@ -456,6 +456,32 @@ int ofnode_read_string_count(ofnode node, const char *property) } } +int ofnode_read_string_list (ofnode node,const char *property, +const char ***listp) +{
drivers/core/ofnode.c int ofnode_read_string_count(ofnode node, const char *property) · line 471
Quoted 10 lines
drivers/core/ofnode.c +10
-0+const char **prop; +int count; +int i; + + *listp =NULL ; + count =ofnode_read_string_count (node, property); +if (count <0 ) +return count; +if (!count) +return 0 ;
Those can fold into a single if and always return 'count'. if (count <= 0)
return count;
drivers/core/ofnode.c int ofnode_read_string_count(ofnode node, const char *property) · line 473
Quoted 2 lines
drivers/core/ofnode.c +2
-0+ + prop =calloc (count +1 ,sizeof (char *));
[...]
Regards
/Ilias
Re: [PATCH v2 13/41] dm: core: Add a way to obtain a string list
Hi Ilias,
Quoted 47 lines · Ilias Apalodimas
Quoted 32 lines · Simon Glass
At present we support reading a string list a string at a time. Apart from being inefficient, this makes it impossible to separate reading of the devicetree into the
of_to_plat()method where it belongs, since any code which needs access to the string must read it from the devicetree.Add a function which returns the string property as an array of pointers to the strings, which is easily used by clients.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
drivers/core/ofnode.c | 26 ++++++++++++++++++++++++++ drivers/core/read.c | 6 ++++++ include/dm/ofnode.h | 20 ++++++++++++++++++++ include/dm/read.h | 28 ++++++++++++++++++++++++++++ test/dm/ofnode.c | 20 ++++++++++++++++++++ 5 files changed, 100 insertions(+)drivers/core/ofnode.c +3
-0@@ -456,6 +456,32 @@ int ofnode_read_string_count(ofnode node, const char *property) } } +int ofnode_read_string_list (ofnode node,const char *property, +const char ***listp) +{drivers/core/ofnode.c int ofnode_read_string_count(ofnode node, const char *property) · line 471
Quoted 10 lines
drivers/core/ofnode.c +10
-0+const char **prop; +int count; +int i; + + *listp =NULL ; + count =ofnode_read_string_count (node, property); +if (count <0 ) +return count; +if (!count) +return 0 ;Those can fold into a single if and always return 'count'. if (count <= 0)
Quoted 1 line
return count;
Yes, but I prefer to deal with errors separately. The first case is an error.
Quoted 4 lines
Quoted 3 lines
drivers/core/ofnode.c +2
-0+ + prop =calloc (count +1 ,sizeof (char *));[...]
Regards,
Simon
PATCH v2 14/41 dm: core: Allow finding children / uclasses by partial name
In reply to Simon GlassIn some cases it is useful to search just by a partial name, such as when looking for a sibling device that has a common name substring. Add helper functions to handle these requirements.
---
(no changes since v1)
drivers/core/device.c | 13 ++++++++++--- drivers/core/uclass.c | 9 +++++++-- include/dm/device.h | 12 ++++++++++++ include/dm/uclass.h | 9 +++++++++ 4 files changed, 38 insertions(+), 5 deletions(-)
drivers/core/device.c +10 -3
@@ -894,15 +894,16 @@ int device_find_first_child_by_uclass(const struct udevice *parent,return -ENODEV ; } -int device_find_child_by_name (const struct udevice *parent,const char *name, -struct udevice **devp) +int device_find_child_by_namelen (const struct udevice *parent,const char *name, +int len,struct udevice **devp) {struct udevice *dev; *devp =NULL ;list_for_each_entry (dev, &parent->child_head, sibling_node) { -if (!strcmp (dev->name, name)) { +if (!strncmp (dev->name, name, len) && +strlen (dev->name) == len) { *devp = dev;return 0 ; }
@@ -911,6 +912,12 @@ int device_find_child_by_name(const struct udevice *parent, const char *name,return -ENODEV ; } +int device_find_child_by_name (const struct udevice *parent,const char *name, +struct udevice **devp) +{ +return device_find_child_by_namelen (parent, name,strlen (name), devp); +} +int device_first_child_err (struct udevice *parent,struct udevice **devp) {struct udevice *dev;
drivers/core/uclass.c +7 -2
@@ -180,20 +180,25 @@ void uclass_set_priv(struct uclass *uc, void *priv) uc->priv_ = priv; } -enum uclass_id uclass_get_by_name (const char *name) +enum uclass_id uclass_get_by_name_len (const char *name,int len) {int i;for (i =0 ; i <UCLASS_COUNT ; i++) {struct uclass_driver *uc_drv =lists_uclass_lookup (i); -if (uc_drv && !strcmp (uc_drv->name, name)) +if (uc_drv && !strncmp (uc_drv->name, name, len))return i; }return UCLASS_INVALID ; } +enum uclass_id uclass_get_by_name (const char *name) +{ +return uclass_get_by_name_len (name,strlen (name)); +} +int dev_get_uclass_index (struct udevice *dev,struct uclass **ucp) {struct udevice *iter;
include/dm/device.h +12 -0
@@ -758,6 +758,18 @@ int device_find_first_child_by_uclass(const struct udevice *parent,enum uclass_id uclass_id, struct udevice **devp); +/** +* device_find_child_by_name() - Find a child by device name +* +* @parent: Parent device to search +* @name: Name to look for +* @len: Length of the name +* @devp: Returns device found, if any +* @return 0 if found, else -ENODEV +*/ +int device_find_child_by_namelen (const struct udevice *parent,const char *name, +int len,struct udevice **devp); +/** * device_find_child_by_name() - Find a child by device name *
include/dm/uclass.h +9 -0
@@ -172,6 +172,15 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);*/ const char *uclass_get_name (enum uclass_id id); +/** +* uclass_get_by_name() - Look up a uclass by its driver name +* +* @name: Name to look up +* @len: Length of name +* @returns the associated uclass ID, or UCLASS_INVALID if not found +*/ +enum uclass_id uclass_get_by_name_len (const char *name,int len); +/** * uclass_get_by_name() - Look up a uclass by its driver name *
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 14/41] dm: core: Allow finding children / uclasses by partial name
In some cases it is useful to search just by a partial name, such as when looking for a sibling device that has a common name substring. Add helper functions to handle these requirements.
---
(no changes since v1)
drivers/core/device.c | 13 ++++++++++--- drivers/core/uclass.c | 9 +++++++-- include/dm/device.h | 12 ++++++++++++ include/dm/uclass.h | 9 +++++++++ 4 files changed, 38 insertions(+), 5 deletions(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 15/41 dm: core: Add a way to count the devices in a uclass
In reply to Simon GlassAdd a function that returns the number of devices in a uclass. This can be helpful in sizing an array that needs to hold a list of them.
---
(no changes since v1)
drivers/core/uclass.c | 12 ++++++++++++ include/dm/uclass.h | 8 ++++++++ 2 files changed, 20 insertions(+)
drivers/core/uclass.c +12 -0
@@ -794,6 +794,18 @@ int uclass_probe_all(enum uclass_id id)return 0 ; } +int uclass_id_count (enum uclass_id id) +{ +struct udevice *dev; +struct uclass *uc; +int count =0 ; + +uclass_id_foreach_dev (id, dev, uc) + count++; + +return count; +} +UCLASS_DRIVER (nop) = { .id =UCLASS_NOP , .name ="nop" ,
include/dm/uclass.h +8 -0
@@ -425,6 +425,14 @@ int uclass_first_device_drvdata(enum uclass_id id, ulong driver_data,*/ int uclass_probe_all (enum uclass_id id); +/** +* uclass_id_count() - Count the number of devices in a uclass +* +* @id: uclass ID to look up +* @return number of devices in that uclass (0 if none) +*/ +int uclass_id_count (enum uclass_id id); +/** * uclass_id_foreach_dev() - Helper function to iteration through devices *
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 15/41] dm: core: Add a way to count the devices in a uclass
Add a function that returns the number of devices in a uclass. This can be helpful in sizing an array that needs to hold a list of them.
---
(no changes since v1)
drivers/core/uclass.c | 12 ++++++++++++ include/dm/uclass.h | 8 ++++++++ 2 files changed, 20 insertions(+)
Applied to u-boot-dm/next, thanks!
PATCH v2 16/41 sandbox: Enable HEXDUMP for sandbox_flattree
In reply to Simon GlassAt present the hexdump tests are disabled in sandbox_flattree. This is good, because they do not pass. Enable the required Kconfig so that they will, when enabled.
---
(no changes since v1)
configs/sandbox_flattree_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/sandbox_flattree_defconfig +1 -0
@@ -202,6 +202,7 @@ CONFIG_RSA_VERIFY_WITH_PKEY=y CONFIG_TPM=y CONFIG_LZ4=y CONFIG_ERRNO_STR=y +CONFIG_HEXDUMP=y CONFIG_UNIT_TEST=y CONFIG_UT_TIME=y CONFIG_UT_DM=y
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 16/41] sandbox: Enable HEXDUMP for sandbox_flattree
At present the hexdump tests are disabled in sandbox_flattree. This is good, because they do not pass. Enable the required Kconfig so that they will, when enabled.
---
(no changes since v1)
configs/sandbox_flattree_defconfig | 1 + 1 file changed, 1 insertion(+)
Applied to u-boot-dm/next, thanks!
PATCH v2 17/41 test/py: Relax the naming rules for unit tests
In reply to Simon GlassAt present the collection function used by pytest is quite strict on the naming of the functions it detects. In particular it requires the name of the test to be repeated in the function name.
This is not enforced anywhere else, but instead the tests are silently omitted from the pytest run. This affects a few dozen tests.
The rule does not seem to have any particular purpose. Relax it, so that all tests that use the UNIT_TEST() macro will run, regardless of the name of the test function.
---
(no changes since v1)
test/py/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/py/conftest.py +1 -1
@@ -226,7 +226,7 @@ def pytest_configure(config): import u_boot_console_exec_attach console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig) -re_ut_test_list = re.compile(r'[^a-zA-Z0-9_]_u_boot_list_2_ut_(.*)_test_2_\1_test_(.*)\s*$') +re_ut_test_list = re.compile(r'[^a-zA-Z0-9_]_u_boot_list_2_ut_(.*)_test_2_(.*)\s*$') def generate_ut_subtest(metafunc, fixture_name, sym_path): """Provide parametrization for a ut_subtest fixture.
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 17/41] test/py: Relax the naming rules for unit tests
At present the collection function used by pytest is quite strict on the naming of the functions it detects. In particular it requires the name of the test to be repeated in the function name.
This is not enforced anywhere else, but instead the tests are silently omitted from the pytest run. This affects a few dozen tests.
The rule does not seem to have any particular purpose. Relax it, so that all tests that use the UNIT_TEST() macro will run, regardless of the name of the test function.
---
(no changes since v1)
test/py/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 18/41 test/py: Raise a ValueError if a command fails
In reply to Simon GlassAt present an Exception is raised if a command fails. This is a very broad class and makes it difficult for callers to catch the error without also catching other things, like programming bugs.
Change it to ValueError to make this easier.
---
(no changes since v1)
test/py/multiplexed_log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
test/py/multiplexed_log.py +1 -1
@@ -165,7 +165,7 @@ class RunAndLog(object): if output and not output.endswith('\n'): output += '\n' if exit_status and not exception and not ignore_errors: - exception = Exception('Exit code: ' + str(exit_status)) + exception = ValueError('Exit code: ' + str(exit_status)) if exception: output += str(exception) + '\n' self.logfile.write(self, output)
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 18/41] test/py: Raise a ValueError if a command fails
At present an Exception is raised if a command fails. This is a very broad class and makes it difficult for callers to catch the error without also catching other things, like programming bugs.
Change it to ValueError to make this easier.
---
(no changes since v1)
test/py/multiplexed_log.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm/next, thanks!
PATCH v2 19/41 bootstd: Add the concept of a bootflow
In reply to Simon GlassA bootflow encapsulates the process used to boot an operating system. It typically has a control file (such as extlinux.conf) and information about which 'bootdev' it came from.
Add the header file for this first, since it is needed by all other files.
---
(no changes since v1)
MAINTAINERS | 5 + include/bootflow.h | 254 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 259 insertions(+) create mode 100644 include/bootflow.h
MAINTAINERS +5 -0
@@ -633,6 +633,11 @@ M: Simon Glass <[email protected]> S: Maintained F: tools/binman/ +BOOTDEVICE +M: Simon Glass <[email protected]> +S: Maintained +F: include/bootflow.h + BTRFS M: Marek Behun <[email protected]> R: Qu Wenruo <[email protected]>
include/bootflow.h new file +254 -0
254 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 20/41 bootstd: Add the bootstd uclass and core implementation
In reply to Simon GlassThe 'bootstd' device provides the central information about U-Boot standard boot.
Add a uclass for bootstd and the various helpers needed to make it work. Also add a binding file.
---
(no changes since v1)
MAINTAINERS | 2 + boot/Kconfig | 21 ++++ boot/Makefile | 3 + boot/bootstd-uclass.c | 145 +++++++++++++++++++++++++++ doc/device-tree-bindings/bootstd.txt | 28 ++++++ include/bootstd.h | 80 +++++++++++++++ include/dm/uclass-id.h | 1 + 7 files changed, 280 insertions(+) create mode 100644 boot/bootstd-uclass.c create mode 100644 doc/device-tree-bindings/bootstd.txt create mode 100644 include/bootstd.h
MAINTAINERS +2 -0
@@ -636,6 +636,8 @@ F: tools/binman/ BOOTDEVICE M: Simon Glass <[email protected]> S: Maintained +F: boot/bootstd.c +F: include/bootstd.h F: include/bootflow.h BTRFS
boot/Kconfig +21 -0
@@ -274,6 +274,27 @@ endif # SPL endif # FIT +config BOOTSTD + bool "Standard boot support" + default y + depends on OF_CONTROL + help + U-Boot supports a standard way of locating something to boot, + typically an Operating System such as Linux, provided by a distro such + as Arch Linux or Debian. Enable this to support iterating through + available bootdevs and using bootmeths to find bootflows suitable for + booting. + + Standard boot is not a standard way of booting, just a framework + within U-Boot for supporting all the different ways that exist. + + Terminology: + + - bootdev - a device which can hold a distro (e.g. MMC) + - bootmeth - a method to scan a bootdev to find bootflows (owned by + U-Boot) + - bootflow - a description of how to boot (owned by the distro) + config LEGACY_IMAGE_FORMAT bool "Enable support for the legacy image format" default y if !FIT_SIGNATURE
boot/Makefile +3 -0
@@ -22,6 +22,9 @@ endif obj-y += image.o image-board.o obj-$(CONFIG_ANDROID_AB) += android_ab.o obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o + +obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o + obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o
boot/bootstd-uclass.c new file +145 -0
145 lines not on this page · raw message
doc/device-tree-bindings/bootstd.txt new file +28 -0
@@ -0,0 +1,28 @@ +U-Boot standard boot device (bootstd) +===================================== + +This is the controlling device for U-Boot standard boot, providing a way to +boot operating systems in a way that can be controlled by distros. + +Required properties: + +compatible: "u-boot,boot-std" + +Optional properties: + +filename-prefixes: + List of strings, each a directory to search for bootflow files + +bootdev-order: + List of bootdevs to check for bootflows, each a bootdev label (the media + uclass followed by the numeric sequence number of the media device) + + +Example: + + bootstd { + compatible = "u-boot,boot-std"; + + filename-prefixes = "/", "/boot/"; + bootdev-order = "mmc2", "mmc1"; + };
include/bootstd.h new file +80 -0
80 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -38,6 +38,7 @@ enum uclass_id {UCLASS_AXI ,/* AXI bus */ UCLASS_BLK ,/* Block device */ UCLASS_BOOTCOUNT ,/* Bootcount backing store */ +UCLASS_BOOTSTD ,/* Standard boot driver */ UCLASS_BUTTON ,/* Button */ UCLASS_CACHE ,/* Cache controller */ UCLASS_CLK, /* Clock source, e.g. used by peripherals */
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 21/41 bootstd: Add the bootdev uclass
In reply to Simon GlassA 'bootdev' is a device which can be used to boot an operating system. It is a child of the media device (e.g. MMC) which handles reading files from that device, such as a bootflow file.
Add a uclass for bootdev and the various helpers needed to make it work. Also add a binding file, empty for now.
---
(no changes since v1)
MAINTAINERS | 4 +- boot/Makefile | 1 + boot/bootdev-uclass.c | 431 +++++++++++++++++++++++++++ doc/device-tree-bindings/bootdev.txt | 8 + include/bootdev.h | 258 ++++++++++++++++ include/dm/uclass-id.h | 1 + 6 files changed, 702 insertions(+), 1 deletion(-) create mode 100644 boot/bootdev-uclass.c create mode 100644 doc/device-tree-bindings/bootdev.txt create mode 100644 include/bootdev.h
MAINTAINERS +3 -1
@@ -636,9 +636,11 @@ F: tools/binman/ BOOTDEVICE M: Simon Glass <[email protected]> S: Maintained +F: boot/bootdev*.c F: boot/bootstd.c -F: include/bootstd.h +F: include/bootdev*.h F: include/bootflow.h +F: include/bootstd.h BTRFS M: Marek Behun <[email protected]>
boot/Makefile +1 -0
@@ -23,6 +23,7 @@ obj-y += image.o image-board.o obj-$(CONFIG_ANDROID_AB) += android_ab.o obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o +obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootdev-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
boot/bootdev-uclass.c new file +431 -0
431 lines not on this page · raw message
doc/device-tree-bindings/bootdev.txt new file +8 -0
@@ -0,0 +1,8 @@ +U-Boot boot device (bootdev) +============================ + +A bootdev provides a way to obtain a bootflow file from a device. It is a +child of the media device (UCLASS_MMC, UCLASS_SPI_FLASH, etc.) + +The bootdev driver is provided by the media devices. The bindings for each +are described in this file (to come).
include/bootdev.h new file +258 -0
258 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -38,6 +38,7 @@ enum uclass_id {UCLASS_AXI ,/* AXI bus */ UCLASS_BLK ,/* Block device */ UCLASS_BOOTCOUNT ,/* Bootcount backing store */ +UCLASS_BOOTDEV ,/* Boot device for locating an OS to boot */ UCLASS_BOOTSTD ,/* Standard boot driver */ UCLASS_BUTTON ,/* Button */ UCLASS_CACHE, /* Cache controller */
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 22/41 bootstd: Add the bootmeth uclass and helpers
In reply to Simon GlassA bootmeth is a method of locating an operating system. For now, just add the uclass itself. Drivers for particular bootmeths are added later.
If no bootmeths devices are included in the devicetree, create them automatically. This avoids the need for boilerplate in the devicetree files.
---
(no changes since v1)
MAINTAINERS | 2 + boot/Makefile | 1 + boot/bootmeth-uclass.c | 59 ++++++++++++++++ boot/bootstd-uclass.c | 29 +++++++- include/bootmeth.h | 156 +++++++++++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + 6 files changed, 246 insertions(+), 2 deletions(-) create mode 100644 boot/bootmeth-uclass.c create mode 100644 include/bootmeth.h
MAINTAINERS +2 -0
@@ -636,10 +636,12 @@ F: tools/binman/ BOOTDEVICE M: Simon Glass <[email protected]> S: Maintained +F: boot/bootmeth*.c F: boot/bootdev*.c F: boot/bootstd.c F: include/bootdev*.h F: include/bootflow.h +F: include/bootmeth.h F: include/bootstd.h BTRFS
boot/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_ANDROID_AB) += android_ab.o obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootdev-uclass.o +obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootmeth-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o
boot/bootmeth-uclass.c new file +59 -0
59 lines not on this page · raw message
boot/bootstd-uclass.c +27 -2
@@ -102,8 +102,10 @@ static int bootstd_probe(struct udevice *dev)/* For now, bind the boormethod device if none are found in the devicetree */ int dm_scan_other (bool pre_reloc_only) { -struct udevice *bootstd; -int ret; + struct driver *drv = ll_entry_start(struct driver, driver); + const int n_ents = ll_entry_count(struct driver, driver); +struct udevice *dev, *bootstd; +int i, ret;/* These are not needed before relocation */ if (!(gd->flags &GD_FLG_RELOC ))
@@ -118,6 +120,29 @@ int dm_scan_other(bool pre_reloc_only)return log_msg_ret ("bootstd" , ret); } +/* If there are no bootmeth devices, create them */ +uclass_find_first_device (UCLASS_BOOTMETH , &dev); +if (dev) +return 0 ; + +for (i =0 ; i < n_ents; i++, drv++) { +/* +* Disable EFI Manager for now as no one uses it so it is +* confusing +*/ +if (drv->id ==UCLASS_BOOTMETH && +strcmp ("efi_mgr_bootmeth" , drv->name)) { +const char *name = drv->name; + +if (!strncmp ("bootmeth_" , name,9 )) + name +=9 ; + ret =device_bind (bootstd, drv, name,0 ,ofnode_null (), + &dev);if (ret) + +return log_msg_ret ("meth" , ret); + } + } +return 0 ; }
include/bootmeth.h new file +156 -0
156 lines not on this page · raw message
include/dm/uclass-id.h +1 -0
@@ -39,6 +39,7 @@ enum uclass_id {UCLASS_BLK ,/* Block device */ UCLASS_BOOTCOUNT ,/* Bootcount backing store */ UCLASS_BOOTDEV ,/* Boot device for locating an OS to boot */ +UCLASS_BOOTMETH ,/* Bootmethod for booting an OS */ UCLASS_BOOTSTD ,/* Standard boot driver */ UCLASS_BUTTON ,/* Button */ UCLASS_CACHE, /* Cache controller */
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 23/41 bootstd: Add support for bootflows
In reply to Simon GlassAdd support for bootflows, including maintaining a list of them and iterating to find them.
---
(no changes since v1)
MAINTAINERS | 3 +- boot/Makefile | 1 + boot/bootdev-uclass.c | 12 +- boot/bootflow.c | 576 ++++++++++++++++++++++++++++++++++++++++++ boot/bootstd-uclass.c | 2 +- include/bootflow.h | 50 ++++ 6 files changed, 640 insertions(+), 4 deletions(-) create mode 100644 boot/bootflow.c
MAINTAINERS +2 -1
@@ -636,8 +636,9 @@ F: tools/binman/ BOOTDEVICE M: Simon Glass <[email protected]> S: Maintained -F: boot/bootmeth*.c F: boot/bootdev*.c +F: boot/bootflow.c +F: boot/bootmeth*.c F: boot/bootstd.c F: include/bootdev*.h F: include/bootflow.h
boot/Makefile +1 -0
@@ -24,6 +24,7 @@ obj-$(CONFIG_ANDROID_AB) += android_ab.o obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootdev-uclass.o +obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootmeth-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o
boot/bootdev-uclass.c +10 -2
@@ -8,6 +8,7 @@#include <dm.h> #include <bootdev.h> #include <bootflow.h> +#include <bootmeth.h> #include <bootstd.h> #include <fs.h> #include <log.h>
@@ -121,9 +122,12 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk,if (!bflow->name)return log_msg_ret ("name" , -ENOMEM ); - bflow->state =BOOTFLOWST_BASE ; bflow->part = iter->part; + ret =bootmeth_check (bflow->method, iter); +if (ret) +return log_msg_ret ("check" , ret); +/* * partition numbers start at 0 so this cannot succeed, but it can tell * us whether there is valid media there
@@ -165,6 +169,10 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, bflow->state =BOOTFLOWST_FS ; } + ret =bootmeth_read_bootflow (bflow->method, bflow); +if (ret) +return log_msg_ret ("method" , ret); +return 0 ; }
@@ -401,7 +409,7 @@ void bootdev_clear_bootflows(struct udevice *dev) bflow = list_first_entry(&ucp->bootflow_head, struct bootflow, bm_node); -/* later bootflow_remove(bflow); */ +bootflow_remove (bflow); } }
boot/bootflow.c new file +576 -0
576 lines not on this page · raw message
boot/bootstd-uclass.c +1 -1
@@ -38,7 +38,7 @@ static void bootstd_clear_glob_(struct bootstd_priv *priv) bflow = list_first_entry(&priv->glob_head, struct bootflow, glob_node); -/* add later bootflow_remove(bflow); */ +bootflow_remove (bflow); } }
include/bootflow.h +50 -0
60 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 23/41] bootstd: Add support for bootflows
Hi Simon,
Quoted 1 line
+
[...]
boot/bootflow.c line 31
Quoted 13 lines
boot/bootflow.c new file +13
-0+/* error codes used to signal running out of things */ +enum { +BF_NO_MORE_PARTS = -ESHUTDOWN , +BF_NO_MORE_DEVICES = -ENODEV , +}; + +static const char *const bootflow_state[BOOTFLOWST_COUNT ] = { +"base" , +"media" , +"part" , +"fs" , +"file" , +"ready" ,
I can understand 'ready' as a boot state. What are the rest supposed to be ?
boot/bootflow.c line 37
Quoted 6 lines
boot/bootflow.c new file +6
-0+}; + +const char *bootflow_state_get_name (enum bootflow_state_t state) +{ +if (state <0 || state >=BOOTFLOWST_COUNT ) +return "?" ;
s/?/Unknown/ or invalid maybe?
boot/bootflow.c line 44
Quoted 7 lines
boot/bootflow.c new file +7
-0+ +return bootflow_state[state]; +} + +int bootflow_first_glob (struct bootflow **bflowp) +{ +struct bootstd_priv *std;
[...]
Regards
/Ilias
Re: [PATCH v2 23/41] bootstd: Add support for bootflows
Hi Ilias,
Quoted 7 lines · Ilias Apalodimas
Hi Simon,
Quoted 1 line
+
[...]
Quoted 16 lines
boot/bootflow.c line 31
Quoted 13 lines
boot/bootflow.c new file +13
-0+/* error codes used to signal running out of things */ +enum { +BF_NO_MORE_PARTS = -ESHUTDOWN , +BF_NO_MORE_DEVICES = -ENODEV , +}; + +static const char *const bootflow_state[BOOTFLOWST_COUNT ] = { +"base" , +"media" , +"part" , +"fs" , +"file" , +"ready" ,I can understand 'ready' as a boot state. What are the rest supposed to be ?
These are documented in the header file.
Quoted 9 lines
boot/bootflow.c line 37
Quoted 7 lines
boot/bootflow.c new file +6
-0+}; + +const char *bootflow_state_get_name (enum bootflow_state_t state) +{ +if (state <0 || state >=BOOTFLOWST_COUNT ) +return "?" ;s/?/Unknown/ or invalid maybe?
This is an invalid state so should not happen. Tom is pushing for the minimum possible code size so it doesn't seem worth putting a user-friendly error for a case that can't happen.
Quoted 13 lines
boot/bootflow.c line 44
Quoted 8 lines
boot/bootflow.c new file +7
-0+ +return bootflow_state[state]; +} + +int bootflow_first_glob (struct bootflow **bflowp) +{ +struct bootstd_priv *std;[...]
Regards
/Ilias
PATCH v2 24/41 bootstd: Add a bootdev command
In reply to Simon GlassAdd a 'bootdev' command to handle listing and selection of bootdevs.
Disable standard boot for a few boards which otherwise run out of space.
---
(no changes since v1)
MAINTAINERS | 1 + cmd/Kconfig | 8 ++ cmd/Makefile | 1 + cmd/bootdev.c | 120 +++++++++++++++++++++++++++++ configs/amcore_defconfig | 1 + configs/rcar3_salvator-x_defconfig | 1 + configs/tbs2910_defconfig | 1 + 7 files changed, 133 insertions(+) create mode 100644 cmd/bootdev.c
MAINTAINERS +1 -0
@@ -640,6 +640,7 @@ F: boot/bootdev*.c F: boot/bootflow.c F: boot/bootmeth*.c F: boot/bootstd.c +F: cmd/bootdev.c F: include/bootdev*.h F: include/bootflow.h F: include/bootmeth.h
cmd/Kconfig +8 -0
@@ -194,6 +194,14 @@ config CMD_BOOTM help Boot an application image from the memory. +config CMD_BOOTSTD + bool "bootdev" + depends on BOOTSTD + default y + help + Support working with standard boot, including listing available + bootdevs and showing information about a particular one. + config BOOTM_EFI bool "Support booting UEFI FIT images" depends on CMD_BOOTEFI && CMD_BOOTM && FIT
cmd/Makefile +1 -0
@@ -19,6 +19,7 @@ obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o obj-$(CONFIG_CMD_ADC) += adc.o obj-$(CONFIG_CMD_ARMFLASH) += armflash.o obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_common.o +obj-$(CONFIG_CMD_BOOTSTD) += bootdev.o obj-$(CONFIG_CMD_SOURCE) += source.o obj-$(CONFIG_CMD_BCB) += bcb.o obj-$(CONFIG_CMD_BDI) += bdinfo.o
cmd/bootdev.c new file +120 -0
120 lines not on this page · raw message
configs/amcore_defconfig +1 -0
@@ -7,6 +7,7 @@ CONFIG_SYS_MALLOC_LEN=0x100000 CONFIG_DEFAULT_DEVICE_TREE="amcore" CONFIG_TARGET_AMCORE=y CONFIG_SYS_LOAD_ADDR=0x20000 +# CONFIG_BOOTSTD is not set CONFIG_BOOTDELAY=1 CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set
configs/rcar3_salvator-x_defconfig +1 -0
@@ -11,6 +11,7 @@ CONFIG_RCAR_GEN3=y CONFIG_TARGET_SALVATOR_X=y CONFIG_SYS_LOAD_ADDR=0x58000000 CONFIG_FIT=y +# CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_USE_BOOTARGS=y CONFIG_DEFAULT_FDT_FILE="r8a77950-salvator-x.dtb"
configs/tbs2910_defconfig +1 -0
@@ -14,6 +14,7 @@ CONFIG_DEFAULT_DEVICE_TREE="imx6q-tbs2910" CONFIG_PRE_CON_BUF_ADDR=0x7c000000 CONFIG_CMD_HDMIDETECT=y CONFIG_AHCI=y +# CONFIG_BOOTSTD is not set CONFIG_SUPPORT_RAW_INITRD=y CONFIG_BOOTDELAY=3 CONFIG_USE_BOOTCOMMAND=y
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 25/41 bootstd: Add a bootflow ommand
In reply to Simon GlassAdd a 'bootflow' command to handle listing and selection of bootflow.
---
(no changes since v1)
cmd/Kconfig | 10 +- cmd/Makefile | 2 +- cmd/bootflow.c | 386 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 395 insertions(+), 3 deletions(-) create mode 100644 cmd/bootflow.c
cmd/Kconfig +8 -2
@@ -195,12 +195,18 @@ config CMD_BOOTM Boot an application image from the memory. config CMD_BOOTSTD - bool "bootdev" + bool "bootdev, bootflow" depends on BOOTSTD default y help Support working with standard boot, including listing available - bootdevs and showing information about a particular one. + bootdevs and showing information about a particular one. It also + allows scanning for bootflows available with the bootdev. + + This enables the following commands: + + bootdev + bootflow config BOOTM_EFI bool "Support booting UEFI FIT images"
cmd/Makefile +1 -1
@@ -19,7 +19,7 @@ obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o obj-$(CONFIG_CMD_ADC) += adc.o obj-$(CONFIG_CMD_ARMFLASH) += armflash.o obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_common.o -obj-$(CONFIG_CMD_BOOTSTD) += bootdev.o +obj-$(CONFIG_CMD_BOOTSTD) += bootdev.o bootflow.o obj-$(CONFIG_CMD_SOURCE) += source.o obj-$(CONFIG_CMD_BCB) += bcb.o obj-$(CONFIG_CMD_BDI) += bdinfo.o
cmd/bootflow.c new file +386 -0
386 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 26/41 bootstd: Add a bootmeth command
In reply to Simon GlassAdd a 'bootmeth' command to handle listing and ordering of boot methods.
---
(no changes since v1)
cmd/Kconfig | 3 +- cmd/Makefile | 2 +- cmd/bootmeth.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 cmd/bootmeth.c
cmd/Kconfig +2 -1
@@ -195,7 +195,7 @@ config CMD_BOOTM Boot an application image from the memory. config CMD_BOOTSTD - bool "bootdev, bootflow" + bool "bootdev, bootflow, bootmeth" depends on BOOTSTD default y help
@@ -207,6 +207,7 @@ config CMD_BOOTSTD bootdev bootflow + bootmeth config BOOTM_EFI bool "Support booting UEFI FIT images"
cmd/Makefile +1 -1
@@ -19,7 +19,7 @@ obj-$(CONFIG_CMD_AB_SELECT) += ab_select.o obj-$(CONFIG_CMD_ADC) += adc.o obj-$(CONFIG_CMD_ARMFLASH) += armflash.o obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_common.o -obj-$(CONFIG_CMD_BOOTSTD) += bootdev.o bootflow.o +obj-$(CONFIG_CMD_BOOTSTD) += bootdev.o bootflow.o bootmeth.o obj-$(CONFIG_CMD_SOURCE) += source.o obj-$(CONFIG_CMD_BCB) += bcb.o obj-$(CONFIG_CMD_BDI) += bdinfo.o
cmd/bootmeth.c new file +158 -0
158 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 27/41 bootstd: Add an implementation of distro boot
In reply to Simon GlassAdd a bootmeth driver which handles distro boot from a disk, so we can boot a bootflow using this commonly used mechanism.
In effect, this provides the same functionality as the 'sysboot' command and shares the same code. But the interface into it is via a bootmeth.
For now this requires the 'pxe' command be enabled. Future work may tidy this up so that it can be used without CONFIG_CMDLINE being enabled.
---
(no changes since v1)
MAINTAINERS | 3 +- boot/Kconfig | 15 +++ boot/Makefile | 2 + boot/bootmeth_distro.c | 217 +++++++++++++++++++++++++++++++++++++++++ include/distro.h | 24 +++++ 5 files changed, 260 insertions(+), 1 deletion(-) create mode 100644 boot/bootmeth_distro.c create mode 100644 include/distro.h
MAINTAINERS +2 -1
@@ -641,7 +641,8 @@ F: boot/bootflow.c F: boot/bootmeth*.c F: boot/bootstd.c F: cmd/bootdev.c -F: include/bootdev*.h +F: cmd/bootflow.c +F: include/bootdev.h F: include/bootflow.h F: include/bootmeth.h F: include/bootstd.h
boot/Kconfig +15 -0
@@ -295,6 +295,21 @@ config BOOTSTD U-Boot) - bootflow - a description of how to boot (owned by the distro) +if BOOTSTD + +config BOOTMETH_DISTRO + bool "Bootdev support for distro boot" + depends on CMD_PXE + default y + help + Enables support for distro boot using bootdevs. This makes the + bootdevs look for a 'extlinux/extlinux.conf' on each filesystem + they scan. + + This provides a way to try out standard boot on an existing boot flow. + +endif + config LEGACY_IMAGE_FORMAT bool "Enable support for the legacy image format" default y if !FIT_SIGNATURE
boot/Makefile +2 -0
@@ -28,6 +28,8 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootmeth-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o + obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o obj-$(CONFIG_$(SPL_TPL_)FIT) += image-fit.o
boot/bootmeth_distro.c new file +217 -0
217 lines not on this page · raw message
include/distro.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#ifndef __distro_h +#define __distro_h + +#define DISTRO_FNAME "extlinux/extlinux.conf" + +/** +* struct distro_info - useful information for distro_getfile() +* +* @dev: bootmethod device being used to boot +* @bflow: bootflow being booted +*/ +struct distro_info { +struct udevice *dev; +struct bootflow *bflow; +struct cmd_tbl *cmdtp; +}; + +#endif
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 28/41 bootstd: mmc: Add a bootdev driver
In reply to Simon GlassAdd a bootdev driver for MMC. It mostly just calls the bootdev helper function.
Add a function to obtain the block device for an MMC controller.
Fix up the comment for mmc_get_blk_desc() while we are here.
---
(no changes since v1)
MAINTAINERS | 1 + drivers/mmc/Makefile | 5 ++++ drivers/mmc/mmc-uclass.c | 23 +++++++++++++++ drivers/mmc/mmc_bootdev.c | 62 +++++++++++++++++++++++++++++++++++++++ include/mmc.h | 12 +++++++- 5 files changed, 102 insertions(+), 1 deletion(-) create mode 100644 drivers/mmc/mmc_bootdev.c
MAINTAINERS +1 -0
@@ -642,6 +642,7 @@ F: boot/bootmeth*.c F: boot/bootstd.c F: cmd/bootdev.c F: cmd/bootflow.c +F: drivers/mmc/mmc_bootdev.c F: include/bootdev.h F: include/bootflow.h F: include/bootmeth.h
drivers/mmc/Makefile +5 -0
@@ -5,6 +5,11 @@ obj-y += mmc.o obj-$(CONFIG_$(SPL_)DM_MMC) += mmc-uclass.o + +ifdef CONFIG_$(SPL_TPL_)DM_MMC +obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += mmc_bootdev.o +endif + obj-$(CONFIG_$(SPL_)MMC_WRITE) += mmc_write.o obj-$(CONFIG_MMC_PWRSEQ) += mmc-pwrseq.o obj-$(CONFIG_MMC_SDHCI_ADMA_HELPERS) += sdhci-adma.o
drivers/mmc/mmc-uclass.c +23 -0
@@ -8,6 +8,7 @@#define LOG_CATEGORY UCLASS_MMC#include <common.h> +#include <bootdev.h> #include <log.h> #include <mmc.h> #include <dm.h>
@@ -315,6 +316,20 @@ int mmc_get_next_devnum(void)return blk_find_max_devnum (IF_TYPE_MMC ); } +int mmc_get_blk (struct udevice *dev,struct udevice **blkp) +{ +struct udevice *blk; +int ret; + +device_find_first_child_by_uclass (dev,UCLASS_BLK , &blk); + ret =device_probe (blk); +if (ret) +return ret; + *blkp = blk; + +return 0 ; +} +struct blk_desc *mmc_get_blk_desc (struct mmc *mmc) {struct blk_desc *desc;
@@ -406,6 +421,10 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg) mmc->cfg = cfg; mmc->priv = dev; + ret =bootdev_setup_for_dev (dev,"mmc_bootdev" ); +if (ret) +return log_msg_ret ("bootdev" , ret); +/* the following chunk was from mmc_register() */ /* Setup dsr related values */
@@ -424,12 +443,16 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const struct mmc_config *cfg)int mmc_unbind (struct udevice *dev) {struct udevice *bdev; +int ret;device_find_first_child_by_uclass (dev,UCLASS_BLK , &bdev);if (bdev) {device_remove (bdev,DM_REMOVE_NORMAL );device_unbind (bdev); } + ret =bootdev_unbind_dev (dev); +if (ret) +return log_msg_ret ("bootdev" , ret);return 0 ; }
drivers/mmc/mmc_bootdev.c new file +62 -0
62 lines not on this page · raw message
include/mmc.h +11 -1
@@ -961,10 +961,20 @@ int mmc_get_env_dev(void);* mmc_get_blk_desc() - Get the block descriptor for an MMC device * * @mmc: MMC device -* @return block device if found, else NULL +* @return block descriptor if found, else NULL */ struct blk_desc *mmc_get_blk_desc (struct mmc *mmc); +/** +* mmc_get_blk() - Get the block device for an MMC device +* +* @dev: MMC device +* @blkp: Returns pointer to probed block device on sucesss +* +* @return 0 on success, -ve on error +*/ +int mmc_get_blk (struct udevice *dev,struct udevice **blkp); +/** * mmc_send_ext_csd() - read the extended CSD register *
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 29/41 bootstd: ethernet: Add a bootdev driver
In reply to Simon GlassAdd a bootdev driver for Ethernet. It can use the PXE boot mechanism to locate a file, added later.
---
(no changes since v1)
MAINTAINERS | 1 + net/Kconfig | 9 +++++ net/Makefile | 1 + net/eth-uclass.c | 8 ++++ net/eth_bootdev.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 120 insertions(+) create mode 100644 net/eth_bootdev.c
MAINTAINERS +1 -0
@@ -647,6 +647,7 @@ F: include/bootdev.h F: include/bootflow.h F: include/bootmeth.h F: include/bootstd.h +F: net/eth_bootdevice.c BTRFS M: Marek Behun <[email protected]>
net/Kconfig +9 -0
@@ -14,6 +14,15 @@ config PROT_UDP Enable a generic udp framework that allows defining a custom handler for udp protocol. +config BOOTDEV_ETH + bool "Enable bootdev for ethernet" + depends on BOOTSTD + default y + help + Provide a bootdev for ethernet so that is it possible to boot + an operationg system over the network, using the PXE (Preboot + Execution Environment) protocol. + config BOOTP_SEND_HOSTNAME bool "Send hostname to DNS server" help
net/Makefile +1 -0
@@ -12,6 +12,7 @@ obj-$(CONFIG_CMD_DNS) += dns.o obj-$(CONFIG_DM_DSA) += dsa-uclass.o ifdef CONFIG_DM_ETH obj-$(CONFIG_NET) += eth-uclass.o +obj-$(CONFIG_$(SPL_TPL_)BOOTDEV_ETH) += eth_bootdev.o else obj-$(CONFIG_NET) += eth_legacy.o endif
net/eth-uclass.c +8 -0
@@ -8,6 +8,7 @@#define LOG_CATEGORY UCLASS_ETH#include <common.h> +#include <bootdev.h> #include <bootstage.h> #include <dm.h> #include <env.h>
@@ -473,6 +474,8 @@ int eth_initialize(void)static int eth_post_bind (struct udevice *dev) { +int ret; +if (strchr (dev->name,' ' )) {printf ("\nError: eth device name \"%s\" has a space!\n" , dev->name);
@@ -482,6 +485,11 @@ static int eth_post_bind(struct udevice *dev)#ifdef CONFIG_DM_ETH_PHY eth_phy_binds_nodes (dev);#endif +if (CONFIG_IS_ENABLED (BOOTDEV_ETH )) { + ret =bootdev_setup_for_dev (dev,"eth_bootdev" ); +if (ret) +return log_msg_ret ("bootdev" , ret); + }return 0 ; }
net/eth_bootdev.c new file +101 -0
101 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 30/41 bootstd: Add an implementation of distro PXE boot
In reply to Simon GlassAdd a bootmeth driver which handles distro boot from a network device, so we can boot a bootflow using this commonly used mechanism.
In effect, this provides the same functionality as the 'pxe' command and shares the same code. But the interface into it is via a bootmeth.
For now this requires the 'pxe' command be enabled. Future work may tidy this up so that it can be used without CONFIG_CMDLINE being enabled.
---
(no changes since v1)
boot/Kconfig | 10 +++ boot/Makefile | 1 + boot/bootmeth_pxe.c | 183 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 boot/bootmeth_pxe.c
boot/Kconfig +10 -0
@@ -308,6 +308,16 @@ config BOOTMETH_DISTRO This provides a way to try out standard boot on an existing boot flow. +config BOOTMETH_DISTRO_PXE + bool "Bootdev support for distro boot over network" + depends on CMD_PXE && CMD_NET && DM_ETH + default y + help + Enables support for distro boot using bootdevs. This makes the + bootdevs look for a 'extlinux/extlinux.conf' on the tftp server. + + This provides a way to try out standard boot on an existing boot flow. + endif config LEGACY_IMAGE_FORMAT
boot/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootmeth-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) += bootmeth_pxe.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
boot/bootmeth_pxe.c new file +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 31/41 bootstd: Add an implementation of EFI boot
In reply to Simon GlassAdd a bootmeth driver which handles EFI boot, using EFI_LOADER.
In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without CONFIG_CMDLINE being enabled.
---
(no changes since v1)
boot/Kconfig | 21 ++++ boot/Makefile | 1 + boot/bootmeth_efi.c | 263 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+) create mode 100644 boot/bootmeth_efi.c
boot/Kconfig +21 -0
@@ -318,6 +318,27 @@ config BOOTMETH_DISTRO_PXE This provides a way to try out standard boot on an existing boot flow. +config BOOTMETH_EFILOADER + bool "Bootdev support for EFI boot" + depends on CMD_BOOTEFI + default y + help + Enables support for EFI boot using bootdevs. This makes the + bootdevs look for a 'boot<arch>.efi' on each filesystem + they scan. The resulting file is booted after enabling U-Boot's + EFI loader support. + + The <arch> depends on the architecture of the board: + + aa64 - aarch64 (ARM 64-bit) + arm - ARM 32-bit + ia32 - x86 32-bit + x64 - x86 64-bit + riscv32 - RISC-V 32-bit + riscv64 - RISC-V 64-bit + + This provides a way to try out standard boot on an existing boot flow. + endif config LEGACY_IMAGE_FORMAT
boot/Makefile +1 -0
@@ -30,6 +30,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) += bootmeth_pxe.o +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
boot/bootmeth_efi.c new file +263 -0
263 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Hi Simon,
Quoted 9 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.
I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
Regards
/Ilias
Quoted 328 lines
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
boot/Kconfig | 21 ++++ boot/Makefile | 1 + boot/bootmeth_efi.c | 263 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+) create mode 100644 boot/bootmeth_efi.cboot/Kconfig +21
-0@@ -318,6 +318,27 @@ config BOOTMETH_DISTRO_PXE This provides a way to try out standard boot on an existing boot flow. +config BOOTMETH_EFILOADER + bool "Bootdev support for EFI boot" + depends on CMD_BOOTEFI + default y + help + Enables support for EFI boot using bootdevs. This makes the + bootdevs look for a 'boot<arch>.efi' on each filesystem + they scan. The resulting file is booted after enabling U-Boot's + EFI loader support. + + The <arch> depends on the architecture of the board: + + aa64 - aarch64 (ARM 64-bit) + arm - ARM 32-bit + ia32 - x86 32-bit + x64 - x86 64-bit + riscv32 - RISC-V 32-bit + riscv64 - RISC-V 64-bit + + This provides a way to try out standard boot on an existing boot flow. + endif config LEGACY_IMAGE_FORMATboot/Makefile +1
-0@@ -30,6 +30,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) += bootmeth_pxe.o +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.oboot/bootmeth_efi.c new file +263
-1@@ -0,0 +1,263 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Bootmethod for distro boot via EFI +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#include <common.h> +#include <bootdev.h> +#include <bootflow.h> +#include <bootmeth.h> +#include <command.h> +#include <dm.h> +#include <efi_loader.h> +#include <fs.h> +#include <malloc.h> +#include <mapmem.h> +#include <mmc.h> +#include <pxe_utils.h> + +#define EFI_DIRNAME "efi/boot/" + +/** +* get_efi_leafname() - Get the leaf name for the EFI file we expect +* +* @str: Place to put leaf name for this architecture, e.g. "bootaa64.efi". +* Must have at least 16 bytes of space +* @max_len: Length of @str, must be >=16 +*/ +static int get_efi_leafname (char *str,int max_len) +{ +const char *base; + +if (max_len <16 ) +return log_msg_ret ("spc" , -ENOSPC ); +if (IS_ENABLED (CONFIG_ARM64 )) + base ="bootaa64" ; +else if (IS_ENABLED (CONFIG_ARM )) + base ="bootarm" ; +else if (IS_ENABLED (CONFIG_X86_RUN_32BIT )) + base ="bootia32" ; +else if (IS_ENABLED (CONFIG_X86_RUN_64BIT )) + base ="bootx64" ; +else if (IS_ENABLED (CONFIG_ARCH_RV32I )) + base ="bootriscv32" ; +else if (IS_ENABLED (CONFIG_ARCH_RV64I )) + base ="bootriscv64" ; +else if (IS_ENABLED (CONFIG_SANDBOX )) + base ="bootsbox" ; +else +return -EINVAL ; + +strcpy (str, base); +strcat (str,".efi" ); + +return 0 ; +} + +static int efiload_read_file (struct blk_desc *desc,struct bootflow *bflow) +{ +const struct udevice *media_dev; +int size = bflow->size; +char devnum_str[9 ]; +char dirname[200 ]; +loff_t bytes_read; +char *last_slash; +ulong addr; +char *buf; +int ret; + +/* Sadly FS closes the file after fs_size() so we must redo this */ + ret =fs_set_blk_dev_with_part (desc, bflow->part); +if (ret) +return log_msg_ret ("set" , ret); + + buf =malloc (size +1 ); +if (!buf) +return log_msg_ret ("buf" , -ENOMEM ); + addr =map_to_sysmem (buf); + + ret =fs_read (bflow->fname, addr,0 ,0 , &bytes_read); +if (ret) { +free (buf); +return log_msg_ret ("read" , ret); + } +if (size != bytes_read) +return log_msg_ret ("bread" , -EINVAL ); + buf[size] ='\0' ; + bflow->state =BOOTFLOWST_READY ; + bflow->buf = buf; + +/* +* This is a horrible hack to tell EFI about this boot device. Once we +* unify EFI with the rest of U-Boot we can clean this up. The same hack +* exists in multiple places, e.g. in the fs, tftp and load commands. +* +* Once we can clean up the EFI code to make proper use of driver model, +* this can go away. +*/ + media_dev =dev_get_parent (bflow->dev); +snprintf (devnum_str,sizeof (devnum_str),"%x" ,dev_seq (media_dev)); + +strlcpy (dirname, bflow->fname,sizeof (dirname)); + last_slash =strrchr (dirname,'/' ); +if (last_slash) + *last_slash ='\0' ; + +efi_set_bootdev (dev_get_uclass_name (media_dev), devnum_str, dirname, + bflow->buf, size); + +return 0 ; +} + +static int distro_efi_check (struct udevice *dev,struct bootflow_iter *iter) +{ +int ret; + +/* This only works on block devices */ + ret =bootflow_iter_uses_blk_dev (iter); +if (ret) +return log_msg_ret ("blk" , ret); + +return 0 ; +} + +static int distro_efi_read_bootflow (struct udevice *dev,struct bootflow *bflow) +{ +struct blk_desc *desc =dev_get_uclass_plat (bflow->blk); +char fname[sizeof (EFI_DIRNAME ) +16 ]; +loff_t size; +int ret; + +/* We require a partition table */ +if (!bflow->part) +return -ENOENT ; + +strcpy (fname,EFI_DIRNAME ); + ret =get_efi_leafname (fname +strlen (fname), +sizeof (fname) -strlen (fname)); +if (ret) +return log_msg_ret ("leaf" , ret); + + bflow->fname =strdup (fname); +if (!bflow->fname) +return log_msg_ret ("name" , -ENOMEM ); + ret =fs_size (bflow->fname, &size); + bflow->size = size; +if (ret) +return log_msg_ret ("size" , ret); + bflow->state =BOOTFLOWST_FILE ; +log_debug (" - distro file size %x\n" , (uint )size); +if (size >0x2000000 ) +return log_msg_ret ("chk" , -E2BIG ); + + ret =efiload_read_file (desc, bflow); +if (ret) +return log_msg_ret ("read" , -EINVAL ); + +return 0 ; +} + +static int distro_efi_read_file (struct udevice *dev,struct bootflow *bflow, +const char *file_path,ulong addr,ulong *sizep) +{ +struct blk_desc *desc =dev_get_uclass_plat (bflow->blk); +const struct udevice *media_dev; +int size = bflow->size; +char devnum_str[9 ]; +char dirname[200 ]; +loff_t bytes_read; +char *last_slash; +char *buf; +int ret; + +/* Sadly FS closes the file after fs_size() so we must redo this */ + ret =fs_set_blk_dev_with_part (desc, bflow->part); +if (ret) +return log_msg_ret ("set" , ret); + + buf =malloc (size +1 ); +if (!buf) +return log_msg_ret ("buf" , -ENOMEM ); + addr =map_to_sysmem (buf); + + ret =fs_read (bflow->fname, addr,0 ,0 , &bytes_read); +if (ret) { +free (buf); +return log_msg_ret ("read" , ret); + } +if (size != bytes_read) +return log_msg_ret ("bread" , -EINVAL ); + buf[size] ='\0' ; + bflow->state =BOOTFLOWST_READY ; + bflow->buf = buf; + +/* +* This is a horrible hack to tell EFI about this boot device. Once we +* unify EFI with the rest of U-Boot we can clean this up. The same hack +* exists in multiple places, e.g. in the fs, tftp and load commands. +* +* Once we can clean up the EFI code to make proper use of driver model, +* this can go away. +*/ + media_dev =dev_get_parent (bflow->dev); +snprintf (devnum_str,sizeof (devnum_str),"%x" ,dev_seq (media_dev)); + +strlcpy (dirname, bflow->fname,sizeof (dirname)); + last_slash =strrchr (dirname,'/' ); +if (last_slash) + *last_slash ='\0' ; + +efi_set_bootdev (dev_get_uclass_name (media_dev), devnum_str, dirname, + bflow->buf, size); + +return 0 ; +} + +int distro_efi_boot (struct udevice *dev,struct bootflow *bflow) +{ +char cmd[50 ]; + +/* +* At some point we can add a real interface to bootefi so we can call +* this directly. For now, go through the CLI like distro boot. +*/ +snprintf (cmd,sizeof (cmd),"bootefi %lx %lx" , + (ulong )map_to_sysmem (bflow->buf), + (ulong )map_to_sysmem (gd->fdt_blob)); +if (run_command (cmd,0 )) +return log_msg_ret ("run" , -EINVAL ); + +return 0 ; +} + +static int distro_bootmeth_efi_bind (struct udevice *dev) +{ +struct bootmeth_uc_plat *plat =dev_get_uclass_plat (dev); + + plat->desc ="EFI boot from a .efi file" ; + +return 0 ; +} + +static struct bootmeth_ops distro_efi_bootmeth_ops = { + .check = distro_efi_check, + .read_bootflow = distro_efi_read_bootflow, + .read_file = distro_efi_read_file, + .boot = distro_efi_boot, +}; + +static const struct udevice_id distro_efi_bootmeth_ids[] = { + { .compatible ="u-boot,distro-efi" }, + { } +}; + +U_BOOT_DRIVER (bootmeth_efi) = { + .name ="bootmeth_efi" , + .id =UCLASS_BOOTMETH , + .of_match = distro_efi_bootmeth_ids, + .ops = &distro_efi_bootmeth_ops, + .bind = distro_bootmeth_efi_bind, +}; --2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 7 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
This is needed so that EFI boot is actually invoked. If bootmgr starts being used then it can still be invoked from standard boot. The point is that there is a standard way of booting that supports EFI and other things.
This series is about replacing the scripts we currently have with a proper C implementation that uses driver model.
Quoted 3 lines
Regards
/Ilias
[..]
Regards,
Simon
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Hi Simon,
Quoted 24 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 7 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
Quoted 4 lines
This is needed so that EFI boot is actually invoked. If bootmgr starts being used then it can still be invoked from standard boot. The point is that there is a standard way of booting that supports EFI and other things.
This patch tries to reason about the default naming EFI imposes on it's boot files. distro_efi_read_bootflow() will try to find files following the EFI naming convention (e.g bootaarch64.efi, bootarm.efi etc). If those are found it will try to boot them right? That's not the right thing to do though. On the EFI spec these files are tried if no Boot#### variables are found. So we can get rid of this entirely, add a dummy entry on the bootflow that says 'boot the efi manager' (which is what the next patch does).
The efibootmgr then will check Boot#### variables and if none are found, it's going to fallback into loading bootaarch64.efi, bootarm.efi etc essentially offering identical functionality.
Regards
/Ilias
Quoted 11 lines
This series is about replacing the scripts we currently have with a proper C implementation that uses driver model.
Quoted 3 lines
Regards
/Ilias[..]
Regards,
Simon
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Hi Ilias,
Quoted 41 lines · Ilias Apalodimas
Hi Simon,
Quoted 24 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 7 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
Quoted 4 lines
This is needed so that EFI boot is actually invoked. If bootmgr starts being used then it can still be invoked from standard boot. The point is that there is a standard way of booting that supports EFI and other things.
This patch tries to reason about the default naming EFI imposes on it's boot files.
distro_efi_read_bootflow()will try to find files following the EFI naming convention (e.g bootaarch64.efi, bootarm.efi etc). If those are found it will try to boot them right? That's not the right thing to do though. On the EFI spec these files are tried if no Boot#### variables are found. So we can get rid of this entirely, add a dummy entry on the bootflow that says 'boot the efi manager' (which is what the next patch does).
Quoted 3 lines
The efibootmgr then will check Boot#### variables and if none are found, it's going to fallback into loading bootaarch64.efi, bootarm.efi etc essentially offering identical functionality.
Yes that's fine, and when EFI's boot manager is in use I have a driver for that too, as you can see in the other patch. We may need to adjust the order, by the sound of it, if it needs to run before EFI things. But that is easy enough.
But we do need to provide the existing functionality for now, as I understand it.
Quoted 3 lines
Quoted 3 lines
This series is about replacing the scripts we currently have with a proper C implementation that uses driver model.
Regards,
Simon
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Quoted 45 lines · Simon Glass
Hi Ilias,
Quoted 41 lines · Ilias Apalodimas
Hi Simon,
Quoted 24 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 7 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
Quoted 4 lines
This is needed so that EFI boot is actually invoked. If bootmgr starts being used then it can still be invoked from standard boot. The point is that there is a standard way of booting that supports EFI and other things.
This patch tries to reason about the default naming EFI imposes on it's boot files.
distro_efi_read_bootflow()will try to find files following the EFI naming convention (e.g bootaarch64.efi, bootarm.efi etc). If those are found it will try to boot them right? That's not the right thing to do though. On the EFI spec these files are tried if no Boot#### variables are found. So we can get rid of this entirely, add a dummy entry on the bootflow that says 'boot the efi manager' (which is what the next patch does).
Quoted 9 lines
Quoted 3 lines
The efibootmgr then will check Boot#### variables and if none are found, it's going to fallback into loading bootaarch64.efi, bootarm.efi etc essentially offering identical functionality.
Yes that's fine, and when EFI's boot manager is in use I have a driver for that too, as you can see in the other patch. We may need to adjust the order, by the sound of it, if it needs to run before EFI things. But that is easy enough.
That's the point though. I don't want to have 2 different ways of booting EFI as I don't see any benefit. Do you?
Regards
/Ilias
Quoted 9 lines
But we do need to provide the existing functionality for now, as I understand it.
Quoted 3 lines
Quoted 3 lines
This series is about replacing the scripts we currently have with a proper C implementation that uses driver model.
Regards,
Simon
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Quoted 50 lines · Ilias Apalodimas
Quoted 49 lines · Simon Glass
Hi Ilias,
Quoted 44 lines · Ilias Apalodimas
Hi Simon,
Quoted 24 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 7 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
Quoted 4 lines
This is needed so that EFI boot is actually invoked. If bootmgr starts being used then it can still be invoked from standard boot. The point is that there is a standard way of booting that supports EFI and other things.
This patch tries to reason about the default naming EFI imposes on it's boot files.
distro_efi_read_bootflow()will try to find files following the EFI naming convention (e.g bootaarch64.efi, bootarm.efi etc). If those are found it will try to boot them right? That's not the right thing to do though. On the EFI spec these files are tried if no Boot#### variables are found. So we can get rid of this entirely, add a dummy entry on the bootflow that says 'boot the efi manager' (which is what the next patch does).The efibootmgr then will check Boot#### variables and if none are found, it's going to fallback into loading bootaarch64.efi, bootarm.efi etc essentially offering identical functionality.
Quoted 7 lines
Quoted 4 lines
Yes that's fine, and when EFI's boot manager is in use I have a driver for that too, as you can see in the other patch. We may need to adjust the order, by the sound of it, if it needs to run before EFI things. But that is easy enough.
That's the point though. I don't want to have 2 different ways of booting EFI as I don't see any benefit. Do you?
Unless we're saying that "bootefi bootmgr" is ready to be used always and without further pre-req support (which I don't think is quite the case, since we don't have persistent EFI vars, so can't set Boot### persistently or via userspace) _something_ is likely needed to either set those, or scan a configurable list of where, to find the EFI payload.
Signature · 1 line
Tom
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Hi Tom,
Quoted 60 lines · Tom Rini
Quoted 50 lines · Ilias Apalodimas
Quoted 49 lines · Simon Glass
Hi Ilias,
Quoted 44 lines · Ilias Apalodimas
Hi Simon,
Quoted 24 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 7 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
Quoted 4 lines
This is needed so that EFI boot is actually invoked. If bootmgr starts being used then it can still be invoked from standard boot. The point is that there is a standard way of booting that supports EFI and other things.
This patch tries to reason about the default naming EFI imposes on it's boot files.
distro_efi_read_bootflow()will try to find files following the EFI naming convention (e.g bootaarch64.efi, bootarm.efi etc). If those are found it will try to boot them right? That's not the right thing to do though. On the EFI spec these files are tried if no Boot#### variables are found. So we can get rid of this entirely, add a dummy entry on the bootflow that says 'boot the efi manager' (which is what the next patch does).The efibootmgr then will check Boot#### variables and if none are found, it's going to fallback into loading bootaarch64.efi, bootarm.efi etc essentially offering identical functionality.
Quoted 7 lines
Quoted 4 lines
Yes that's fine, and when EFI's boot manager is in use I have a driver for that too, as you can see in the other patch. We may need to adjust the order, by the sound of it, if it needs to run before EFI things. But that is easy enough.
That's the point though. I don't want to have 2 different ways of booting EFI as I don't see any benefit. Do you?
Quoted 6 lines
Unless we're saying that "bootefi bootmgr" is ready to be used always and without further pre-req support (which I don't think is quite the case, since we don't have persistent EFI vars, so can't set Boot### persistently or via userspace) _something_ is likely needed to either set those, or scan a configurable list of where, to find the EFI payload.
The efibootmgr will try to boot bootaa64.efi, bootarm.efi etc if Boot### variables are not found. The Boot#### themselves are obviously configurable from U-Boot(at boot time). Since this method doesn't allow Linux to edit the boot options either, is it something we need? Since distros usually name their SHIM as bootaa64.efi, I am afraid we are adding code that we will rarely (if at all) ever use.
Regards
/Ilias
Quoted 3 lines
--
Tom
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Quoted 70 lines · Ilias Apalodimas
Hi Tom,
Quoted 60 lines · Tom Rini
Quoted 50 lines · Ilias Apalodimas
Quoted 49 lines · Simon Glass
Hi Ilias,
Quoted 44 lines · Ilias Apalodimas
Hi Simon,
Quoted 24 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 7 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
Quoted 4 lines
This is needed so that EFI boot is actually invoked. If bootmgr starts being used then it can still be invoked from standard boot. The point is that there is a standard way of booting that supports EFI and other things.
This patch tries to reason about the default naming EFI imposes on it's boot files.
distro_efi_read_bootflow()will try to find files following the EFI naming convention (e.g bootaarch64.efi, bootarm.efi etc). If those are found it will try to boot them right? That's not the right thing to do though. On the EFI spec these files are tried if no Boot#### variables are found. So we can get rid of this entirely, add a dummy entry on the bootflow that says 'boot the efi manager' (which is what the next patch does).The efibootmgr then will check Boot#### variables and if none are found, it's going to fallback into loading bootaarch64.efi, bootarm.efi etc essentially offering identical functionality.
Quoted 7 lines
Quoted 4 lines
Yes that's fine, and when EFI's boot manager is in use I have a driver for that too, as you can see in the other patch. We may need to adjust the order, by the sound of it, if it needs to run before EFI things. But that is easy enough.
That's the point though. I don't want to have 2 different ways of booting EFI as I don't see any benefit. Do you?
Quoted 6 lines
Unless we're saying that "bootefi bootmgr" is ready to be used always and without further pre-req support (which I don't think is quite the case, since we don't have persistent EFI vars, so can't set Boot### persistently or via userspace) _something_ is likely needed to either set those, or scan a configurable list of where, to find the EFI payload.
Quoted 2 lines
The efibootmgr will try to boot bootaa64.efi, bootarm.efi etc if Boot### variables are not found.
To be clear, the current efibootmgr (or "bootefi bootmgr" command) doesn't have this feature. Instead, distro_bootcmd mimics it in some way. # I have an experimental patch to efibootmgr for the support, though.
Nevertheless,
Quoted 3 lines
The Boot#### themselves are
obviously configurable from U-Boot(at boot time). Since this method doesn't allow Linux to edit the boot options either,>
Yeah. Please remember that, even on normal PCs, specifying an order of boot devices (for "removable media" with the default path) is done through UEFI UI.
-Takahiro Akashi
Quoted 11 lines
is it something
we need? Since distros usually name their SHIM as bootaa64.efi, I am afraid we are adding code that we will rarely (if at all) ever use.Regards
/Ilias
Quoted 3 lines
--
Tom
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Quoted 72 lines · AKASHI Takahiro
Quoted 70 lines · Ilias Apalodimas
Hi Tom,
Quoted 66 lines · Tom Rini
Quoted 50 lines · Ilias Apalodimas
Quoted 49 lines · Simon Glass
Hi Ilias,
Quoted 44 lines · Ilias Apalodimas
Hi Simon,
Quoted 24 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 7 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
Quoted 4 lines
This is needed so that EFI boot is actually invoked. If bootmgr starts being used then it can still be invoked from standard boot. The point is that there is a standard way of booting that supports EFI and other things.
This patch tries to reason about the default naming EFI imposes on it's boot files.
distro_efi_read_bootflow()will try to find files following the EFI naming convention (e.g bootaarch64.efi, bootarm.efi etc). If those are found it will try to boot them right? That's not the right thing to do though. On the EFI spec these files are tried if no Boot#### variables are found. So we can get rid of this entirely, add a dummy entry on the bootflow that says 'boot the efi manager' (which is what the next patch does).The efibootmgr then will check Boot#### variables and if none are found, it's going to fallback into loading bootaarch64.efi, bootarm.efi etc essentially offering identical functionality.
Quoted 7 lines
Quoted 4 lines
Yes that's fine, and when EFI's boot manager is in use I have a driver for that too, as you can see in the other patch. We may need to adjust the order, by the sound of it, if it needs to run before EFI things. But that is easy enough.
That's the point though. I don't want to have 2 different ways of booting EFI as I don't see any benefit. Do you?
Unless we're saying that "bootefi bootmgr" is ready to be used always and without further pre-req support (which I don't think is quite the case, since we don't have persistent EFI vars, so can't set Boot### persistently or via userspace) _something_ is likely needed to either set those, or scan a configurable list of where, to find the EFI payload.
Quoted 6 lines
Quoted 2 lines
The efibootmgr will try to boot bootaa64.efi, bootarm.efi etc if Boot### variables are not found.
To be clear, the current efibootmgr (or "bootefi bootmgr" command) doesn't have this feature. Instead,
distro_bootcmdmimics it in some way. # I have an experimental patch to efibootmgr for the support, though.
Ah thanks Akashi! I thought we had that already. In any case it makes much more sense adding that to efibootmgr, instead of inventing yet another way to do that, doesn't it?
Quoted 7 lines
Nevertheless,
Quoted 3 lines
The Boot#### themselves are
obviously configurable from U-Boot(at boot time). Since this method doesn't allow Linux to edit the boot options either,>
Quoted 17 lines
Yeah. Please remember that, even on normal PCs, specifying an order of boot devices (for "removable media" with the default path) is done through UEFI UI.
-Takahiro Akashi
Quoted 11 lines
is it something
we need? Since distros usually name their SHIM as bootaa64.efi, I am afraid we are adding code that we will rarely (if at all) ever use.Regards
/Ilias
Quoted 3 lines
--
Tom
Regards
/Ilias
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
In reply to Ilias ApalodimasQuoted 73 lines
From: Ilias Apalodimas <[email protected]>
Date: Fri, 29 Oct 2021 16:42:45 +0300Hi Tom,
Quoted 60 lines · Tom Rini
Quoted 50 lines · Ilias Apalodimas
Quoted 49 lines · Simon Glass
Hi Ilias,
Quoted 44 lines · Ilias Apalodimas
Hi Simon,
Quoted 24 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 7 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
Quoted 4 lines
This is needed so that EFI boot is actually invoked. If bootmgr starts being used then it can still be invoked from standard boot. The point is that there is a standard way of booting that supports EFI and other things.
This patch tries to reason about the default naming EFI imposes on it's boot files.
distro_efi_read_bootflow()will try to find files following the EFI naming convention (e.g bootaarch64.efi, bootarm.efi etc). If those are found it will try to boot them right? That's not the right thing to do though. On the EFI spec these files are tried if no Boot#### variables are found. So we can get rid of this entirely, add a dummy entry on the bootflow that says 'boot the efi manager' (which is what the next patch does).The efibootmgr then will check Boot#### variables and if none are found, it's going to fallback into loading bootaarch64.efi, bootarm.efi etc essentially offering identical functionality.
Quoted 7 lines
Quoted 4 lines
Yes that's fine, and when EFI's boot manager is in use I have a driver for that too, as you can see in the other patch. We may need to adjust the order, by the sound of it, if it needs to run before EFI things. But that is easy enough.
That's the point though. I don't want to have 2 different ways of booting EFI as I don't see any benefit. Do you?
Quoted 6 lines
Unless we're saying that "bootefi bootmgr" is ready to be used always and without further pre-req support (which I don't think is quite the case, since we don't have persistent EFI vars, so can't set Boot### persistently or via userspace) _something_ is likely needed to either set those, or scan a configurable list of where, to find the EFI payload.
Quoted 6 lines
The efibootmgr will try to boot bootaa64.efi, bootarm.efi etc if Boot### variables are not found. The Boot#### themselves are obviously configurable from U-Boot(at boot time). Since this method doesn't allow Linux to edit the boot options either, is it something we need? Since distros usually name their SHIM as bootaa64.efi, I am afraid we are adding code that we will rarely (if at all) ever use.
Hi Ilias,
I'm still seeing:
Device 0: Vendor: Lexar Rev: 1100 Prod: USB Flash Drive
Type: Removable Hard Disk
Capacity: 30526.0 MB = 29.8 GB (62517248 x 512)
... is now current device
Scanning usb 0:1...
** Unable to read file / **
Failed to load '/'
libfdt fdt_check_header(): FDT_ERR_BADMAGIC BootOrder not defined
EFI boot manager: Cannot load any image
Found EFI removable media binary efi/boot/bootaa64.efi 170694 bytes read in 9 ms (18.1 MiB/s)
libfdt fdt_check_header(): FDT_ERR_BADMAGIC Booting /efi\boot\bootaa64.efi
So it doesn't seem that efibootmgr will try to bootaa64.efi just yet.
Cheers,
Mark
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Hi Mark,
Quoted 100 lines · Mark Kettenis
Quoted 74 lines
From: Ilias Apalodimas <[email protected]>
Date: Fri, 29 Oct 2021 16:42:45 +0300Hi Tom,
Quoted 60 lines · Tom Rini
Quoted 50 lines · Ilias Apalodimas
Quoted 49 lines · Simon Glass
Hi Ilias,
Quoted 44 lines · Ilias Apalodimas
Hi Simon,
Quoted 24 lines · Simon Glass
Hi Ilias,
Quoted 11 lines · Ilias Apalodimas
Hi Simon,
Quoted 7 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.I'll leave this up to Heinrich, but personally I wouldn't include this patch at all. EFI has it's bootmgr which can handle booting just fine. I don't see why we should duplicate the functionality. The new boot method can just have an entry called 'EFI' and then let the existing EFI code to decide.
Quoted 4 lines
This is needed so that EFI boot is actually invoked. If bootmgr starts being used then it can still be invoked from standard boot. The point is that there is a standard way of booting that supports EFI and other things.
This patch tries to reason about the default naming EFI imposes on it's boot files.
distro_efi_read_bootflow()will try to find files following the EFI naming convention (e.g bootaarch64.efi, bootarm.efi etc). If those are found it will try to boot them right? That's not the right thing to do though. On the EFI spec these files are tried if no Boot#### variables are found. So we can get rid of this entirely, add a dummy entry on the bootflow that says 'boot the efi manager' (which is what the next patch does).The efibootmgr then will check Boot#### variables and if none are found, it's going to fallback into loading bootaarch64.efi, bootarm.efi etc essentially offering identical functionality.
Quoted 7 lines
Quoted 4 lines
Yes that's fine, and when EFI's boot manager is in use I have a driver for that too, as you can see in the other patch. We may need to adjust the order, by the sound of it, if it needs to run before EFI things. But that is easy enough.
That's the point though. I don't want to have 2 different ways of booting EFI as I don't see any benefit. Do you?
Quoted 6 lines
Unless we're saying that "bootefi bootmgr" is ready to be used always and without further pre-req support (which I don't think is quite the case, since we don't have persistent EFI vars, so can't set Boot### persistently or via userspace) _something_ is likely needed to either set those, or scan a configurable list of where, to find the EFI payload.
Quoted 6 lines
The efibootmgr will try to boot bootaa64.efi, bootarm.efi etc if Boot### variables are not found. The Boot#### themselves are obviously configurable from U-Boot(at boot time). Since this method doesn't allow Linux to edit the boot options either, is it something we need? Since distros usually name their SHIM as bootaa64.efi, I am afraid we are adding code that we will rarely (if at all) ever use.
Hi Ilias,
I'm still seeing:
Device 0: Vendor: Lexar Rev: 1100 Prod: USB Flash Drive
Type: Removable Hard Disk
Capacity: 30526.0 MB = 29.8 GB (62517248 x 512)
... is now current device
Scanning usb 0:1...
** Unable to read file / **
Failed to load '/'
libfdtfdt_check_header():FDT_ERR_BADMAGICBootOrder not defined
EFI boot manager: Cannot load any image
Found EFI removable media binary efi/boot/bootaa64.efi 170694 bytes read in 9 ms (18.1 MiB/s)
libfdtfdt_check_header():FDT_ERR_BADMAGICBooting /efi\boot\bootaa64.efi
Quoted 1 line
So it doesn't seem that efibootmgr will try to bootaa64.efi just yet.
Yea Akashi-san already corrected me on this one. I was somehow under the impression we do that already, while it's the distro bootcmd doing that. In any case it would make much more sense for me to add the missing pieces in the efibootmgr, instead of an extra app. That way we can either cleanup the distro bootmcd or skip this patch when Simon's proposal gets resubmitted.
Thanks!
/Ilias
Quoted 4 lines
Cheers,
Mark
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
In reply to Simon GlassQuoted 8 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.
Booting via the boot manager must occur without issuing a command on the command line. How will the boot method in this file be invoked?
The bootefi command may be implemented by invoking a boot method. A boot method invoking a command does not make sense to me.
Best regards
Heinrich
Quoted 326 lines
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
boot/Kconfig | 21 ++++ boot/Makefile | 1 + boot/bootmeth_efi.c | 263 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 285 insertions(+)create mode 100644
boot/bootmeth_efi.cboot/Kconfig +21
-0@@ -318,6 +318,27 @@ config BOOTMETH_DISTRO_PXE This provides a way to try out standard boot on an existing boot flow. +config BOOTMETH_EFILOADER + bool "Bootdev support for EFI boot" + depends on CMD_BOOTEFI + default y + help + Enables support for EFI boot using bootdevs. This makes the + bootdevs look for a 'boot<arch>.efi' on each filesystem + they scan. The resulting file is booted after enabling U-Boot's + EFI loader support. + + The <arch> depends on the architecture of the board: + + aa64 - aarch64 (ARM 64-bit) + arm - ARM 32-bit + ia32 - x86 32-bit + x64 - x86 64-bit + riscv32 - RISC-V 32-bit + riscv64 - RISC-V 64-bit + + This provides a way to try out standard boot on an existing boot flow. + endif config LEGACY_IMAGE_FORMATboot/Makefile +1
-0@@ -30,6 +30,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) += bootmeth_pxe.o +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.oboot/bootmeth_efi.c new file +263
-0@@ -0,0 +1,263 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Bootmethod for distro boot via EFI +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#include <common.h> +#include <bootdev.h> +#include <bootflow.h> +#include <bootmeth.h> +#include <command.h> +#include <dm.h> +#include <efi_loader.h> +#include <fs.h> +#include <malloc.h> +#include <mapmem.h> +#include <mmc.h> +#include <pxe_utils.h> + +#define EFI_DIRNAME "efi/boot/" + +/** +* get_efi_leafname() - Get the leaf name for the EFI file we expect +* +* @str: Place to put leaf name for this architecture, e.g. "bootaa64.efi". +* Must have at least 16 bytes of space +* @max_len: Length of @str, must be >=16 +*/ +static int get_efi_leafname (char *str,int max_len) +{ +const char *base; + +if (max_len <16 ) +return log_msg_ret ("spc" , -ENOSPC ); +if (IS_ENABLED (CONFIG_ARM64 )) + base ="bootaa64" ; +else if (IS_ENABLED (CONFIG_ARM )) + base ="bootarm" ; +else if (IS_ENABLED (CONFIG_X86_RUN_32BIT )) + base ="bootia32" ; +else if (IS_ENABLED (CONFIG_X86_RUN_64BIT )) + base ="bootx64" ; +else if (IS_ENABLED (CONFIG_ARCH_RV32I )) + base ="bootriscv32" ; +else if (IS_ENABLED (CONFIG_ARCH_RV64I )) + base ="bootriscv64" ; +else if (IS_ENABLED (CONFIG_SANDBOX )) + base ="bootsbox" ; +else +return -EINVAL ; + +strcpy (str, base); +strcat (str,".efi" ); + +return 0 ; +} + +static int efiload_read_file (struct blk_desc *desc,struct bootflow *bflow) +{ +const struct udevice *media_dev; +int size = bflow->size; +char devnum_str[9 ]; +char dirname[200 ]; +loff_t bytes_read; +char *last_slash; +ulong addr; +char *buf; +int ret; + +/* Sadly FS closes the file after fs_size() so we must redo this */ + ret =fs_set_blk_dev_with_part (desc, bflow->part); +if (ret) +return log_msg_ret ("set" , ret); + + buf =malloc (size +1 ); +if (!buf) +return log_msg_ret ("buf" , -ENOMEM ); + addr =map_to_sysmem (buf); + + ret =fs_read (bflow->fname, addr,0 ,0 , &bytes_read); +if (ret) { +free (buf); +return log_msg_ret ("read" , ret); + } +if (size != bytes_read) +return log_msg_ret ("bread" , -EINVAL ); + buf[size] ='\0' ; + bflow->state =BOOTFLOWST_READY ; + bflow->buf = buf; + +/* +* This is a horrible hack to tell EFI about this boot device. Once we +* unify EFI with the rest of U-Boot we can clean this up. The same hack +* exists in multiple places, e.g. in the fs, tftp and load commands. +* +* Once we can clean up the EFI code to make proper use of driver model, +* this can go away. +*/ + media_dev =dev_get_parent (bflow->dev); +snprintf (devnum_str,sizeof (devnum_str),"%x" ,dev_seq (media_dev)); + +strlcpy (dirname, bflow->fname,sizeof (dirname)); + last_slash =strrchr (dirname,'/' ); +if (last_slash) + *last_slash ='\0' ; + +efi_set_bootdev (dev_get_uclass_name (media_dev), devnum_str, dirname, + bflow->buf, size); + +return 0 ; +} + +static int distro_efi_check (struct udevice *dev,struct bootflow_iter *iter) +{ +int ret; + +/* This only works on block devices */ + ret =bootflow_iter_uses_blk_dev (iter); +if (ret) +return log_msg_ret ("blk" , ret); + +return 0 ; +} + +static int distro_efi_read_bootflow (struct udevice *dev,struct bootflow *bflow) +{ +struct blk_desc *desc =dev_get_uclass_plat (bflow->blk); +char fname[sizeof (EFI_DIRNAME ) +16 ]; +loff_t size; +int ret; + +/* We require a partition table */ +if (!bflow->part) +return -ENOENT ; + +strcpy (fname,EFI_DIRNAME ); + ret =get_efi_leafname (fname +strlen (fname), +sizeof (fname) -strlen (fname)); +if (ret) +return log_msg_ret ("leaf" , ret); + + bflow->fname =strdup (fname); +if (!bflow->fname) +return log_msg_ret ("name" , -ENOMEM ); + ret =fs_size (bflow->fname, &size); + bflow->size = size; +if (ret) +return log_msg_ret ("size" , ret); + bflow->state =BOOTFLOWST_FILE ; +log_debug (" - distro file size %x\n" , (uint )size); +if (size >0x2000000 ) +return log_msg_ret ("chk" , -E2BIG ); + + ret =efiload_read_file (desc, bflow); +if (ret) +return log_msg_ret ("read" , -EINVAL ); + +return 0 ; +} + +static int distro_efi_read_file (struct udevice *dev,struct bootflow *bflow, +const char *file_path,ulong addr,ulong *sizep) +{ +struct blk_desc *desc =dev_get_uclass_plat (bflow->blk); +const struct udevice *media_dev; +int size = bflow->size; +char devnum_str[9 ]; +char dirname[200 ]; +loff_t bytes_read; +char *last_slash; +char *buf; +int ret; + +/* Sadly FS closes the file after fs_size() so we must redo this */ + ret =fs_set_blk_dev_with_part (desc, bflow->part); +if (ret) +return log_msg_ret ("set" , ret); + + buf =malloc (size +1 ); +if (!buf) +return log_msg_ret ("buf" , -ENOMEM ); + addr =map_to_sysmem (buf); + + ret =fs_read (bflow->fname, addr,0 ,0 , &bytes_read); +if (ret) { +free (buf); +return log_msg_ret ("read" , ret); + } +if (size != bytes_read) +return log_msg_ret ("bread" , -EINVAL ); + buf[size] ='\0' ; + bflow->state =BOOTFLOWST_READY ; + bflow->buf = buf; + +/* +* This is a horrible hack to tell EFI about this boot device. Once we +* unify EFI with the rest of U-Boot we can clean this up. The same hack +* exists in multiple places, e.g. in the fs, tftp and load commands. +* +* Once we can clean up the EFI code to make proper use of driver model, +* this can go away. +*/ + media_dev =dev_get_parent (bflow->dev); +snprintf (devnum_str,sizeof (devnum_str),"%x" ,dev_seq (media_dev)); + +strlcpy (dirname, bflow->fname,sizeof (dirname)); + last_slash =strrchr (dirname,'/' ); +if (last_slash) + *last_slash ='\0' ; + +efi_set_bootdev (dev_get_uclass_name (media_dev), devnum_str, dirname, + bflow->buf, size); + +return 0 ; +} + +int distro_efi_boot (struct udevice *dev,struct bootflow *bflow) +{ +char cmd[50 ]; + +/* +* At some point we can add a real interface to bootefi so we can call +* this directly. For now, go through the CLI like distro boot. +*/ +snprintf (cmd,sizeof (cmd),"bootefi %lx %lx" , + (ulong )map_to_sysmem (bflow->buf), + (ulong )map_to_sysmem (gd->fdt_blob)); +if (run_command (cmd,0 )) +return log_msg_ret ("run" , -EINVAL ); + +return 0 ; +} + +static int distro_bootmeth_efi_bind (struct udevice *dev) +{ +struct bootmeth_uc_plat *plat =dev_get_uclass_plat (dev); + + plat->desc ="EFI boot from a .efi file" ; + +return 0 ; +} + +static struct bootmeth_ops distro_efi_bootmeth_ops = { + .check = distro_efi_check, + .read_bootflow = distro_efi_read_bootflow, + .read_file = distro_efi_read_file, + .boot = distro_efi_boot, +}; + +static const struct udevice_id distro_efi_bootmeth_ids[] = { + { .compatible ="u-boot,distro-efi" }, + { } +}; + +U_BOOT_DRIVER (bootmeth_efi) = { + .name ="bootmeth_efi" , + .id =UCLASS_BOOTMETH , + .of_match = distro_efi_bootmeth_ids, + .ops = &distro_efi_bootmeth_ops, + .bind = distro_bootmeth_efi_bind, +};
Re: [PATCH v2 31/41] bootstd: Add an implementation of EFI boot
Hi Heinrich, Ilias,
Quoted 10 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass
Add a bootmeth driver which handles EFI boot, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
Quoted 8 lines
Quoted 2 lines
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without
CONFIG_CMDLINEbeing enabled.Booting via the boot manager must occur without issuing a command on the command line. How will the boot method in this file be invoked?
The bootefi command may be implemented by invoking a boot method. A boot method invoking a command does not make sense to me.
What do you mean? What other way is there to boot an image at present?
The same thing happens with PXE, for example today, although I have sent a series to start to change that.
The idea here is that to boot something on U-Boot you use 'bootflow scan -b' and everything happens automatically. In all cases (at present) this involves running commands, whether it is bootm, bootefi, etc.
Quoted 8 lines
Best regards
Heinrich
Quoted 3 lines
Signed-off-by Simon Glass <[email protected]>---
[..]
Regards,
Simon
PATCH v2 32/41 bootstd: Add a system bootdev for strange boot methods
In reply to Simon GlassSome boot methods don't act on a single bootdev but instead do their own thing. An example is EFI bootmgr which scan various devices using its own logic. Add a bootdev to handle this.
---
(no changes since v1)
boot/Makefile | 2 +- boot/bootstd-uclass.c | 6 ++++ boot/system_bootdev.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 boot/system_bootdev.c
boot/Makefile +1 -1
@@ -23,7 +23,7 @@ obj-y += image.o image-board.o obj-$(CONFIG_ANDROID_AB) += android_ab.o obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o image-android-dt.o -obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootdev-uclass.o +obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootdev-uclass.o system_bootdev.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootflow.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootmeth-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o
boot/bootstd-uclass.c +6 -0
@@ -143,6 +143,12 @@ int dm_scan_other(bool pre_reloc_only) } } +/* Create the system bootdev too */ + ret =device_bind_driver (bootstd,"system_bootdev" ,"system-bootdev" , + &dev); +if (ret) +return log_msg_ret ("sys" , ret); +return 0 ; }
boot/system_bootdev.c new file +64 -0
64 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 33/41 bootstd: Add an implementation of EFI bootmgr
In reply to Simon GlassAdd a bootmeth driver which handles EFI boot manager, using EFI_LOADER.
In effect, this provides the same functionality as the 'bootefi bootmgr' command and shares the same code. But the interface into it is via a bootmeth, so it does not require any special scripts, etc.
For now this requires the 'bootefi' command be enabled. Future work may tidy this up so that it can be used without CONFIG_CMDLINE being enabled.
---
(no changes since v1)
boot/Makefile | 3 ++ boot/bootmeth_efi_mgr.c | 84 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 boot/bootmeth_efi_mgr.c
boot/Makefile +3 -0
@@ -31,6 +31,9 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) += bootmeth_pxe.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o +ifdef CONFIG_$(SPL_TPL_)BOOTSTD +obj-$(CONFIG_$(SPL_TPL_)CMD_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o +endif obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += image-fdt.o obj-$(CONFIG_$(SPL_TPL_)FIT_SIGNATURE) += fdt_region.o
boot/bootmeth_efi_mgr.c new file +84 -0
84 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 34/41 bootstd: Add a sandbox bootmeth driver
In reply to Simon GlassAdd a bootmeth driver for sandbox, used for testing.
---
(no changes since v1)
boot/Kconfig | 7 +++++ boot/Makefile | 1 + boot/bootmeth_sandbox.c | 67 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 boot/bootmeth_sandbox.c
boot/Kconfig +7 -0
@@ -339,6 +339,13 @@ config BOOTMETH_EFILOADER This provides a way to try out standard boot on an existing boot flow. +config BOOTMETH_SANDBOX + def_bool y + depends on SANDBOX + help + This is a sandbox bootmeth driver used for testing. It always returns + -ENOTSUPP when attempting to boot. + endif config LEGACY_IMAGE_FORMAT
boot/Makefile +1 -0
@@ -31,6 +31,7 @@ obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += bootstd-uclass.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO) += bootmeth_distro.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_DISTRO_PXE) += bootmeth_pxe.o obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_EFILOADER) += bootmeth_efi.o +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SANDBOX) += bootmeth_sandbox.o ifdef CONFIG_$(SPL_TPL_)BOOTSTD obj-$(CONFIG_$(SPL_TPL_)CMD_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o endif
boot/bootmeth_sandbox.c new file +67 -0
67 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
[email protected]
[email protected]
Quoted 280 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned byU-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
With this we can boot on a Raspberry Pi 3 with just one command:
bootflow scan -lb
which means to scan, listing (-l) each bootflow and trying to boot each one (-b). The final patch shows this.
With a standard way to identify boot devices, booting become easier. It also should be possible to support U-Boot scripts, for backwards compatibility only.
This series relies on the PXE clean-up series, posted here:
https://patchwork.ozlabs.org/project/uboot/list/?series=267078For documentation, see the 'doc' patch.
For version 2, a new naming scheme is used as above:
- bootdev is used instead of bootdevice, because 'device' is overused, is everywhere in U-Boot, can be confused with udevice
- bootmeth - because 'method' is too vanilla, appears 1300 times in U-BootAlso in version 2, drivers are introduced for the boot methods, to make it more extensible. Booting a custom OS is simply a matter of creating a bootmeth for it and implementing the
read_file()andboot()methods.The design is described in these two documents:
https://drive.google.com/file/d/1ggW0KJpUOR__vBkj3l61L2dav4ZkNC12/view?usp=sharing
https://drive.google.com/file/d/1kTrflO9vvGlKp-ZH_jlgb9TY3WYG6FF9/view?usp=sharing
The series is available at u-boot-dm/bme-working
Sample log on
rpi_3_32b:U-Boot 2021.10-rc2-00043-gccd453aa918-dirty (Aug 28 2021 - 13:58:46 -0600)
DRAM: 992 MiB
RPI 3 Model B (0xa22082)
MMC: mmc@7e202000: 0, sdhci@7e300000: 1
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... In: serialOut: vidconsole Err: vidconsole Net: No ethernet found.starting USB...
Bus usb@7e980000: USB DWC2
scanning bus usb@7e980000 for devices...usb_kbdusb_kbd: Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000
4 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot: 0
Scanning for bootflows in all bootmethodsSeq Type State Uclass Part Name Filename --- ----------- ------ -------- ---- ------------------------ ----------------Scanning bootmethod '[email protected]':
0 efi-loader loaded mmc 1 [email protected] efi/boot/bootarm.efi
** Booting bootflow '[email protected]_1' Scanning disk [email protected]...
** Unrecognized filesystem type **
Card did not respond to voltage select! : -110 Scanning disk [email protected]...
Disk [email protected] not ready
Found 4 disks
No EFI system partition
Booting /efi\boot
Waiting for Ethernet connection... done.Fedora (5.11.12-300.fc34.armv7hl) 34 (Workstation Edition) UEFI Firmware Settings
Use the ▲ and ▼ keys to change the selection.
Press 'e' to edit the selected item, or 'c' for a command prompt. Press Escape to return to the previous menu.
The selected entry will be started automatically in 0s.Changes in v2:
- Free the memory buffer, to avoid running out of memory
- Unmap the file
- Reorder structsandbox_mmc_privSimon Glass (41):
lib: Add a way to find the postiion of a trailing number
Makefile: Allow LTO to be disabled for a build test/py: Allow passing input to a program
sandbox: Support unmapping a file
sandbox: mmc: Support a backing file
mmc: Allow for children other than the block device
mbr: Correct verification check
disk:part_dos: Fix a NULL pointer error
common: Allow a smaller console-recording pre-reloc
dm: core: Add tests for stringlist functions
dm: core: Fix handling of uclasspre_unbindmethod
dm: core: Fix up string-function documentation
dm: core: Add a way to obtain a string list
dm: core: Allow finding children / uclasses by partial name
dm: core: Add a way to count the devices in a uclass
sandbox: Enable HEXDUMP forsandbox_flattreetest/py: Relax the naming rules for unit tests test/py: Raise a ValueError if a command fails
bootstd: Add the concept of a bootflow
bootstd: Add the bootstd uclass and core implementation
bootstd: Add the bootdev uclass
bootstd: Add the bootmeth uclass and helpers
bootstd: Add support for bootflows
bootstd: Add a bootdev command
bootstd: Add a bootflow ommand
bootstd: Add a bootmeth command
bootstd: Add an implementation of distro boot
bootstd: mmc: Add a bootdev driver
bootstd: ethernet: Add a bootdev driver
bootstd: Add an implementation of distro PXE boot
bootstd: Add an implementation of EFI boot
bootstd: Add a system bootdev for strange boot methods
bootstd: Add an implementation of EFI bootmgr
bootstd: Add a sandbox bootmeth driver
bootstd: usb: Add a bootdev driver
test: fastboot: Avoid using mmc1
test: dm: Restart USB before assuming it is stopped
bootstd: Add tests for bootstd including all uclasses
bootstd: Add setup for the bootflow tests
bootstd: doc: Add documentation
RFC: Switch rpi over to use bootstdMAINTAINERS | 21 + Makefile | 18 +- arch/arm/config.mk | 4 +- arch/arm/include/asm/global_data.h | 2 +- arch/sandbox/cpu/os.c | 10 + arch/sandbox/dts/test.dts | 19 + boot/Kconfig | 77 ++- boot/Makefile | 14 + boot/bootdev-uclass.c | 439 ++++++++++++++ boot/bootflow.c | 576 ++++++++++++++++++ boot/bootmeth-uclass.c | 59 ++ boot/bootmeth_distro.c | 217 +++++++ boot/bootmeth_efi.c | 263 ++++++++ boot/bootmeth_efi_mgr.c | 84 +++ boot/bootmeth_pxe.c | 183 ++++++ boot/bootmeth_sandbox.c | 67 +++ boot/bootstd-uclass.c | 176 ++++++ boot/system_bootdev.c | 64 ++ cmd/Kconfig | 15 + cmd/Makefile | 1 + cmd/bootdev.c | 120 ++++ cmd/bootflow.c | 386 ++++++++++++ cmd/bootmeth.c | 158 +++++ cmd/mbr.c | 8 +- common/Kconfig | 10 + common/console.c | 4 +- common/usb_storage.c | 12 + configs/amcore_defconfig | 1 + configs/rcar3_salvator-x_defconfig | 1 + configs/sandbox_defconfig | 3 +- configs/sandbox_flattree_defconfig | 4 +- configs/tbs2910_defconfig | 1 + disk/part_dos.c | 10 +- doc/build/gcc.rst | 17 + doc/develop/bootstd.rst | 600 +++++++++++++++++++ doc/develop/distro.rst | 3 + doc/develop/index.rst | 1 + doc/device-tree-bindings/bootdev.txt | 26 + doc/device-tree-bindings/bootmeth.txt | 31 + doc/device-tree-bindings/bootstd.txt | 36 ++ doc/device-tree-bindings/mmc/sandbox,mmc.txt | 18 + doc/usage/bootdev.rst | 135 +++++ doc/usage/bootflow.rst | 427 +++++++++++++ doc/usage/bootmeth.rst | 106 ++++ doc/usage/index.rst | 3 + drivers/core/device-remove.c | 9 +- drivers/core/device.c | 13 +- drivers/core/of_access.c | 3 +- drivers/core/ofnode.c | 26 + drivers/core/read.c | 6 + drivers/core/uclass.c | 29 +- drivers/mmc/Makefile | 5 + drivers/mmc/mmc-uclass.c | 27 +- drivers/mmc/mmc_bootdev.c | 62 ++ drivers/mmc/sandbox_mmc.c | 60 +- drivers/usb/host/Makefile | 4 + drivers/usb/host/usb_bootdev.c | 61 ++ include/bootdev.h | 258 ++++++++ include/bootflow.h | 304 ++++++++++ include/bootmeth.h | 156 +++++ include/bootstd.h | 80 +++ include/configs/rpi.h | 41 +- include/distro.h | 24 + include/dm/device.h | 12 + include/dm/ofnode.h | 24 +- include/dm/read.h | 28 + include/dm/uclass-id.h | 3 + include/dm/uclass-internal.h | 14 +- include/dm/uclass.h | 17 + include/mmc.h | 12 +- include/os.h | 9 + include/test/suites.h | 2 + include/vsprintf.h | 18 + lib/strto.c | 14 +- net/Kconfig | 9 + net/Makefile | 1 + net/eth-uclass.c | 8 + net/eth_bootdev.c | 101 ++++ test/Makefile | 1 + test/boot/Makefile | 5 + test/boot/bootdev.c | 200 +++++++ test/boot/bootflow.c | 398 ++++++++++++ test/boot/bootmeth.c | 90 +++ test/boot/bootstd_common.c | 35 ++ test/boot/bootstd_common.h | 27 + test/cmd_ut.c | 7 + test/dm/blk.c | 6 + test/dm/fastboot.c | 4 +- test/dm/ofnode.c | 96 +++ test/py/conftest.py | 2 +- test/py/multiplexed_log.py | 10 +- test/py/tests/bootstd/mmc1.img.xz | Bin 0 -> 4448 bytes test/py/tests/test_ut.py | 103 ++++ test/py/u_boot_utils.py | 5 +- 94 files changed, 6765 insertions(+), 94 deletions(-) create mode 100644 boot/bootdev-uclass.c create mode 100644 boot/bootflow.c create mode 100644 boot/bootmeth-uclass.c create mode 100644 boot/bootmeth_distro.c create mode 100644 boot/bootmeth_efi.c create mode 100644 boot/bootmeth_efi_mgr.c create mode 100644 boot/bootmeth_pxe.c create mode 100644 boot/bootmeth_sandbox.c create mode 100644 boot/bootstd-uclass.c create mode 100644 boot/system_bootdev.c create mode 100644 cmd/bootdev.c create mode 100644 cmd/bootflow.c create mode 100644 cmd/bootmeth.c create mode 100644 doc/develop/bootstd.rst create mode 100644 doc/device-tree-bindings/bootdev.txt create mode 100644 doc/device-tree-bindings/bootmeth.txt create mode 100644 doc/device-tree-bindings/bootstd.txt create mode 100644 doc/device-tree-bindings/mmc/sandbox,mmc.txt create mode 100644 doc/usage/bootdev.rst create mode 100644 doc/usage/bootflow.rst create mode 100644 doc/usage/bootmeth.rst create mode 100644 drivers/mmc/mmc_bootdev.c create mode 100644 drivers/usb/host/usb_bootdev.c create mode 100644 include/bootdev.h create mode 100644 include/bootflow.h create mode 100644 include/bootmeth.h create mode 100644 include/bootstd.h create mode 100644 include/distro.h create mode 100644 net/eth_bootdev.c create mode 100644 test/boot/Makefile create mode 100644 test/boot/bootdev.c create mode 100644 test/boot/bootflow.c create mode 100644 test/boot/bootmeth.c create mode 100644 test/boot/bootstd_common.c create mode 100644 test/boot/bootstd_common.h create mode 100644 test/py/tests/bootstd/mmc1.img.xz--
2.33.0.1079.g6e70778dc9-goog
PATCH v2 35/41 bootstd: usb: Add a bootdev driver
In reply to Simon GlassAdd a bootdev driver for USB host. It can use the distro boot mechanism to locate a file, or any other available bootmeth.
---
(no changes since v1)
common/usb_storage.c | 12 +++++++ drivers/usb/host/Makefile | 4 +++ drivers/usb/host/usb_bootdev.c | 61 ++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 drivers/usb/host/usb_bootdev.c
common/usb_storage.c +12 -0
@@ -34,6 +34,7 @@#include <common.h> #include <blk.h> +#include <bootdev.h> #include <command.h> #include <dm.h> #include <errno.h>
@@ -239,6 +240,17 @@ static int usb_stor_probe_device(struct usb_device *udev)if (ret) return ret; } + + ret =bootdev_setup_sibling_blk (dev,"usb_bootdev" ); +if (ret) { +int ret2; + + ret2 =device_unbind (dev); +if (ret2) +return log_msg_ret ("bootdev" , ret2); +return log_msg_ret ("bootdev" , ret); + } + }#else /* We don't have space to even probe if we hit the maximum */
drivers/usb/host/Makefile +4 -0
@@ -8,6 +8,10 @@ obj-y += usb-uclass.o obj-$(CONFIG_SANDBOX) += usb-sandbox.o endif +ifdef CONFIG_$(SPL_TPL_)USB_STORAGE +obj-$(CONFIG_$(SPL_TPL_)BOOTSTD) += usb_bootdev.o +endif + # ohci obj-$(CONFIG_USB_OHCI_NEW) += ohci-hcd.o obj-$(CONFIG_USB_ATMEL) += ohci-at91.o
drivers/usb/host/usb_bootdev.c new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 36/41 test: fastboot: Avoid using mmc1
In reply to Simon GlassThe bootflow tests need to use an MMC with an associated backing file containing a filesystem. Update the fastboot tests to cope with this.
---
(no changes since v1)
test/dm/fastboot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
test/dm/fastboot.c +2 -2
@@ -81,9 +81,9 @@ static int dm_test_fastboot_mmc_part(struct unit_test_state *uts) &part_info, response));ut_asserteq (0 ,fastboot_mmc_get_part_info ("0.0:0" , &fb_dev_desc, &part_info, response)); -ut_asserteq (0 ,fastboot_mmc_get_part_info ("1" , &fb_dev_desc, +ut_asserteq (0 ,fastboot_mmc_get_part_info ("2" , &fb_dev_desc, &part_info, response)); -ut_asserteq (0 ,fastboot_mmc_get_part_info ("1.0" , &fb_dev_desc, +ut_asserteq (0 ,fastboot_mmc_get_part_info ("2.0" , &fb_dev_desc, &part_info, response));ut_asserteq (1 ,fastboot_mmc_get_part_info (":1" , &fb_dev_desc, &part_info, response));
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 37/41 test: dm: Restart USB before assuming it is stopped
In reply to Simon GlassUpdate the blk test to stop USB first, in case another test has started it.
---
(no changes since v1)
test/dm/blk.c | 6 ++++++ 1 file changed, 6 insertions(+)
test/dm/blk.c +6 -0
@@ -15,6 +15,9 @@DECLARE_GLOBAL_DATA_PTR ; +/* Allow resetting the USB-started flag */ +extern char usb_started; +/* Test that block devices can be created */ static int dm_test_blk_base (struct unit_test_state *uts) {
@@ -66,8 +69,11 @@ static int dm_test_blk_usb(struct unit_test_state *uts)struct udevice *usb_dev, *dev;struct blk_desc *dev_desc; + usb_started = false; +/* Get a flash device */ state_set_skip_delays (true); +ut_assertok (usb_stop ());ut_assertok (usb_init ());ut_assertok (uclass_get_device (UCLASS_MASS_STORAGE ,0 , &usb_dev));ut_assertok (blk_get_device_by_str ("usb" ,"0" , &dev_desc));
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 38/41 bootstd: Add tests for bootstd including all uclasses
In reply to Simon GlassAdd a set of combined tests for the bootdev, bootflow and bootmeth commands, along with associated functionality.
Expand the sandbox console-recording limit so that these can work.
These tests rely on a filesystem script which is not yet added to the Python tests. It is included here as a shell script.
---
(no changes since v1)
MAINTAINERS | 1 + arch/sandbox/dts/test.dts | 18 ++ configs/sandbox_defconfig | 3 +- configs/sandbox_flattree_defconfig | 3 +- include/test/suites.h | 2 + test/Makefile | 1 + test/boot/Makefile | 5 + test/boot/bootdev.c | 200 +++++++++++++++ test/boot/bootflow.c | 398 +++++++++++++++++++++++++++++ test/boot/bootmeth.c | 90 +++++++ test/boot/bootstd_common.c | 35 +++ test/boot/bootstd_common.h | 27 ++ test/cmd_ut.c | 7 + 13 files changed, 788 insertions(+), 2 deletions(-) create mode 100644 test/boot/Makefile create mode 100644 test/boot/bootdev.c create mode 100644 test/boot/bootflow.c create mode 100644 test/boot/bootmeth.c create mode 100644 test/boot/bootstd_common.c create mode 100644 test/boot/bootstd_common.h
MAINTAINERS +1 -0
@@ -648,6 +648,7 @@ F: include/bootflow.h F: include/bootmeth.h F: include/bootstd.h F: net/eth_bootdevice.c +F: test/boot/ BTRFS M: Marek Behun <[email protected]>
arch/sandbox/dts/test.dts +18 -0
@@ -71,6 +71,21 @@ }; }; + bootstd { + compatible = "u-boot,boot-std"; + + filename-prefixes = "/", "/boot/"; + bootdev-order = "mmc2", "mmc1"; + + syslinux { + compatible = "u-boot,distro-syslinux"; + }; + + efi { + compatible = "u-boot,distro-efi"; + }; + }; + reboot-mode0 { compatible = "reboot-mode-gpio"; gpios = <&gpio_c 0 GPIO_ACTIVE_HIGH>, <&gpio_c 1 GPIO_ACTIVE_HIGH>;
@@ -882,10 +897,13 @@ non-removable; }; + /* This is used for the bootdev tests */ mmc1 { compatible = "sandbox,mmc"; + filename = "mmc1.img"; }; + /* This is used for the fastboot tests */ mmc0 { compatible = "sandbox,mmc"; };
configs/sandbox_defconfig +2 -1
@@ -28,7 +28,7 @@ CONFIG_AUTOBOOT_NEVER_TIMEOUT=y CONFIG_AUTOBOOT_STOP_STR_ENABLE=y CONFIG_AUTOBOOT_STOP_STR_CRYPT="$5$rounds=640000$HrpE65IkB8CM5nCL$BKT3QdF98Bo8fJpTr9tjZLZQyzqPASBY20xuK5Rent9" CONFIG_CONSOLE_RECORD=y -CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 +CONFIG_CONSOLE_RECORD_OUT_SIZE=0x6000 CONFIG_PRE_CONSOLE_BUFFER=y CONFIG_LOG=y CONFIG_DISPLAY_BOARDINFO_LATE=y
@@ -119,6 +119,7 @@ CONFIG_ENV_IS_IN_EXT4=y CONFIG_ENV_EXT4_INTERFACE="host" CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0" CONFIG_ENV_IMPORT_FDT=y +# CONFIG_BOOTDEV_ETH is not set CONFIG_BOOTP_SEND_HOSTNAME=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y
configs/sandbox_flattree_defconfig +2 -1
@@ -18,7 +18,7 @@ CONFIG_BOOTSTAGE_FDT=y CONFIG_BOOTSTAGE_STASH=y CONFIG_BOOTSTAGE_STASH_SIZE=0x4096 CONFIG_CONSOLE_RECORD=y -CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000 +CONFIG_CONSOLE_RECORD_OUT_SIZE=0x6000 CONFIG_DISPLAY_BOARDINFO_LATE=y CONFIG_MISC_INIT_F=y CONFIG_CMD_CPU=y
@@ -74,6 +74,7 @@ CONFIG_ENV_IS_NOWHERE=y CONFIG_ENV_IS_IN_EXT4=y CONFIG_ENV_EXT4_INTERFACE="host" CONFIG_ENV_EXT4_DEVICE_AND_PART="0:0" +# CONFIG_BOOTDEV_ETH is not set CONFIG_BOOTP_SEND_HOSTNAME=y CONFIG_NETCONSOLE=y CONFIG_IP_DEFRAG=y
include/test/suites.h +2 -0
@@ -29,6 +29,8 @@ int cmd_ut_category(const char *name, const char *prefix,int do_ut_addrmap (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);int do_ut_bootm (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); +int do_ut_bootstd (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]);int do_ut_bloblist (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);int do_ut_common (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);
test/Makefile +1 -0
@@ -22,6 +22,7 @@ obj-$(CONFIG_UT_TIME) += time_ut.o obj-y += ut.o ifeq ($(CONFIG_SPL_BUILD),) +obj-$(CONFIG_UNIT_TEST) += boot/ obj-$(CONFIG_UNIT_TEST) += common/ obj-$(CONFIG_UNIT_TEST) += lib/ obj-y += log/
test/boot/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright 2021 Google LLC + +obj-$(CONFIG_BOOTSTD) += bootdev.o bootstd_common.o bootflow.o bootmeth.o
test/boot/bootdev.c new file +200 -0
200 lines not on this page · raw message
test/boot/bootflow.c new file +398 -0
398 lines not on this page · raw message
test/boot/bootmeth.c new file +90 -0
90 lines not on this page · raw message
test/boot/bootstd_common.c new file +35 -0
@@ -0,0 +1,35 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Test for bootdev functions. All start with 'bootdev' +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#include <common.h> +#include <bootstd.h> +#include <dm.h> +#include <test/suites.h> +#include <test/ut.h> +#include "bootstd_common.h" + +int bootstd_test_drop_bootdev_order (struct unit_test_state *uts) +{ +struct bootstd_priv *priv; +struct udevice *bootstd; + +ut_assertok (uclass_first_device_err (UCLASS_BOOTSTD , &bootstd)); + priv =dev_get_priv (bootstd); + priv->bootdev_order =NULL ; + +return 0 ; +} + +int do_ut_bootstd (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) +{ +struct unit_test *tests =UNIT_TEST_SUITE_START (bootstd_test); +const int n_ents =UNIT_TEST_SUITE_COUNT (bootstd_test); + +return cmd_ut_category ("bootstd" ,"bootstd_test_" , + tests, n_ents, argc, argv); +}
test/boot/bootstd_common.h new file +27 -0
@@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Common header file for bootdev, bootflow, bootmeth tests +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#ifndef __bootstd_common_h +#define __bootstd_common_h + +/* Declare a new bootdev test */ +#define BOOTSTD_TEST (_name, _flags) \ + UNIT_TEST(_name, _flags, bootstd_test) + +struct unit_test_state ; + +/** +* bootstd_test_drop_bootdev_order() - Remove the existing boot order +* +* Drop the boot order so that all bootdevs are used in their alias order +* +* @uts: Unit test state to use for ut_assert...() functions +*/ +int bootstd_test_drop_bootdev_order (struct unit_test_state *uts); + +#endif
test/cmd_ut.c +7 -0
@@ -28,6 +28,10 @@ int cmd_ut_category(const char *name, const char *prefix,static struct cmd_tbl cmd_ut_sub[] = {U_BOOT_CMD_MKENT (all,CONFIG_SYS_MAXARGS ,1 , do_ut_all,"" ,"" ), +#ifdef CONFIG_BOOTSTD +U_BOOT_CMD_MKENT (bootstd,CONFIG_SYS_MAXARGS ,1 , do_ut_bootstd, +"" ,"" ), +#endifU_BOOT_CMD_MKENT (common,CONFIG_SYS_MAXARGS ,1 , do_ut_common,"" ,"" ), #if defined(CONFIG_UT_DM) U_BOOT_CMD_MKENT(dm, CONFIG_SYS_MAXARGS, 1, do_ut_dm, "", ""),
@@ -115,6 +119,9 @@ static char ut_help_text[] ="ut bloblist - Test bloblist implementation\n" "ut compression - Test compressors and bootm decompression\n"#endif +#ifdef CONFIG_BOOTSTD + "ut bootstd - Test standard boot implementation\n" +#endif #ifdef CONFIG_UT_DM "ut dm [test-name]\n"#endif
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 39/41 bootstd: Add setup for the bootflow tests
In reply to Simon GlassWe need to create a disk image with a partition table and a DOS-format filesystem containing a few files. Provide a fallback binary for CI since it does not seem able to detect the loopback partitions.
Add this to a dm_init test so that it happens when needed.
---
(no changes since v1)
test/py/tests/bootstd/mmc1.img.xz | Bin 0 -> 4448 bytes test/py/tests/test_ut.py | 103 ++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 test/py/tests/bootstd/mmc1.img.xz
test/py/tests/bootstd/mmc1.img.xz new file binary +0 -0
test/py/tests/test_ut.py +103 -0
118 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 40/41 bootstd: doc: Add documentation
In reply to Simon GlassAdd documentation for this feature, including the commands and full devicetree bindings.
---
(no changes since v1)
MAINTAINERS | 4 + doc/develop/bootstd.rst | 600 ++++++++++++++++++++++++++ doc/develop/distro.rst | 3 + doc/develop/index.rst | 1 + doc/device-tree-bindings/bootdev.txt | 18 + doc/device-tree-bindings/bootmeth.txt | 31 ++ doc/device-tree-bindings/bootstd.txt | 8 + doc/usage/bootdev.rst | 135 ++++++ doc/usage/bootflow.rst | 427 ++++++++++++++++++ doc/usage/bootmeth.rst | 106 +++++ doc/usage/index.rst | 3 + 11 files changed, 1336 insertions(+) create mode 100644 doc/develop/bootstd.rst create mode 100644 doc/device-tree-bindings/bootmeth.txt create mode 100644 doc/usage/bootdev.rst create mode 100644 doc/usage/bootflow.rst create mode 100644 doc/usage/bootmeth.rst
MAINTAINERS +4 -0
@@ -642,6 +642,10 @@ F: boot/bootmeth*.c F: boot/bootstd.c F: cmd/bootdev.c F: cmd/bootflow.c +F: doc/develop/bootstd.rst +F: doc/usage/bootdev.rst +F: doc/usage/bootflow.rst +F: doc/usage/bootmeth.rst F: drivers/mmc/mmc_bootdev.c F: include/bootdev.h F: include/bootflow.h
doc/develop/bootstd.rst new file +600 -0
600 lines not on this page · raw message
doc/develop/distro.rst +3 -0
@@ -157,6 +157,9 @@ a line with "CONFIG_DISTRO_DEFAULTS=y". If you want to enable this from Kconfig itself, for e.g. all boards using a specific SoC then add a "imply DISTRO_DEFAULTS" to your SoC CONFIG option. + +TO BE UPDATED: + In your board configuration file, include the following:: #ifndef CONFIG_SPL_BUILD
doc/develop/index.rst +1 -0
@@ -10,6 +10,7 @@ Implementation :maxdepth: 1 bloblist + bootstd ci_testing commands config_binding
doc/device-tree-bindings/bootdev.txt +18 -0
@@ -6,3 +6,21 @@ child of the media device (UCLASS_MMC, UCLASS_SPI_FLASH, etc.) The bootdev driver is provided by the media devices. The bindings for each are described in this file (to come). + +Required properties: + +compatible: + "u-boot,bootdev-eth" - Ethernet bootdev + "u-boot,bootdev-mmc" - MMC bootdev + "u-boot,bootdev-usb" - USB bootdev + + +Example: + + mmc1 { + compatible = "sandbox,mmc"; + + mmc-bootdev { + compatible = "u-boot,bootdev-eth"; + }; + };
doc/device-tree-bindings/bootmeth.txt new file +31 -0
@@ -0,0 +1,31 @@ +U-Boot standard boot methods (bootmeth) +====================================== + +This provides methods (called bootmeths) for locating bootflows on a boot +device (bootdev). These are normally created as children of the bootstd device. + +Required properties: + +compatible: + "u-boot,distro-syslinux" - distro boot from a block device + "u-boot,distro-pxe" - distro boot from a network device + "u-boot,distro-efi" - EFI boot from a .efi file + "u-boot,efi-bootmgr" - EFI boot using boot manager (bootmgr) + + +Example: + + bootstd { + compatible = "u-boot,boot-std"; + + filename-prefixes = "/", "/boot/"; + bootdev-order = "mmc2", "mmc1"; + + syslinux { + compatible = "u-boot,distro-syslinux"; + }; + + efi { + compatible = "u-boot,distro-efi"; + }; + };
doc/device-tree-bindings/bootstd.txt +8 -0
@@ -25,4 +25,12 @@ Example: filename-prefixes = "/", "/boot/"; bootdev-order = "mmc2", "mmc1"; + + syslinux { + compatible = "u-boot,distro-syslinux"; + }; + + efi { + compatible = "u-boot,distro-efi"; + }; };
doc/usage/bootdev.rst new file +135 -0
135 lines not on this page · raw message
doc/usage/bootflow.rst new file +427 -0
427 lines not on this page · raw message
doc/usage/bootmeth.rst new file +106 -0
106 lines not on this page · raw message
doc/usage/index.rst +3 -0
@@ -20,9 +20,12 @@ Shell commands addrmap askenv base + bootdev bootefi + bootflow booti bootmenu + bootmeth button x86/cbsysinfo conitrace
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
PATCH v2 41/41 RFC: Switch rpi over to use bootstd
In reply to Simon GlassSwitch this over, for testing purposes.
---
(no changes since v1)
boot/Kconfig | 3 ++- include/configs/rpi.h | 41 ++++------------------------------------- 2 files changed, 6 insertions(+), 38 deletions(-)
boot/Kconfig +2 -1
@@ -1061,7 +1061,8 @@ config USE_BOOTCOMMAND config BOOTCOMMAND string "bootcmd value" depends on USE_BOOTCOMMAND && !USE_DEFAULT_ENV_FILE - default "run distro_bootcmd" if DISTRO_DEFAULTS + default "bootflow scan -lb" if BOOTSTD + default "run distro_bootcmd" if !BOOTSTD && DISTRO_DEFAULTS help This is the string of commands that will be used as bootcmd and if AUTOBOOT is set, automatically run.
include/configs/rpi.h +4 -37
52 lines not on this page · raw message
Signature · 1 line
2.33.0.1079.g6e70778dc9-goog
Re: [PATCH v2 41/41] RFC: Switch rpi over to use bootstd
Quoted 3 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>
[snip]
include/configs/rpi.h line 136
Quoted 2 lines
include/configs/rpi.h +2
-0+"ramdisk_addr_r=0x02700000\0" \ +"ethaddr=b8:27:eb:a6:61:e1\0"
I know this is just testing, but, you cannot hard-code the ethaddr to the environment.
Signature · 1 line
Tom
Re: [PATCH v2 41/41] RFC: Switch rpi over to use bootstd
In reply to Simon GlassQuoted 3 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>
[snip]
include/configs/rpi.h line 140
Quoted 3 lines
#define
CONFIG_EXTRA_ENV_SETTINGS\include/configs/rpi.h +1
-0"dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ +"boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \
So, based on this patch I went "oh, so we can still easily control the device order, per board and also for users to tweak". Then I looked for where boot_targets was used, saw it wasn't and looked over the
documentation patch previous to this. That's not looking easier to
configure than what we have now either.
Signature · 1 line
Tom
Re: [PATCH v2 41/41] RFC: Switch rpi over to use bootstd
Hi Tom,
Quoted 11 lines · Tom Rini
Quoted 3 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>[snip]
Quoted 3 lines
#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \+ "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \
Quoted 5 lines
So, based on this patch I went "oh, so we can still easily control the device order, per board and also for users to tweak". Then I looked for where
boot_targetswas used, saw it wasn't and looked over the
documentation patch previous to this. That's not looking easier to
configure than what we have now either.
Yes, I did originally implement the boot_targets env var, then decided it should be in the device tree instead, since you can do:
bootstd {
compatible = "u-boot,boot-std";
bootdev-order = "mmc2", "mmc1";
};
(with nothing else in the devicetree)
I made this change since it seems that boot_targets is always set in the env and should not be touched by the distro. If that is not correct I can bring the code back...
BTW the MAC address was just for my testing.
Regards,
Simon
Re: [PATCH v2 41/41] RFC: Switch rpi over to use bootstd
Quoted 28 lines · Simon Glass
Hi Tom,
Quoted 11 lines · Tom Rini
Quoted 3 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>[snip]
Quoted 3 lines
#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \+ "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \
Quoted 5 lines
So, based on this patch I went "oh, so we can still easily control the device order, per board and also for users to tweak". Then I looked for where
boot_targetswas used, saw it wasn't and looked over the
documentation patch previous to this. That's not looking easier to
configure than what we have now either.Yes, I did originally implement the
boot_targetsenv var, then decided it should be in the device tree instead, since you can do:bootstd { compatible = "u-boot,boot-std"; bootdev-order = "mmc2", "mmc1"; };
Quoted 5 lines
(with nothing else in the devicetree)
I made this change since it seems that
boot_targetsis always set in the env and should not be touched by the distro. If that is not correct I can bring the code back...
Aside from what I said to the cover letter, I think all of the device tree stuff is taking it the wrong direction. The environment is something that can easily be manipulated in a persistent and well understood manner by a number of tools, and is done so today. Defining the boot order to start with in a device tree fragment is going to be annoying for all of the platforms where the device tree comes from somewhere else. But it's going to suck even more for users to manipulate (now that we've installed, we don't want to probe the whole world normally, just check where it's installed).
I'm not seeing this as a better step forward at all right now, sorry.
Quoted 1 line
BTW the MAC address was just for my testing.
Hoped so, thanks :)
Signature · 1 line
Tom
Quoted 6 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
Quoted 6 lines
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)
Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
Best regards
Heinrich
Quoted 264 lines
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
With this we can boot on a Raspberry Pi 3 with just one command:
bootflow scan -lb
which means to scan, listing (-l) each bootflow and trying to boot each one (-b). The final patch shows this.
With a standard way to identify boot devices, booting become easier. It also should be possible to support U-Boot scripts, for backwards compatibility only.
This series relies on the PXE clean-up series, posted here:
https://patchwork.ozlabs.org/project/uboot/list/?series=267078For documentation, see the 'doc' patch.
For version 2, a new naming scheme is used as above:
- bootdev is used instead of bootdevice, because 'device' is overused, is everywhere in U-Boot, can be confused with udevice
- bootmeth - because 'method' is too vanilla, appears 1300 times in U-BootAlso in version 2, drivers are introduced for the boot methods, to make it more extensible. Booting a custom OS is simply a matter of creating a bootmeth for it and implementing the
read_file()andboot()methods.The design is described in these two documents:
https://drive.google.com/file/d/1ggW0KJpUOR__vBkj3l61L2dav4ZkNC12/view?usp=sharing
https://drive.google.com/file/d/1kTrflO9vvGlKp-ZH_jlgb9TY3WYG6FF9/view?usp=sharing
The series is available at u-boot-dm/bme-working
Sample log on
rpi_3_32b:U-Boot 2021.10-rc2-00043-gccd453aa918-dirty (Aug 28 2021 - 13:58:46 -0600)
DRAM: 992 MiB
RPI 3 Model B (0xa22082)
MMC: mmc@7e202000: 0, sdhci@7e300000: 1
Loading Environment from FAT... Unable to read "uboot.env" from mmc0:1... In: serialOut: vidconsole Err: vidconsole Net: No ethernet found.starting USB...
Bus usb@7e980000: USB DWC2
scanning bus usb@7e980000 for devices...usb_kbdusb_kbd: Timeout poll on interrupt endpoint Failed to get keyboard state from device 0c40:8000
4 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot: 0
Scanning for bootflows in all bootmethodsSeq Type State Uclass Part Name Filename --- ----------- ------ -------- ---- ------------------------ ----------------Scanning bootmethod '[email protected]':
0 efi-loader loaded mmc 1 [email protected] efi/boot/bootarm.efi
** Booting bootflow '[email protected]_1' Scanning disk [email protected]...
** Unrecognized filesystem type **
Card did not respond to voltage select! : -110 Scanning disk [email protected]...
Disk [email protected] not ready
Found 4 disks
No EFI system partition
Booting /efi\boot
Waiting for Ethernet connection... done.Fedora (5.11.12-300.fc34.armv7hl) 34 (Workstation Edition) UEFI Firmware Settings
Use the ▲ and ▼ keys to change the selection.
Press 'e' to edit the selected item, or 'c' for a command prompt. Press Escape to return to the previous menu.
The selected entry will be started automatically in 0s.Changes in v2:
- Free the memory buffer, to avoid running out of memory
- Unmap the file
- Reorder structsandbox_mmc_privSimon Glass (41):
lib: Add a way to find the postiion of a trailing number
Makefile: Allow LTO to be disabled for a build test/py: Allow passing input to a program
sandbox: Support unmapping a file
sandbox: mmc: Support a backing file
mmc: Allow for children other than the block device
mbr: Correct verification check
disk:part_dos: Fix a NULL pointer error
common: Allow a smaller console-recording pre-reloc
dm: core: Add tests for stringlist functions
dm: core: Fix handling of uclasspre_unbindmethod
dm: core: Fix up string-function documentation
dm: core: Add a way to obtain a string list
dm: core: Allow finding children / uclasses by partial name
dm: core: Add a way to count the devices in a uclass
sandbox: Enable HEXDUMP forsandbox_flattreetest/py: Relax the naming rules for unit tests test/py: Raise a ValueError if a command fails
bootstd: Add the concept of a bootflow
bootstd: Add the bootstd uclass and core implementation
bootstd: Add the bootdev uclass
bootstd: Add the bootmeth uclass and helpers
bootstd: Add support for bootflows
bootstd: Add a bootdev command
bootstd: Add a bootflow ommand
bootstd: Add a bootmeth command
bootstd: Add an implementation of distro boot
bootstd: mmc: Add a bootdev driver
bootstd: ethernet: Add a bootdev driver
bootstd: Add an implementation of distro PXE boot
bootstd: Add an implementation of EFI boot
bootstd: Add a system bootdev for strange boot methods
bootstd: Add an implementation of EFI bootmgr
bootstd: Add a sandbox bootmeth driver
bootstd: usb: Add a bootdev driver
test: fastboot: Avoid using mmc1
test: dm: Restart USB before assuming it is stopped
bootstd: Add tests for bootstd including all uclasses
bootstd: Add setup for the bootflow tests
bootstd: doc: Add documentation
RFC: Switch rpi over to use bootstdMAINTAINERS | 21 + Makefile | 18 +- arch/arm/config.mk | 4 +- arch/arm/include/asm/global_data.h | 2 +- arch/sandbox/cpu/os.c | 10 + arch/sandbox/dts/test.dts | 19 + boot/Kconfig | 77 ++- boot/Makefile | 14 + boot/bootdev-uclass.c | 439 ++++++++++++++ boot/bootflow.c | 576 ++++++++++++++++++ boot/bootmeth-uclass.c | 59 ++ boot/bootmeth_distro.c | 217 +++++++ boot/bootmeth_efi.c | 263 ++++++++ boot/bootmeth_efi_mgr.c | 84 +++ boot/bootmeth_pxe.c | 183 ++++++ boot/bootmeth_sandbox.c | 67 +++ boot/bootstd-uclass.c | 176 ++++++ boot/system_bootdev.c | 64 ++ cmd/Kconfig | 15 + cmd/Makefile | 1 + cmd/bootdev.c | 120 ++++ cmd/bootflow.c | 386 ++++++++++++ cmd/bootmeth.c | 158 +++++ cmd/mbr.c | 8 +- common/Kconfig | 10 + common/console.c | 4 +- common/usb_storage.c | 12 + configs/amcore_defconfig | 1 + configs/rcar3_salvator-x_defconfig | 1 + configs/sandbox_defconfig | 3 +- configs/sandbox_flattree_defconfig | 4 +- configs/tbs2910_defconfig | 1 + disk/part_dos.c | 10 +- doc/build/gcc.rst | 17 + doc/develop/bootstd.rst | 600 +++++++++++++++++++ doc/develop/distro.rst | 3 + doc/develop/index.rst | 1 + doc/device-tree-bindings/bootdev.txt | 26 + doc/device-tree-bindings/bootmeth.txt | 31 + doc/device-tree-bindings/bootstd.txt | 36 ++ doc/device-tree-bindings/mmc/sandbox,mmc.txt | 18 + doc/usage/bootdev.rst | 135 +++++ doc/usage/bootflow.rst | 427 +++++++++++++ doc/usage/bootmeth.rst | 106 ++++ doc/usage/index.rst | 3 + drivers/core/device-remove.c | 9 +- drivers/core/device.c | 13 +- drivers/core/of_access.c | 3 +- drivers/core/ofnode.c | 26 + drivers/core/read.c | 6 + drivers/core/uclass.c | 29 +- drivers/mmc/Makefile | 5 + drivers/mmc/mmc-uclass.c | 27 +- drivers/mmc/mmc_bootdev.c | 62 ++ drivers/mmc/sandbox_mmc.c | 60 +- drivers/usb/host/Makefile | 4 + drivers/usb/host/usb_bootdev.c | 61 ++ include/bootdev.h | 258 ++++++++ include/bootflow.h | 304 ++++++++++ include/bootmeth.h | 156 +++++ include/bootstd.h | 80 +++ include/configs/rpi.h | 41 +- include/distro.h | 24 + include/dm/device.h | 12 + include/dm/ofnode.h | 24 +- include/dm/read.h | 28 + include/dm/uclass-id.h | 3 + include/dm/uclass-internal.h | 14 +- include/dm/uclass.h | 17 + include/mmc.h | 12 +- include/os.h | 9 + include/test/suites.h | 2 + include/vsprintf.h | 18 + lib/strto.c | 14 +- net/Kconfig | 9 + net/Makefile | 1 + net/eth-uclass.c | 8 + net/eth_bootdev.c | 101 ++++ test/Makefile | 1 + test/boot/Makefile | 5 + test/boot/bootdev.c | 200 +++++++ test/boot/bootflow.c | 398 ++++++++++++ test/boot/bootmeth.c | 90 +++ test/boot/bootstd_common.c | 35 ++ test/boot/bootstd_common.h | 27 + test/cmd_ut.c | 7 + test/dm/blk.c | 6 + test/dm/fastboot.c | 4 +- test/dm/ofnode.c | 96 +++ test/py/conftest.py | 2 +- test/py/multiplexed_log.py | 10 +- test/py/tests/bootstd/mmc1.img.xz | Bin 0 -> 4448 bytes test/py/tests/test_ut.py | 103 ++++ test/py/u_boot_utils.py | 5 +- 94 files changed, 6765 insertions(+), 94 deletions(-)create mode 100644
boot/bootdev-uclass.c
create mode 100644boot/bootflow.c
create mode 100644boot/bootmeth-uclass.c
create mode 100644boot/bootmeth_distro.c
create mode 100644boot/bootmeth_efi.c
create mode 100644boot/bootmeth_efi_mgr.c
create mode 100644boot/bootmeth_pxe.c
create mode 100644boot/bootmeth_sandbox.c
create mode 100644boot/bootstd-uclass.c
create mode 100644boot/system_bootdev.c
create mode 100644cmd/bootdev.c
create mode 100644cmd/bootflow.c
create mode 100644cmd/bootmeth.c
create mode 100644doc/develop/bootstd.rst
create mode 100644doc/device-tree-bindings/bootdev.txtcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/device-tree-bindings/bootstd.txtcreate mode 100644doc/device-tree-bindings/mmc/sandbox,mmc.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rst
create mode 100644doc/usage/bootmeth.rst
create mode 100644drivers/mmc/mmc_bootdev.c
create mode 100644drivers/usb/host/usb_bootdev.ccreate mode 100644include/bootdev.h
create mode 100644include/bootflow.h
create mode 100644include/bootmeth.h
create mode 100644include/bootstd.h
create mode 100644include/distro.h
create mode 100644net/eth_bootdev.c
create mode 100644 test/boot/Makefile
create mode 100644test/boot/bootdev.c
create mode 100644test/boot/bootflow.c
create mode 100644test/boot/bootmeth.c
create mode 100644test/boot/bootstd_common.c
create mode 100644test/boot/bootstd_common.h
create mode 100644 test/py/tests/bootstd/mmc1.img.xz
Hi Heinrich,
Quoted 27 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
Quoted 6 lines
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
Quoted 7 lines
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you might have the wrong end of the stick. It is certainly possible to add nodes to configure things, if needed, but it works find without any changes to the devicetree, as you can see from the rpi_3 patch.
There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that everyone can plug into (distros, board vendors, people using a custom flow)
- Move all this stuff out of the environment so we can move to a text-based environment that doesn't rely on ad-hoc CONFIG options (this unblocks the 7-year-old CONFIG migration)
- Add proper tests to cover this important functionality (the scripts have no tests)
(this makes development much easier and faster)
- Provide a path to booting more 'directly' without needing the CLI (which adds size / security risk)
This initial series is not the end of the matter. I expect various other people will contribute to cover their use cases and additional features, but at least now we have good basis for this development and innovation.
[..]
Regards,
Simon
Quoted 45 lines · Simon Glass
Hi Heinrich,
Quoted 27 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
Quoted 6 lines
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
Quoted 7 lines
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you might have the wrong end of the stick. It is certainly possible to add nodes to configure things, if needed, but it works find without any changes to the devicetree, as you can see from the
rpi_3patch.
Quoted 4 lines
There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that everyone can plug into (distros, board vendors, people using a custom flow)
I as a distro maintainer don't want this, we already get the "standard way to boot" from UEFI, this just feels like another unnecessary abstraction to that.
I do actually like a bunch of the ideas in here, random scripts in distro_boot were a big step forward for straight forward booting a decade or so when everything prior was random board specific boot.scr and uImage but things have evolved into booting via UEFI which is very standard across the general purpose compute devices style industries and clearing up the random behind the scenes hush scripting is definitely long overdue but I don't feel there needs to be another layer of unnecessary indirection here.
Quoted 18 lines
- Move all this stuff out of the environment so we can move to a text-based environment that doesn't rely on ad-hoc CONFIG options (this unblocks the 7-year-old CONFIG migration)
- Add proper tests to cover this important functionality (the scripts have no tests)
(this makes development much easier and faster)
- Provide a path to booting more 'directly' without needing the CLI (which adds size / security risk)This initial series is not the end of the matter. I expect various other people will contribute to cover their use cases and additional features, but at least now we have good basis for this development and innovation.
[..]
Regards,
Simon
Quoted 46 lines · Peter Robinson
Quoted 45 lines · Simon Glass
Hi Heinrich,
Quoted 27 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
Quoted 6 lines
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
Quoted 7 lines
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you might have the wrong end of the stick. It is certainly possible to add nodes to configure things, if needed, but it works find without any changes to the devicetree, as you can see from the
rpi_3patch.
Quoted 8 lines
Quoted 4 lines
There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that everyone can plug into (distros, board vendors, people using a custom flow)
I as a distro maintainer don't want this, we already get the "standard way to boot" from UEFI, this just feels like another unnecessary abstraction to that.
Right. But part of the problem is "How do I find UEFI". Something somewhere needs to be configurable to say where to look, yes?
Signature · 1 line
Tom
Quoted 53 lines · Tom Rini
Quoted 51 lines · Peter Robinson
Quoted 49 lines · Simon Glass
Hi Heinrich,
Quoted 27 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
Quoted 6 lines
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
Quoted 7 lines
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you might have the wrong end of the stick. It is certainly possible to add nodes to configure things, if needed, but it works find without any changes to the devicetree, as you can see from the
rpi_3patch.There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that everyone can plug into (distros, board vendors, people using a custom flow)
Quoted 6 lines
Quoted 3 lines
I as a distro maintainer don't want this, we already get the "standard way to boot" from UEFI, this just feels like another unnecessary abstraction to that.
Right. But part of the problem is "How do I find UEFI". Something somewhere needs to be configurable to say where to look, yes?
Is this question from the board PoV, the developer of U-Boot or the distro trying to boot?
If you mean from a boot flow PoV for UEFI to find the HW that contains the OS to boot I thought that was handled elsewhere in the series.
Quoted 58 lines · Peter Robinson
Quoted 57 lines · Tom Rini
Quoted 54 lines · Peter Robinson
Quoted 45 lines · Simon Glass
Hi Heinrich,
Quoted 27 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
Quoted 6 lines
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
Quoted 7 lines
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you might have the wrong end of the stick. It is certainly possible to add nodes to configure things, if needed, but it works find without any changes to the devicetree, as you can see from the
rpi_3patch.Quoted 4 lines
There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that everyone can plug into (distros, board vendors, people using a custom flow)
I as a distro maintainer don't want this, we already get the "standard way to boot" from UEFI, this just feels like another unnecessary abstraction to that.
Quoted 8 lines
Quoted 2 lines
Right. But part of the problem is "How do I find UEFI". Something somewhere needs to be configurable to say where to look, yes?
Is this question from the board PoV, the developer of U-Boot or the distro trying to boot?
If you mean from a boot flow PoV for UEFI to find the HW that contains the OS to boot I thought that was handled elsewhere in the series.
What I mean is that today looking at Pi we have:
#define BOOT_TARGET_DEVICES(func) \
BOOT_TARGET_MMC(func) \
BOOT_TARGET_USB(func) \
BOOT_TARGET_PXE(func) \
BOOT_TARGET_DHCP(func)As the board maintainer set that as the list of places to start looking for the next payload (say the GRUB EFI binary). Simon's series replaces that with I think he said "bootflow scan -b". And then the above env portion is replaced with, well, what's documented in patch #40 if you don't just want to rely on device probe order.
Because we need to have _something_ that says where to look for what, yes? Or should that be replaced entirely with efi vars and BootOrder/BootXXX and "bootefi bootmgr $fdt_addr_r" ?
Signature · 1 line
Tom
Quoted 81 lines · Tom Rini
Quoted 58 lines · Peter Robinson
Quoted 57 lines · Tom Rini
Quoted 54 lines · Peter Robinson
Quoted 45 lines · Simon Glass
Hi Heinrich,
Quoted 27 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
Quoted 6 lines
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
Quoted 7 lines
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you might have the wrong end of the stick. It is certainly possible to add nodes to configure things, if needed, but it works find without any changes to the devicetree, as you can see from the
rpi_3patch.Quoted 4 lines
There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that everyone can plug into (distros, board vendors, people using a custom flow)
I as a distro maintainer don't want this, we already get the "standard way to boot" from UEFI, this just feels like another unnecessary abstraction to that.
Quoted 8 lines
Quoted 2 lines
Right. But part of the problem is "How do I find UEFI". Something somewhere needs to be configurable to say where to look, yes?
Is this question from the board PoV, the developer of U-Boot or the distro trying to boot?
If you mean from a boot flow PoV for UEFI to find the HW that contains the OS to boot I thought that was handled elsewhere in the series.
What I mean is that today looking at Pi we have:
#define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_MMC(func) \ BOOT_TARGET_USB(func) \ BOOT_TARGET_PXE(func) \ BOOT_TARGET_DHCP(func)As the board maintainer set that as the list of places to start looking for the next payload (say the GRUB EFI binary). Simon's series replaces that with I think he said "bootflow scan -b". And then the above env portion is replaced with, well, what's documented in patch #40 if you don't just want to rely on device probe order.
Quoted 4 lines
Because we need to have _something_ that says where to look for what, yes? Or should that be replaced entirely with efi vars and BootOrder/BootXXX and "bootefi bootmgr $fdt_addr_r" ?
UEFI variables must be supported for booting via UEFI. But if no valid image can be found via the UEFI variables you have to scan the EFI system partition for the file EFI/BOOT/BOOT<arch>.EFI and run it. This requires to scan all block devices for the ESP.
Furthermore not all distributions use UEFI by default on all systems.
Best regards
Heinrich
Quoted 87 lines · Heinrich Schuchardt
Quoted 81 lines · Tom Rini
Quoted 58 lines · Peter Robinson
Quoted 57 lines · Tom Rini
Quoted 54 lines · Peter Robinson
Quoted 45 lines · Simon Glass
Hi Heinrich,
Quoted 27 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
Quoted 6 lines
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
Quoted 7 lines
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you might have the wrong end of the stick. It is certainly possible to add nodes to configure things, if needed, but it works find without any changes to the devicetree, as you can see from the
rpi_3patch.Quoted 4 lines
There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that everyone can plug into (distros, board vendors, people using a custom flow)
I as a distro maintainer don't want this, we already get the "standard way to boot" from UEFI, this just feels like another unnecessary abstraction to that.
Quoted 8 lines
Quoted 2 lines
Right. But part of the problem is "How do I find UEFI". Something somewhere needs to be configurable to say where to look, yes?
Is this question from the board PoV, the developer of U-Boot or the distro trying to boot?
If you mean from a boot flow PoV for UEFI to find the HW that contains the OS to boot I thought that was handled elsewhere in the series.
What I mean is that today looking at Pi we have:
#define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_MMC(func) \ BOOT_TARGET_USB(func) \ BOOT_TARGET_PXE(func) \ BOOT_TARGET_DHCP(func)As the board maintainer set that as the list of places to start looking for the next payload (say the GRUB EFI binary). Simon's series replaces that with I think he said "bootflow scan -b". And then the above env portion is replaced with, well, what's documented in patch #40 if you don't just want to rely on device probe order.
Quoted 4 lines
Because we need to have _something_ that says where to look for what, yes? Or should that be replaced entirely with efi vars and BootOrder/BootXXX and "bootefi bootmgr $fdt_addr_r" ?
Quoted 6 lines
UEFI variables must be supported for booting via UEFI. But if no valid image can be found via the UEFI variables you have to scan the EFI system partition for the file EFI/BOOT/BOOT<arch>.EFI and run it. This requires to scan all block devices for the ESP.
Furthermore not all distributions use UEFI by default on all systems.
Assume a UEFI distribution for the moment. What should the default boot command look like, these days? Can U-Boot have persistent UEFI variables directly (rather than say indirectly with a preboot=... to set them) or no? Or should it continue to be the EFI-related logic in include/config_distro_bootcmd.h ?
Signature · 1 line
Tom
Hi Tom,
Quoted 92 lines · Tom Rini
Quoted 4 lines · Peter Robinson
Quoted 3 lines · Tom Rini
Quoted 1 line · Peter Robinson
On Wed, Oct 27, 2021 at 3:11 PM Simon Glass <[email protected]>
Quoted 11 lines · wrote:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Hi Heinrich,
Quoted 6 lines · Heinrich Schuchardt
Quoted 2 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to
automatically
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
boot an Operating System without custom scripting and other
customisation.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
This is called 'standard boot' since it provides a standard
way for
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows(owned by
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
U-Boot)
- bootflow - a description of how to boot (owned by thedistro)
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing
flexibility
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow
shall be
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
defined. Describing some device-tree binding in patch 40/41 does
not
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
replace describing the development and usage workflow. Who will
provide
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
which bootflow information when?
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before
considering
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
this series.
In my view bootflows cannot be defined in the devicetree because
prior
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
firmware providing a devicetree is completely independent of any
distro
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you might have the wrong end of the stick. It is certainly possible to add
nodes
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
to configure things, if needed, but it works find without any
changes
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
to the devicetree, as you can see from the
rpi_3patch.There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that everyone
can
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
plug into (distros, board vendors, people using a custom flow)
I as a distro maintainer don't want this, we already get the
"standard
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
way to boot" from UEFI, this just feels like another unnecessary abstraction to that.
Right. But part of the problem is "How do I find UEFI". Something somewhere needs to be configurable to say where to look, yes?
Is this question from the board PoV, the developer of U-Boot or the distro trying to boot?
If you mean from a boot flow PoV for UEFI to find the HW that contains the OS to boot I thought that was handled elsewhere in the series.
What I mean is that today looking at Pi we have:
#define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_MMC(func) \ BOOT_TARGET_USB(func) \ BOOT_TARGET_PXE(func) \ BOOT_TARGET_DHCP(func)
Quoted 8 lines
As the board maintainer set that as the list of places to start looking for the next payload (say the GRUB EFI binary). Simon's series replaces that with I think he said "bootflow scan -b". And then the above env portion is replaced with, well, what's documented in patch #40 if you don't just want to rely on device probe order.
Because we need to have _something_ that says where to look for what, yes?
Shouldn’t we describe the user point of view ?
Even before EFI existed on x86 it went like (this is not intending to be exhaustive or even exact):
Start a non installed system: the boot goes through a device list much like distro_boot_CMd works except if the user select a manual boot selection (the boot devices goes into a menu)
When the installer finishes it “informs” the firmware with the desired boot target.
When the OS runs it can select the next boot (transient or permanent) option. This usually involves grub rather than firmware but the user can decide if the boot target change is driven by the firmware. (For SystemReady we want to have an option to live without shim and grub so the boot target change will involve setting BootXXXX.)
I think it is first important to describe the observable behavior before jumping into implementation. Scenarios involving développer systems may be different from the ones for consumer products.
Or should that be replaced entirely with efi vars and
Quoted 1 line
BootOrder/BootXXX and "bootefi bootmgr $fdt_addr_r" ?
for EFI there is also the last resort /BOOT/BOOT${arch}.efi in ESP
Quoted 4 lines
--
Tom
Signature · 3 lines
François-Frédéric Ozog | *Director Business Development* T: +33.67221.6485 [email protected] | Skype: ffozog
Quoted 102 lines · François Ozog
Hi Tom,
Quoted 98 lines · Tom Rini
Quoted 4 lines · Peter Robinson
Quoted 3 lines · Tom Rini
Quoted 1 line · Peter Robinson
On Wed, Oct 27, 2021 at 3:11 PM Simon Glass <[email protected]>
Quoted 11 lines · wrote:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Hi Heinrich,
Quoted 6 lines · Heinrich Schuchardt
Quoted 2 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to
automatically
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
boot an Operating System without custom scripting and other
customisation.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
This is called 'standard boot' since it provides a standard
way for
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows(owned by
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
U-Boot)
- bootflow - a description of how to boot (owned by thedistro)
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing
flexibility
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow
shall be
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
defined. Describing some device-tree binding in patch 40/41 does
not
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
replace describing the development and usage workflow. Who will
provide
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
which bootflow information when?
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before
considering
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
this series.
In my view bootflows cannot be defined in the devicetree because
prior
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
firmware providing a devicetree is completely independent of any
distro
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you might have the wrong end of the stick. It is certainly possible to add
nodes
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
to configure things, if needed, but it works find without any
changes
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
to the devicetree, as you can see from the
rpi_3patch.There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that everyone
can
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
plug into (distros, board vendors, people using a custom flow)
I as a distro maintainer don't want this, we already get the
"standard
Quoted 11 lines
Quoted 5 lines
Quoted 2 lines
way to boot" from UEFI, this just feels like another unnecessary abstraction to that.
Right. But part of the problem is "How do I find UEFI". Something somewhere needs to be configurable to say where to look, yes?
Is this question from the board PoV, the developer of U-Boot or the distro trying to boot?
If you mean from a boot flow PoV for UEFI to find the HW that contains the OS to boot I thought that was handled elsewhere in the series.
What I mean is that today looking at Pi we have:
#define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_MMC(func) \ BOOT_TARGET_USB(func) \ BOOT_TARGET_PXE(func) \ BOOT_TARGET_DHCP(func)As the board maintainer set that as the list of places to start looking for the next payload (say the GRUB EFI binary). Simon's series replaces that with I think he said "bootflow scan -b". And then the above env portion is replaced with, well, what's documented in patch #40 if you don't just want to rely on device probe order.
Quoted 4 lines
Quoted 2 lines
Because we need to have _something_ that says where to look for what, yes?
Shouldn’t we describe the user point of view ?
No, because to extend the x86 metaphor we're talking about the defaults here, not what the user has configured later on. The user has and continues to be able to configure the system afterwards, if desired.
Signature · 1 line
Tom
Hi Tom
Quoted 114 lines · Tom Rini
Quoted 32 lines · François Ozog
Hi Tom,
Quoted 28 lines · Tom Rini
Quoted 4 lines · Peter Robinson
Quoted 3 lines · Tom Rini
Quoted 1 line · Peter Robinson
On Wed, Oct 27, 2021 at 3:11 PM Simon Glass <[email protected]>
Quoted 11 lines · wrote:
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Hi Heinrich,
Quoted 6 lines · Heinrich Schuchardt
Quoted 2 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to
automatically
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
boot an Operating System without custom scripting and other
customisation.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
This is called 'standard boot' since it provides a standard
way for
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to findbootflows
Quoted 7 lines
Quoted 7 lines
(owned by
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
U-Boot)
- bootflow - a description of how to boot (owned by thedistro)
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Please, describe why you are suggesting this change.
Quoted 7 lines
Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Replacing a script by a devicetree chunk is just decreasing
flexibility
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow
shall be
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
defined. Describing some device-tree binding in patch 40/41
does
Quoted 2 lines
Quoted 2 lines
not
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
replace describing the development and usage workflow. Who
will
Quoted 4 lines
Quoted 4 lines
provide
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
which bootflow information when?
You still have an open discussion with Linaro about the
source of
Quoted 5 lines
Quoted 5 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
devicetrees. This discussion needs to be finalized before
considering
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
this series.
In my view bootflows cannot be defined in the devicetree
because
Quoted 2 lines
Quoted 2 lines
prior
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
firmware providing a devicetree is completely independent of
any
Quoted 4 lines
Quoted 4 lines
distro
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you
might
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
have the wrong end of the stick. It is certainly possible to
add
Quoted 8 lines
Quoted 8 lines
nodes
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
to configure things, if needed, but it works find without any
changes
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
to the devicetree, as you can see from the
rpi_3patch.There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that
everyone
Quoted 8 lines
Quoted 8 lines
can
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
plug into (distros, board vendors, people using a custom flow)
I as a distro maintainer don't want this, we already get the
"standard
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines
way to boot" from UEFI, this just feels like another unnecessary abstraction to that.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Right. But part of the problem is "How do I find UEFI". Something somewhere needs to be configurable to say where to look, yes?
Is this question from the board PoV, the developer of U-Boot or the distro trying to boot?
If you mean from a boot flow PoV for UEFI to find the HW that
contains
Quoted 11 lines
Quoted 11 lines
Quoted 1 line
the OS to boot I thought that was handled elsewhere in the series.
What I mean is that today looking at Pi we have:
#define BOOT_TARGET_DEVICES(func) \ BOOT_TARGET_MMC(func) \ BOOT_TARGET_USB(func) \ BOOT_TARGET_PXE(func) \ BOOT_TARGET_DHCP(func)As the board maintainer set that as the list of places to start looking for the next payload (say the GRUB EFI binary). Simon's series
replaces
Quoted 4 lines
Quoted 4 lines
that with I think he said "bootflow scan -b". And then the above env portion is replaced with, well, what's documented in patch #40 if you don't just want to rely on device probe order.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
Because we need to have _something_ that says where to look for what, yes?
Shouldn’t we describe the user point of view ?
No, because to extend the x86 metaphor we're talking about the defaults here, not what the user has configured later on. The user has and continues to be able to configure the system afterwards, if desired.
Sorry , missed this “detail”…
Quoted 4 lines
--
Tom
Signature · 3 lines
François-Frédéric Ozog | *Director Business Development* T: +33.67221.6485 [email protected] | Skype: ffozog
Quoted 55 lines
Date: Thu, 28 Oct 2021 13:47:21 -0400
From: Tom Rini <[email protected]>Quoted 51 lines · Peter Robinson
Quoted 49 lines · Simon Glass
Hi Heinrich,
Quoted 27 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
Quoted 6 lines
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
Quoted 7 lines
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
There is actually no need to use devicetree here. I think you might have the wrong end of the stick. It is certainly possible to add nodes to configure things, if needed, but it works find without any changes to the devicetree, as you can see from the
rpi_3patch.There are several aims with this effort:
- Provide a standard way to boot anything on U-Boot, that everyone can plug into (distros, board vendors, people using a custom flow)
Quoted 6 lines
Quoted 3 lines
I as a distro maintainer don't want this, we already get the "standard way to boot" from UEFI, this just feels like another unnecessary abstraction to that.
Right. But part of the problem is "How do I find UEFI". Something somewhere needs to be configurable to say where to look, yes?
Before we had "bootefi bootmgr", this was done using "setenv boot_targets ...", where you would specify a list of devices to try and boot from. This is effectively a command line version of the menu that most x86 BIOS (and UEFI) implementations offer to specify the order of devices to boot from. We document this in the OpenBSD/arm64 installtion instructions and it wouldn't surprise me of some of the Linux distro's do this as well. This still works fine, unless you set the UEFI variables that "bootefi bootmgr" looks at. But I fear Simon's patch series breaks this. I didn't try the patch series yet though, so I might be mistaken.
When "bootefi bootmgr" is used, the device/OS to boot is specified by the Boot#### and BootOrder UEFI variables. I believe these can be set from the U-Boot command line, but doing so in the right way isn't trivial. The way this is supposed to work I think is that the OS installer defines an appropriate Boot#### variable and adds it to tje BootOrder variable. But that pretty much relies on on the ability to set those variables at OS runtime using EFI runtime services. And as was pointed out that doesn't really work for most U-Boot targets. To be honest, I don't really understand how "bootefi bootmgr" is used in the real world right now.
There is a lot of good work done in this area in U-Boot. But I get the feeling that too much of it is driven by meeting requirements of specs and that there is too little thought put into the practicalities of actually booting a general purpose OS (e.g. a mainstrain Linux distro) on a board with U-Boot support.
Hi Heinrich,
Quoted 27 lines · Heinrich Schuchardt
Quoted 3 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other
customisation.
Quoted 9 lines
This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
Quoted 8 lines
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
Agreed if we talk about the DT passed to the OS.
There are discussions in System Device Tree to represent partition booting orchestration information in a System Device Tree.
This information may end-up being integrated in "a" device tree that will be used only by hypervisor as dynamic config.
The same applies to secure world partitions: manifest are declared in "a" device tree that is consumed only by secure hypervisor (hafnium for the moment) as dynamic configuration, passed as a separate entity from a FIP section (I think it is TOS_CONFIG)
https://trustedfirmware-a.readthedocs.io/en/latest/components/ffa-manifest-binding.html
The other pattern is firmware component DT binding can be standardized separately from platform device tree.
Quoted 280 lines
Best regards
Heinrich
Quoted 20 lines
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
With this we can boot on a Raspberry Pi 3 with just one command:
bootflow scan -lb
which means to scan, listing (-l) each bootflow and trying to boot each one (-b). The final patch shows this.
With a standard way to identify boot devices, booting become easier. It also should be possible to support U-Boot scripts, for backwards compatibility only.
This series relies on the PXE clean-up series, posted here:
Quoted 7 lines
https://patchwork.ozlabs.org/project/uboot/list/?series=267078For documentation, see the 'doc' patch.
For version 2, a new naming scheme is used as above:
- bootdev is used instead of bootdevice, because 'device' is
overused,
Quoted 11 lines
is everywhere in U-Boot, can be confused with udevice
- bootmeth - because 'method' is too vanilla, appears 1300 times in U-BootAlso in version 2, drivers are introduced for the boot methods, to make it more extensible. Booting a custom OS is simply a matter of creating a bootmeth for it and implementing the
read_file()andboot()methods.The design is described in these two documents:
https://drive.google.com/file/d/1ggW0KJpUOR__vBkj3l61L2dav4ZkNC12/view?usp=sharing
Quoted 2 lines
https://drive.google.com/file/d/1kTrflO9vvGlKp-ZH_jlgb9TY3WYG6FF9/view?usp=sharing
Quoted 6 lines
The series is available at u-boot-dm/bme-working
Sample log on
rpi_3_32b:U-Boot 2021.10-rc2-00043-gccd453aa918-dirty (Aug 28 2021 - 13:58:46
-0600)
Quoted 5 lines
DRAM: 992 MiB
RPI 3 Model B (0xa22082)
MMC: mmc@7e202000: 0, sdhci@7e300000: 1
Loading Environment from FAT... Unable to read "uboot.env" frommmc0:1... In: serial
Quoted 6 lines
Out: vidconsole Err: vidconsole Net: No ethernet found.starting USB...
Bus usb@7e980000: USB DWC2
scanning bus usb@7e980000 for devices...usb_kbdusb_kbd: Timeout pollon interrupt endpoint
Quoted 6 lines
Failed to get keyboard state from device 0c40:8000
4 USB Device(s) found
scanning usb for storage devices... 0 Storage Device(s) found
Hit any key to stop autoboot: 0
Scanning for bootflows in all bootmethods
Seq Type State Uclass Part NameFilename
Quoted 1 line
--- ----------- ------ -------- ---- ------------------------
----------------
Quoted 2 lines
Scanning bootmethod '[email protected]':
0 efi-loader loaded mmc 1 [email protected]efi/boot/bootarm.efi
Quoted 11 lines
** Booting bootflow '[email protected]_1' Scanning disk [email protected]...
** Unrecognized filesystem type **
Card did not respond to voltage select! : -110 Scanning disk [email protected]...
Disk [email protected] not ready
Found 4 disks
No EFI system partition
Booting /efi\boot
Waiting for Ethernet connection... done.Quoted 5 lines
Fedora (5.11.12-300.fc34.armv7hl) 34 (Workstation Edition) UEFI Firmware Settings
Use the ▲ and ▼ keys to change the selection.
Press 'e' to edit the selected item, or 'c' for a command prompt.Press Escape to return to the previous menu.
Quoted 182 lines
The selected entry will be started automatically in 0s.
Changes in v2:
- Free the memory buffer, to avoid running out of memory
- Unmap the file
- Reorder structsandbox_mmc_privSimon Glass (41):
lib: Add a way to find the postiion of a trailing number
Makefile: Allow LTO to be disabled for a build test/py: Allow passing input to a program
sandbox: Support unmapping a file
sandbox: mmc: Support a backing file
mmc: Allow for children other than the block device
mbr: Correct verification check
disk:part_dos: Fix a NULL pointer error
common: Allow a smaller console-recording pre-reloc
dm: core: Add tests for stringlist functions
dm: core: Fix handling of uclasspre_unbindmethod
dm: core: Fix up string-function documentation
dm: core: Add a way to obtain a string list
dm: core: Allow finding children / uclasses by partial name
dm: core: Add a way to count the devices in a uclass
sandbox: Enable HEXDUMP forsandbox_flattreetest/py: Relax the naming rules for unit tests test/py: Raise a ValueError if a command fails
bootstd: Add the concept of a bootflow
bootstd: Add the bootstd uclass and core implementation
bootstd: Add the bootdev uclass
bootstd: Add the bootmeth uclass and helpers
bootstd: Add support for bootflows
bootstd: Add a bootdev command
bootstd: Add a bootflow ommand
bootstd: Add a bootmeth command
bootstd: Add an implementation of distro boot
bootstd: mmc: Add a bootdev driver
bootstd: ethernet: Add a bootdev driver
bootstd: Add an implementation of distro PXE boot
bootstd: Add an implementation of EFI boot
bootstd: Add a system bootdev for strange boot methods
bootstd: Add an implementation of EFI bootmgr
bootstd: Add a sandbox bootmeth driver
bootstd: usb: Add a bootdev driver
test: fastboot: Avoid using mmc1
test: dm: Restart USB before assuming it is stopped
bootstd: Add tests for bootstd including all uclasses
bootstd: Add setup for the bootflow tests
bootstd: doc: Add documentation
RFC: Switch rpi over to use bootstdMAINTAINERS | 21 + Makefile | 18 +- arch/arm/config.mk | 4 +- arch/arm/include/asm/global_data.h | 2 +- arch/sandbox/cpu/os.c | 10 + arch/sandbox/dts/test.dts | 19 + boot/Kconfig | 77 ++- boot/Makefile | 14 + boot/bootdev-uclass.c | 439 ++++++++++++++ boot/bootflow.c | 576 ++++++++++++++++++ boot/bootmeth-uclass.c | 59 ++ boot/bootmeth_distro.c | 217 +++++++ boot/bootmeth_efi.c | 263 ++++++++ boot/bootmeth_efi_mgr.c | 84 +++ boot/bootmeth_pxe.c | 183 ++++++ boot/bootmeth_sandbox.c | 67 +++ boot/bootstd-uclass.c | 176 ++++++ boot/system_bootdev.c | 64 ++ cmd/Kconfig | 15 + cmd/Makefile | 1 + cmd/bootdev.c | 120 ++++ cmd/bootflow.c | 386 ++++++++++++ cmd/bootmeth.c | 158 +++++ cmd/mbr.c | 8 +- common/Kconfig | 10 + common/console.c | 4 +- common/usb_storage.c | 12 + configs/amcore_defconfig | 1 + configs/rcar3_salvator-x_defconfig | 1 + configs/sandbox_defconfig | 3 +- configs/sandbox_flattree_defconfig | 4 +- configs/tbs2910_defconfig | 1 + disk/part_dos.c | 10 +- doc/build/gcc.rst | 17 + doc/develop/bootstd.rst | 600 +++++++++++++++++++ doc/develop/distro.rst | 3 + doc/develop/index.rst | 1 + doc/device-tree-bindings/bootdev.txt | 26 + doc/device-tree-bindings/bootmeth.txt | 31 + doc/device-tree-bindings/bootstd.txt | 36 ++ doc/device-tree-bindings/mmc/sandbox,mmc.txt | 18 + doc/usage/bootdev.rst | 135 +++++ doc/usage/bootflow.rst | 427 +++++++++++++ doc/usage/bootmeth.rst | 106 ++++ doc/usage/index.rst | 3 + drivers/core/device-remove.c | 9 +- drivers/core/device.c | 13 +- drivers/core/of_access.c | 3 +- drivers/core/ofnode.c | 26 + drivers/core/read.c | 6 + drivers/core/uclass.c | 29 +- drivers/mmc/Makefile | 5 + drivers/mmc/mmc-uclass.c | 27 +- drivers/mmc/mmc_bootdev.c | 62 ++ drivers/mmc/sandbox_mmc.c | 60 +- drivers/usb/host/Makefile | 4 + drivers/usb/host/usb_bootdev.c | 61 ++ include/bootdev.h | 258 ++++++++ include/bootflow.h | 304 ++++++++++ include/bootmeth.h | 156 +++++ include/bootstd.h | 80 +++ include/configs/rpi.h | 41 +- include/distro.h | 24 + include/dm/device.h | 12 + include/dm/ofnode.h | 24 +- include/dm/read.h | 28 + include/dm/uclass-id.h | 3 + include/dm/uclass-internal.h | 14 +- include/dm/uclass.h | 17 + include/mmc.h | 12 +- include/os.h | 9 + include/test/suites.h | 2 + include/vsprintf.h | 18 + lib/strto.c | 14 +- net/Kconfig | 9 + net/Makefile | 1 + net/eth-uclass.c | 8 + net/eth_bootdev.c | 101 ++++ test/Makefile | 1 + test/boot/Makefile | 5 + test/boot/bootdev.c | 200 +++++++ test/boot/bootflow.c | 398 ++++++++++++ test/boot/bootmeth.c | 90 +++ test/boot/bootstd_common.c | 35 ++ test/boot/bootstd_common.h | 27 + test/cmd_ut.c | 7 + test/dm/blk.c | 6 + test/dm/fastboot.c | 4 +- test/dm/ofnode.c | 96 +++ test/py/conftest.py | 2 +- test/py/multiplexed_log.py | 10 +- test/py/tests/bootstd/mmc1.img.xz | Bin 0 -> 4448 bytes test/py/tests/test_ut.py | 103 ++++ test/py/u_boot_utils.py | 5 +- 94 files changed, 6765 insertions(+), 94 deletions(-)create mode 100644
boot/bootdev-uclass.c
create mode 100644boot/bootflow.c
create mode 100644boot/bootmeth-uclass.c
create mode 100644boot/bootmeth_distro.c
create mode 100644boot/bootmeth_efi.c
create mode 100644boot/bootmeth_efi_mgr.c
create mode 100644boot/bootmeth_pxe.c
create mode 100644boot/bootmeth_sandbox.c
create mode 100644boot/bootstd-uclass.c
create mode 100644boot/system_bootdev.c
create mode 100644cmd/bootdev.c
create mode 100644cmd/bootflow.c
create mode 100644cmd/bootmeth.c
create mode 100644doc/develop/bootstd.rst
create mode 100644doc/device-tree-bindings/bootdev.txtcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/device-tree-bindings/bootstd.txtcreate mode 100644doc/device-tree-bindings/mmc/sandbox,mmc.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rst
create mode 100644doc/usage/bootmeth.rst
create mode 100644drivers/mmc/mmc_bootdev.c
create mode 100644drivers/usb/host/usb_bootdev.ccreate mode 100644include/bootdev.h
create mode 100644include/bootflow.h
create mode 100644include/bootmeth.h
create mode 100644include/bootstd.h
create mode 100644include/distro.h
create mode 100644net/eth_bootdev.c
create mode 100644 test/boot/Makefile
create mode 100644test/boot/bootdev.c
create mode 100644test/boot/bootflow.c
create mode 100644test/boot/bootmeth.c
create mode 100644test/boot/bootstd_common.c
create mode 100644test/boot/bootstd_common.h
create mode 100644 test/py/tests/bootstd/mmc1.img.xz
Signature · 3 lines
François-Frédéric Ozog | *Director Business Development* T: +33.67221.6485 [email protected] | Skype: ffozog
Hi Heinrich,
Quoted 17 lines · Heinrich Schuchardt
Quoted 6 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
Quoted 6 lines
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by U-Boot)
- bootflow - a description of how to boot (owned by the distro)
Quoted 4 lines
Please, describe why you are suggesting this change.
Replacing a script by a devicetree chunk is just decreasing flexibility and increasing complexity. Where is the benefit?
See previous email in thread. Continuing here on a few of your other points...
Quoted 5 lines
I am missing a description here of where and how a boot flow shall be defined. Describing some device-tree binding in patch 40/41 does not replace describing the development and usage workflow. Who will provide which bootflow information when?
We already have this with distro boot, so nothing really changes there. Think of this as a generalised 'standard boot' implementation, which can support distro boot and anything else we need in the future.
There is nothing required in the devicetree for normal operation.
Quoted 4 lines
You still have an open discussion with Linaro about the source of devicetrees. This discussion needs to be finalized before considering this series.
Why is that? They don't seem to be at all related to me.
Quoted 4 lines
In my view bootflows cannot be defined in the devicetree because prior firmware providing a devicetree is completely independent of any distro and therefore cannot provide a distro specific bootflow.
See previous post, they are not defined in the devicetree. Can you suggest how I can change the language to make that clear?
Regards,
Simon
Quoted 20 lines
Quoted 20 lines
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
With this we can boot on a Raspberry Pi 3 with just one command:
bootflow scan -lb
which means to scan, listing (-l) each bootflow and trying to boot each one (-b). The final patch shows this.
With a standard way to identify boot devices, booting become easier. It also should be possible to support U-Boot scripts, for backwards compatibility only.
[..]
Quoted 9 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned by
Quoted 8 lines
U-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
I'm going to break my feedback down in to a few threads, to hopefully not confuse things too much. My first comment is that rpi_arm64 grows in size by 17 kilobytes, with the whole series (pxe, env, this) applied. And while there's a few small changes in the pxe cleanup I'm going to re-investigate on their own, it's really just this series, right here, adding tons of code. To replace an admittedly complex bit of environment scripting, with C. It's not even the earlier parts of the series to clean up / prepare, it starts at "bootstd: Add the bootstd uclass and core implementation" and keeps going from there.
Signature · 1 line
Tom
Hi Tom,
Quoted 21 lines · Tom Rini
Quoted 9 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned byQuoted 8 lines
U-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
Quoted 9 lines
I'm going to break my feedback down in to a few threads, to hopefully not confuse things too much. My first comment is that
rpi_arm64grows in size by 17 kilobytes, with the whole series (pxe, env, this) applied. And while there's a few small changes in the pxe cleanup I'm going to re-investigate on their own, it's really just this series, right here, adding tons of code. To replace an admittedly complex bit of environment scripting, with C. It's not even the earlier parts of the series to clean up / prepare, it starts at "bootstd: Add the bootstd uclass and core implementation" and keeps going from there.
Yes it does add a lot of code, although it is a lot less if the commands are disabled or simplified, e.g. to only support 'bootflow scan -b'. At the moment it enables all dev features.
It does save a small amount of data. E.g. rpi_3_32b environment goes drops by 3.5KB.
We should compare this with the EFI support which is about 90KB, as I recall.
If we continue down the path of making this feature use U-Boot functions directly, instead the command line, I suspect we can save quite a bit more, since there is a lot of overhead with these commands. At present it is impossible to boot without CONFIG_CMDLINE enabled, for example.
In any case, I think this feature is filling a gap in U-Boot since at present everything about boot is ad-hoc. This gives us a base to build on. Nothing is for free.
Anyway, I can look at what the minimum size is with the above points and send that info through.
Regards,
Simon
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 21 lines · Tom Rini
Quoted 9 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned byQuoted 8 lines
U-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
Quoted 9 lines
I'm going to break my feedback down in to a few threads, to hopefully not confuse things too much. My first comment is that
rpi_arm64grows in size by 17 kilobytes, with the whole series (pxe, env, this) applied. And while there's a few small changes in the pxe cleanup I'm going to re-investigate on their own, it's really just this series, right here, adding tons of code. To replace an admittedly complex bit of environment scripting, with C. It's not even the earlier parts of the series to clean up / prepare, it starts at "bootstd: Add the bootstd uclass and core implementation" and keeps going from there.
Quoted 3 lines
Yes it does add a lot of code, although it is a lot less if the commands are disabled or simplified, e.g. to only support 'bootflow scan -b'. At the moment it enables all dev features.
OK, for the next go-round yes, please show what a typical enablement would look like on Pi, for example.
Quoted 2 lines
It does save a small amount of data. E.g.
rpi_3_32benvironment goes drops by 3.5KB.
So we're replacing 3.5KB of scripts with 17KB of code. That is not a win.
Quoted 1 line
We should compare this with the EFI support which is about 90KB, as I recall.
No, we shouldn't. This isn't about replacing EFI, this is about replacing the generic distro boot macros, so that's what the size comparison is to. At the end of the day, and looking towards non-legacy uses, a big common use case is "Find the EFI app to run".
Quoted 5 lines
If we continue down the path of making this feature use U-Boot functions directly, instead the command line, I suspect we can save quite a bit more, since there is a lot of overhead with these commands. At present it is impossible to boot without
CONFIG_CMDLINEenabled, for example.
Yes, this should be using the API and not the command interface.
Quoted 3 lines
In any case, I think this feature is filling a gap in U-Boot since at present everything about boot is ad-hoc. This gives us a base to build on. Nothing is for free.
I disagree. At present, booting is either intentionally per-board, or it's using the generic distro boot framework. That framework is what to further build on or perhaps make more readily simplified (for example, making it just be "scan around for EFI" or just be "scan around of extlinux.conf").
Quoted 2 lines
Anyway, I can look at what the minimum size is with the above points and send that info through.
I looked at the PXE stuff, and I think the minimal growth there ends up being reasonable, fwiw. It comes down to adding sanity checks in places where the code wasn't always sanity checking, as you reduced duplication.
Signature · 1 line
Tom
Hi Tom,
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 9 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned byQuoted 8 lines
U-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
I'm going to break my feedback down in to a few threads, to hopefully not confuse things too much. My first comment is that
rpi_arm64grows in size by 17 kilobytes, with the whole series (pxe, env, this) applied. And while there's a few small changes in the pxe cleanup I'm going to re-investigate on their own, it's really just this series, right here, adding tons of code. To replace an admittedly complex bit of environment scripting, with C. It's not even the earlier parts of the series to clean up / prepare, it starts at "bootstd: Add the bootstd uclass and core implementation" and keeps going from there.
Quoted 6 lines
Quoted 3 lines
Yes it does add a lot of code, although it is a lot less if the commands are disabled or simplified, e.g. to only support 'bootflow scan -b'. At the moment it enables all dev features.
OK, for the next go-round yes, please show what a typical enablement would look like on Pi, for example.
OK. Do understand that conceiving of this and implementing it is quite a bit of effort. At some point I just send things out, to get feedback and to think some more. Apart from anything else, there is a risk of going into the weeds or never finishing it.
Quoted 6 lines
Quoted 3 lines
It does save a small amount of data. E.g.
rpi_3_32benvironment goes drops by 3.5KB.So we're replacing 3.5KB of scripts with 17KB of code. That is not a win.
Certainly not on size! On testing, debug, visibility and control of the boot process, there are wins.
Quoted 7 lines
Quoted 2 lines
We should compare this with the EFI support which is about 90KB, as I recall.
No, we shouldn't. This isn't about replacing EFI, this is about replacing the generic distro boot macros, so that's what the size comparison is to. At the end of the day, and looking towards non-legacy uses, a big common use case is "Find the EFI app to run".
I just mean that EFI has been accepted as part of U-Boot and adds 90KB.
Quoted 8 lines
Quoted 6 lines
If we continue down the path of making this feature use U-Boot functions directly, instead the command line, I suspect we can save quite a bit more, since there is a lot of overhead with these commands. At present it is impossible to boot without
CONFIG_CMDLINEenabled, for example.Yes, this should be using the API and not the command interface.
Right, but that's not something I am taking on right now. The PXE refactoring gives an idea of what is needed. I did that work mainly because I don't like adding to code that desperately needs refactoring. We need to do the same for dhcp, EFI and bootm/zboot, but that might take a year.
Quoted 10 lines
Quoted 4 lines
In any case, I think this feature is filling a gap in U-Boot since at present everything about boot is ad-hoc. This gives us a base to build on. Nothing is for free.
I disagree. At present, booting is either intentionally per-board, or it's using the generic distro boot framework. That framework is what to further build on or perhaps make more readily simplified (for example, making it just be "scan around for EFI" or just be "scan around of extlinux.conf").
Well if the Universal Bootloader is only going to exist to boot EFI, then we should rename it :-)
I am not sure that anyone wants something intentionally per-board, it's just that everything about the boot in U-Boot is really low-level (bootm, fixed addresses, etc.) We need the layer on top that can deal with these silly details. For example, yes there is a Chrome OS boot script in chromebook_coral, but it is the same on all devices. I would rather just enable that bootmethod so that if Chrome OS is present it will boot.
Re the memory side, i don't like the vars that define the kernel address, FDT address, etc. It seems to me that most/all are unnecessary, if there is something able to deal with memory allocatoin automatically. Perhaps we should use malloc() more, or use LMB more proactively.
Even for custom flows, creating a bootmethod will have advantages, I think.
The other thing is that this allows further innovation. For verified boot, it makes it possible to sensibly deal with A/B;recovery, whereas at present that is all just scripting, certainly not handled by distro boot.
Quoted 8 lines
Quoted 3 lines
Anyway, I can look at what the minimum size is with the above points and send that info through.
I looked at the PXE stuff, and I think the minimal growth there ends up being reasonable, fwiw. It comes down to adding sanity checks in places where the code wasn't always sanity checking, as you reduced duplication.
Yes and perhaps the growth can be reduced, too.
Regards,
Simon
Quoted 52 lines · Simon Glass
Hi Tom,
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 9 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned byQuoted 8 lines
U-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
I'm going to break my feedback down in to a few threads, to hopefully not confuse things too much. My first comment is that
rpi_arm64grows in size by 17 kilobytes, with the whole series (pxe, env, this) applied. And while there's a few small changes in the pxe cleanup I'm going to re-investigate on their own, it's really just this series, right here, adding tons of code. To replace an admittedly complex bit of environment scripting, with C. It's not even the earlier parts of the series to clean up / prepare, it starts at "bootstd: Add the bootstd uclass and core implementation" and keeps going from there.Quoted 6 lines
Quoted 3 lines
Yes it does add a lot of code, although it is a lot less if the commands are disabled or simplified, e.g. to only support 'bootflow scan -b'. At the moment it enables all dev features.
OK, for the next go-round yes, please show what a typical enablement would look like on Pi, for example.
OK. Do understand that conceiving of this and implementing it is quite a bit of effort. At some point I just send things out, to get feedback and to think some more. Apart from anything else, there is a risk of going into the weeds or never finishing it.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
It does save a small amount of data. E.g.
rpi_3_32benvironment goes drops by 3.5KB.So we're replacing 3.5KB of scripts with 17KB of code. That is not a win.
Certainly not on size! On testing, debug, visibility and control of the boot process, there are wins.
I'm not sure if there's wins on those grounds either, and certainly not enough to justify what this adds.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
We should compare this with the EFI support which is about 90KB, as I recall.
No, we shouldn't. This isn't about replacing EFI, this is about replacing the generic distro boot macros, so that's what the size comparison is to. At the end of the day, and looking towards non-legacy uses, a big common use case is "Find the EFI app to run".
I just mean that EFI has been accepted as part of U-Boot and adds 90KB.
OK? I still don't see the relevance here.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
If we continue down the path of making this feature use U-Boot functions directly, instead the command line, I suspect we can save quite a bit more, since there is a lot of overhead with these commands. At present it is impossible to boot without
CONFIG_CMDLINEenabled, for example.
Quoted 7 lines
Quoted 1 line
Yes, this should be using the API and not the command interface.
Right, but that's not something I am taking on right now. The PXE refactoring gives an idea of what is needed. I did that work mainly because I don't like adding to code that desperately needs refactoring. We need to do the same for dhcp, EFI and bootm/zboot, but that might take a year.
Well, maybe this particular part of things get set aside for now, and the generic distro boot framework just needs to be moved to the env update you did.
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
In any case, I think this feature is filling a gap in U-Boot since at present everything about boot is ad-hoc. This gives us a base to build on. Nothing is for free.
I disagree. At present, booting is either intentionally per-board, or it's using the generic distro boot framework. That framework is what to further build on or perhaps make more readily simplified (for example, making it just be "scan around for EFI" or just be "scan around of extlinux.conf").
Quoted 4 lines
Well if the Universal Bootloader is only going to exist to boot EFI, then we should rename it :-)
I am not sure that anyone wants something intentionally per-board,
There's some cases, yes, where the system is supposed to do X (or Y, or Z). Otherwise there's the generic framework. Or...
Quoted 6 lines
it's just that everything about the boot in U-Boot is really low-level (bootm, fixed addresses, etc.) We need the layer on top that can deal with these silly details. For example, yes there is a Chrome OS boot script in
chromebook_coral, but it is the same on all devices. I would rather just enable that bootmethod so that if Chrome OS is present it will boot.
there's things like what Chrome OS wants.
Quoted 5 lines
Re the memory side, i don't like the vars that define the kernel address, FDT address, etc. It seems to me that most/all are unnecessary, if there is something able to deal with memory allocatoin automatically. Perhaps we should use
malloc()more, or use LMB more proactively.
Well, in that for Linux, arm64 the Image format has a header that lets us avoid a number of problems that weren't possible on arm32, there's a tiny bit more flexibility there. But it sounds like you're talking about "bootm_size" and "bootm_low" now.
Quoted 6 lines
Even for custom flows, creating a bootmethod will have advantages, I think.
The other thing is that this allows further innovation. For verified boot, it makes it possible to sensibly deal with A/B;recovery, whereas at present that is all just scripting, certainly not handled by distro boot.
No distros implement A/B updates directly. When implemented on top of them it's done via the environment, yes. I don't think adding Mender and RAUC and swupdate specific bootflow commands is a step in the right direction at all.
Quoted 9 lines
Quoted 7 lines
Quoted 2 lines
Anyway, I can look at what the minimum size is with the above points and send that info through.
I looked at the PXE stuff, and I think the minimal growth there ends up being reasonable, fwiw. It comes down to adding sanity checks in places where the code wasn't always sanity checking, as you reduced duplication.
Yes and perhaps the growth can be reduced, too.
It must be. You need to be a lot closer to parity with the existing generic boot mechanism and around that size. I am not liking what I'm seeing here so far.
Signature · 1 line
Tom
Hi Tom,
Quoted 153 lines · Tom Rini
Quoted 52 lines · Simon Glass
Hi Tom,
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 9 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned byQuoted 8 lines
U-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
I'm going to break my feedback down in to a few threads, to hopefully not confuse things too much. My first comment is that
rpi_arm64grows in size by 17 kilobytes, with the whole series (pxe, env, this) applied. And while there's a few small changes in the pxe cleanup I'm going to re-investigate on their own, it's really just this series, right here, adding tons of code. To replace an admittedly complex bit of environment scripting, with C. It's not even the earlier parts of the series to clean up / prepare, it starts at "bootstd: Add the bootstd uclass and core implementation" and keeps going from there.Quoted 6 lines
Quoted 3 lines
Yes it does add a lot of code, although it is a lot less if the commands are disabled or simplified, e.g. to only support 'bootflow scan -b'. At the moment it enables all dev features.
OK, for the next go-round yes, please show what a typical enablement would look like on Pi, for example.
OK. Do understand that conceiving of this and implementing it is quite a bit of effort. At some point I just send things out, to get feedback and to think some more. Apart from anything else, there is a risk of going into the weeds or never finishing it.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
It does save a small amount of data. E.g.
rpi_3_32benvironment goes drops by 3.5KB.So we're replacing 3.5KB of scripts with 17KB of code. That is not a win.
Certainly not on size! On testing, debug, visibility and control of the boot process, there are wins.
I'm not sure if there's wins on those grounds either, and certainly not enough to justify what this adds.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
We should compare this with the EFI support which is about 90KB, as I recall.
No, we shouldn't. This isn't about replacing EFI, this is about replacing the generic distro boot macros, so that's what the size comparison is to. At the end of the day, and looking towards non-legacy uses, a big common use case is "Find the EFI app to run".
I just mean that EFI has been accepted as part of U-Boot and adds 90KB.
OK? I still don't see the relevance here.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
If we continue down the path of making this feature use U-Boot functions directly, instead the command line, I suspect we can save quite a bit more, since there is a lot of overhead with these commands. At present it is impossible to boot without
CONFIG_CMDLINEenabled, for example.Quoted 7 lines
Quoted 1 line
Yes, this should be using the API and not the command interface.
Right, but that's not something I am taking on right now. The PXE refactoring gives an idea of what is needed. I did that work mainly because I don't like adding to code that desperately needs refactoring. We need to do the same for dhcp, EFI and bootm/zboot, but that might take a year.
Well, maybe this particular part of things get set aside for now, and the generic distro boot framework just needs to be moved to the env update you did.
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
In any case, I think this feature is filling a gap in U-Boot since at present everything about boot is ad-hoc. This gives us a base to build on. Nothing is for free.
I disagree. At present, booting is either intentionally per-board, or it's using the generic distro boot framework. That framework is what to further build on or perhaps make more readily simplified (for example, making it just be "scan around for EFI" or just be "scan around of extlinux.conf").
Quoted 4 lines
Well if the Universal Bootloader is only going to exist to boot EFI, then we should rename it :-)
I am not sure that anyone wants something intentionally per-board,
There's some cases, yes, where the system is supposed to do X (or Y, or Z). Otherwise there's the generic framework. Or...
Quoted 6 lines
it's just that everything about the boot in U-Boot is really low-level (bootm, fixed addresses, etc.) We need the layer on top that can deal with these silly details. For example, yes there is a Chrome OS boot script in
chromebook_coral, but it is the same on all devices. I would rather just enable that bootmethod so that if Chrome OS is present it will boot.there's things like what Chrome OS wants.
Quoted 5 lines
Re the memory side, i don't like the vars that define the kernel address, FDT address, etc. It seems to me that most/all are unnecessary, if there is something able to deal with memory allocatoin automatically. Perhaps we should use
malloc()more, or use LMB more proactively.Well, in that for Linux, arm64 the Image format has a header that lets us avoid a number of problems that weren't possible on arm32, there's a tiny bit more flexibility there. But it sounds like you're talking about "
bootm_size" and "bootm_low" now.Quoted 6 lines
Even for custom flows, creating a bootmethod will have advantages, I think.
The other thing is that this allows further innovation. For verified boot, it makes it possible to sensibly deal with A/B;recovery, whereas at present that is all just scripting, certainly not handled by distro boot.
No distros implement A/B updates directly. When implemented on top of them it's done via the environment, yes. I don't think adding Mender and RAUC and swupdate specific bootflow commands is a step in the right direction at all.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Anyway, I can look at what the minimum size is with the above points and send that info through.
I looked at the PXE stuff, and I think the minimal growth there ends up being reasonable, fwiw. It comes down to adding sanity checks in places where the code wasn't always sanity checking, as you reduced duplication.
Quoted 5 lines
Quoted 1 line
Yes and perhaps the growth can be reduced, too.
It must be. You need to be a lot closer to parity with the existing generic boot mechanism and around that size. I am not liking what I'm seeing here so far.
Just on this point, I'm pretty sure this will kill it. We cannot add code without increasing the size! It sounds like 17KB on ARM64 is too much (perhaps 13.5KB including env reduction). Firstly, why, and secondly, how much is acceptable? If the answer is zero, we are not going to go anywhere with this, at least without a huge amount of future refactoring, which is not going to happen since we cannot land 100s of patches all at once.
The big prize would be to be able to disable CONFIG_CMDLINE and still boot. That saves 200KB or more.
Regards,
Simon
Quoted 170 lines · Simon Glass
Hi Tom,
Quoted 153 lines · Tom Rini
Quoted 52 lines · Simon Glass
Hi Tom,
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 9 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned byQuoted 8 lines
U-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
I'm going to break my feedback down in to a few threads, to hopefully not confuse things too much. My first comment is that
rpi_arm64grows in size by 17 kilobytes, with the whole series (pxe, env, this) applied. And while there's a few small changes in the pxe cleanup I'm going to re-investigate on their own, it's really just this series, right here, adding tons of code. To replace an admittedly complex bit of environment scripting, with C. It's not even the earlier parts of the series to clean up / prepare, it starts at "bootstd: Add the bootstd uclass and core implementation" and keeps going from there.Quoted 6 lines
Quoted 3 lines
Yes it does add a lot of code, although it is a lot less if the commands are disabled or simplified, e.g. to only support 'bootflow scan -b'. At the moment it enables all dev features.
OK, for the next go-round yes, please show what a typical enablement would look like on Pi, for example.
OK. Do understand that conceiving of this and implementing it is quite a bit of effort. At some point I just send things out, to get feedback and to think some more. Apart from anything else, there is a risk of going into the weeds or never finishing it.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
It does save a small amount of data. E.g.
rpi_3_32benvironment goes drops by 3.5KB.So we're replacing 3.5KB of scripts with 17KB of code. That is not a win.
Certainly not on size! On testing, debug, visibility and control of the boot process, there are wins.
I'm not sure if there's wins on those grounds either, and certainly not enough to justify what this adds.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
We should compare this with the EFI support which is about 90KB, as I recall.
No, we shouldn't. This isn't about replacing EFI, this is about replacing the generic distro boot macros, so that's what the size comparison is to. At the end of the day, and looking towards non-legacy uses, a big common use case is "Find the EFI app to run".
I just mean that EFI has been accepted as part of U-Boot and adds 90KB.
OK? I still don't see the relevance here.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
If we continue down the path of making this feature use U-Boot functions directly, instead the command line, I suspect we can save quite a bit more, since there is a lot of overhead with these commands. At present it is impossible to boot without
CONFIG_CMDLINEenabled, for example.Quoted 7 lines
Quoted 1 line
Yes, this should be using the API and not the command interface.
Right, but that's not something I am taking on right now. The PXE refactoring gives an idea of what is needed. I did that work mainly because I don't like adding to code that desperately needs refactoring. We need to do the same for dhcp, EFI and bootm/zboot, but that might take a year.
Well, maybe this particular part of things get set aside for now, and the generic distro boot framework just needs to be moved to the env update you did.
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
In any case, I think this feature is filling a gap in U-Boot since at present everything about boot is ad-hoc. This gives us a base to build on. Nothing is for free.
I disagree. At present, booting is either intentionally per-board, or it's using the generic distro boot framework. That framework is what to further build on or perhaps make more readily simplified (for example, making it just be "scan around for EFI" or just be "scan around of extlinux.conf").
Quoted 4 lines
Well if the Universal Bootloader is only going to exist to boot EFI, then we should rename it :-)
I am not sure that anyone wants something intentionally per-board,
There's some cases, yes, where the system is supposed to do X (or Y, or Z). Otherwise there's the generic framework. Or...
Quoted 6 lines
it's just that everything about the boot in U-Boot is really low-level (bootm, fixed addresses, etc.) We need the layer on top that can deal with these silly details. For example, yes there is a Chrome OS boot script in
chromebook_coral, but it is the same on all devices. I would rather just enable that bootmethod so that if Chrome OS is present it will boot.there's things like what Chrome OS wants.
Quoted 5 lines
Re the memory side, i don't like the vars that define the kernel address, FDT address, etc. It seems to me that most/all are unnecessary, if there is something able to deal with memory allocatoin automatically. Perhaps we should use
malloc()more, or use LMB more proactively.Well, in that for Linux, arm64 the Image format has a header that lets us avoid a number of problems that weren't possible on arm32, there's a tiny bit more flexibility there. But it sounds like you're talking about "
bootm_size" and "bootm_low" now.Quoted 6 lines
Even for custom flows, creating a bootmethod will have advantages, I think.
The other thing is that this allows further innovation. For verified boot, it makes it possible to sensibly deal with A/B;recovery, whereas at present that is all just scripting, certainly not handled by distro boot.
No distros implement A/B updates directly. When implemented on top of them it's done via the environment, yes. I don't think adding Mender and RAUC and swupdate specific bootflow commands is a step in the right direction at all.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Anyway, I can look at what the minimum size is with the above points and send that info through.
I looked at the PXE stuff, and I think the minimal growth there ends up being reasonable, fwiw. It comes down to adding sanity checks in places where the code wasn't always sanity checking, as you reduced duplication.
Quoted 5 lines
Quoted 1 line
Yes and perhaps the growth can be reduced, too.
It must be. You need to be a lot closer to parity with the existing generic boot mechanism and around that size. I am not liking what I'm seeing here so far.
Just on this point, I'm pretty sure this will kill it. We cannot add code without increasing the size! It sounds like 17KB on ARM64 is too much (perhaps 13.5KB including env reduction). Firstly, why, and secondly, how much is acceptable? If the answer is zero, we are not going to go anywhere with this, at least without a huge amount of future refactoring, which is not going to happen since we cannot land 100s of patches all at once.
Quoted 2 lines
The big prize would be to be able to disable
CONFIG_CMDLINEand still boot. That saves 200KB or more.
I think the problem is this just needs to get put on hold for a while. I am not convinced this is moving things in the right direction. Conceptually, it's duplicating a lot of the efi bootmgr functionality, but also adding in non-block devices. And I am not liking configuring this via device tree, rather than environment. Lets move the generic distro framework to the new env framework and continue finishing off other technical debts that we have, before we re-visit a brand new way of handling booting.
Signature · 1 line
Tom
Hi Tom,
Quoted 175 lines · Tom Rini
Quoted 170 lines · Simon Glass
Hi Tom,
Quoted 153 lines · Tom Rini
Quoted 52 lines · Simon Glass
Hi Tom,
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 9 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned byQuoted 8 lines
U-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
I'm going to break my feedback down in to a few threads, to hopefully not confuse things too much. My first comment is that
rpi_arm64grows in size by 17 kilobytes, with the whole series (pxe, env, this) applied. And while there's a few small changes in the pxe cleanup I'm going to re-investigate on their own, it's really just this series, right here, adding tons of code. To replace an admittedly complex bit of environment scripting, with C. It's not even the earlier parts of the series to clean up / prepare, it starts at "bootstd: Add the bootstd uclass and core implementation" and keeps going from there.Quoted 6 lines
Quoted 3 lines
Yes it does add a lot of code, although it is a lot less if the commands are disabled or simplified, e.g. to only support 'bootflow scan -b'. At the moment it enables all dev features.
OK, for the next go-round yes, please show what a typical enablement would look like on Pi, for example.
OK. Do understand that conceiving of this and implementing it is quite a bit of effort. At some point I just send things out, to get feedback and to think some more. Apart from anything else, there is a risk of going into the weeds or never finishing it.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
It does save a small amount of data. E.g.
rpi_3_32benvironment goes drops by 3.5KB.So we're replacing 3.5KB of scripts with 17KB of code. That is not a win.
Certainly not on size! On testing, debug, visibility and control of the boot process, there are wins.
I'm not sure if there's wins on those grounds either, and certainly not enough to justify what this adds.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
We should compare this with the EFI support which is about 90KB, as I recall.
No, we shouldn't. This isn't about replacing EFI, this is about replacing the generic distro boot macros, so that's what the size comparison is to. At the end of the day, and looking towards non-legacy uses, a big common use case is "Find the EFI app to run".
I just mean that EFI has been accepted as part of U-Boot and adds 90KB.
OK? I still don't see the relevance here.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
If we continue down the path of making this feature use U-Boot functions directly, instead the command line, I suspect we can save quite a bit more, since there is a lot of overhead with these commands. At present it is impossible to boot without
CONFIG_CMDLINEenabled, for example.Quoted 7 lines
Quoted 1 line
Yes, this should be using the API and not the command interface.
Right, but that's not something I am taking on right now. The PXE refactoring gives an idea of what is needed. I did that work mainly because I don't like adding to code that desperately needs refactoring. We need to do the same for dhcp, EFI and bootm/zboot, but that might take a year.
Well, maybe this particular part of things get set aside for now, and the generic distro boot framework just needs to be moved to the env update you did.
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
In any case, I think this feature is filling a gap in U-Boot since at present everything about boot is ad-hoc. This gives us a base to build on. Nothing is for free.
I disagree. At present, booting is either intentionally per-board, or it's using the generic distro boot framework. That framework is what to further build on or perhaps make more readily simplified (for example, making it just be "scan around for EFI" or just be "scan around of extlinux.conf").
Quoted 4 lines
Well if the Universal Bootloader is only going to exist to boot EFI, then we should rename it :-)
I am not sure that anyone wants something intentionally per-board,
There's some cases, yes, where the system is supposed to do X (or Y, or Z). Otherwise there's the generic framework. Or...
Quoted 6 lines
it's just that everything about the boot in U-Boot is really low-level (bootm, fixed addresses, etc.) We need the layer on top that can deal with these silly details. For example, yes there is a Chrome OS boot script in
chromebook_coral, but it is the same on all devices. I would rather just enable that bootmethod so that if Chrome OS is present it will boot.there's things like what Chrome OS wants.
Quoted 5 lines
Re the memory side, i don't like the vars that define the kernel address, FDT address, etc. It seems to me that most/all are unnecessary, if there is something able to deal with memory allocatoin automatically. Perhaps we should use
malloc()more, or use LMB more proactively.Well, in that for Linux, arm64 the Image format has a header that lets us avoid a number of problems that weren't possible on arm32, there's a tiny bit more flexibility there. But it sounds like you're talking about "
bootm_size" and "bootm_low" now.Quoted 6 lines
Even for custom flows, creating a bootmethod will have advantages, I think.
The other thing is that this allows further innovation. For verified boot, it makes it possible to sensibly deal with A/B;recovery, whereas at present that is all just scripting, certainly not handled by distro boot.
No distros implement A/B updates directly. When implemented on top of them it's done via the environment, yes. I don't think adding Mender and RAUC and swupdate specific bootflow commands is a step in the right direction at all.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Anyway, I can look at what the minimum size is with the above points and send that info through.
I looked at the PXE stuff, and I think the minimal growth there ends up being reasonable, fwiw. It comes down to adding sanity checks in places where the code wasn't always sanity checking, as you reduced duplication.
Quoted 5 lines
Quoted 1 line
Yes and perhaps the growth can be reduced, too.
It must be. You need to be a lot closer to parity with the existing generic boot mechanism and around that size. I am not liking what I'm seeing here so far.
Just on this point, I'm pretty sure this will kill it. We cannot add code without increasing the size! It sounds like 17KB on ARM64 is too much (perhaps 13.5KB including env reduction). Firstly, why, and secondly, how much is acceptable? If the answer is zero, we are not going to go anywhere with this, at least without a huge amount of future refactoring, which is not going to happen since we cannot land 100s of patches all at once.
Quoted 2 lines
The big prize would be to be able to disable
CONFIG_CMDLINEand still boot. That saves 200KB or more.
Quoted 8 lines
I think the problem is this just needs to get put on hold for a while. I am not convinced this is moving things in the right direction. Conceptually, it's duplicating a lot of the efi bootmgr functionality, but also adding in non-block devices. And I am not liking configuring this via device tree, rather than environment. Lets move the generic distro framework to the new env framework and continue finishing off other technical debts that we have, before we re-visit a brand new way of handling booting.
OMG, please, no :-) That would be a mess IMO. We should have done a proper boot framework when distroboot was created, instead of all the scripts.
Now it's seems we need to stick with that, or move to EFI bootmgr?
Is the new env framework agreed? I'd love to see some reviews from Wolfgang.
Regards,
Simon
Quoted 187 lines · Simon Glass
Hi Tom,
Quoted 175 lines · Tom Rini
Quoted 170 lines · Simon Glass
Hi Tom,
Quoted 153 lines · Tom Rini
Quoted 52 lines · Simon Glass
Hi Tom,
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 9 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned byQuoted 8 lines
U-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
I'm going to break my feedback down in to a few threads, to hopefully not confuse things too much. My first comment is that
rpi_arm64grows in size by 17 kilobytes, with the whole series (pxe, env, this) applied. And while there's a few small changes in the pxe cleanup I'm going to re-investigate on their own, it's really just this series, right here, adding tons of code. To replace an admittedly complex bit of environment scripting, with C. It's not even the earlier parts of the series to clean up / prepare, it starts at "bootstd: Add the bootstd uclass and core implementation" and keeps going from there.Quoted 6 lines
Quoted 3 lines
Yes it does add a lot of code, although it is a lot less if the commands are disabled or simplified, e.g. to only support 'bootflow scan -b'. At the moment it enables all dev features.
OK, for the next go-round yes, please show what a typical enablement would look like on Pi, for example.
OK. Do understand that conceiving of this and implementing it is quite a bit of effort. At some point I just send things out, to get feedback and to think some more. Apart from anything else, there is a risk of going into the weeds or never finishing it.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
It does save a small amount of data. E.g.
rpi_3_32benvironment goes drops by 3.5KB.So we're replacing 3.5KB of scripts with 17KB of code. That is not a win.
Certainly not on size! On testing, debug, visibility and control of the boot process, there are wins.
I'm not sure if there's wins on those grounds either, and certainly not enough to justify what this adds.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
We should compare this with the EFI support which is about 90KB, as I recall.
No, we shouldn't. This isn't about replacing EFI, this is about replacing the generic distro boot macros, so that's what the size comparison is to. At the end of the day, and looking towards non-legacy uses, a big common use case is "Find the EFI app to run".
I just mean that EFI has been accepted as part of U-Boot and adds 90KB.
OK? I still don't see the relevance here.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
If we continue down the path of making this feature use U-Boot functions directly, instead the command line, I suspect we can save quite a bit more, since there is a lot of overhead with these commands. At present it is impossible to boot without
CONFIG_CMDLINEenabled, for example.Quoted 7 lines
Quoted 1 line
Yes, this should be using the API and not the command interface.
Right, but that's not something I am taking on right now. The PXE refactoring gives an idea of what is needed. I did that work mainly because I don't like adding to code that desperately needs refactoring. We need to do the same for dhcp, EFI and bootm/zboot, but that might take a year.
Well, maybe this particular part of things get set aside for now, and the generic distro boot framework just needs to be moved to the env update you did.
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
In any case, I think this feature is filling a gap in U-Boot since at present everything about boot is ad-hoc. This gives us a base to build on. Nothing is for free.
I disagree. At present, booting is either intentionally per-board, or it's using the generic distro boot framework. That framework is what to further build on or perhaps make more readily simplified (for example, making it just be "scan around for EFI" or just be "scan around of extlinux.conf").
Quoted 4 lines
Well if the Universal Bootloader is only going to exist to boot EFI, then we should rename it :-)
I am not sure that anyone wants something intentionally per-board,
There's some cases, yes, where the system is supposed to do X (or Y, or Z). Otherwise there's the generic framework. Or...
Quoted 6 lines
it's just that everything about the boot in U-Boot is really low-level (bootm, fixed addresses, etc.) We need the layer on top that can deal with these silly details. For example, yes there is a Chrome OS boot script in
chromebook_coral, but it is the same on all devices. I would rather just enable that bootmethod so that if Chrome OS is present it will boot.there's things like what Chrome OS wants.
Quoted 5 lines
Re the memory side, i don't like the vars that define the kernel address, FDT address, etc. It seems to me that most/all are unnecessary, if there is something able to deal with memory allocatoin automatically. Perhaps we should use
malloc()more, or use LMB more proactively.Well, in that for Linux, arm64 the Image format has a header that lets us avoid a number of problems that weren't possible on arm32, there's a tiny bit more flexibility there. But it sounds like you're talking about "
bootm_size" and "bootm_low" now.Quoted 6 lines
Even for custom flows, creating a bootmethod will have advantages, I think.
The other thing is that this allows further innovation. For verified boot, it makes it possible to sensibly deal with A/B;recovery, whereas at present that is all just scripting, certainly not handled by distro boot.
No distros implement A/B updates directly. When implemented on top of them it's done via the environment, yes. I don't think adding Mender and RAUC and swupdate specific bootflow commands is a step in the right direction at all.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Anyway, I can look at what the minimum size is with the above points and send that info through.
I looked at the PXE stuff, and I think the minimal growth there ends up being reasonable, fwiw. It comes down to adding sanity checks in places where the code wasn't always sanity checking, as you reduced duplication.
Quoted 5 lines
Quoted 1 line
Yes and perhaps the growth can be reduced, too.
It must be. You need to be a lot closer to parity with the existing generic boot mechanism and around that size. I am not liking what I'm seeing here so far.
Just on this point, I'm pretty sure this will kill it. We cannot add code without increasing the size! It sounds like 17KB on ARM64 is too much (perhaps 13.5KB including env reduction). Firstly, why, and secondly, how much is acceptable? If the answer is zero, we are not going to go anywhere with this, at least without a huge amount of future refactoring, which is not going to happen since we cannot land 100s of patches all at once.
Quoted 2 lines
The big prize would be to be able to disable
CONFIG_CMDLINEand still boot. That saves 200KB or more.Quoted 8 lines
I think the problem is this just needs to get put on hold for a while. I am not convinced this is moving things in the right direction. Conceptually, it's duplicating a lot of the efi bootmgr functionality, but also adding in non-block devices. And I am not liking configuring this via device tree, rather than environment. Lets move the generic distro framework to the new env framework and continue finishing off other technical debts that we have, before we re-visit a brand new way of handling booting.
Quoted 5 lines
OMG, please, no :-) That would be a mess IMO. We should have done a proper boot framework when distroboot was created, instead of all the scripts.
Now it's seems we need to stick with that, or move to EFI bootmgr?
I'm not sure if EFI bootmgr is going to cover the cases, or not. But yes, in so far as I have problems with the current distro boot, it's that dealing with strings in C kinda sucks. Having that be plain text will be good.
Quoted 1 line
Is the new env framework agreed? I'd love to see some reviews from Wolfgang.
I believe the new env framework is agreed, yes. So long as "complex" environments can be constructed and dropped in some way or another outside of the new tooling, that's good enough.
Quoted 3 lines
Regards,
Simon
Signature · 1 line
Tom
Hi Tom,
Quoted 193 lines · Tom Rini
Quoted 191 lines · Simon Glass
Hi Tom,
Quoted 175 lines · Tom Rini
Quoted 170 lines · Simon Glass
Hi Tom,
Quoted 153 lines · Tom Rini
Quoted 52 lines · Simon Glass
Hi Tom,
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 9 lines · Simon Glass
The bootflow feature provide a built-in way for U-Boot to automatically boot an Operating System without custom scripting and other customisation. This is called 'standard boot' since it provides a standard way for U-Boot to boot a distro, without scripting.
It introduces the following concepts:
- bootdev - a device which can hold a distro
- bootmeth - a method to scan a bootdev to find bootflows (owned byQuoted 8 lines
U-Boot)- bootflow - a description of how to boot (owned by the distro)
This series provides an implementation of these, enabled to scan for bootflows from MMC, USB and Ethernet. It supports the existing distro boot as well as the EFI loader flow (bootefi/bootmgr). It works similiarly to the existing script-based approach, but is native to U-Boot.
I'm going to break my feedback down in to a few threads, to hopefully not confuse things too much. My first comment is that
rpi_arm64grows in size by 17 kilobytes, with the whole series (pxe, env, this) applied. And while there's a few small changes in the pxe cleanup I'm going to re-investigate on their own, it's really just this series, right here, adding tons of code. To replace an admittedly complex bit of environment scripting, with C. It's not even the earlier parts of the series to clean up / prepare, it starts at "bootstd: Add the bootstd uclass and core implementation" and keeps going from there.Quoted 6 lines
Quoted 3 lines
Yes it does add a lot of code, although it is a lot less if the commands are disabled or simplified, e.g. to only support 'bootflow scan -b'. At the moment it enables all dev features.
OK, for the next go-round yes, please show what a typical enablement would look like on Pi, for example.
OK. Do understand that conceiving of this and implementing it is quite a bit of effort. At some point I just send things out, to get feedback and to think some more. Apart from anything else, there is a risk of going into the weeds or never finishing it.
Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
It does save a small amount of data. E.g.
rpi_3_32benvironment goes drops by 3.5KB.So we're replacing 3.5KB of scripts with 17KB of code. That is not a win.
Certainly not on size! On testing, debug, visibility and control of the boot process, there are wins.
I'm not sure if there's wins on those grounds either, and certainly not enough to justify what this adds.
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
We should compare this with the EFI support which is about 90KB, as I recall.
No, we shouldn't. This isn't about replacing EFI, this is about replacing the generic distro boot macros, so that's what the size comparison is to. At the end of the day, and looking towards non-legacy uses, a big common use case is "Find the EFI app to run".
I just mean that EFI has been accepted as part of U-Boot and adds 90KB.
OK? I still don't see the relevance here.
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
If we continue down the path of making this feature use U-Boot functions directly, instead the command line, I suspect we can save quite a bit more, since there is a lot of overhead with these commands. At present it is impossible to boot without
CONFIG_CMDLINEenabled, for example.Quoted 7 lines
Quoted 1 line
Yes, this should be using the API and not the command interface.
Right, but that's not something I am taking on right now. The PXE refactoring gives an idea of what is needed. I did that work mainly because I don't like adding to code that desperately needs refactoring. We need to do the same for dhcp, EFI and bootm/zboot, but that might take a year.
Well, maybe this particular part of things get set aside for now, and the generic distro boot framework just needs to be moved to the env update you did.
Quoted 10 lines
Quoted 9 lines
Quoted 3 lines
In any case, I think this feature is filling a gap in U-Boot since at present everything about boot is ad-hoc. This gives us a base to build on. Nothing is for free.
I disagree. At present, booting is either intentionally per-board, or it's using the generic distro boot framework. That framework is what to further build on or perhaps make more readily simplified (for example, making it just be "scan around for EFI" or just be "scan around of extlinux.conf").
Quoted 4 lines
Well if the Universal Bootloader is only going to exist to boot EFI, then we should rename it :-)
I am not sure that anyone wants something intentionally per-board,
There's some cases, yes, where the system is supposed to do X (or Y, or Z). Otherwise there's the generic framework. Or...
Quoted 6 lines
it's just that everything about the boot in U-Boot is really low-level (bootm, fixed addresses, etc.) We need the layer on top that can deal with these silly details. For example, yes there is a Chrome OS boot script in
chromebook_coral, but it is the same on all devices. I would rather just enable that bootmethod so that if Chrome OS is present it will boot.there's things like what Chrome OS wants.
Quoted 5 lines
Re the memory side, i don't like the vars that define the kernel address, FDT address, etc. It seems to me that most/all are unnecessary, if there is something able to deal with memory allocatoin automatically. Perhaps we should use
malloc()more, or use LMB more proactively.Well, in that for Linux, arm64 the Image format has a header that lets us avoid a number of problems that weren't possible on arm32, there's a tiny bit more flexibility there. But it sounds like you're talking about "
bootm_size" and "bootm_low" now.Quoted 6 lines
Even for custom flows, creating a bootmethod will have advantages, I think.
The other thing is that this allows further innovation. For verified boot, it makes it possible to sensibly deal with A/B;recovery, whereas at present that is all just scripting, certainly not handled by distro boot.
No distros implement A/B updates directly. When implemented on top of them it's done via the environment, yes. I don't think adding Mender and RAUC and swupdate specific bootflow commands is a step in the right direction at all.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Anyway, I can look at what the minimum size is with the above points and send that info through.
I looked at the PXE stuff, and I think the minimal growth there ends up being reasonable, fwiw. It comes down to adding sanity checks in places where the code wasn't always sanity checking, as you reduced duplication.
Quoted 5 lines
Quoted 1 line
Yes and perhaps the growth can be reduced, too.
It must be. You need to be a lot closer to parity with the existing generic boot mechanism and around that size. I am not liking what I'm seeing here so far.
Just on this point, I'm pretty sure this will kill it. We cannot add code without increasing the size! It sounds like 17KB on ARM64 is too much (perhaps 13.5KB including env reduction). Firstly, why, and secondly, how much is acceptable? If the answer is zero, we are not going to go anywhere with this, at least without a huge amount of future refactoring, which is not going to happen since we cannot land 100s of patches all at once.
Quoted 2 lines
The big prize would be to be able to disable
CONFIG_CMDLINEand still boot. That saves 200KB or more.Quoted 8 lines
I think the problem is this just needs to get put on hold for a while. I am not convinced this is moving things in the right direction. Conceptually, it's duplicating a lot of the efi bootmgr functionality, but also adding in non-block devices. And I am not liking configuring this via device tree, rather than environment. Lets move the generic distro framework to the new env framework and continue finishing off other technical debts that we have, before we re-visit a brand new way of handling booting.
OMG, please, no :-) That would be a mess IMO. We should have done a proper boot framework when distroboot was created, instead of all the scripts.
Quoted 6 lines
Quoted 1 line
Now it's seems we need to stick with that, or move to EFI bootmgr?
I'm not sure if EFI bootmgr is going to cover the cases, or not. But yes, in so far as I have problems with the current distro boot, it's that dealing with strings in C kinda sucks. Having that be plain text will be good.
I'm sure EFI bootmgr will cover all the *EFI* cases, by definition. No one will understand it, though...
Yes the scripts themselves are not ideal. It is great that we have this feature but it will be even better to have proper U-Boot support for booting, I think. But anyway, I'll do the analysis I talked about and deal with any other feedback and we can park it for now.
I'd still like you to think about what would be an acceptable increment in terms of code size (you cannot say zero!)
Quoted 6 lines
Quoted 2 lines
Is the new env framework agreed? I'd love to see some reviews from Wolfgang.
I believe the new env framework is agreed, yes. So long as "complex" environments can be constructed and dropped in some way or another outside of the new tooling, that's good enough.
Well I was planning on migrating env_default.h but we can leave that for later I suppose.
I am pretty sure we will need to enhance it, but we can see how it goes. I'd like to get rid of the sandbox config file, at least. I got someway down the path there, so will dig up the patches.
Regards,
Simon
A message that is not in the archive (sent off-list or not yet received): CAPnjgZ2TFOQGoQ1+Vt6LRMk+nULj9joS0C7fMMiXfg7JNien7g@mail.gmail.com
Re: [PATCH v2 13/41] dm: core: Add a way to obtain a string list
Hi Ilias,
Quoted 16 lines · Ilias Apalodimas
Quoted 14 lines · Simon Glass
At present we support reading a string list a string at a time. Apart from being inefficient, this makes it impossible to separate reading of the devicetree into the
of_to_plat()method where it belongs, since any code which needs access to the string must read it from the devicetree.Add a function which returns the string property as an array of pointers to the strings, which is easily used by clients.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Quoted 7 lines
Quoted 7 lines
drivers/core/ofnode.c | 26 ++++++++++++++++++++++++++ drivers/core/read.c | 6 ++++++ include/dm/ofnode.h | 20 ++++++++++++++++++++ include/dm/read.h | 28 ++++++++++++++++++++++++++++ test/dm/ofnode.c | 20 ++++++++++++++++++++ 5 files changed, 100 insertions(+)
Applied to u-boot-dm/next, thanks!