Initial implementation of standard boot
Subsystems (6)
v3 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
Overall size increment on rpi_3_32b is 6.75KB.
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 v3:
- Change the function to return a pointer to the first digit
- Add some tests, including one for 'abc123def456'
- Add new patch to rename uclass_get_by_name_len()
- Add new patch to support finding a uclass device by partial name
- Mention bootflow_state[] in enum bootflow_state_t
- Add CONFIG_BOOTSTD_FULL to enable the full feature set
- Support bootdev-order and filename-prefixes only with CONFIG_BOOTSTD_FULL
- Update for the new trailing_strtoln_end()
- Add bootdev_get_from_blk() function
- Use blk_find_device() to find the block device for a media device
- Move bootdev ordering into the uclass
- Move bootmeth ordering into the uclass
- Support "bootmeths" env var
- Add some more common functions
- Point to the header file for bootflow_state[] docs
- Explain why it is OK to use "?" as an unknown bootflow state
- Move bootmeth/bootdev ordering into the uclass
- Use separate Kconfig options for each command
- Use separate Kconfig options for each command
- Put some features behind CONFIG_BOOTFLOW_FULL
- Move bootmeth ordering into the uclass
- Use new bootmeth_try_file() function
- Use a short name when BOOTSTD_FULL is not enabled
- Use common bootmeth functions
- Adjust for new blk_find_device() function
- Add a log category
- Use a short name when BOOTSTD_FULL is not enabled
- Add a log category
- Use a short name when BOOTSTD_FULL is not enabled
- Align the EFI load address
- Use common bootmeth functions
- Add a log category
- Add a log category
- Add a log category
- Add support for script boot
- Update bootdev_test_order() for boot_targets env var
- Add tests for the "bootmeths" env var
- Update tests for the new 'bootmeth order' syntax
- Update test condition to use CMD_BOOTFLOW
- Update docs for "bootmeths" and "boot_targets" env vars
Simon Glass (31):
str: Move string tests to the string module
test: Add tests for trailing_strtol()
str: Fix a few bugs in trailing_strtoln()
lib: Add a way to find the postiion of a trailing number
dm: core: Rename uclass_get_by_name_len()
dm: core: Allow finding a uclass device by partial name
test: fastboot: Avoid using mmc1
test: dm: Restart USB before assuming it is stopped
dm: blk: Add a function to return the device type
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 command
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: Add an implementation of script boot
bootstd: usb: Add a bootdev driver
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 + arch/sandbox/dts/test.dts | 18 + boot/Kconfig | 101 +++- boot/Makefile | 15 + boot/bootdev-uclass.c | 649 ++++++++++++++++++++++++++ boot/bootflow.c | 410 ++++++++++++++++ boot/bootmeth-uclass.c | 298 ++++++++++++ boot/bootmeth_distro.c | 142 ++++++ boot/bootmeth_efi.c | 183 ++++++++ boot/bootmeth_efi_mgr.c | 86 ++++ boot/bootmeth_pxe.c | 186 ++++++++ boot/bootmeth_sandbox.c | 69 +++ boot/bootmeth_script.c | 137 ++++++ boot/bootstd-uclass.c | 183 ++++++++ boot/system_bootdev.c | 66 +++ cmd/Kconfig | 39 ++ cmd/Makefile | 3 + cmd/bootdev.c | 120 +++++ cmd/bootflow.c | 399 ++++++++++++++++ cmd/bootmeth.c | 113 +++++ common/usb_storage.c | 12 + configs/amcore_defconfig | 1 + configs/rcar3_salvator-x_defconfig | 1 + configs/sandbox_defconfig | 3 +- configs/sandbox_flattree_defconfig | 3 +- configs/tbs2910_defconfig | 1 + doc/develop/bootstd.rst | 638 +++++++++++++++++++++++++ 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/usage/bootdev.rst | 135 ++++++ doc/usage/bootflow.rst | 427 +++++++++++++++++ doc/usage/bootmeth.rst | 108 +++++ doc/usage/index.rst | 3 + drivers/block/blk-uclass.c | 8 + drivers/core/uclass.c | 20 +- drivers/mmc/Makefile | 5 + drivers/mmc/mmc-uclass.c | 23 + drivers/mmc/mmc_bootdev.c | 62 +++ drivers/usb/host/Makefile | 4 + drivers/usb/host/usb_bootdev.c | 61 +++ include/blk.h | 8 + include/bootdev.h | 275 +++++++++++ include/bootflow.h | 306 ++++++++++++ include/bootmeth.h | 234 ++++++++++ include/bootstd.h | 80 ++++ include/configs/rpi.h | 39 +- include/distro.h | 24 + include/dm/device.h | 2 +- include/dm/uclass-id.h | 3 + include/dm/uclass-internal.h | 16 + include/dm/uclass.h | 8 +- include/env_callback.h | 7 + include/mmc.h | 12 +- include/test/suites.h | 2 + include/vsprintf.h | 22 +- lib/strto.c | 23 +- 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 | 223 +++++++++ test/boot/bootflow.c | 398 ++++++++++++++++ test/boot/bootmeth.c | 122 +++++ 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/print_ut.c | 40 -- test/py/tests/bootstd/mmc1.img.xz | Bin 0 -> 4448 bytes test/py/tests/test_ut.py | 103 ++++ test/str_ut.c | 72 +++ 77 files changed, 6971 insertions(+), 102 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/bootmeth_script.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/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.34.1.703.g22d0c6ccf7-goog
PATCH v3 1/31 str: Move string tests to the string module
A few string tests were added to the print module by mistake. Move them.
---
(no changes since v1)
test/print_ut.c | 40 ---------------------------------------- test/str_ut.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 40 deletions(-)
test/print_ut.c +0 -40
@@ -333,26 +333,6 @@ static int print_do_hex_dump(struct unit_test_state *uts) }PRINT_TEST (print_do_hex_dump,UT_TESTF_CONSOLE_REC ); -static int print_itoa (struct unit_test_state *uts) -{ -ut_asserteq_str ("123" ,simple_itoa (123 )); -ut_asserteq_str ("0" ,simple_itoa (0 )); -ut_asserteq_str ("2147483647" ,simple_itoa (0x7fffffff )); -ut_asserteq_str ("4294967295" ,simple_itoa (0xffffffff )); - -/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ -#ifdef CONFIG_PHYS_64BIT -if (sizeof (ulong) ==8 ) { -ut_asserteq_str ("9223372036854775807" , -simple_itoa ((1UL <<63 ) -1 )); -ut_asserteq_str ("18446744073709551615" ,simple_itoa (-1 )); - } -#endif /* CONFIG_PHYS_64BIT */ - -return 0 ; -} -PRINT_TEST (print_itoa,0 ); -static int snprint (struct unit_test_state *uts) {char buf[10 ] ="xxxxxxxxx" ;
@@ -367,26 +347,6 @@ static int snprint(struct unit_test_state *uts) }PRINT_TEST (snprint,0 ); -static int print_xtoa (struct unit_test_state *uts) -{ -ut_asserteq_str ("7f" ,simple_xtoa (127 )); -ut_asserteq_str ("00" ,simple_xtoa (0 )); -ut_asserteq_str ("7fffffff" ,simple_xtoa (0x7fffffff )); -ut_asserteq_str ("ffffffff" ,simple_xtoa (0xffffffff )); - -/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ -#ifdef CONFIG_PHYS_64BIT -if (sizeof (ulong) ==8 ) { -ut_asserteq_str ("7fffffffffffffff" , -simple_xtoa ((1UL <<63 ) -1 )); -ut_asserteq_str ("ffffffffffffffff" ,simple_xtoa (-1 )); - } -#endif /* CONFIG_PHYS_64BIT */ - -return 0 ; -} -PRINT_TEST (print_xtoa,0 ); -int do_ut_print (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct unit_test *tests =UNIT_TEST_SUITE_START (print_test);
test/str_ut.c +40 -0
@@ -202,6 +202,46 @@ static int str_dectoul(struct unit_test_state *uts) }STR_TEST (str_dectoul,0 ); +static int str_itoa (struct unit_test_state *uts) +{ +ut_asserteq_str ("123" ,simple_itoa (123 )); +ut_asserteq_str ("0" ,simple_itoa (0 )); +ut_asserteq_str ("2147483647" ,simple_itoa (0x7fffffff )); +ut_asserteq_str ("4294967295" ,simple_itoa (0xffffffff )); + +/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ +#ifdef CONFIG_PHYS_64BIT +if (sizeof (ulong) ==8 ) { +ut_asserteq_str ("9223372036854775807" , +simple_itoa ((1UL <<63 ) -1 )); +ut_asserteq_str ("18446744073709551615" ,simple_itoa (-1 )); + } +#endif /* CONFIG_PHYS_64BIT */ + +return 0 ; +} +STR_TEST (str_itoa,0 ); + +static int str_xtoa (struct unit_test_state *uts) +{ +ut_asserteq_str ("7f" ,simple_xtoa (127 )); +ut_asserteq_str ("00" ,simple_xtoa (0 )); +ut_asserteq_str ("7fffffff" ,simple_xtoa (0x7fffffff )); +ut_asserteq_str ("ffffffff" ,simple_xtoa (0xffffffff )); + +/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ +#ifdef CONFIG_PHYS_64BIT +if (sizeof (ulong) ==8 ) { +ut_asserteq_str ("7fffffffffffffff" , +simple_xtoa ((1UL <<63 ) -1 )); +ut_asserteq_str ("ffffffffffffffff" ,simple_xtoa (-1 )); + } +#endif /* CONFIG_PHYS_64BIT */ + +return 0 ; +} +STR_TEST (str_xtoa,0 ); +int do_ut_str (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct unit_test *tests =UNIT_TEST_SUITE_START (str_test);
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 01/31] str: Move string tests to the string module
Quoted 76 lines · Simon Glass
A few string tests were added to the print module by mistake. Move them.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
test/print_ut.c | 40 ---------------------------------------- test/str_ut.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 40 deletions(-)test/print_ut.c +0
-40@@ -333,26 +333,6 @@ static int print_do_hex_dump(struct unit_test_state *uts) }PRINT_TEST (print_do_hex_dump,UT_TESTF_CONSOLE_REC ); -static int print_itoa (struct unit_test_state *uts) -{ -ut_asserteq_str ("123" ,simple_itoa (123 )); -ut_asserteq_str ("0" ,simple_itoa (0 )); -ut_asserteq_str ("2147483647" ,simple_itoa (0x7fffffff )); -ut_asserteq_str ("4294967295" ,simple_itoa (0xffffffff )); - -/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ -#ifdef CONFIG_PHYS_64BIT -if (sizeof (ulong) ==8 ) { -ut_asserteq_str ("9223372036854775807" , -simple_itoa ((1UL <<63 ) -1 )); -ut_asserteq_str ("18446744073709551615" ,simple_itoa (-1 )); - } -#endif /* CONFIG_PHYS_64BIT */ - -return 0 ; -} -PRINT_TEST (print_itoa,0 ); -static int snprint (struct unit_test_state *uts) {char buf[10 ] ="xxxxxxxxx" ;@@ -367,26 +347,6 @@ static int snprint(struct unit_test_state *uts) }PRINT_TEST (snprint,0 ); -static int print_xtoa (struct unit_test_state *uts) -{ -ut_asserteq_str ("7f" ,simple_xtoa (127 )); -ut_asserteq_str ("00" ,simple_xtoa (0 )); -ut_asserteq_str ("7fffffff" ,simple_xtoa (0x7fffffff )); -ut_asserteq_str ("ffffffff" ,simple_xtoa (0xffffffff )); - -/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ -#ifdef CONFIG_PHYS_64BIT -if (sizeof (ulong) ==8 ) { -ut_asserteq_str ("7fffffffffffffff" , -simple_xtoa ((1UL <<63 ) -1 )); -ut_asserteq_str ("ffffffffffffffff" ,simple_xtoa (-1 )); - } -#endif /* CONFIG_PHYS_64BIT */ - -return 0 ; -} -PRINT_TEST (print_xtoa,0 ); -int do_ut_print (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct unit_test *tests =UNIT_TEST_SUITE_START (print_test);test/str_ut.c +0
-0@@ -202,6 +202,46 @@ static int str_dectoul(struct unit_test_state *uts) }STR_TEST (str_dectoul,0 );
test/str_ut.c static int str_dectoul(struct unit_test_state *uts) · line 213
Quoted 10 lines
test/str_ut.c +9
-0+static int str_itoa (struct unit_test_state *uts) +{ +ut_asserteq_str ("123" ,simple_itoa (123 )); +ut_asserteq_str ("0" ,simple_itoa (0 )); +ut_asserteq_str ("2147483647" ,simple_itoa (0x7fffffff )); +ut_asserteq_str ("4294967295" ,simple_itoa (0xffffffff )); + +/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ +#ifdef CONFIG_PHYS_64BIT
CONFIG_PHYS_64BIT changes the size of phys_addr_t. It is not related to the size of long.
Please remove the superfluous ifdef.
Quoted 10 lines
test/str_ut.c +10
-0+if (sizeof (ulong) ==8 ) { +ut_asserteq_str ("9223372036854775807" , +simple_itoa ((1UL <<63 ) -1 )); +ut_asserteq_str ("18446744073709551615" ,simple_itoa (-1 )); + } +#endif /* CONFIG_PHYS_64BIT */ + +return 0 ; +} +STR_TEST (str_itoa,0 );
test/str_ut.c static int str_dectoul(struct unit_test_state *uts) · line 233
Quoted 10 lines
test/str_ut.c +10
-0+ +static int str_xtoa (struct unit_test_state *uts) +{ +ut_asserteq_str ("7f" ,simple_xtoa (127 )); +ut_asserteq_str ("00" ,simple_xtoa (0 )); +ut_asserteq_str ("7fffffff" ,simple_xtoa (0x7fffffff )); +ut_asserteq_str ("ffffffff" ,simple_xtoa (0xffffffff )); + +/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ +#ifdef CONFIG_PHYS_64BIT
ditto
Best regards
Heinrich
Quoted 14 lines
test/str_ut.c +11
-0+if (sizeof (ulong) ==8 ) { +ut_asserteq_str ("7fffffffffffffff" , +simple_xtoa ((1UL <<63 ) -1 )); +ut_asserteq_str ("ffffffffffffffff" ,simple_xtoa (-1 )); + } +#endif /* CONFIG_PHYS_64BIT */ + +return 0 ; +} +STR_TEST (str_xtoa,0 ); +int do_ut_str (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct unit_test *tests =UNIT_TEST_SUITE_START (str_test);
Re: [PATCH v3 01/31] str: Move string tests to the string module
Hi Heinrich,
Quoted 92 lines · Heinrich Schuchardt
Quoted 76 lines · Simon Glass
A few string tests were added to the print module by mistake. Move them.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
test/print_ut.c | 40 ---------------------------------------- test/str_ut.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 40 deletions(-)test/print_ut.c +0
-40@@ -333,26 +333,6 @@ static int print_do_hex_dump(struct unit_test_state *uts) }PRINT_TEST (print_do_hex_dump,UT_TESTF_CONSOLE_REC ); -static int print_itoa (struct unit_test_state *uts) -{ -ut_asserteq_str ("123" ,simple_itoa (123 )); -ut_asserteq_str ("0" ,simple_itoa (0 )); -ut_asserteq_str ("2147483647" ,simple_itoa (0x7fffffff )); -ut_asserteq_str ("4294967295" ,simple_itoa (0xffffffff )); - -/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ -#ifdef CONFIG_PHYS_64BIT -if (sizeof (ulong) ==8 ) { -ut_asserteq_str ("9223372036854775807" , -simple_itoa ((1UL <<63 ) -1 )); -ut_asserteq_str ("18446744073709551615" ,simple_itoa (-1 )); - } -#endif /* CONFIG_PHYS_64BIT */ - -return 0 ; -} -PRINT_TEST (print_itoa,0 ); -static int snprint (struct unit_test_state *uts) {char buf[10 ] ="xxxxxxxxx" ;@@ -367,26 +347,6 @@ static int snprint(struct unit_test_state *uts) }PRINT_TEST (snprint,0 ); -static int print_xtoa (struct unit_test_state *uts) -{ -ut_asserteq_str ("7f" ,simple_xtoa (127 )); -ut_asserteq_str ("00" ,simple_xtoa (0 )); -ut_asserteq_str ("7fffffff" ,simple_xtoa (0x7fffffff )); -ut_asserteq_str ("ffffffff" ,simple_xtoa (0xffffffff )); - -/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ -#ifdef CONFIG_PHYS_64BIT -if (sizeof (ulong) ==8 ) { -ut_asserteq_str ("7fffffffffffffff" , -simple_xtoa ((1UL <<63 ) -1 )); -ut_asserteq_str ("ffffffffffffffff" ,simple_xtoa (-1 )); - } -#endif /* CONFIG_PHYS_64BIT */ - -return 0 ; -} -PRINT_TEST (print_xtoa,0 ); -int do_ut_print (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct unit_test *tests =UNIT_TEST_SUITE_START (print_test);test/str_ut.c +0
-0@@ -202,6 +202,46 @@ static int str_dectoul(struct unit_test_state *uts) }STR_TEST (str_dectoul,0 );test/str_ut.c static int str_dectoul(struct unit_test_state *uts) · line 213
Quoted 10 lines
test/str_ut.c +9
-0+static int str_itoa (struct unit_test_state *uts) +{ +ut_asserteq_str ("123" ,simple_itoa (123 )); +ut_asserteq_str ("0" ,simple_itoa (0 )); +ut_asserteq_str ("2147483647" ,simple_itoa (0x7fffffff )); +ut_asserteq_str ("4294967295" ,simple_itoa (0xffffffff )); + +/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ +#ifdef CONFIG_PHYS_64BIT
CONFIG_PHYS_64BITchanges the size ofphys_addr_t. It is not related to the size of long.
Quoted 1 line
Please remove the superfluous ifdef.
What is superfluous about it? It avoids a build error on snow, for example.
It's close enough since 32-bit machines that run tests currently do not enable this option.
Also I am just moving code around, so changing it is beyond the scope of the patch.
Quoted 14 lines
Quoted 14 lines
test/str_ut.c +14
-0+if (sizeof (ulong) ==8 ) { +ut_asserteq_str ("9223372036854775807" , +simple_itoa ((1UL <<63 ) -1 )); +ut_asserteq_str ("18446744073709551615" ,simple_itoa (-1 )); + } +#endif /* CONFIG_PHYS_64BIT */ + +return 0 ; +} +STR_TEST (str_itoa,0 ); + +static int str_xtoa (struct unit_test_state *uts) +{ +ut_asserteq_str ("7f" ,simple_xtoa (127 ));
Quoted 9 lines
test/str_ut.c static int str_dectoul(struct unit_test_state *uts) · line 233
Quoted 6 lines
test/str_ut.c +6
-0+ut_asserteq_str ("00" ,simple_xtoa (0 )); +ut_asserteq_str ("7fffffff" ,simple_xtoa (0x7fffffff )); +ut_asserteq_str ("ffffffff" ,simple_xtoa (0xffffffff )); + +/* Use #ifdef here to avoid a compiler warning on 32-bit machines */ +#ifdef CONFIG_PHYS_64BIT ditto
Regards,
Simon
PATCH v3 2/31 test: Add tests for trailing_strtol()
In reply to Simon GlassThis function currently has no tests. Add some.
---
(no changes since v1)
include/vsprintf.h | 4 ++-- test/str_ut.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-)
include/vsprintf.h +2 -2
@@ -99,7 +99,7 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base);* For example, "abc123" would return 123. * * @str: String to exxamine -* @return training number if found, else -1 +* @return trailing number if found, else -1 */ long trailing_strtol (const char *str);
@@ -114,7 +114,7 @@ long trailing_strtol(const char *str);* @str: String to exxamine * @end: Pointer to end of string to examine, or NULL to use the * whole string -* @return training number if found, else -1 +* @return trailing number if found, else -1 */ long trailing_strtoln (const char *str,const char *end);
test/str_ut.c +19 -0
@@ -242,6 +242,25 @@ static int str_xtoa(struct unit_test_state *uts) }STR_TEST (str_xtoa,0 ); +static int str_trailing (struct unit_test_state *uts) +{ +char str1[] ="abc123def" ; + +ut_asserteq (-1 ,trailing_strtol ("" )); +ut_asserteq (-1 ,trailing_strtol ("123" )); +ut_asserteq (123 ,trailing_strtol ("abc123" )); +ut_asserteq (4 ,trailing_strtol ("12c4" )); +ut_asserteq (-1 ,trailing_strtol ("abd" )); +ut_asserteq (-1 ,trailing_strtol ("abc123def" )); + +ut_asserteq (-1 ,trailing_strtoln (str1,NULL )); +ut_asserteq (123 ,trailing_strtoln (str1, str1 +6 )); +ut_asserteq (-1 ,trailing_strtoln (str1, str1 +9 )); + +return 0 ; +} +STR_TEST (str_trailing,0 ); +int do_ut_str (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct unit_test *tests =UNIT_TEST_SUITE_START (str_test);
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 02/31] test: Add tests for trailing_strtol()
Quoted 16 lines · Simon Glass
This function currently has no tests. Add some.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
include/vsprintf.h | 4 ++-- test/str_ut.c | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-)include/vsprintf.h +0
-0
include/vsprintf.h long long simple_strtoll(const char *cp, char **endp, unsigned int base); · line 102
Quoted 5 lines
include/vsprintf.h +1
-1@@ -99,7 +99,7 @@ long long simple_strtoll(const char *cp, char **endp, unsigned int base);* For example, "abc123" would return 123. * * @str: String to exxamine -* @return training number if found, else -1 +* @return trailing number if found, else -1
%s/@return/Return:/
Cf.
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
Best regards
Heinrich
Quoted 42 lines
include/vsprintf.h +1
-1*/ long trailing_strtol (const char *str);@@ -114,7 +114,7 @@ long trailing_strtol(const char *str);* @str: String to exxamine * @end: Pointer to end of string to examine, or NULL to use the * whole string -* @return training number if found, else -1 +* @return trailing number if found, else -1 */ long trailing_strtoln (const char *str,const char *end);test/str_ut.c +19
-0@@ -242,6 +242,25 @@ static int str_xtoa(struct unit_test_state *uts) }STR_TEST (str_xtoa,0 ); +static int str_trailing (struct unit_test_state *uts) +{ +char str1[] ="abc123def" ; + +ut_asserteq (-1 ,trailing_strtol ("" )); +ut_asserteq (-1 ,trailing_strtol ("123" )); +ut_asserteq (123 ,trailing_strtol ("abc123" )); +ut_asserteq (4 ,trailing_strtol ("12c4" )); +ut_asserteq (-1 ,trailing_strtol ("abd" )); +ut_asserteq (-1 ,trailing_strtol ("abc123def" )); + +ut_asserteq (-1 ,trailing_strtoln (str1,NULL )); +ut_asserteq (123 ,trailing_strtoln (str1, str1 +6 )); +ut_asserteq (-1 ,trailing_strtoln (str1, str1 +9 )); + +return 0 ; +} +STR_TEST (str_trailing,0 ); +int do_ut_str (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]) {struct unit_test *tests =UNIT_TEST_SUITE_START (str_test);
PATCH v3 3/31 str: Fix a few bugs in trailing_strtoln()
In reply to Simon GlassAt present this has a minor bug in that it reads the byte before the start of the string. Also it doesn't handle a non-numeric prefix which is only one character long.
Fix these bugs with a reworked implementation. Add a test for the second case. The first one is hard to test.
---
(no changes since v1)
lib/strto.c | 11 ++++++----- test/str_ut.c | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-)
lib/strto.c +6 -5
@@ -189,11 +189,12 @@ long trailing_strtoln(const char *str, const char *end)if (!end) end = str +strlen (str); -if (isdigit (end[-1 ])) { -for (p = end -1 ; p > str; p--) { -if (!isdigit (*p)) -return dectoul (p +1 ,NULL ); - } + p = end -1 ; +if (p > str &&isdigit (*p)) { +do { +if (!isdigit (p[-1 ])) +return dectoul (p,NULL ); + }while (--p > str); }return -1 ;
test/str_ut.c +2 -0
@@ -257,6 +257,8 @@ static int str_trailing(struct unit_test_state *uts)ut_asserteq (123 ,trailing_strtoln (str1, str1 +6 ));ut_asserteq (-1 ,trailing_strtoln (str1, str1 +9 )); +ut_asserteq (3 ,trailing_strtol ("a3" )); +return 0 ; }STR_TEST (str_trailing,0 );
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 03/31] str: Fix a few bugs in trailing_strtoln()
Quoted 2 lines · Simon Glass
At present this has a minor bug in that it reads the byte before the start of the string.
Only for an empty string, AFAICS. Which is a bug, of course, but mostly the caller is to blame.
Also it doesn't handle a non-numeric prefix which is
Quoted 3 lines
only one character long.
Fix these bugs with a reworked implementation.
How does your new implementation handle the case of no prefix at all, i.e. "456"? Shouldn't that also work? Or a single-digit "7"?
Both the old and new seem to have a bug in that the end parameter is essentially ignored. If I have
const char *s = "abc123";
and do
trailing_strtoln(s, s+5);
I'd expect 12.
Rasmus
Re: [PATCH v3 03/31] str: Fix a few bugs in trailing_strtoln()
Hi Rasmus,
Quoted 7 lines · Rasmus Villemoes
Quoted 2 lines · Simon Glass
At present this has a minor bug in that it reads the byte before the start of the string.
Only for an empty string, AFAICS. Which is a bug, of course, but mostly the caller is to blame.
Yes
Quoted 8 lines
Also it doesn't handle a non-numeric prefix which is
Quoted 3 lines
only one character long.
Fix these bugs with a reworked implementation.
How does your new implementation handle the case of no prefix at all, i.e. "456"? Shouldn't that also work? Or a single-digit "7"?
It is not designed to work for that case. You could just use dectoul() or similar.
Quoted 11 lines
Both the old and new seem to have a bug in that the end parameter is essentially ignored. If I have
const char *s = "abc123";
and do
trailing_strtoln(s, s+5);I'd expect 12.
That is intentional though - end is expected to point to a letter. I can reword the function comment to cover both of these cases.
Regards,
Simon
PATCH v3 4/31 lib: Add a way to find the postiion of a trailing number
In reply to Simon GlassAt 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.
---
Changes in v3:
- Change the function to return a pointer to the first digit
- Add some tests, including one for 'abc123def456'
include/vsprintf.h | 18 ++++++++++++++++++ lib/strto.c | 14 ++++++++++++-- test/str_ut.c | 13 ++++++++++++- 3 files changed, 42 insertions(+), 3 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_end() - extract 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 +* @endp: If non-NULL, this is set to point to the character where the +* number starts, e.g. for "mmc0" this would be point to the '0'; if no +* trailing number is found, it is set to the end of the string +* @return training number if found, else -1 +*/ +long trailing_strtoln_end (const char *str,const char *end,char const **endp); +/** * 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_end (const char *str,const char *end,char const **endp) {const char *p;
@@ -192,14 +192,24 @@ long trailing_strtoln(const char *str, const char *end) p = end -1 ;if (p > str &&isdigit (*p)) {do { -if (!isdigit (p[-1 ])) +if (!isdigit (p[-1 ])) { +if (endp) + *endp = p;return dectoul (p,NULL ); + } }while (--p > str); } +if (endp) + *endp = end;return -1 ; } +long trailing_strtoln (const char *str,const char *end) +{ +return trailing_strtoln_end (str, end,NULL ); +} +long trailing_strtol (const char *str) {return trailing_strtoln (str,NULL );
test/str_ut.c +12 -1
@@ -244,7 +244,9 @@ STR_TEST(str_xtoa, 0);static int str_trailing (struct unit_test_state *uts) { -char str1[] ="abc123def" ; +const char str1[] ="abc123def" ; +const char str2[] ="abc123def456" ; +const char *end;ut_asserteq (-1 ,trailing_strtol ("" ));ut_asserteq (-1 ,trailing_strtol ("123" ));
@@ -259,6 +261,15 @@ static int str_trailing(struct unit_test_state *uts)ut_asserteq (3 ,trailing_strtol ("a3" )); +ut_asserteq (123 ,trailing_strtoln_end (str1, str1 +6 , &end)); +ut_asserteq (3 , end - str1); + +ut_asserteq (-1 ,trailing_strtoln_end (str1, str1 +7 , &end)); +ut_asserteq (7 , end - str1); + +ut_asserteq (456 ,trailing_strtoln_end (str2,NULL , &end)); +ut_asserteq (9 , end - str2); +return 0 ; }STR_TEST (str_trailing,0 );
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 04/31] lib: Add a way to find the postiion of a trailing number
Quoted 29 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]>---
Changes in v3:
- Change the function to return a pointer to the first digit
- Add some tests, including one for 'abc123def456'include/vsprintf.h | 18 ++++++++++++++++++ lib/strto.c | 14 ++++++++++++-- test/str_ut.c | 13 ++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-)include/vsprintf.h +5
-0@@ -118,6 +118,24 @@ long trailing_strtol(const char *str);*/ long trailing_strtoln (const char *str,const char *end); +/** +* trailing_strtoln_end() - extract 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
include/vsprintf.h long trailing_strtol(const char *str); · line 135
Quoted 10 lines
include/vsprintf.h +10
-0+* 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 +* @endp: If non-NULL, this is set to point to the character where the +* number starts, e.g. for "mmc0" this would be point to the '0'; if no +* trailing number is found, it is set to the end of the string +* @return training number if found, else -1
Return:
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
Best regards
Heinrich
Quoted 76 lines
include/vsprintf.h +3
-0+*/ +long trailing_strtoln_end (const char *str,const char *end,char const **endp); +/** * 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_end (const char *str,const char *end,char const **endp) {const char *p;@@ -192,14 +192,24 @@ long trailing_strtoln(const char *str, const char *end) p = end -1 ;if (p > str &&isdigit (*p)) {do { -if (!isdigit (p[-1 ])) +if (!isdigit (p[-1 ])) { +if (endp) + *endp = p;return dectoul (p,NULL ); + } }while (--p > str); } +if (endp) + *endp = end;return -1 ; } +long trailing_strtoln (const char *str,const char *end) +{ +return trailing_strtoln_end (str, end,NULL ); +} +long trailing_strtol (const char *str) {return trailing_strtoln (str,NULL );test/str_ut.c +12
-1@@ -244,7 +244,9 @@ STR_TEST(str_xtoa, 0);static int str_trailing (struct unit_test_state *uts) { -char str1[] ="abc123def" ; +const char str1[] ="abc123def" ; +const char str2[] ="abc123def456" ; +const char *end;ut_asserteq (-1 ,trailing_strtol ("" ));ut_asserteq (-1 ,trailing_strtol ("123" ));@@ -259,6 +261,15 @@ static int str_trailing(struct unit_test_state *uts)ut_asserteq (3 ,trailing_strtol ("a3" )); +ut_asserteq (123 ,trailing_strtoln_end (str1, str1 +6 , &end)); +ut_asserteq (3 , end - str1); + +ut_asserteq (-1 ,trailing_strtoln_end (str1, str1 +7 , &end)); +ut_asserteq (7 , end - str1); + +ut_asserteq (456 ,trailing_strtoln_end (str2,NULL , &end)); +ut_asserteq (9 , end - str2); +return 0 ; }STR_TEST (str_trailing,0 );
Re: [PATCH v3 04/31] lib: Add a way to find the postiion of a trailing number
Hi Heinrich,
Quoted 44 lines · Heinrich Schuchardt
Quoted 29 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]>---
Changes in v3:
- Change the function to return a pointer to the first digit
- Add some tests, including one for 'abc123def456'include/vsprintf.h | 18 ++++++++++++++++++ lib/strto.c | 14 ++++++++++++-- test/str_ut.c | 13 ++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-)include/vsprintf.h +5
-0@@ -118,6 +118,24 @@ long trailing_strtol(const char *str);*/ long trailing_strtoln (const char *str,const char *end); +/** +* trailing_strtoln_end() - extract 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 include/vsprintf.h long trailing_strtol(const char *str); · line 135
Quoted 10 lines
include/vsprintf.h +10
-0+* 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 +* @endp: If non-NULL, this is set to point to the character where the +* number starts, e.g. for "mmc0" this would be point to the '0'; if no +* trailing number is found, it is set to the end of the string +* @return training number if found, else -1 Return:
Quoted 1 line
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
Yes I am slowly getting used to this.
Is there any way to accept both? U=Boot has used @return for years so there is lots of itin the code.
Regards,
Simon
Re: [PATCH v3 04/31] lib: Add a way to find the postiion of a trailing number
Quoted 47 lines · Simon Glass
Hi Heinrich,
Quoted 44 lines · Heinrich Schuchardt
Quoted 29 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]>---
Changes in v3:
- Change the function to return a pointer to the first digit
- Add some tests, including one for 'abc123def456'include/vsprintf.h | 18 ++++++++++++++++++ lib/strto.c | 14 ++++++++++++-- test/str_ut.c | 13 ++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-)include/vsprintf.h +5
-0@@ -118,6 +118,24 @@ long trailing_strtol(const char *str);*/ long trailing_strtoln (const char *str,const char *end); +/** +* trailing_strtoln_end() - extract 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 include/vsprintf.h long trailing_strtol(const char *str); · line 135
Quoted 10 lines
include/vsprintf.h +10
-0+* 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 +* @endp: If non-NULL, this is set to point to the character where the +* number starts, e.g. for "mmc0" this would be point to the '0'; if no +* trailing number is found, it is set to the end of the string +* @return training number if found, else -1 Return:
Quoted 6 lines
Quoted 1 line
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
Yes I am slowly getting used to this.
Is there any way to accept both? U=Boot has used @return for years so there is lots of itin the code.
Can we just do a coccinelle script to just update the codebase?
Signature · 1 line
Tom
Re: [PATCH v3 04/31] lib: Add a way to find the postiion of a trailing number
Quoted 48 lines · Tom Rini
Quoted 47 lines · Simon Glass
Hi Heinrich,
Quoted 44 lines · Heinrich Schuchardt
Quoted 29 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]>---
Changes in v3:
- Change the function to return a pointer to the first digit
- Add some tests, including one for 'abc123def456'include/vsprintf.h | 18 ++++++++++++++++++ lib/strto.c | 14 ++++++++++++-- test/str_ut.c | 13 ++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-)include/vsprintf.h +5
-0@@ -118,6 +118,24 @@ long trailing_strtol(const char *str);*/ long trailing_strtoln (const char *str,const char *end); +/** +* trailing_strtoln_end() - extract 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 include/vsprintf.h long trailing_strtol(const char *str); · line 135
Quoted 10 lines
include/vsprintf.h +10
-0+* 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 +* @endp: If non-NULL, this is set to point to the character where the +* number starts, e.g. for "mmc0" this would be point to the '0'; if no +* trailing number is found, it is set to the end of the string +* @return training number if found, else -1 Return:
Quoted 6 lines
Quoted 6 lines
Quoted 1 line
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
Yes I am slowly getting used to this.
Is there any way to accept both? U=Boot has used @return for years so there is lots of itin the code.
This was before we started publishing HTML documentation on readthedocs.io. Sphinx will not build with @return or @return:.
Quoted 3 lines
Can we just do a coccinelle script to just update the codebase?
For new lines we just need to remind the author.
For existing code sed should be good enough, e.g.
find . -name '*.c' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;
find . -name '*.h' -exec \
sed -i 's/^\(\s\)\*\(\s*\)@return\(\s\)/\1*\2Return:\3/' {} \;
I just sent a patch.
Best regards
Heinrich
Re: [PATCH v3 04/31] lib: Add a way to find the postiion of a trailing number
In reply to Heinrich SchuchardtQuoted 43 lines · Heinrich Schuchardt
Quoted 29 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]>---
Changes in v3:
- Change the function to return a pointer to the first digit
- Add some tests, including one for 'abc123def456'include/vsprintf.h | 18 ++++++++++++++++++ lib/strto.c | 14 ++++++++++++-- test/str_ut.c | 13 ++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-)include/vsprintf.h +5
-0@@ -118,6 +118,24 @@ long trailing_strtol(const char *str);*/ long trailing_strtoln (const char *str,const char *end); +/** +* trailing_strtoln_end() - extract 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 include/vsprintf.h long trailing_strtol(const char *str); · line 135
Quoted 10 lines
include/vsprintf.h +10
-0+* 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 +* @endp: If non-NULL, this is set to point to the character where the +* number starts, e.g. for "mmc0" this would be point to the '0'; if no +* trailing number is found, it is set to the end of the string +* @return training number if found, else -1 Return:
Quoted 1 line
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
One of other common mistakes(?) that I can see in the repository is a violation of the rule below:
===8<===
Function parameters
~~~~~~~~~~~~~~~~~~~
Each function argument should be described in order, immediately following
^^^^^^^^^^^^^^^^^^^^^
the short function description. Do not leave a blank line between the function description and the arguments, nor between the arguments. ===>8===
For instance, in this patch,
Quoted 9 lines
include/vsprintf.h long trailing_strtol(const char *str); · line 129
Quoted 9 lines
include/vsprintf.h +9
-0+/** +* trailing_strtoln_end() - extract 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
(snip)
The structure of trailing_strtoln_end() looks like:
<short function description>
<blank line>
<long function description>
<blank line>
<function arguments>
Doesn't this matter so far in formatting Sphinx texts?
-Takahiro Akashi
Quoted 81 lines
Best regards
Heinrich
Quoted 76 lines
+ */
include/vsprintf.h +2
-0+long trailing_strtoln_end (const char *str,const char *end,char const **endp); +/** * 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_end (const char *str,const char *end,char const **endp) {const char *p;@@ -192,14 +192,24 @@ long trailing_strtoln(const char *str, const char *end) p = end -1 ;if (p > str &&isdigit (*p)) {do { -if (!isdigit (p[-1 ])) +if (!isdigit (p[-1 ])) { +if (endp) + *endp = p;return dectoul (p,NULL ); + } }while (--p > str); } +if (endp) + *endp = end;return -1 ; } +long trailing_strtoln (const char *str,const char *end) +{ +return trailing_strtoln_end (str, end,NULL ); +} +long trailing_strtol (const char *str) {return trailing_strtoln (str,NULL );test/str_ut.c +12
-1@@ -244,7 +244,9 @@ STR_TEST(str_xtoa, 0);static int str_trailing (struct unit_test_state *uts) { -char str1[] ="abc123def" ; +const char str1[] ="abc123def" ; +const char str2[] ="abc123def456" ; +const char *end;ut_asserteq (-1 ,trailing_strtol ("" ));ut_asserteq (-1 ,trailing_strtol ("123" ));@@ -259,6 +261,15 @@ static int str_trailing(struct unit_test_state *uts)ut_asserteq (3 ,trailing_strtol ("a3" )); +ut_asserteq (123 ,trailing_strtoln_end (str1, str1 +6 , &end)); +ut_asserteq (3 , end - str1); + +ut_asserteq (-1 ,trailing_strtoln_end (str1, str1 +7 , &end)); +ut_asserteq (7 , end - str1); + +ut_asserteq (456 ,trailing_strtoln_end (str2,NULL , &end)); +ut_asserteq (9 , end - str2); +return 0 ; }STR_TEST (str_trailing,0 );
Re: [PATCH v3 04/31] lib: Add a way to find the postiion of a trailing number
Hi Takahiro,
Quoted 71 lines · AKASHI Takahiro
Quoted 43 lines · Heinrich Schuchardt
Quoted 29 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]>---
Changes in v3:
- Change the function to return a pointer to the first digit
- Add some tests, including one for 'abc123def456'include/vsprintf.h | 18 ++++++++++++++++++ lib/strto.c | 14 ++++++++++++-- test/str_ut.c | 13 ++++++++++++- 3 files changed, 42 insertions(+), 3 deletions(-)include/vsprintf.h +5
-0@@ -118,6 +118,24 @@ long trailing_strtol(const char *str);*/ long trailing_strtoln (const char *str,const char *end); +/** +* trailing_strtoln_end() - extract 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 include/vsprintf.h long trailing_strtol(const char *str); · line 135
Quoted 10 lines
include/vsprintf.h +10
-0+* 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 +* @endp: If non-NULL, this is set to point to the character where the +* number starts, e.g. for "mmc0" this would be point to the '0'; if no +* trailing number is found, it is set to the end of the string +* @return training number if found, else -1 Return:
Quoted 1 line
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
One of other common mistakes(?) that I can see in the repository is a violation of the rule below:
===8<===
Function parameters
~~~~~~~~~~~~~~~~~~~Each function argument should be described in order, immediately following
^^^^^^^^^^^^^^^^^^^^^the short function description. Do not leave a blank line between the function description and the arguments, nor between the arguments. ===>8===
For instance, in this patch,
Quoted 9 lines
Quoted 9 lines
include/vsprintf.h +9
-0+/** +* trailing_strtoln_end() - extract 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 (snip)
Quoted 8 lines
The structure of
trailing_strtoln_end()looks like:
<short function description>
<blank line>
<long function description>
<blank line>
<function arguments>Doesn't this matter so far in formatting Sphinx texts?
It doesn't seem to, luckily. I'm not too impressed with how simplistic Sphinx is with formatting, but it seems OK in that case.
Regards,
Simon
PATCH v3 5/31 dm: core: Rename uclass_get_by_name_len()
In reply to Simon GlassIt seems that namelen is more common in U-Boot. Rename this function to fit in better.
---
Changes in v3:
- Add new patch to rename uclass_get_by_name_len()
drivers/core/uclass.c | 7 ++++--- include/dm/uclass.h | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-)
drivers/core/uclass.c +4 -3
@@ -180,14 +180,15 @@ void uclass_set_priv(struct uclass *uc, void *priv) uc->priv_ = priv; } -enum uclass_id uclass_get_by_name_len (const char *name,int len) +enum uclass_id uclass_get_by_namelen (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 && !strncmp (uc_drv->name, name, len)) +if (uc_drv && !strncmp (uc_drv->name, name, len) && +strlen (uc_drv->name) == len)return i; }
@@ -196,7 +197,7 @@ enum uclass_id uclass_get_by_name_len(const char *name, int len)enum uclass_id uclass_get_by_name (const char *name) { -return uclass_get_by_name_len (name,strlen (name)); +return uclass_get_by_namelen (name,strlen (name)); }int dev_get_uclass_index (struct udevice *dev,struct uclass **ucp)
include/dm/uclass.h +4 -4
@@ -173,13 +173,13 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);const char *uclass_get_name (enum uclass_id id);/** -* uclass_get_by_name_len() - Look up a uclass by its partial driver name +* uclass_get_by_namelen() - Look up a uclass by its driver name * * @name: Name to look up -* @len: Length of the partial name -* Return: the associated uclass ID, or UCLASS_INVALID if not found +* @len: Length of @name (the uclass driver name must have the same length) +* @returns the associated uclass ID, or UCLASS_INVALID if not found */ -enum uclass_id uclass_get_by_name_len (const char *name,int len); +enum uclass_id uclass_get_by_namelen (const char *name,int len);/** * uclass_get_by_name() - Look up a uclass by its driver name
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 05/31] dm: core: Rename uclass_get_by_name_len()
Quoted 50 lines · Simon Glass
It seems that namelen is more common in U-Boot. Rename this function to fit in better.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add new patch to renameuclass_get_by_name_len()drivers/core/uclass.c | 7 ++++--- include/dm/uclass.h | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-)drivers/core/uclass.c +4
-3@@ -180,14 +180,15 @@ void uclass_set_priv(struct uclass *uc, void *priv) uc->priv_ = priv; } -enum uclass_id uclass_get_by_name_len (const char *name,int len) +enum uclass_id uclass_get_by_namelen (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 && !strncmp (uc_drv->name, name, len)) +if (uc_drv && !strncmp (uc_drv->name, name, len) && +strlen (uc_drv->name) == len)return i; }@@ -196,7 +197,7 @@ enum uclass_id uclass_get_by_name_len(const char *name, int len)enum uclass_id uclass_get_by_name (const char *name) { -return uclass_get_by_name_len (name,strlen (name)); +return uclass_get_by_namelen (name,strlen (name)); }int dev_get_uclass_index (struct udevice *dev,struct uclass **ucp)include/dm/uclass.h +0
-0@@ -173,13 +173,13 @@ int uclass_get(enum uclass_id key, struct uclass **ucp);const char *uclass_get_name (enum uclass_id id);
include/dm/uclass.h int uclass_get(enum uclass_id key, struct uclass **ucp); · line 180
Quoted 10 lines
include/dm/uclass.h +3
-3/** -* uclass_get_by_name_len() - Look up a uclass by its partial driver name +* uclass_get_by_namelen() - Look up a uclass by its driver name * * @name: Name to look up -* @len: Length of the partial name -* Return: the associated uclass ID, or UCLASS_INVALID if not found +* @len: Length of @name (the uclass driver name must have the same length) +* @returns the associated uclass ID, or UCLASS_INVALID if not found
Return:
Cf.
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
Best regards
Heinrich
Quoted 6 lines
include/dm/uclass.h +1
-1*/ -enum uclass_id uclass_get_by_name_len (const char *name,int len); +enum uclass_id uclass_get_by_namelen (const char *name,int len);/** * uclass_get_by_name() - Look up a uclass by its driver name
PATCH v3 6/31 dm: core: Allow finding a uclass device by partial name
In reply to Simon GlassIn some cases two devices are related and the only way to tell is to check that the names partially patch. Add a way to check this without needing to create a new string for the comparison.
Fix the comment for device_find_child_by_namelen() while we are here.
---
Changes in v3:
- Add new patch to support finding a uclass device by partial name
drivers/core/uclass.c | 13 ++++++++++--- include/dm/device.h | 2 +- include/dm/uclass-internal.h | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-)
drivers/core/uclass.c +10 -3
@@ -274,8 +274,8 @@ int uclass_find_next_device(struct udevice **devp)return 0 ; } -int uclass_find_device_by_name (enum uclass_id id,const char *name, -struct udevice **devp) +int uclass_find_device_by_namelen (enum uclass_id id,const char *name,int len, +struct udevice **devp) {struct uclass *uc;struct udevice *dev;
@@ -289,7 +289,8 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,return ret; uclass_foreach_dev(dev, uc) { -if (!strcmp (dev->name, name)) { +if (!strncmp (dev->name, name, len) && +strlen (dev->name) == len) { *devp = dev;return 0 ; }
@@ -298,6 +299,12 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,return -ENODEV ; } +int uclass_find_device_by_name (enum uclass_id id,const char *name, +struct udevice **devp) +{ +return uclass_find_device_by_namelen (id, name,strlen (name), devp); +} +int uclass_find_next_free_seq (struct uclass *uc) {struct udevice *dev;
include/dm/device.h +1 -1
@@ -791,7 +791,7 @@ int device_find_first_child_by_uclass(const struct udevice *parent, struct udevice **devp);/** -* device_find_child_by_name() - Find a child by device name +* device_find_child_by_namelen() - Find a child by device name * * @parent: Parent device to search * @name: Name to look for
include/dm/uclass-internal.h +16 -0
@@ -154,6 +154,22 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp);*/ int uclass_find_next_device (struct udevice **devp); +/** +* uclass_find_device_by_namelen() - Find uclass device based on ID and name +* +* This searches for a device with the exactly given name. +* +* The device is NOT probed, it is merely returned. +* +* @id: ID to look up +* @name: name of a device to find +* @len: Length of @name (the uclass driver name must have the same length) +* @devp: Returns pointer to device (the first one with the name) +* @return 0 if OK, -ve on error +*/ +int uclass_find_device_by_namelen (enum uclass_id id,const char *name,int len, +struct udevice **devp); +/** * uclass_find_device_by_name() - Find uclass device based on ID and name *
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 06/31] dm: core: Allow finding a uclass device by partial name
Quoted 78 lines · Simon Glass
In some cases two devices are related and the only way to tell is to check that the names partially patch. Add a way to check this without needing to create a new string for the comparison.
Fix the comment for
device_find_child_by_namelen()while we are here.Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add new patch to support finding a uclass device by partial namedrivers/core/uclass.c | 13 ++++++++++--- include/dm/device.h | 2 +- include/dm/uclass-internal.h | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 4 deletions(-)drivers/core/uclass.c +10
-3@@ -274,8 +274,8 @@ int uclass_find_next_device(struct udevice **devp)return 0 ; } -int uclass_find_device_by_name (enum uclass_id id,const char *name, -struct udevice **devp) +int uclass_find_device_by_namelen (enum uclass_id id,const char *name,int len, +struct udevice **devp) {struct uclass *uc;struct udevice *dev;@@ -289,7 +289,8 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,return ret; uclass_foreach_dev(dev, uc) { -if (!strcmp (dev->name, name)) { +if (!strncmp (dev->name, name, len) && +strlen (dev->name) == len) { *devp = dev;return 0 ; }@@ -298,6 +299,12 @@ int uclass_find_device_by_name(enum uclass_id id, const char *name,return -ENODEV ; } +int uclass_find_device_by_name (enum uclass_id id,const char *name, +struct udevice **devp) +{ +return uclass_find_device_by_namelen (id, name,strlen (name), devp); +} +int uclass_find_next_free_seq (struct uclass *uc) {struct udevice *dev;include/dm/device.h +1
-1@@ -791,7 +791,7 @@ int device_find_first_child_by_uclass(const struct udevice *parent, struct udevice **devp);/** -* device_find_child_by_name() - Find a child by device name +* device_find_child_by_namelen() - Find a child by device name * * @parent: Parent device to search * @name: Name to look for include/dm/uclass-internal.h +2
-0@@ -154,6 +154,22 @@ int uclass_find_first_device(enum uclass_id id, struct udevice **devp);*/ int uclass_find_next_device (struct udevice **devp); +/** +* uclass_find_device_by_namelen() - Find uclass device based on ID and name
include/dm/uclass-internal.h int uclass_find_first_device(enum uclass_id id, struct udevice **devp); · line 168
Quoted 10 lines
include/dm/uclass-internal.h +10
-0+* +* This searches for a device with the exactly given name. +* +* The device is NOT probed, it is merely returned. +* +* @id: ID to look up +* @name: name of a device to find +* @len: Length of @name (the uclass driver name must have the same length) +* @devp: Returns pointer to device (the first one with the name) +* @return 0 if OK, -ve on error
Return:
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
Best regards
Heinrich
Quoted 7 lines
include/dm/uclass-internal.h +4
-0+*/ +int uclass_find_device_by_namelen (enum uclass_id id,const char *name,int len, +struct udevice **devp); +/** * uclass_find_device_by_name() - Find uclass device based on ID and name *
PATCH v3 7/31 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.34.1.703.g22d0c6ccf7-goog
PATCH v3 8/31 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.34.1.703.g22d0c6ccf7-goog
PATCH v3 9/31 dm: blk: Add a function to return the device type
In reply to Simon GlassUse the uclass name to get the device type for a block device.
---
(no changes since v1)
drivers/block/blk-uclass.c | 8 ++++++++ include/blk.h | 8 ++++++++ 2 files changed, 16 insertions(+)
drivers/block/blk-uclass.c +8 -0
@@ -509,6 +509,14 @@ int blk_get_from_parent(struct udevice *parent, struct udevice **devp)return 0 ; } +const char *blk_get_devtype (struct udevice *dev) +{ +struct udevice *parent =dev_get_parent (dev); + +return uclass_get_name (device_get_uclass_id (parent)); +}; + +int blk_find_max_devnum (enum if_type if_type) {struct udevice *dev;
include/blk.h +8 -0
@@ -433,6 +433,14 @@ int blk_select_hwpart(struct udevice *dev, int hwpart);*/ int blk_get_from_parent (struct udevice *parent,struct udevice **devp); +/** +* blk_get_devtype() - Get the device type of a block device +* +* @dev: Block device to check +* @return device tree, i.e. the uclass name of its parent, e.g. "mmc" +*/ +const char *blk_get_devtype (struct udevice *dev); +/** * blk_get_by_device() - Get the block device descriptor for the given device * @dev: Instance of a storage device
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 09/31] dm: blk: Add a function to return the device type
Quoted 35 lines · Simon Glass
Use the uclass name to get the device type for a block device.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
drivers/block/blk-uclass.c | 8 ++++++++ include/blk.h | 8 ++++++++ 2 files changed, 16 insertions(+)drivers/block/blk-uclass.c +8
-0@@ -509,6 +509,14 @@ int blk_get_from_parent(struct udevice *parent, struct udevice **devp)return 0 ; } +const char *blk_get_devtype (struct udevice *dev) +{ +struct udevice *parent =dev_get_parent (dev); + +return uclass_get_name (device_get_uclass_id (parent)); +}; + +int blk_find_max_devnum (enum if_type if_type) {struct udevice *dev;include/blk.h +0
-0
include/blk.h int blk_select_hwpart(struct udevice *dev, int hwpart); · line 440
Quoted 8 lines
include/blk.h +5
-0@@ -433,6 +433,14 @@ int blk_select_hwpart(struct udevice *dev, int hwpart);*/ int blk_get_from_parent (struct udevice *parent,struct udevice **devp); +/** +* blk_get_devtype() - Get the device type of a block device +* +* @dev: Block device to check +* @return device tree, i.e. the uclass name of its parent, e.g. "mmc"
Return:
Cf.
https://www.kernel.org/doc/html/latest/doc-guide/kernel-doc.html#function-documentation
Best regards
Heinrich
Quoted 6 lines
include/blk.h +3
-0+*/ +const char *blk_get_devtype (struct udevice *dev); +/** * blk_get_by_device() - Get the block device descriptor for the given device * @dev: Instance of a storage device
PATCH v3 10/31 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.
---
Changes in v3:
- Mention bootflow_state[] in enum bootflow_state_t
MAINTAINERS | 5 + include/bootflow.h | 256 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 261 insertions(+) create mode 100644 include/bootflow.h
MAINTAINERS +5 -0
@@ -660,6 +660,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 +256 -0
256 lines not on this page · raw message
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
PATCH v3 11/31 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.
---
Changes in v3:
- Add CONFIG_BOOTSTD_FULL to enable the full feature set
- Support bootdev-order and filename-prefixes only with CONFIG_BOOTSTD_FULL
MAINTAINERS | 2 + boot/Kconfig | 34 ++++++ boot/Makefile | 3 + boot/bootstd-uclass.c | 152 +++++++++++++++++++++++++++ doc/device-tree-bindings/bootstd.txt | 28 +++++ include/bootstd.h | 80 ++++++++++++++ include/dm/uclass-id.h | 1 + 7 files changed, 300 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
@@ -663,6 +663,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 +34 -0
@@ -281,6 +281,40 @@ endif # SPL endif # FIT +config BOOTSTD + bool "Standard boot support" + default y + depends on DM && OF_CONTROL && BLK + 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 BOOTSTD_FULL + bool "Enhanced features for standard boot" + default y if SANDBOX + help + This enables various useful features for standard boot, which are not + essential for operation: + + - bootdev, bootmeth commands + - extra features in the bootflow command + - support for selecting the ordering of bootmeths ("bootmeth order") + - support for selecting the ordering of bootdevs using the devicetree + as well as the "boot_targets" environment variable + 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 +152 -0
152 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.34.1.703.g22d0c6ccf7-goog
PATCH v3 12/31 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.
---
Changes in v3:
- Update for the new trailing_strtoln_end()
- Add bootdev_get_from_blk() function
- Use blk_find_device() to find the block device for a media device
- Move bootdev ordering into the uclass
MAINTAINERS | 4 +- boot/Makefile | 1 + boot/bootdev-uclass.c | 640 +++++++++++++++++++++++++++ doc/device-tree-bindings/bootdev.txt | 8 + include/bootdev.h | 275 ++++++++++++ include/dm/uclass-id.h | 1 + 6 files changed, 928 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
@@ -663,9 +663,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 +640 -0
640 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 +275 -0
275 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.34.1.703.g22d0c6ccf7-goog
PATCH v3 13/31 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.
---
Changes in v3:
- Move bootmeth ordering into the uclass
- Support "bootmeths" env var
- Add some more common functions
MAINTAINERS | 2 + boot/Makefile | 1 + boot/bootmeth-uclass.c | 298 +++++++++++++++++++++++++++++++++++++++++ boot/bootstd-uclass.c | 29 +++- include/bootmeth.h | 234 ++++++++++++++++++++++++++++++++ include/dm/uclass-id.h | 1 + include/env_callback.h | 7 + 7 files changed, 570 insertions(+), 2 deletions(-) create mode 100644 boot/bootmeth-uclass.c create mode 100644 include/bootmeth.h
MAINTAINERS +2 -0
@@ -663,10 +663,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 +298 -0
298 lines not on this page · raw message
boot/bootstd-uclass.c +27 -2
@@ -109,8 +109,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 ))
@@ -125,6 +127,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 +234 -0
234 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 */
include/env_callback.h +7 -0
@@ -57,6 +57,12 @@#define NET_CALLBACKS #endif +#ifdef CONFIG_BOOTSTD +#define BOOTSTD_CALLBACK "bootmeths:bootmeths," +#else +#define BOOTSTD_CALLBACK +#endif +/* * This list of callback bindings is static, but may be overridden by defining * a new association in the ".callbacks" environment variable.
@@ -65,6 +71,7 @@ ENV_DOT_ESCAPE ENV_FLAGS_VAR ":flags," \"baudrate:baudrate," \NET_CALLBACKS \ +BOOTSTD_CALLBACK \"loadaddr:loadaddr," \SILENT_CALLBACK \SPLASHIMAGE_CALLBACK \
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
PATCH v3 14/31 bootstd: Add support for bootflows
In reply to Simon GlassAdd support for bootflows, including maintaining a list of them and iterating to find them.
---
Changes in v3:
- Point to the header file for bootflow_state[] docs
- Explain why it is OK to use "?" as an unknown bootflow state
- Move bootmeth/bootdev ordering into the uclass
MAINTAINERS | 3 +- boot/Makefile | 1 + boot/bootdev-uclass.c | 11 +- boot/bootflow.c | 410 ++++++++++++++++++++++++++++++++++++++++++ boot/bootstd-uclass.c | 2 +- include/bootflow.h | 50 ++++++ 6 files changed, 474 insertions(+), 3 deletions(-) create mode 100644 boot/bootflow.c
MAINTAINERS +2 -1
@@ -663,8 +663,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 -1
@@ -10,6 +10,7 @@#include <dm.h> #include <bootdev.h> #include <bootflow.h> +#include <bootmeth.h> #include <bootstd.h> #include <env.h> #include <fs.h>
@@ -130,6 +131,10 @@ int bootdev_find_in_blk(struct udevice *dev, struct udevice *blk, 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
@@ -171,6 +176,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 ; }
@@ -445,7 +454,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 +410 -0
410 lines not on this page · raw message
boot/bootstd-uclass.c +1 -1
@@ -45,7 +45,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.34.1.703.g22d0c6ccf7-goog
PATCH v3 15/31 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.
---
Changes in v3:
- Use separate Kconfig options for each command
MAINTAINERS | 1 + cmd/Kconfig | 10 +++ cmd/Makefile | 1 + cmd/bootdev.c | 120 +++++++++++++++++++++++++++++ configs/amcore_defconfig | 1 + configs/rcar3_salvator-x_defconfig | 1 + configs/tbs2910_defconfig | 1 + 7 files changed, 135 insertions(+) create mode 100644 cmd/bootdev.c
MAINTAINERS +1 -0
@@ -667,6 +667,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 +10 -0
@@ -194,6 +194,16 @@ config CMD_BOOTM help Boot an application image from the memory. +config CMD_BOOTDEV + bool "bootdev" + depends on BOOTSTD + default y if BOOTSTD_FULL + help + Support listing available bootdevs (boot devices) which can provide an + OS to boot, as well as showing information about a particular one. + + This command is not necessary for bootstd to work. + 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_BOOTDEV) += 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_ENV_SECT_SIZE=0x1000 CONFIG_DEFAULT_DEVICE_TREE="amcore" CONFIG_TARGET_AMCORE=y CONFIG_SYS_LOAD_ADDR=0x20000 +# CONFIG_BOOTSTD is not set CONFIG_BOOTDELAY=1 CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="bootm ffc20000"
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_USE_BOOTCOMMAND=y
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.34.1.703.g22d0c6ccf7-goog
PATCH v3 16/31 bootstd: Add a bootflow command
In reply to Simon GlassAdd a 'bootflow' command to handle listing and selection of bootflow.
---
Changes in v3:
- Use separate Kconfig options for each command
- Put some features behind CONFIG_BOOTFLOW_FULL
cmd/Kconfig | 18 +++ cmd/Makefile | 1 + cmd/bootflow.c | 399 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 418 insertions(+) create mode 100644 cmd/bootflow.c
cmd/Kconfig +18 -0
@@ -204,6 +204,24 @@ config CMD_BOOTDEV This command is not necessary for bootstd to work. +config CMD_BOOTFLOW + bool "bootflow" + depends on BOOTSTD + default y + help + Support scanning for bootflows available with the bootdevs. The + bootflows can optionally be booted. + +config CMD_BOOTFLOW_FULL + bool "bootflow - extract subcommands" + depends on BOOTSTD + default y if BOOTSTD_FULL + help + Add the ability to list the available bootflows, select one and obtain + information about it. + + This command is not necessary for bootstd to work. + config BOOTM_EFI bool "Support booting UEFI FIT images" depends on CMD_BOOTEFI && CMD_BOOTM && FIT
cmd/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_CMD_ADC) += adc.o obj-$(CONFIG_CMD_ARMFLASH) += armflash.o obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_common.o obj-$(CONFIG_CMD_BOOTDEV) += bootdev.o +obj-$(CONFIG_CMD_BOOTFLOW) += 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 +399 -0
399 lines not on this page · raw message
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
PATCH v3 17/31 bootstd: Add a bootmeth command
In reply to Simon GlassAdd a 'bootmeth' command to handle listing and ordering of boot methods.
---
Changes in v3:
- Move bootmeth ordering into the uclass
cmd/Kconfig | 11 +++++ cmd/Makefile | 1 + cmd/bootmeth.c | 113 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 cmd/bootmeth.c
cmd/Kconfig +11 -0
@@ -222,6 +222,17 @@ config CMD_BOOTFLOW_FULL This command is not necessary for bootstd to work. +config CMD_BOOTMETH + bool "bootmeth" + depends on BOOTSTD + default y if BOOTSTD_FULL + help + Support listing available bootmethds (methods used to boot an + Operating System), as well as selecting the order that the bootmeths + are used. + + This command is not necessary for bootstd to work. + config BOOTM_EFI bool "Support booting UEFI FIT images" depends on CMD_BOOTEFI && CMD_BOOTM && FIT
cmd/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_CMD_ARMFLASH) += armflash.o obj-$(CONFIG_HAVE_BLOCK_DEVICE) += blk_common.o obj-$(CONFIG_CMD_BOOTDEV) += bootdev.o obj-$(CONFIG_CMD_BOOTFLOW) += bootflow.o +obj-$(CONFIG_CMD_BOOTMETH) += 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 +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
PATCH v3 18/31 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.
---
Changes in v3:
- Use new bootmeth_try_file() function
- Use a short name when BOOTSTD_FULL is not enabled
- Use common bootmeth functions
MAINTAINERS | 3 +- boot/Kconfig | 15 +++++ boot/Makefile | 2 + boot/bootmeth_distro.c | 142 +++++++++++++++++++++++++++++++++++++++++ include/distro.h | 24 +++++++ 5 files changed, 185 insertions(+), 1 deletion(-) create mode 100644 boot/bootmeth_distro.c create mode 100644 include/distro.h
MAINTAINERS +2 -1
@@ -668,7 +668,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
@@ -315,6 +315,21 @@ config BOOTSTD_FULL - support for selecting the ordering of bootdevs using the devicetree as well as the "boot_targets" environment variable +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 +142 -0
142 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.34.1.703.g22d0c6ccf7-goog
PATCH v3 19/31 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.
---
Changes in v3:
- Adjust for new blk_find_device() function
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
@@ -669,6 +669,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
@@ -956,10 +956,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.34.1.703.g22d0c6ccf7-goog
PATCH v3 20/31 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
@@ -674,6 +674,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.34.1.703.g22d0c6ccf7-goog
PATCH v3 21/31 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.
---
Changes in v3:
- Add a log category
- Use a short name when BOOTSTD_FULL is not enabled
boot/Kconfig | 10 +++ boot/Makefile | 1 + boot/bootmeth_pxe.c | 186 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 197 insertions(+) create mode 100644 boot/bootmeth_pxe.c
boot/Kconfig +10 -0
@@ -328,6 +328,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 +186 -0
186 lines not on this page · raw message
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
PATCH v3 22/31 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.
There was much discussion about whether this is needed, but it seems that it is, at least for now.
---
Changes in v3:
- Add a log category
- Use a short name when BOOTSTD_FULL is not enabled
- Align the EFI load address
- Use common bootmeth functions
boot/Kconfig | 21 +++++ boot/Makefile | 1 + boot/bootmeth_efi.c | 183 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+) create mode 100644 boot/bootmeth_efi.c
boot/Kconfig +21 -0
@@ -338,6 +338,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 +183 -0
183 lines not on this page · raw message
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 22/31] bootstd: Add an implementation of EFI boot
Quoted 11 lines
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.There was much discussion about whether this is needed, but it seems that it is, at least for now.
FWIW, the distro boot will also load the device tree from the installer medium for example. The filename is fetched from fdtfile. This is missing here, thus for my board, this cannot be a replacement for distro boot; which is the ultimate goal here, no?
-michael
Re: [PATCH v3 22/31] bootstd: Add an implementation of EFI boot
In reply to Simon GlassQuoted 227 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.There was much discussion about whether this is needed, but it seems that it is, at least for now.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add a log category
- Use a short name whenBOOTSTD_FULLis not enabled
- Align the EFI load address
- Use common bootmeth functionsboot/Kconfig | 21 +++++ boot/Makefile | 1 + boot/bootmeth_efi.c | 183 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+)create mode 100644
boot/bootmeth_efi.cboot/Kconfig +21
-0@@ -338,6 +338,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 +150
-0@@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Bootmethod for distro boot via EFI +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#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 ]; +char *last_slash; +int ret; + + ret =bootmeth_alloc_file (bflow,0x2000000 ,0x10000 ); +if (ret) +return log_msg_ret ("read" , ret); + +/* +* 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' ; + +log_debug ("setting bootdev %s, %s\n" ,dev_get_uclass_name (media_dev), + bflow->fname); +efi_set_bootdev (dev_get_uclass_name (media_dev), devnum_str, + bflow->fname, 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 ]; +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); + + ret =bootmeth_try_file (bflow, desc,NULL , fname); +if (ret) +return log_msg_ret ("try" , ret); + + ret =efiload_read_file (desc, bflow); +if (ret) +return log_msg_ret ("read" , -EINVAL ); + +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 );
boot/bootmeth_efi.c line 160
Quoted 10 lines
boot/bootmeth_efi.c new file +10
-0+ +return 0 ; +} + +static int distro_bootmeth_efi_bind (struct udevice *dev) +{ +struct bootmeth_uc_plat *plat =dev_get_uclass_plat (dev); + + plat->desc =IS_ENABLED (CONFIG_BOOTSTD_FULL ) ? +"EFI boot from a .efi file" :"EFI" ;
nits:
%s/a/an/
boot/bootmeth_efi.c line 170
Quoted 10 lines
boot/bootmeth_efi.c new file +10
-0+ +return 0 ; +} + +static struct bootmeth_ops distro_efi_bootmeth_ops = { + .check = distro_efi_check, + .read_bootflow = distro_efi_read_bootflow, + .read_file = bootmeth_common_read_file, + .boot = distro_efi_boot, +};
Where is the device tree read?
Best regards
Heinrich
Quoted 13 lines
boot/bootmeth_efi.c new file +13
-0+ +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 v3 22/31] bootstd: Add an implementation of EFI boot
Hi Heinrich,
Quoted 243 lines · Heinrich Schuchardt
Quoted 227 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.There was much discussion about whether this is needed, but it seems that it is, at least for now.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add a log category
- Use a short name whenBOOTSTD_FULLis not enabled
- Align the EFI load address
- Use common bootmeth functionsboot/Kconfig | 21 +++++ boot/Makefile | 1 + boot/bootmeth_efi.c | 183 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+)create mode 100644
boot/bootmeth_efi.cboot/Kconfig +21
-0@@ -338,6 +338,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 +150
-0@@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Bootmethod for distro boot via EFI +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#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 ]; +char *last_slash; +int ret; + + ret =bootmeth_alloc_file (bflow,0x2000000 ,0x10000 ); +if (ret) +return log_msg_ret ("read" , ret); + +/* +* 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' ; + +log_debug ("setting bootdev %s, %s\n" ,dev_get_uclass_name (media_dev), + bflow->fname); +efi_set_bootdev (dev_get_uclass_name (media_dev), devnum_str, + bflow->fname, 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 ]; +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); + + ret =bootmeth_try_file (bflow, desc,NULL , fname); +if (ret) +return log_msg_ret ("try" , ret); + + ret =efiload_read_file (desc, bflow); +if (ret) +return log_msg_ret ("read" , -EINVAL ); + +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 );boot/bootmeth_efi.c line 160
Quoted 10 lines
boot/bootmeth_efi.c new file +10
-0+ +return 0 ; +} + +static int distro_bootmeth_efi_bind (struct udevice *dev) +{ +struct bootmeth_uc_plat *plat =dev_get_uclass_plat (dev); + + plat->desc =IS_ENABLED (CONFIG_BOOTSTD_FULL ) ? +"EFI boot from a .efi file" :"EFI" ;nits:
%s/a/an/
Quoted 12 lines
boot/bootmeth_efi.c line 170
Quoted 10 lines
boot/bootmeth_efi.c new file +10
-0+ +return 0 ; +} + +static struct bootmeth_ops distro_efi_bootmeth_ops = { + .check = distro_efi_check, + .read_bootflow = distro_efi_read_bootflow, + .read_file = bootmeth_common_read_file, + .boot = distro_efi_boot, +};Where is the device tree read?
I'm not sure...where is it read with the scripts?
Do you know a distro that uses that feature? So far I don't have one.
Of course there are no tests with the scripts so I am flying blind here.
Regards,
Simon
Re: [PATCH v3 22/31] bootstd: Add an implementation of EFI boot
Quoted 257 lines · Heinrich Schuchardt
Quoted 243 lines · Simon Glass
Quoted 227 lines
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.There was much discussion about whether this is needed, but it seems that it is, at least for now.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add a log category
- Use a short name whenBOOTSTD_FULLis not enabled
- Align the EFI load address
- Use common bootmeth functionsboot/Kconfig | 21 +++++ boot/Makefile | 1 + boot/bootmeth_efi.c | 183 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 205 insertions(+)create mode 100644
boot/bootmeth_efi.cboot/Kconfig +21
-0@@ -338,6 +338,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 +150
-0@@ -0,0 +1,183 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Bootmethod for distro boot via EFI +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#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 ]; +char *last_slash; +int ret; + + ret =bootmeth_alloc_file (bflow,0x2000000 ,0x10000 ); +if (ret) +return log_msg_ret ("read" , ret); + +/* +* 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' ; + +log_debug ("setting bootdev %s, %s\n" ,dev_get_uclass_name (media_dev), + bflow->fname); +efi_set_bootdev (dev_get_uclass_name (media_dev), devnum_str, + bflow->fname, 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 ]; +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); + + ret =bootmeth_try_file (bflow, desc,NULL , fname); +if (ret) +return log_msg_ret ("try" , ret); + + ret =efiload_read_file (desc, bflow); +if (ret) +return log_msg_ret ("read" , -EINVAL ); + +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 );boot/bootmeth_efi.c line 160
Quoted 10 lines
boot/bootmeth_efi.c new file +10
-0+ +return 0 ; +} + +static int distro_bootmeth_efi_bind (struct udevice *dev) +{ +struct bootmeth_uc_plat *plat =dev_get_uclass_plat (dev); + + plat->desc =IS_ENABLED (CONFIG_BOOTSTD_FULL ) ? +"EFI boot from a .efi file" :"EFI" ;nits:
%s/a/an/Quoted 12 lines
boot/bootmeth_efi.c line 170
Quoted 10 lines
boot/bootmeth_efi.c new file +10
-0+ +return 0 ; +} + +static struct bootmeth_ops distro_efi_bootmeth_ops = { + .check = distro_efi_check, + .read_bootflow = distro_efi_read_bootflow, + .read_file = bootmeth_common_read_file, + .boot = distro_efi_boot, +};Where is the device tree read?
Quoted 3 lines
I'm not sure...where is it read with the scripts?
Do you know a distro that uses that feature? So far I don't have one.
At least the debian arm64 mini.iso should support it. See also
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=991141
-michael
PATCH v3 23/31 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.
---
Changes in v3:
- Add a log category
boot/Makefile | 2 +- boot/bootstd-uclass.c | 6 ++++ boot/system_bootdev.c | 66 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 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
@@ -150,6 +150,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 +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
PATCH v3 24/31 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.
---
Changes in v3:
- Add a log category
boot/Makefile | 3 ++ boot/bootmeth_efi_mgr.c | 86 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 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_FULL +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 +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 24/31] bootstd: Add an implementation of EFI bootmgr
Quoted 84 lines · Simon Glass
Add 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_CMDLINEbeing enabled.Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add a log categoryboot/Makefile | 3 ++ boot/bootmeth_efi_mgr.c | 86 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+)create mode 100644
boot/bootmeth_efi_mgr.cboot/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_FULL +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.oboot/bootmeth_efi_mgr.c new file +44
-0@@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Bootmethod for EFI boot manager +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#include <common.h> +#include <bootdev.h> +#include <bootflow.h> +#include <bootmeth.h> +#include <command.h> +#include <dm.h> + +static int efi_mgr_check (struct udevice *dev,struct bootflow_iter *iter) +{ +int ret; + +/* Must be an bootstd device */ + ret =bootflow_iter_uses_system (iter); +if (ret) +return log_msg_ret ("net" , ret); + +return 0 ; +} + +static int efi_mgr_read_bootflow (struct udevice *dev,struct bootflow *bflow) +{ +/* +* Just assume there is something to boot since we don't have any way +* of knowing in advance +*/ + bflow->state =BOOTFLOWST_READY ; + +return 0 ; +} + +static int efi_mgr_read_file (struct udevice *dev,struct bootflow *bflow, +const char *file_path,ulong addr,ulong *sizep) +{ +/* Files are loaded by the 'bootefi bootmgr' command */
boot/bootmeth_efi_mgr.c line 54
Quoted 10 lines
boot/bootmeth_efi_mgr.c new file +10
-0+ +return -ENOSYS ; +} + +static int efi_mgr_boot (struct udevice *dev,struct bootflow *bflow) +{ +int ret; + +/* Booting is handled by the 'bootefi bootmgr' command */ + ret =run_command ("bootefi bootmgr" ,0 );
You are missing to provide the device tree.
Best regards
Heinrich
Quoted 32 lines
boot/bootmeth_efi_mgr.c new file +32
-0+ +return 0 ; +} + +static int bootmeth_efi_mgr_bind (struct udevice *dev) +{ +struct bootmeth_uc_plat *plat =dev_get_uclass_plat (dev); + + plat->desc ="EFI bootmgr flow" ; + +return 0 ; +} + +static struct bootmeth_ops efi_mgr_bootmeth_ops = { + .check = efi_mgr_check, + .read_bootflow = efi_mgr_read_bootflow, + .read_file = efi_mgr_read_file, + .boot = efi_mgr_boot, +}; + +static const struct udevice_id efi_mgr_bootmeth_ids[] = { + { .compatible ="u-boot,efi-bootmgr" }, + { } +}; + +U_BOOT_DRIVER (bootmeth_zefi_mgr) = { + .name ="bootmeth_efi_mgr" , + .id =UCLASS_BOOTMETH , + .of_match = efi_mgr_bootmeth_ids, + .ops = &efi_mgr_bootmeth_ops, + .bind = bootmeth_efi_mgr_bind, +};
Re: [PATCH v3 24/31] bootstd: Add an implementation of EFI bootmgr
Hi Heinrich,
Quoted 90 lines · Heinrich Schuchardt
Quoted 88 lines · Simon Glass
Add 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_CMDLINEbeing enabled.Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add a log categoryboot/Makefile | 3 ++ boot/bootmeth_efi_mgr.c | 86 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+)create mode 100644
boot/bootmeth_efi_mgr.cboot/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_FULL +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.oboot/bootmeth_efi_mgr.c new file +48
-0@@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Bootmethod for EFI boot manager +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#include <common.h> +#include <bootdev.h> +#include <bootflow.h> +#include <bootmeth.h> +#include <command.h> +#include <dm.h> + +static int efi_mgr_check (struct udevice *dev,struct bootflow_iter *iter) +{ +int ret; + +/* Must be an bootstd device */ + ret =bootflow_iter_uses_system (iter); +if (ret) +return log_msg_ret ("net" , ret); + +return 0 ; +} + +static int efi_mgr_read_bootflow (struct udevice *dev,struct bootflow *bflow) +{ +/* +* Just assume there is something to boot since we don't have any way +* of knowing in advance +*/ + bflow->state =BOOTFLOWST_READY ; + +return 0 ; +} + +static int efi_mgr_read_file (struct udevice *dev,struct bootflow *bflow, +const char *file_path,ulong addr,ulong *sizep) +{ +/* Files are loaded by the 'bootefi bootmgr' command */ + +return -ENOSYS ; +} +
Quoted 8 lines
boot/bootmeth_efi_mgr.c line 54
Quoted 6 lines
boot/bootmeth_efi_mgr.c new file +6
-0+static int efi_mgr_boot (struct udevice *dev,struct bootflow *bflow) +{ +int ret; + +/* Booting is handled by the 'bootefi bootmgr' command */ + ret =run_command ("bootefi bootmgr" ,0 );You are missing to provide the device tree.
OK well I can deal with that when I get to it, I suppose. Which distro can I try with?
Regards,
Simon
Re: [PATCH v3 24/31] bootstd: Add an implementation of EFI bootmgr
Hi Simon
Quoted 111 lines · Simon Glass
Hi Heinrich,
Quoted 5 lines · Heinrich Schuchardt
Quoted 3 lines · Simon Glass
Add a bootmeth driver which handles EFI boot manager, using
EFI_LOADER.In effect, this provides the same functionality as the 'bootefi
bootmgr'
Quoted 5 lines
Quoted 5 lines
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_CMDLINEbeingenabled.
Quoted 9 lines
Quoted 9 lines
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add a log categoryboot/Makefile | 3 ++ boot/bootmeth_efi_mgr.c | 86+++++++++++++++++++++++++++++++++++++++++
Quoted 33 lines
Quoted 33 lines
2 files changed, 89 insertions(+)create mode 100644
boot/bootmeth_efi_mgr.cboot/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_FULL +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.oboot/bootmeth_efi_mgr.c new file +10
-0@@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Bootmethod for EFI boot manager +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEGORY UCLASS_BOOTSTD +Quoted 8 lines
boot/bootmeth_efi_mgr.c
Quoted 8 lines
boot/bootmeth_efi_mgr.c new file +8
-0+#include <common.h> +#include <bootdev.h> +#include <bootflow.h> +#include <bootmeth.h> +#include <command.h> +#include <dm.h> + +static int efi_mgr_check(struct udevice *dev, struct bootflow_iter*iter)
Quoted 4 lines
Quoted 4 lines
boot/bootmeth_efi_mgr.c new file +4
-0+{ +int ret; + +/* Must be an bootstd device */ Quoted 8 lines
boot/bootmeth_efi_mgr.c
Quoted 8 lines
boot/bootmeth_efi_mgr.c new file +8
-0+ ret =bootflow_iter_uses_system (iter); +if (ret) +return log_msg_ret ("net" , ret); + +return 0 ; +} + +static int efi_mgr_read_bootflow(struct udevice *dev, struct bootflow*bflow)
Quoted 3 lines
boot/bootmeth_efi_mgr.c
Quoted 3 lines
boot/bootmeth_efi_mgr.c new file +3
-0+{ +/* +* Just assume there is something to boot since we don't have any way
Quoted 8 lines
boot/bootmeth_efi_mgr.c
Quoted 8 lines
boot/bootmeth_efi_mgr.c new file +8
-0+* of knowing in advance +*/ + bflow->state =BOOTFLOWST_READY ; + +return 0 ; +} + +static int efi_mgr_read_file(struct udevice *dev, struct bootflow*bflow,
Quoted 1 line
boot/bootmeth_efi_mgr.c line 42
Quoted 1 line
boot/bootmeth_efi_mgr.c new file +1
-0+ const char *file_path, ulong addr, ulong*sizep)
Quoted 6 lines
Quoted 6 lines
boot/bootmeth_efi_mgr.c new file +6
-0+{ +/* Files are loaded by the 'bootefi bootmgr' command */ + +return -ENOSYS ; +} +Quoted 8 lines
boot/bootmeth_efi_mgr.c line 54
Quoted 6 lines
boot/bootmeth_efi_mgr.c new file +6
-0+static int efi_mgr_boot (struct udevice *dev,struct bootflow *bflow) +{ +int ret; + +/* Booting is handled by the 'bootefi bootmgr' command */ + ret =run_command ("bootefi bootmgr" ,0 );You are missing to provide the device tree.
Quoted 3 lines
OK well I can deal with that when I get to it, I suppose. Which distro can I try with?
Any recent distro would work. If you try to run an installer keep in mind setting up grub will fail (since runtime variable support isn't yet supported). You can find more info on installing fedora here[1] just skip the security and encryption parts
[1] https://www.linaro.org/blog/securing-a-device-with-trusted-substrate/
Cheers
/Ilias
Quoted 4 lines
Regards,
Simon
Re: [PATCH v3 24/31] bootstd: Add an implementation of EFI bootmgr
Hi Ilias,
Quoted 107 lines · Ilias Apalodimas
Hi Simon
Quoted 103 lines · Simon Glass
Hi Heinrich,
Quoted 98 lines · Heinrich Schuchardt
Quoted 84 lines · Simon Glass
Add 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_CMDLINEbeing enabled.Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Add a log categoryboot/Makefile | 3 ++ boot/bootmeth_efi_mgr.c | 86 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+)create mode 100644
boot/bootmeth_efi_mgr.cboot/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_FULL +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.oboot/bootmeth_efi_mgr.c new file +44
-0@@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Bootmethod for EFI boot manager +* +* Copyright 2021 Google LLC +* Written by Simon Glass <[email protected]> +*/ + +#define LOG_CATEGORY UCLASS_BOOTSTD + +#include <common.h> +#include <bootdev.h> +#include <bootflow.h> +#include <bootmeth.h> +#include <command.h> +#include <dm.h> + +static int efi_mgr_check (struct udevice *dev,struct bootflow_iter *iter) +{ +int ret; + +/* Must be an bootstd device */ + ret =bootflow_iter_uses_system (iter); +if (ret) +return log_msg_ret ("net" , ret); + +return 0 ; +} + +static int efi_mgr_read_bootflow (struct udevice *dev,struct bootflow *bflow) +{ +/* +* Just assume there is something to boot since we don't have any way +* of knowing in advance +*/ + bflow->state =BOOTFLOWST_READY ; + +return 0 ; +} + +static int efi_mgr_read_file (struct udevice *dev,struct bootflow *bflow, +const char *file_path,ulong addr,ulong *sizep) +{ +/* Files are loaded by the 'bootefi bootmgr' command */ boot/bootmeth_efi_mgr.c line 54
Quoted 10 lines
boot/bootmeth_efi_mgr.c new file +10
-0+ +return -ENOSYS ; +} + +static int efi_mgr_boot (struct udevice *dev,struct bootflow *bflow) +{ +int ret; + +/* Booting is handled by the 'bootefi bootmgr' command */ + ret =run_command ("bootefi bootmgr" ,0 );You are missing to provide the device tree.
Quoted 5 lines
Quoted 2 lines
OK well I can deal with that when I get to it, I suppose. Which distro can I try with?
Any recent distro would work. If you try to run an installer keep in mind setting up grub will fail (since runtime variable support isn't yet supported). You can find more info on installing fedora here[1] just skip the security and encryption parts
I see that Fedora 35 is out, so I will give that a go at some point.
Quoted 2 lines
[1] https://www.linaro.org/blog/securing-a-device-with-trusted-substrate/
Regards,
Simon
PATCH v3 25/31 bootstd: Add a sandbox bootmeth driver
In reply to Simon GlassAdd a bootmeth driver for sandbox, used for testing.
---
Changes in v3:
- Add a log category
boot/Kconfig | 7 +++++ boot/Makefile | 1 + boot/bootmeth_sandbox.c | 69 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 boot/bootmeth_sandbox.c
boot/Kconfig +7 -0
@@ -359,6 +359,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_FULL obj-$(CONFIG_$(SPL_TPL_)CMD_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o endif
boot/bootmeth_sandbox.c new file +69 -0
69 lines not on this page · raw message
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
PATCH v3 26/31 bootstd: Add an implementation of script boot
In reply to Simon GlassAdd a bootmeth driver which handles distro boot from a disk via a U-Boot script, so we can boot a bootflow using this commonly used mechanism. This is required by Armbian, for example.
---
Changes in v3:
- Add support for script boot
boot/Kconfig | 11 ++++ boot/Makefile | 1 + boot/bootmeth_script.c | 137 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 149 insertions(+) create mode 100644 boot/bootmeth_script.c
boot/Kconfig +11 -0
@@ -366,6 +366,17 @@ config BOOTMETH_SANDBOX This is a sandbox bootmeth driver used for testing. It always returns -ENOTSUPP when attempting to boot. +config BOOTMETH_SCRIPT + bool "Bootdev support for U-Boot scripts" + default y if BOOTSTD_FULL + help + Enables support for booting a distro via a U-Boot script. This makes + the bootdevs look for a 'boot/boot.scr' file which can be used to + boot the distro. + + This provides a way to try out standard boot on an existing boot flow. + It is not enabled by default to save space. + endif config LEGACY_IMAGE_FORMAT
boot/Makefile +1 -0
@@ -32,6 +32,7 @@ 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 +obj-$(CONFIG_$(SPL_TPL_)BOOTMETH_SCRIPT) += bootmeth_script.o ifdef CONFIG_$(SPL_TPL_)BOOTSTD_FULL obj-$(CONFIG_$(SPL_TPL_)CMD_BOOTEFI_BOOTMGR) += bootmeth_efi_mgr.o endif
boot/bootmeth_script.c new file +137 -0
137 lines not on this page · raw message
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
PATCH v3 27/31 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.34.1.703.g22d0c6ccf7-goog
PATCH v3 28/31 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.
---
Changes in v3:
- Update bootdev_test_order() for boot_targets env var
- Add tests for the "bootmeths" env var
- Update tests for the new 'bootmeth order' syntax
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 | 223 ++++++++++++++++ test/boot/bootflow.c | 398 +++++++++++++++++++++++++++++ test/boot/bootmeth.c | 122 +++++++++ test/boot/bootstd_common.c | 35 +++ test/boot/bootstd_common.h | 27 ++ test/cmd_ut.c | 7 + 13 files changed, 843 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
@@ -675,6 +675,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>;
@@ -891,10 +906,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
@@ -118,6 +118,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
@@ -73,6 +73,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 +223 -0
223 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 +122 -0
122 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.34.1.703.g22d0c6ccf7-goog
PATCH v3 29/31 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.
---
Changes in v3:
- Update test condition to use CMD_BOOTFLOW
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.34.1.703.g22d0c6ccf7-goog
PATCH v3 30/31 bootstd: doc: Add documentation
In reply to Simon GlassAdd documentation for this feature, including the commands and full devicetree bindings.
---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env vars
MAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 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
@@ -669,6 +669,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 +638 -0
638 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 +108 -0
108 lines not on this page · raw message
doc/usage/index.rst +3 -0
@@ -21,9 +21,12 @@ Shell commands addrmap askenv base + bootdev bootefi + bootflow booti bootmenu + bootmeth button x86/cbsysinfo conitrace
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Quoted 56 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +8
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ +
doc/develop/bootstd.rst line 18
Quoted 10 lines
doc/develop/bootstd.rst new file +10
-0+Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot) + - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.
This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Only when using the legacy entry point of the Linux kernel - which is discouraged - you have to think about other boot flows.
Best regards
Heinrich
Quoted 1,431 lines
doc/develop/bootstd.rst new file +620
-0+These bootflows are stored on media so they can be discovered by U-Boot. This +feature is typically called `distro boot` (see :doc:`distro`) because it is +a way for distributions to boot on any hardware. + +Traditionally U-Boot has relied on scripts to implement this feature. See +disto_boodcmd_ for details. This is done because U-Boot has no native support +for scanning devices. While the scripts work remarkably well, they can be hard +to understand and extend, and the feature does not include tests. They are also +making it difficult to move away from ad-hoc CONFIGs, since they are implemented +using the environment and a lot of #defines. + +Standard boot is a generalisation of distro boot. It provides a more built-in +way to boot with U-Boot. The feature is extensible to different Operating +Systems (such as Chromium OS) and devices (beyond just block and network +devices). It supports EFI boot and EFI bootmgr too. + + +Bootflow +-------- + +A bootflow is a file that describes how to boot a distro. Conceptually there can +be different formats for that file but at present U-Boot only supports the +BootLoaderSpec_ format. which looks something like this:: + + menu autoboot Welcome to Fedora-Workstation-armhfp-31-1.9. Automatic boot in # second{,s}. Press a key for options. + menu title Fedora-Workstation-armhfp-31-1.9 Boot Options. + menu hidden + + label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl) + kernel /vmlinuz-5.3.7-301.fc31.armv7hl + append ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB + fdtdir /dtb-5.3.7-301.fc31.armv7hl/ + initrd /initramfs-5.3.7-301.fc31.armv7hl.img + +As you can see it specifies a kernel, a ramdisk (initrd) and a directory from +which to load devicetree files. The details are described in disto_boodcmd_. + +The bootflow is provided by the distro. It is not part of U-Boot. U-Boot's job +is simply to interpret the file and carry out the instructions. This allows +distros to boot on essentially any device supported by U-Boot. + +Typically the first available bootflow is selected and booted. If that fails, +then the next one is tried. + + +Bootdev +------- + +Where does U-Boot find the media that holds the operating systems? That is the +job of bootdev. A bootdev is simply a layer on top of a media device (such as +MMC, NVMe). The bootdev accesses the device, including partitions and +filesystems that might contain things related to an operating system. + +For example, an MMC bootdev provides access to the individual partitions on the +MMC device. It scans through these to find filesystems, then provides a list of +these for consideration. + + +Bootmeth +-------- + +Once the list of filesystems is provided, how does U-Boot find the bootflow +files in these filesystems. That is the job of bootmeth. Each boot method has +its own way of doing this. + +For example, the distro bootmeth simply looks through the provided filesystem +for a file called `extlinux/extlinux.conf`. This files constitutes a bootflow. +If the distro bootmeth is used on multiple partitions it may produce multiple +bootflows. + +Note: it is possible to have a bootmeth that uses a partition or a whole device +directly, but it is more common to use a filesystem. + + +Boot process +------------ + +U-Boot tries to use the 'lazy init' approach whereever possible and distro boot +is no exception. The algorithm is:: + + while (get next bootdev) + while (get next bootmeth) + while (get next bootflow) + try to boot it + +So U-Boot works its way through the bootdevs, trying each bootmeth in turn to +obtain bootflows, until it either boots or exhausts the available options. + +Instead of 500 lines of #defines and a 4KB boot script, all that is needed is +the following command:: + + bootflow scan -lb + +which scans for available bootflows, optionally listing each find it finds (-l) +and trying to boot it (-b). + + +Controlling ordering +-------------------- + +Several options are available to control the ordering of boot scanning: + + +boot_targets +~~~~~~~~~~~~ + +This environment variable can be used to control the list of bootdevs searched +and their ordering, for example:: + + setenv boot_targets "mmc0 mmc1 usb pxe" + +Entries may be removed or re-ordered in this list to affect the boot order. If +the variable is empty, the default ordering is used, based on the priority of +bootdevs and their sequence numbers. + + +bootmeths +~~~~~~~~~ + +This environment variable can be used to control the list of bootmeths used and +their ordering for example:: + + setenv bootmeths "syslinux efi" + +Entries may be removed or re-ordered in this list to affect the order the +bootmeths are tried on each bootdev. If the variable is empty, the default +ordering is used, based on the bootmeth sequence numbers, which can be +controlled by aliases. + +The :ref:`usage/bootmeth:bootmeth command` (`bootmeth order`) operates in the +same way as setting this variable. + + +Bootdev uclass +-------------- + +The bootdev uclass provides an simple API call to obtain a bootflows from a +device:: + + int bootdev_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, + struct bootflow *bflow); + +This takes a iterator which indicates the bootdev, partition and bootmeth to +use. It returns a bootflow. This is the core of the bootdev implementation. The +bootdev drivers that implement this differ depending on the media they are +reading from, but each is responsible for returning a valid bootflow if +available. + +A helper called `bootdev_find_in_blk()` makes it fairly easy to implement this +function for each media device uclass, in a few lines of code. + + +Bootdev drivers +--------------- + +A bootdev driver is typically fairly simple. Here is one for mmc:: + + static int mmc_get_bootflow(struct udevice *dev, struct bootflow_iter *iter, + struct bootflow *bflow) + { + struct udevice *mmc_dev = dev_get_parent(dev); + struct udevice *blk; + int ret; + + ret = mmc_get_blk(mmc_dev, &blk); + /* + * If there is no media, indicate that no more partitions should be + * checked + */ + if (ret == -EOPNOTSUPP) + ret = -ESHUTDOWN; + if (ret) + return log_msg_ret("blk", ret); + assert(blk); + ret = bootdev_find_in_blk(dev, blk, iter, bflow); + if (ret) + return log_msg_ret("find", ret); + + return 0; + } + + static int mmc_bootdev_bind(struct udevice *dev) + { + struct bootdev_uc_plat *ucp = dev_get_uclass_plat(dev); + + ucp->prio = BOOTDEVP_0_INTERNAL_FAST; + + return 0; + } + + struct bootdev_ops mmc_bootdev_ops = { + .get_bootflow = mmc_get_bootflow, + }; + + static const struct udevice_id mmc_bootdev_ids[] = { + { .compatible = "u-boot,bootdev-mmc" }, + { } + }; + + U_BOOT_DRIVER(mmc_bootdev) = { + .name = "mmc_bootdev", + .id = UCLASS_BOOTDEV, + .ops = &mmc_bootdev_ops, + .bind = mmc_bootdev_bind, + .of_match = mmc_bootdev_ids, + }; + +The implementation of the `get_bootflow()` method is simply to obtain the +block device and call a bootdev helper function to do the rest. The +implementation of `bootdev_find_in_blk()` checks the partition table, and +attempts to read a file from a filesystem on the partition number given by the +`@iter->part` parameter. + +Each bootdev has a priority, which indicates the order in which it is used. +Faster bootdevs are used first, since they are more likely to be able to boot +the device quickly. + + +Device hierarchy +---------------- + +A bootdev device is a child of the media device. In this example, you can see +that the bootdev is a sibling of the block device and both are children of +media device:: + + mmc 0 [ + ] bcm2835-sdhost | |-- mmc@7e202000 + blk 0 [ + ] mmc_blk | | |-- [email protected] + bootdev 0 [ ] mmc_bootdev | | `-- [email protected] + mmc 1 [ + ] sdhci-bcm2835 | |-- sdhci@7e300000 + blk 1 [ ] mmc_blk | | |-- [email protected] + bootdev 1 [ ] mmc_bootdev | | `-- [email protected] + +The bootdev device is typically created automatically in the media uclass' +`post_bind()` method by calling `bootdev_setup_for_dev()`. The code typically +something like this:: + + ret = bootdev_setup_for_dev(dev, "eth_bootdev"); + if (ret) + return log_msg_ret("bootdev", ret); + +Here, `eth_bootdev` is the name of the Ethernet bootdev driver and `dev` +is the ethernet device. This function is safe to call even if standard boot is +not enabled, since it does nothing in that case. It can be added to all uclasses +which implement suitable media. + + +The bootstd device +------------------ + +Standard boot requires a single instance of the bootstd device to make things +work. This includes global information about the state of standard boot. See +`struct bootstd_priv` for this structure, accessed with `bootstd_get_priv()`. + +Within the devicetree, if you add bootmeth devices or a system bootdev, they +should be children of the bootstd device. See `arch/sandbox/dts/test.dts` for +an example of this. + + +The system bootdev +------------------ + +Some bootmeths don't operate on individual bootdevs, but on the whole system. +For example, the EFI boot manager does its own device scanning and does not +make use of the bootdev devices. Such bootmeths can make use of the system +bootdev, typically considered last, after everything else has been tried. + + +.. _`Automatic Devices`: + +Automatic devices +----------------- + +It is possible to define all the required devices in the devicetree manually, +but it is not necessary. The bootstd uclass includes a `dm_scan_other()` +function which creates the bootstd device if not found. If no bootmeth devices +are found at all, it creates one for each available bootmeth driver as well as a +system bootdev. + +If your devicetree has any bootmeth device it must have all of them that you +want to use, as well as the system bootdev if needed, since no bootmeth devices +will be created automatically in that case. + + +Using devicetree +---------------- + +If a bootdev is complicated or needs configuration information, it can be +added to the devicetree as a child of the media device. For example, imagine a +bootdev which reads a bootflow from SPI flash. The devicetree fragment might +look like this:: + + spi@0 { + flash@0 { + reg = <0>; + compatible = "spansion,m25p16", "jedec,spi-nor"; + spi-max-frequency = <40000000>; + + bootdev { + compatible = "u-boot,sf-bootdev"; + offset = <0x2000>; + size = <0x1000>; + }; + }; + }; + +The `sf-bootdev` driver can implement a way to read from the SPI flash, using +the offset and size provided, and return that bootflow file back to the caller. +When distro boot wants to read the kernel it calls disto_getfile() which must +provide a way to read from the SPI flash. See `distro_boot()` at distro_boot_ +for more details. + +Of course this is all internal to U-Boot. All the distro sees is another way +to boot. + + +Configuration +------------- + +Standard boot is enabled with `CONFIG_BOOTSTD`. Each bootmeth has its own CONFIG +option also. For example, `CONFIG_BOOTMETH_DISTRO` enables support for distro +boot from a disk. + + +Available bootmeth drivers +-------------------------- + +Bootmeth drivers are provided for: + + - distro boot from a disk (syslinux) + - distro boot from a network (PXE) + - EFI boot using bootefi + - EFI boot using boot manager + + +Command interface +----------------- + +Three commands are available: + +`bootdev` + Allows listing of available bootdevs, selecting a particular one and + getting information about it. See :doc:`../usage/bootdev` + +`bootflow` + Allows scanning one or more bootdevs for bootflows, listing available + bootflows, selecting one, obtaining information about it and booting it. + See :doc:`../usage/bootflow` + +`bootmeth` + Allow listing of available bootmethds and setting the order in which they + are tried. See :doc:`../usage/bootmeth` + +.. _BootflowStates: + +Bootflow states +--------------- + +Here is a list of states that a bootflow can be in: + +======= ======================================================================= +State Meaning +======= ======================================================================= +base Starting-out state, indicates that no media/partition was found. For an + SD card socket it may indicate that the card is not inserted. +media Media was found (e.g. SD card is inserted) but no partition information + was found. It might lack a partition table or have a read error. +part Partition was found but a filesystem could not be read. This could be + because the partition does not hold a filesystem or the filesystem is + very corrupted. +fs Filesystem was found but the file could not be read. It could be + missing or in the wrong subdirectory. +file File was found and its size detected, but it could not be read. This + could indicate filesystem corruption. +ready File was loaded and is ready for use. In this state the bootflow is + ready to be booted. +======= ======================================================================= + + +Theory of operation +------------------- + +This describes how standard boot progresses through to booting an operating +system. + +To start. all the necessary devices must be bound, including bootstd, which +provides the top-level `struct bootstd_priv` containing optional configuration +information. The bootstd device is also holds the various lists used while +scanning. This step is normally handled automatically by driver model, as +described in `Automatic Devices`_. + +Bootdevs are also required, to provide access to the media to use. These are not +useful by themselves: bootmeths are needed to provide the means of scanning +those bootdevs. So, all up, we need a single bootstd device, one or more bootdev +devices and one or more bootmeth devices. + +Once these are ready, typically a `bootflow scan` command is issued. This kicks +of the iteration process, which involves looking through the bootdevs and their +partitions one by one to find bootflows. + +Iteration is kicked off using `bootflow_scan_first()`, which calls +`bootflow_scan_bootdev()`. + +The iterator is set up with `bootflow_iter_init()`. This simply creates an +empty one with the given flags. Flags are used to control whether each +iteration is displayed, whether to return iterations even if they did not result +in a valid bootflow, whether to iterate through just a single bootdev, etc. + +Then the ordering of bootdevs is determined, by `bootdev_setup_iter_order()`. By +default, the bootdevs are used in the order specified by the `boot_targets` +environment variable (e.g. "mmc2 mmc0 usb"). If that is missing then their +sequence order is used, as determined by the `/aliases` node, or failing that +their order in the devicetree. For BOOTSTD_FULL, if there is a `bootdev-order` +property in the bootstd node, then this is used as a final fallback. In any +case, the iterator ends up with a `dev_order` array containing the bootdevs that +are going to be used, with `num_devs` set to the number of bootdevs and +`cur_dev` starting at 0. + +Next, the ordering of bootdevs is determined, by `bootmeth_setup_iter_order()`. +By default the ordering is again by sequence number, i.e. the `/aliases` node, +or failing that the order in the devicetree. But the `bootmeth order` command +or `bootmeths` environment variable can be used to set up an ordering. If that +has been done, the ordering is in `struct bootstd_priv`, so that ordering is +simply copied into the iterator. Either way, the `method_order` array it set up, +along with `num_methods`. Then `cur_method` is set to 0. + +At this point the iterator is ready to use, with the first bootdev and bootmeth +selected. All the other fields are 0. This means that the current partition is +0, which is taken to mean the whole device, since partition numbers start at 1. +It also means that `max_part` is 0, i.e. the maximum partition number we know +about is 0, meaning that, as far as we know, there is no partition table on this +bootdev. + +With the iterator ready, `bootflow_scan_bootdev()` checks whether the current +settings produce a valid bootflow. This is handled by `bootflow_check()`, which +either returns 0 (if it got something) or an error if not (more on that later). +If the `BOOTFLOWF_ALL` iterator flag is set, even errors are returned as +incomplete bootflows, but normally an error results in moving onto the next +iteration. + +The `bootflow_scan_next()` function handles moving onto the next iteration and +checking it. In fact it sits in a loop doing that repeatedly until it finds +something it wants to return. + +The actual 'moving on' part is implemented in `iter_incr()`. This is a very +simple function. It increments the first counter. If that hits its maximum, it +sets it to zero and increments the second counter. You can think of all the +counters together as a number with three digits which increment in order, with +the least-sigificant digit on the right, counting like this: + + ======== ======= ======= + bootdev part method + ======== ======= ======= + 0 0 0 + 0 0 1 + 0 0 2 + 0 1 0 + 0 1 1 + 0 1 1 + 1 0 0 + 1 0 1 + ======== ======= ======= + +The maximum value for `method` is `num_methods - 1` so when it exceeds that, it +goes back to 0 and the next `part` is considered. The maximum value for that is +`max_part`, which is initially zero for all bootdevs. If we find a partition +table on that bootdev, `max_part` can be updated during the iteration to a +higher value - see `bootdev_find_in_blk()` for that, described later. If that +exceeds its maximum, then the next bootdev is used. In this way, iter_incr() +works its way through all possibilities, moving forward one each time it is +called. + +There is no expectation that iteration will actually finish. Quite often a +valid bootflow is found early on. With `bootflow scan -b`, that causes the +bootflow to be immediately booted. Assuming it is successful, the iteration never +completes. + +Also note that the iterator hold the **current** combination being considered. +So when `iter_incr()` is called, it increments to the next one and returns it, +the new **current** combination. + +Note also the `err` field in `struct bootflow_iter`. This is normally 0 and has +thus has no effect on `iter_inc()`. But if it is non-zero, signalling an error, +it indicates to the iterator what it should do when called. It can force moving +to the next partition, or bootdev, for example. The special values +`BF_NO_MORE_PARTS` and `BF_NO_MORE_DEVICES` handle this. When `iter_incr` sees +`BF_NO_MORE_PARTS` it knows that it should immediately move to the next bootdev. +When it sees `BF_NO_MORE_DEVICES` it knows that there is nothing more it can do +so it should immediately return. The caller of `iter_incr()` is responsible for +updating the `err` field, based on the return value it sees. + +The above describes the iteration process at a high level. It is basically a +very simple increment function with a checker called `bootflow_check()` that +checks the result of each iteration generated, to determine whether it can +produce a bootflow. + +So what happens inside of `bootflow_check()`? It simply calls the uclass +method `bootdev_get_bootflow()` to ask the bootdev to return a bootflow. It +passes the iterator to the bootdev method, so that function knows what we are +talking about. At first, the bootflow is set up in the state `BOOTFLOWST_BASE`, +with just the `method` and `dev` intiialised. But the bootdev may fill in more, +e.g. updating the state, depending on what it finds. + +Based on what the bootdev responds with, `bootflow_check()` either +returns a valid bootflow, or a partial one with an error. A partial bootflow +is one that has some fields set up, but did not reach the `BOOTFLOWST_READY` +state. As noted before, if the `BOOTFLOWF_ALL` iterator flag is set, then all +bootflows are returned, even partial ones. This can help with debugging. + +So at this point you can see that total control over whether a bootflow can +be generated from a particular iteration, or not, rests with the bootdev. +Each one can adopt its own approach. + +Going down a level, what does the bootdev do in its `get_bootflow()` method? +Let us consider the MMC bootdev. In that case the call to +`bootdev_get_bootflow()` ends up in `mmc_get_bootflow()`. It locates the parent +device of the bootdev, i.e. the `UCLASS_MMC` device itself, then finds the block +device associated with it. It then calls the helper function +`bootdev_find_in_blk()` to do all the work. This is common with just about any +bootdev that is based on a media device. + +The `bootdev_find_in_blk()` helper is implemented in the bootdev uclass. It +names the bootflow and copies the partition number in from the iterator. Then it +calls the bootmeth device to check if it can support this device. This is +important since some bootmeths only work with network devices, for example. If +that check fails, it stops. + +Assuming the bootmeth is happy, or at least indicates that it is willing to try +(by returning 0 from its `check()` method), the next step is to try the +partition. If that works it tries to detect a file system. If that works then it +calls the bootmeth device once more, this time to read the bootflow. + +Note: At present a filesystem is needed for the bootmeth to be called on block +devices, simply because we don't have any examples where this is not the case. +This feature can be added as needed. + +If we take the example of the `bootmeth_distro` driver, this call ends up at +`distro_read_bootflow()`. It has the filesystem ready, so tries various +filenames to try to find the `extlinux.conf` file, reading it if possible. If +all goes well the bootflow ends up in the `BOOTFLOWST_READY` state. + +At this point, we fall back from the bootmeth driver, to +`bootdev_find_in_blk()`, then back to `mmc_get_bootflow()`, then to +`bootdev_get_bootflow()`, then to `bootflow_check()` and finally to its caller, +either `bootflow_scan_bootdev()` or `bootflow_scan_next()`. In either case, +the bootflow is returned as the result of this iteration, assuming it made it to +the `BOOTFLOWST_READY` state. + +That is the basic operation of scanning for bootflows. The process of booting a +bootflow is handled by the bootmeth driver for that bootflow. In the case of +distro boot, this parses and processes the `extlinux.conf` file that was read. +See `distro_boot()` for how that works. The processing may involve reading +additional files, which is handled by the `read_file()` method, which is +`distro_read_file()` in this case. All bootmethds should support reading files, +since the bootflow is typically only the basic instructions and does not include +the operating system itself, ramdisk, device tree, etc. + +The vast majority of the bootstd code is concerned with iterating through +partitions on bootdevs and using bootmethds to find bootflows. + +How about bootdevs which are not block devices? They are handled by the same +methods as above, but with a different implementation. For example, the bootmeth +for PXE boot (over a network) uses `tftp` to read files rather than `fs_read()`. +But other that that it is very similar. + + +Tests +----- + +Tests are located in `test/boot` and cover the core functionality as well as +the commands. All tests use sandbox so can be run on a standard Linux computer +and in U-Boot's CI. + +For testing, a DOS-formatted disk image is used with a single FAT partition on +it. This is created in `setup_bootflow_image()`, with a canned one from the +source tree used if it cannot be created (e.g. in CI). + + +Bootflow internals +------------------ + +The bootstd device holds a linked list of scanned bootflows as well as the +currently selected bootdev and bootflow (for use by commands). This is in +`struct bootstd_priv`. + +Each bootdev device has its own `struct bootdev_uc_plat` which holds a +list of scanned bootflows just for that device. + +The bootflow itself is documented in bootflow_h_. It includes various bits of +information about the bootflow and a buffer to hold the file. + + +Future +------ + +Apart from the to-do items below, different types of bootflow files may be +implemented in future, e.g. Chromium OS support which is currently only +available as a script in chromebook_coral. + + +To do +----- + +Some things that need to be done to completely replace the distro-boot scripts: + +- add bootdev drivers for dhcp, sata, scsi, ide, virtio +- PXE boot for EFI +- support for loading U-Boot scripts + +Other ideas: + +- `bootflow prep` to load everything preparing for boot, so that `bootflow boot` + can just do the boot. +- automatically load kernel, FDT, etc. to suitable addresses so the board does + not need to specify things like `pxefile_addr_r` + + +.. _disto_boodcmd: https://github.com/u-boot/u-boot/blob/master/include/config_distro_bootcmd.h +.. _BootLoaderSpec: http://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/ +.. _distro_boot: https://github.com/u-boot/u-boot/blob/master/boot/distro.c +.. _bootflow_h: https://github.com/u-boot/u-boot/blob/master/include/bootflow.hdoc/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_BUILDdoc/develop/index.rst +1
-0@@ -10,6 +10,7 @@ Implementation :maxdepth: 1 bloblist + bootstd ci_testing commands config_bindingdoc/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@@ -0,0 +1,135 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +bootdev command +=============== + +Synopis +------- + +:: + + bootdev list [-p] - list all available bootdevs (-p to probe)\n" + bootdev select <bm> - select a bootdev by name\n" + bootdev info [-p] - show information about a bootdev"; + +Description +----------- + +The `bootdev` command is used to manage bootdevs. It can list available +bootdevs, select one and obtain information about it. + +See :doc:`../develop/bootstd` for more information about bootdevs in general. + + +bootdev list +~~~~~~~~~~~~ + +This lists available bootdevs + +Scanning with `-p` causes the bootdevs to be probed. This happens automatically +when they are used. + +The list looks something like this: + +=== ====== ====== ======== ========================= +Seq Probed Status Uclass Name +=== ====== ====== ======== ========================= + 0 [ + ] OK mmc [email protected] + 1 [ ] OK mmc [email protected] + 2 [ ] OK ethernet smsc95xx_eth.bootdev +=== ====== ====== ======== ========================= + + +The fields are as follows: + +Seq: + Sequence number in the scan, used to reference the bootflow later + +Probed: + Shows a plus (+) if the device is probed, empty if not. + +Status: + Shows the status of the device. Typically this is `OK` meaning that there is + no error. If you use -p and an error occurs when probing, then this shows + the error number. You can look up Linux error codes to find the meaning of + the number. + +Uclass: + Name of the media device's Uclass. This indicates the type of the parent + device (e.g. MMC, Ethernet). + +Name: + Name of the bootdev. This is generated from the media device appended + with `.bootdev` + + +bootdev select +~~~~~~~~~~~~~~~~~ + +Use this to select a particular bootdev. You can select it by the sequence +number or name, as shown in `bootdev list`. + +Once a bootdev is selected, you can use `bootdev info` to look at it or +`bootflow scan` to scan it. + +If no bootdev name or number is provided, then any existing bootdev is +unselected. + + +bootdev info +~~~~~~~~~~~~~~~ + +This shows information on the current bootdev, with the format looking like +this: + +========= ======================= +Name [email protected] +Sequence 0 +Status Probed +Uclass mmc +Bootflows 1 (1 valid) +========= ======================= + +Most of the information is the same as `bootdev list` above. The new fields +are: + +Device + Name of the bootdev + +Status + Shows `Probed` if the device is probed, `OK` if not. If `-p` is used and the + device fails to probe, an error code is shown. + +Bootflows + Indicates the number of bootflows attached to the bootdev. This is 0 + unless you have used 'bootflow scan' on the bootflow, or on all bootflows. + + +Example +------- + +This example shows listing available bootdev and getting information about +one of them:: + + U-Boot> bootdev list + Seq Probed Status Uclass Name + --- ------ ------ -------- ------------------ + 0 [ + ] OK mmc [email protected] + 1 [ ] OK mmc [email protected] + 2 [ ] OK ethernet smsc95xx_eth.bootdev + --- ------ ------ -------- ------------------ + (3 devices) + U-Boot> bootdev sel 0 + U-Boot> bootflow scan + U-Boot> bootdev info + Name: [email protected] + Sequence: 0 + Status: Probed + Uclass: mmc + Bootflows: 1 (1 valid) + + +Return value +------------ + +The return value $? is always 0 (true).doc/usage/bootflow.rst new file +427
-0@@ -0,0 +1,427 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +bootflow command +================ + +Synopis +------- + +:: + + bootflow scan [-abel] [bootdev] + bootflow list [-e] + bootflow select [<num|name>] + bootflow info [-d] + bootflow boot + + +Description +----------- + +The `bootflow` command is used to manage bootflows. It can scan bootdevs to +locate bootflows, list them and boot them. + +See :doc:`../develop/bootstd` for more information. + + +bootflow scan +~~~~~~~~~~~~~ + +Scans for available bootflows, optionally booting the first valid one it finds. +This operates in two modes: + +- If no bootdev is selected (see `bootdev select`) it scans bootflows one + by one, extracting all the bootdevs from each +- If a bootdev is selected, it just scans that one bootflow + +Flags are: + +-a + Collect all bootflows, even those that cannot be loaded. Normally if a file + is not where it is expected, then the bootflow fails and so is dropped + during the scan. With this option you can see why each bootflow would be + dropped. + +-b + Boot each valid bootflow as it is scanned. Typically only the first bootflow + matters, since by then the system boots in the OS and U-Boot is no-longer + running. `bootflow scan -b` is a quick way to boot the first available OS. + A valid bootflow is one that made it all the way to the `loaded` state. + +-e + Used with -l to also show errors for each bootflow. The shows detailed error + information for each bootflow that failed to make it to the `loaded` state. + +-l + List bootflows while scanning. This is helpful when you want to see what + is happening during scanning. Use it with the `-b` flag to see which + bootdev and bootflows are being tried. + +The optional argument specifies a particular bootdev to scan. This can either be +the name of a bootdev or its sequence number (both shown with `bootdev list`). +Alternatively a convenience label can be used, like `mmc0`, which is the type of +device and an optional sequence number. Specifically, the label is the uclass of +the bootdev's parent followed by the sequence number of that parent. Sequence +numbers are typically set by aliases, so if you have 'mmc0' in your devicetree +alias section, then `mmc0` refers to the bootdev attached to that device. + + +bootflow list +~~~~~~~~~~~~~ + +Lists the previously scanned bootflows. You must use `bootflow scan` before this +to see anything. + +If you scanned with -a and have bootflows with errors, -e can be used to show +those errors. + +The list looks something like this: + +=== ====== ====== ======== ==== =============================== ================ +Seq Method State Uclass Part Name Filename +=== ====== ====== ======== ==== =============================== ================ + 0 distro ready mmc 2 mmc\@7e202000.bootdev.part_2 /boot/extlinux/extlinux.conf + 1 pxe ready ethernet 0 smsc95xx_eth.bootdev.0 rpi.pxe/extlinux/extlinux.conf +=== ====== ====== ======== ==== =============================== ================ + +The fields are as follows: + +Seq: + Sequence number in the scan, used to reference the bootflow later + +Method: + The boot method (bootmeth) used to find the bootflow. Several methods are + included in U-Boot. + +State: + Current state of the bootflow, indicating how far the bootdev got in + obtaining a valid one. See :ref:`BootflowStates` for a list of states. + +Uclass: + Name of the media device's Uclass. This indicates the type of the parent + device (e.g. MMC, Ethernet). + +Part: + Partition number being accesseed, numbered from 1. Normally a device will + have a partition table with a small number of partitions. For devices + without partition tables (e.g. network) this field is 0. + +Name: + Name of the bootflow. This is generated from the bootdev appended with + the partition information + +Filename: + Name of the bootflow file. This indicates where the file is on the + filesystem or network device. + + +bootflow select +~~~~~~~~~~~~~~~ + +Use this to select a particular bootflow. You can select it by the sequence +number or name, as shown in `bootflow list`. + +Once a bootflow is selected, you can use `bootflow info` and `bootflow boot`. + +If no bootflow name or number is provided, then any existing bootflow is +unselected. + + +bootflow info +~~~~~~~~~~~~~ + +This shows information on the current bootflow, with the format looking like +this: + +========= =============================== +Name mmc\@7e202000.bootdev.part_2 +Device mmc\@7e202000.bootdev +Block dev mmc\@7e202000.blk +Type distro +Method: syslinux +State ready +Partition 2 +Subdir (none) +Filename /extlinux/extlinux.conf +Buffer 3db7ad48 +Size 232 (562 bytes) +Error 0 +========= =============================== + +Most of the information is the same as `bootflow list` above. The new fields +are: + +Device + Name of the bootdev + +Block dev + Name of the block device, if any. Network devices don't have a block device. + +Subdir + Subdirectory used for retrieving files. For network bootdevs this is the + directory of the 'bootfile' parameter passed from DHCP. All file retrievals + when booting are relative to this. + +Buffer + Buffer containing the bootflow file. You can use the :doc:`md` to look at + it, or dump it with `bootflow info -d`. + +Size + Size of the bootflow file + +Error + Error number returned from scanning for the bootflow. This is 0 if the + bootflow is in the 'loaded' state, or a negative error value on error. You + can look up Linux error codes to find the meaning of the number. + +Use the `-d` flag to dump out the contents of the bootfile file. + + +bootflow boot +~~~~~~~~~~~~~ + +This boots the current bootflow. + + +Example +------- + +Here is an example of scanning for bootflows, then listing them:: + + U-Boot> bootflow scan -l + Scanning for bootflows in all bootdevs + Seq Type State Uclass Part Name Filename + --- ----------- ------ -------- ---- ------------------------ ---------------- + Scanning bootdev '[email protected]': + 0 distro ready mmc 2 [email protected] /extlinux/extlinux.conf + Scanning bootdev '[email protected]': + Card did not respond to voltage select! : -110 + Scanning bootdev 'smsc95xx_eth.bootdev': + Waiting for Ethernet connection... done. + BOOTP broadcast 1 + DHCP client bound to address 192.168.4.30 (4 ms) + Using smsc95xx_eth device + TFTP from server 192.168.4.1; our IP address is 192.168.4.30 + Filename 'rpi.pxe/'. + Load address: 0x200000 + Loading: * + TFTP error: 'Is a directory' (0) + Starting again + + missing environment variable: pxeuuid + Retrieving file: rpi.pxe/pxelinux.cfg/01-b8-27-eb-a6-61-e1 + Waiting for Ethernet connection... done. + Using smsc95xx_eth device + TFTP from server 192.168.4.1; our IP address is 192.168.4.30 + Filename 'rpi.pxe/pxelinux.cfg/01-b8-27-eb-a6-61-e1'. + Load address: 0x2500000 + Loading: ################################################## 566 Bytes + 45.9 KiB/s + done + Bytes transferred = 566 (236 hex) + 1 distro ready ethernet 0 smsc95xx_eth.bootdev.0 rpi.pxe/extlinux/extlinux.conf + No more bootdevs + --- ----------- ------ -------- ---- ------------------------ ---------------- + (2 bootflows, 2 valid) + U-Boot> bootflow l + Showing all bootflows + Seq Type State Uclass Part Name Filename + --- ----------- ------ -------- ---- ------------------------ ---------------- + 0 distro ready mmc 2 [email protected] /extlinux/extlinux.conf + 1 pxe ready ethernet 0 smsc95xx_eth.bootdev.0 rpi.pxe/extlinux/extlinux.conf + --- ----------- ------ -------- ---- ------------------------ ---------------- + (2 bootflows, 2 valid) + + +The second one is then selected by name (we could instead use `bootflow sel 0`), +displayed and booted:: + + U-Boot> bootflow info + No bootflow selected + U-Boot> bootflow sel [email protected]_2 + U-Boot> bootflow info + Name: [email protected]_2 + Device: [email protected] + Block dev: [email protected] + Sequence: 1 + Method: distro + State: ready + Partition: 2 + Subdir: (none) + Filename: extlinux/extlinux.conf + Buffer: 3db7ae88 + Size: 232 (562 bytes) + Error: 0 + U-Boot> bootflow boot + ** Booting bootflow 'smsc95xx_eth.bootdev.0' + Ignoring unknown command: ui + Ignoring malformed menu command: autoboot + Ignoring malformed menu command: hidden + Ignoring unknown command: totaltimeout + 1: Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl) + Retrieving file: rpi.pxe/initramfs-5.3.7-301.fc31.armv7hl.img + get 2700000 rpi.pxe/initramfs-5.3.7-301.fc31.armv7hl.img + Waiting for Ethernet connection... done. + Using smsc95xx_eth device + TFTP from server 192.168.4.1; our IP address is 192.168.4.30 + Filename 'rpi.pxe/initramfs-5.3.7-301.fc31.armv7hl.img'. + Load address: 0x2700000 + Loading: ###################################T ############### 57.7 MiB + 1.9 MiB/s + done + Bytes transferred = 60498594 (39b22a2 hex) + Retrieving file: rpi.pxe//vmlinuz-5.3.7-301.fc31.armv7hl + get 80000 rpi.pxe//vmlinuz-5.3.7-301.fc31.armv7hl + Waiting for Ethernet connection... done. + Using smsc95xx_eth device + TFTP from server 192.168.4.1; our IP address is 192.168.4.30 + Filename 'rpi.pxe//vmlinuz-5.3.7-301.fc31.armv7hl'. + Load address: 0x80000 + Loading: ################################################## 7.2 MiB + 2.3 MiB/s + done + Bytes transferred = 7508480 (729200 hex) + append: ro root=UUID=9732b35b-4cd5-458b-9b91-80f7047e0b8a rhgb quiet LANG=en_US.UTF-8 cma=192MB cma=256MB + Retrieving file: rpi.pxe//dtb-5.3.7-301.fc31.armv7hl/bcm2837-rpi-3-b.dtb + get 2600000 rpi.pxe//dtb-5.3.7-301.fc31.armv7hl/bcm2837-rpi-3-b.dtb + Waiting for Ethernet connection... done. + Using smsc95xx_eth device + TFTP from server 192.168.4.1; our IP address is 192.168.4.30 + Filename 'rpi.pxe//dtb-5.3.7-301.fc31.armv7hl/bcm2837-rpi-3-b.dtb'. + Load address: 0x2600000 + Loading: ################################################## 13.8 KiB + 764.6 KiB/s + done + Bytes transferred = 14102 (3716 hex) + Kernel image @ 0x080000 [ 0x000000 - 0x729200 ] + ## Flattened Device Tree blob at 02600000 + Booting using the fdt blob at 0x2600000 + Using Device Tree in place at 02600000, end 02606715 + + Starting kernel ... + + [ OK ] Started Show Plymouth Boot Screen. + [ OK ] Started Forward Password R…s to Plymouth Directory Watch. + [ OK ] Reached target Local Encrypted Volumes. + [ OK ] Reached target Paths. + .... + + +Here we scan for bootflows and boot the first one found:: + + U-Boot> bootflow scan -bl + Scanning for bootflows in all bootdevs + Seq Method State Uclass Part Name Filename + --- ----------- ------ -------- ---- ---------------------- ---------------- + Scanning bootdev '[email protected]': + 0 distro ready mmc 2 [email protected] /extlinux/extlinux.conf + ** Booting bootflow '[email protected]_2' + Ignoring unknown command: ui + Ignoring malformed menu command: autoboot + Ignoring malformed menu command: hidden + Ignoring unknown command: totaltimeout + 1: Fedora-KDE-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl) + Retrieving file: /initramfs-5.3.7-301.fc31.armv7hl.img + getfile 2700000 /initramfs-5.3.7-301.fc31.armv7hl.img + Retrieving file: /vmlinuz-5.3.7-301.fc31.armv7hl + getfile 80000 /vmlinuz-5.3.7-301.fc31.armv7hl + append: ro root=UUID=b8781f09-e2dd-4cb8-979b-7df5eeaaabea rhgb LANG=en_US.UTF-8 cma=192MB console=tty0 console=ttyS1,115200 + Retrieving file: /dtb-5.3.7-301.fc31.armv7hl/bcm2837-rpi-3-b.dtb + getfile 2600000 /dtb-5.3.7-301.fc31.armv7hl/bcm2837-rpi-3-b.dtb + Kernel image @ 0x080000 [ 0x000000 - 0x729200 ] + ## Flattened Device Tree blob at 02600000 + Booting using the fdt blob at 0x2600000 + Using Device Tree in place at 02600000, end 02606715 + + Starting kernel ... + + [ 0.000000] Booting Linux on physical CPU 0x0 + + +Here is am example using the -e flag to see all errors:: + + U-Boot> bootflow scan -a + Card did not respond to voltage select! : -110 + Waiting for Ethernet connection... done. + BOOTP broadcast 1 + DHCP client bound to address 192.168.4.30 (4 ms) + Using smsc95xx_eth device + TFTP from server 192.168.4.1; our IP address is 192.168.4.30 + Filename 'rpi.pxe/'. + Load address: 0x200000 + Loading: * + TFTP error: 'Is a directory' (0) + Starting again + + missing environment variable: pxeuuid + Retrieving file: rpi.pxe/pxelinux.cfg/01-b8-27-eb-a6-61-e1 + Waiting for Ethernet connection... done. + Using smsc95xx_eth device + TFTP from server 192.168.4.1; our IP address is 192.168.4.30 + Filename 'rpi.pxe/pxelinux.cfg/01-b8-27-eb-a6-61-e1'. + Load address: 0x2500000 + Loading: ################################################## 566 Bytes + 49.8 KiB/s + done + Bytes transferred = 566 (236 hex) + U-Boot> bootflow l -e + Showing all bootflows + Seq Type State Uclass Part Name Filename + --- ----------- ------ -------- ---- --------------------- ---------------- + 0 distro fs mmc 1 [email protected] /extlinux/extlinux.conf + ** File not found, err=-2 + 1 distro ready mmc 2 [email protected] /extlinux/extlinux.conf + 2 distro fs mmc 3 [email protected] /extlinux/extlinux.conf + ** File not found, err=-1 + 3 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 4 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 5 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 6 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 7 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 8 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 9 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + a distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + b distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + c distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + d distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + e distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + f distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 10 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 11 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 12 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 13 distro media mmc 0 [email protected] <NULL> + ** No partition found, err=-2 + 14 distro ready ethernet 0 smsc95xx_eth.bootdev.0 rpi.pxe/extlinux/extlinux.conf + --- ----------- ------ -------- ---- --------------------- ---------------- + (21 bootflows, 2 valid) + U-Boot> + + +Return value +------------ + +On success `bootflow boot` normally boots into the Operating System and does not +return to U-Boot. If something about the U-Boot processing fails, then the +return value $? is 1. If the boot succeeds but for some reason the Operating +System returns, then $? is 0, indicating success. + +For other subcommands, the return value $? is always 0 (true). + + +.. BootflowStates_:doc/usage/bootmeth.rst new file +108
-0@@ -0,0 +1,108 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +bootmeth command +================ + +Synopis +------- + +:: + + bootmeth list [-a] - list selected bootmeths (-a for all) + bootmeth order "[<bm> ...]" - select the order of bootmeths\n" + + +Description +----------- + +The `bootmeth` command is used to manage bootmeths. It can list them and change +the order in which they are used. + +See :doc:`../develop/bootstd` for more information. + + +.. _bootmeth_order: + +bootmeth order +~~~~~~~~~~~~~~ + +Selects which bootmeths to use and the order in which they are invoked. When +scanning bootdevs, each bootmeth is tried in turn to see if it can find a valid +bootflow. You can use this command to adjust the order or even to omit some +boomeths. + +The argument is a quoted list of bootmeths to use, by name. + + +bootmeth list +~~~~~~~~~~~~~ + +This lists the selected bootmeths, or all of them, if the `-a` flag is used. +The format looks like this: + +===== === ================== ================================= +Order Seq Name Description +===== === ================== ================================= + 0 0 distro Syslinux boot from a block device + 1 1 efi EFI boot from a .efi file + 2 2 pxe PXE boot from a network device + 3 3 sandbox Sandbox boot for testing + 4 4 efi_mgr EFI bootmgr flow +===== === ================== ================================= + +The fields are as follows: + +Order: + The order in which these bootmeths are invoked for each bootdev. If this + shows as a hyphen, then the bootmeth is not in the current ordering. + +Seq: + The sequence number of the bootmeth, i.e. the normal ordering if none is set + +Name: + Name of the bootmeth + +Description: + A friendly description for the bootmeth + + +Example +------- + +This shows listing bootmeths. All are present and in the normal order:: + + => bootmeth list + Order Seq Name Description + ----- --- ------------------ ------------------ + 0 0 distro Syslinux boot from a block device + 1 1 efi EFI boot from a .efi file + 2 2 pxe PXE boot from a network device + 3 3 sandbox Sandbox boot for testing + 4 4 efi_mgr EFI bootmgr flow + ----- --- ------------------ ------------------ + (5 bootmeths) + +Now the order is changed, to include only two of them:: + + => bootmeth order "sandbox distro" + => bootmeth list + Order Seq Name Description + ----- --- ------------------ ------------------ + 0 3 sandbox Sandbox boot for testing + 1 0 distro Syslinux boot from a block device + ----- --- ------------------ ------------------ + (2 bootmeths) + +The -a flag shows all bootmeths so you can clearly see which ones are used and +which are not:: + + => bootmeth list -a + Order Seq Name Description + ----- --- ------------------ ------------------ + 1 0 distro Syslinux boot from a block device + - 1 efi EFI boot from a .efi file + - 2 pxe PXE boot from a network device + 0 3 sandbox Sandbox boot for testing + - 4 efi_mgr EFI bootmgr flow + ----- --- ------------------ ------------------ + (5 bootmeths)doc/usage/index.rst +3
-0@@ -21,9 +21,12 @@ Shell commands addrmap askenv base + bootdev bootefi + bootflow booti bootmenu + bootmeth button x86/cbsysinfo conitrace
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Quoted 63 lines · Heinrich Schuchardt
Quoted 62 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +14
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)
Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Signature · 1 line
Tom
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Hi,
Quoted 74 lines · Tom Rini
Quoted 63 lines · Heinrich Schuchardt
Quoted 62 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +14
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
If we get EFI bootmgr going, then are you saying you want to disable everything else?
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
Also Heinrich your comment says 'U-Boot has to offer UEFI booting out of the box'. Which bit of this series is in conflict with that? What exactly is "completely wrong" ?? Is it just the wording that is confusing?
??
Regards,
Simon
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Quoted 6 lines · Simon Glass
Hi,
Quoted 3 lines · Tom Rini
Quoted 1 line · Heinrich Schuchardt
On 1/19/22 02:43, Simon Glass wrote:
[snip]
Quoted 24 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
doc/develop/bootstd.rst new file +9
-0+Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Quoted 4 lines
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
No one is talking about removing anything else. But a major part of your motivation here seems to be "discovering what to boot where is a pain" and that's solved (or at least defined, I'm poking Ilias about the status of that off-list). And I want to emphasize discover.
Quoted 2 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
Not at all.
Quoted 5 lines
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
I don't know about buildroot off-hand, but I've had OpenEmbedded spit out UEFI-compatible aarch64 images no problem. If you're talking about embedded Debian/Ubuntu/Fedora, that goes back up to "wants UEFI boot flow". Armbian is the biggest distro I know of off-hand that doesn't do UEFI boot for U-Boot targets and I would love to talk with someone there and find out why (but I guess it's all the 32bit platforms).
But I'd also say the vast majority of embedded devices don't need the complexity you're adding here, but DO need the ability to implement A/B things as easily in U-Boot as they can in grub. And that in turn is because it's a pain to modify the default environment in U-Boot and easy to drop in another script for grub.
Signature · 1 line
Tom
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Hi Tom,
Quoted 35 lines · Tom Rini
Quoted 6 lines · Simon Glass
Hi,
Quoted 3 lines · Tom Rini
Quoted 1 line · Heinrich Schuchardt
On 1/19/22 02:43, Simon Glass wrote:
[snip]
Quoted 26 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
doc/develop/bootstd.rst new file +9
-0+Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
Quoted 7 lines
Quoted 2 lines
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
No one is talking about removing anything else. But a major part of your motivation here seems to be "discovering what to boot where is a pain" and that's solved (or at least defined, I'm poking Ilias about the status of that off-list). And I want to emphasize discover.
But only if you use EFI boot manager, right? Even then I'm not sure we have a deterministic way of listing the available bootdevs, which is something that this series provides.
Quoted 5 lines
Quoted 3 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
Not at all.
OK, good.
Quoted 14 lines
Quoted 6 lines
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
I don't know about buildroot off-hand, but I've had OpenEmbedded spit out UEFI-compatible aarch64 images no problem. If you're talking about embedded Debian/Ubuntu/Fedora, that goes back up to "wants UEFI boot flow". Armbian is the biggest distro I know of off-hand that doesn't do UEFI boot for U-Boot targets and I would love to talk with someone there and find out why (but I guess it's all the 32bit platforms).
Quoted 5 lines
But I'd also say the vast majority of embedded devices don't need the complexity you're adding here, but DO need the ability to implement A/B things as easily in U-Boot as they can in grub. And that in turn is because it's a pain to modify the default environment in U-Boot and easy to drop in another script for grub.
My feeling is the complexity is already there, just in scripts, which are harder to understand (from personal experience trying to understand what they do) and don't have tests. They are also very hard to build on top of (e.g. verified boot).
I can't really say that this series is more complex than EFI bootmgr, if that is what you are suggesting. I think the bootdev uclass is well-motivated and will prove useful even for EFI.
Also A/B/recovery is a lot easier to implement in code than in scripts. I have linked to the proposed design there.
Anyway if we can agree that we are not going to disable the non-EFI flows, then how about we focus on replacing the distro boot scripts, dropping the config.h files, and leave EFI bootmgr out of this discussion?
Regards,
Simon
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Quoted 41 lines · Simon Glass
Hi Tom,
Quoted 38 lines · Tom Rini
Quoted 6 lines · Simon Glass
Hi,
Quoted 3 lines · Tom Rini
Quoted 1 line · Heinrich Schuchardt
On 1/19/22 02:43, Simon Glass wrote:
[snip]
Quoted 28 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
doc/develop/bootstd.rst new file +9
-0+Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
Quoted 8 lines
Quoted 4 lines
No one is talking about removing anything else. But a major part of your motivation here seems to be "discovering what to boot where is a pain" and that's solved (or at least defined, I'm poking Ilias about the status of that off-list). And I want to emphasize discover.
But only if you use EFI boot manager, right? Even then I'm not sure we have a deterministic way of listing the available bootdevs, which is something that this series provides.
I'll let someone else that knows the EFI boot manager code / design speak to this. But yes, for the discoverable case I'm not seeing where "use EFI boot manager" isn't the reasonable answer.
Quoted 27 lines
Quoted 4 lines
Quoted 2 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
Not at all.
OK, good.
Quoted 14 lines
Quoted 6 lines
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
I don't know about buildroot off-hand, but I've had OpenEmbedded spit out UEFI-compatible aarch64 images no problem. If you're talking about embedded Debian/Ubuntu/Fedora, that goes back up to "wants UEFI boot flow". Armbian is the biggest distro I know of off-hand that doesn't do UEFI boot for U-Boot targets and I would love to talk with someone there and find out why (but I guess it's all the 32bit platforms).
Quoted 5 lines
But I'd also say the vast majority of embedded devices don't need the complexity you're adding here, but DO need the ability to implement A/B things as easily in U-Boot as they can in grub. And that in turn is because it's a pain to modify the default environment in U-Boot and easy to drop in another script for grub.
Quoted 4 lines
My feeling is the complexity is already there, just in scripts, which are harder to understand (from personal experience trying to understand what they do) and don't have tests. They are also very hard to build on top of (e.g. verified boot).
Yes, the scripts that live in the environment based boot flow is complex. It's also been a huge step forward from what we had before and has been a great help.
Quoted 3 lines
I can't really say that this series is more complex than EFI bootmgr, if that is what you are suggesting. I think the bootdev uclass is well-motivated and will prove useful even for EFI.
No, what I'm suggesting is that I see this as "current boot script stuff is too complex, lets replace it". And I also see the big part of the complexity there being the discover where to boot from side of things.
Quoted 2 lines
Also A/B/recovery is a lot easier to implement in code than in scripts. I have linked to the proposed design there.
Show me what implementing Mender or RAUC or swupdate looks like with your proposal. Those are some of the real A/B use cases today and have had to take various approaches to dealing with our environment, and also supporting x86 and so started dealing with grub.
Quoted 4 lines
Anyway if we can agree that we are not going to disable the non-EFI flows, then how about we focus on replacing the distro boot scripts, dropping the
config.hfiles, and leave EFI bootmgr out of this discussion?
The primary use case for the distro boot work is EFI boot, and the "make this logic clearer" solution is "use EFI bootmgr". That's where we get stuck in a loop here. There's no "the distro must create .." because the distro is already creating what's needed.
Signature · 1 line
Tom
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Hi Tom,
Quoted 48 lines · Tom Rini
Quoted 46 lines · Simon Glass
Hi Tom,
Quoted 42 lines · Tom Rini
Quoted 6 lines · Simon Glass
Hi,
Quoted 3 lines · Tom Rini
Quoted 1 line · Heinrich Schuchardt
On 1/19/22 02:43, Simon Glass wrote:
[snip]
Quoted 24 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +9
-0+Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Quoted 4 lines
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
No one is talking about removing anything else. But a major part of your motivation here seems to be "discovering what to boot where is a pain" and that's solved (or at least defined, I'm poking Ilias about the status of that off-list). And I want to emphasize discover.
Quoted 7 lines
Quoted 3 lines
But only if you use EFI boot manager, right? Even then I'm not sure we have a deterministic way of listing the available bootdevs, which is something that this series provides.
I'll let someone else that knows the EFI boot manager code / design speak to this. But yes, for the discoverable case I'm not seeing where "use EFI boot manager" isn't the reasonable answer.
With bootdev you have a proper driver and device tree node where configuration can be provided. The default ordering for bootdevs can be provided. We can deal with the quirks of particular subsystems, like MMC. I think there will be other benefits apparent as this all matures.
But let's see. Perhaps it doesn't really matter anyway, since it seems that EFI boot manager is doing its own thing for now.
Quoted 37 lines
Quoted 28 lines
Quoted 5 lines
Quoted 3 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
Not at all.
OK, good.
Quoted 14 lines
Quoted 6 lines
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
I don't know about buildroot off-hand, but I've had OpenEmbedded spit out UEFI-compatible aarch64 images no problem. If you're talking about embedded Debian/Ubuntu/Fedora, that goes back up to "wants UEFI boot flow". Armbian is the biggest distro I know of off-hand that doesn't do UEFI boot for U-Boot targets and I would love to talk with someone there and find out why (but I guess it's all the 32bit platforms).
Quoted 5 lines
But I'd also say the vast majority of embedded devices don't need the complexity you're adding here, but DO need the ability to implement A/B things as easily in U-Boot as they can in grub. And that in turn is because it's a pain to modify the default environment in U-Boot and easy to drop in another script for grub.
Quoted 4 lines
My feeling is the complexity is already there, just in scripts, which are harder to understand (from personal experience trying to understand what they do) and don't have tests. They are also very hard to build on top of (e.g. verified boot).
Yes, the scripts that live in the environment based boot flow is complex. It's also been a huge step forward from what we had before and has been a great help.
Quoted 7 lines
Quoted 3 lines
I can't really say that this series is more complex than EFI bootmgr, if that is what you are suggesting. I think the bootdev uclass is well-motivated and will prove useful even for EFI.
No, what I'm suggesting is that I see this as "current boot script stuff is too complex, lets replace it". And I also see the big part of the complexity there being the discover where to boot from side of things.
OK, so shall we replace the scripts, or not?
Quoted 8 lines
Quoted 3 lines
Also A/B/recovery is a lot easier to implement in code than in scripts. I have linked to the proposed design there.
Show me what implementing Mender or RAUC or swupdate looks like with your proposal. Those are some of the real A/B use cases today and have had to take various approaches to dealing with our environment, and also supporting x86 and so started dealing with grub.
That sounds like an interesting project. For mendor I found this:
More scripts...
Quoted 10 lines
Quoted 5 lines
Anyway if we can agree that we are not going to disable the non-EFI flows, then how about we focus on replacing the distro boot scripts, dropping the
config.hfiles, and leave EFI bootmgr out of this discussion?The primary use case for the distro boot work is EFI boot, and the "make this logic clearer" solution is "use EFI bootmgr". That's where we get stuck in a loop here. There's no "the distro must create .." because the distro is already creating what's needed.
So let me ask again. Is EFI bootmgr the only thing U-Boot is going to support? I thought you said no.
Are you saying you want to keep the environment boot scripts, or not?
Regards,
Simon
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Quoted 109 lines · Simon Glass
Hi Tom,
Quoted 48 lines · Tom Rini
Quoted 46 lines · Simon Glass
Hi Tom,
Quoted 42 lines · Tom Rini
Quoted 6 lines · Simon Glass
Hi,
Quoted 3 lines · Tom Rini
Quoted 1 line · Heinrich Schuchardt
On 1/19/22 02:43, Simon Glass wrote:
[snip]
Quoted 24 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +9
-0+Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Quoted 4 lines
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
No one is talking about removing anything else. But a major part of your motivation here seems to be "discovering what to boot where is a pain" and that's solved (or at least defined, I'm poking Ilias about the status of that off-list). And I want to emphasize discover.
Quoted 7 lines
Quoted 3 lines
But only if you use EFI boot manager, right? Even then I'm not sure we have a deterministic way of listing the available bootdevs, which is something that this series provides.
I'll let someone else that knows the EFI boot manager code / design speak to this. But yes, for the discoverable case I'm not seeing where "use EFI boot manager" isn't the reasonable answer.
With bootdev you have a proper driver and device tree node where configuration can be provided. The default ordering for bootdevs can be provided. We can deal with the quirks of particular subsystems, like MMC. I think there will be other benefits apparent as this all matures.
But let's see. Perhaps it doesn't really matter anyway, since it seems that EFI boot manager is doing its own thing for now.
Quoted 41 lines
Quoted 28 lines
Quoted 5 lines
Quoted 3 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
Not at all.
OK, good.
Quoted 14 lines
Quoted 6 lines
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
I don't know about buildroot off-hand, but I've had OpenEmbedded spit out UEFI-compatible aarch64 images no problem. If you're talking about embedded Debian/Ubuntu/Fedora, that goes back up to "wants UEFI boot flow". Armbian is the biggest distro I know of off-hand that doesn't do UEFI boot for U-Boot targets and I would love to talk with someone there and find out why (but I guess it's all the 32bit platforms).
Quoted 5 lines
But I'd also say the vast majority of embedded devices don't need the complexity you're adding here, but DO need the ability to implement A/B things as easily in U-Boot as they can in grub. And that in turn is because it's a pain to modify the default environment in U-Boot and easy to drop in another script for grub.
Quoted 4 lines
My feeling is the complexity is already there, just in scripts, which are harder to understand (from personal experience trying to understand what they do) and don't have tests. They are also very hard to build on top of (e.g. verified boot).
Yes, the scripts that live in the environment based boot flow is complex. It's also been a huge step forward from what we had before and has been a great help.
Quoted 3 lines
I can't really say that this series is more complex than EFI bootmgr, if that is what you are suggesting. I think the bootdev uclass is well-motivated and will prove useful even for EFI.
Quoted 5 lines
Quoted 3 lines
No, what I'm suggesting is that I see this as "current boot script stuff is too complex, lets replace it". And I also see the big part of the complexity there being the discover where to boot from side of things.
OK, so shall we replace the scripts, or not?
I'm still looking to be convinced that something is better than the scripts, or that the problem is the scripts and not the pain involved with modifying the U-Boot environment.
Quoted 8 lines
Quoted 7 lines
Quoted 2 lines
Also A/B/recovery is a lot easier to implement in code than in scripts. I have linked to the proposed design there.
Show me what implementing Mender or RAUC or swupdate looks like with your proposal. Those are some of the real A/B use cases today and have had to take various approaches to dealing with our environment, and also supporting x86 and so started dealing with grub.
Quoted 5 lines
That sounds like an interesting project. For mendor I found this:
More scripts...
Yes. Mender, RAUC and swupdate (iirc) all have some form of environment based bootcmd to Do The Right Thing and boot A or B or detect failure and fall back. Show me how what you're doing improves integration for that case. That's a case that's not covered by "use UEFI boot manager" directly. I know for Mender a huge pain point for integration is "drop _this_ script in to the default environment". RAUC is similar. Show me something that makes that much easier to integrate, like it is with grub.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
Anyway if we can agree that we are not going to disable the non-EFI flows, then how about we focus on replacing the distro boot scripts, dropping the
config.hfiles, and leave EFI bootmgr out of this discussion?
Quoted 7 lines
Quoted 4 lines
The primary use case for the distro boot work is EFI boot, and the "make this logic clearer" solution is "use EFI bootmgr". That's where we get stuck in a loop here. There's no "the distro must create .." because the distro is already creating what's needed.
So let me ask again. Is EFI bootmgr the only thing U-Boot is going to support? I thought you said no.
Maybe we're talking at cross purposes. I'm not going to drop booti/bootm/bootz/bootelf. I'm not going to drop setting bootcmd to whatever the user / board developer knows is best for them.
Quoted 1 line
Are you saying you want to keep the environment boot scripts, or not?
As I said in the previous iteration on this series, I'm not convinced this is a win over other clean-ups that can be done with what we have today, or that it solves the problems that I often see popping up.
Signature · 1 line
Tom
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Hi Tom,
Quoted 115 lines · Tom Rini
Quoted 113 lines · Simon Glass
Hi Tom,
Quoted 48 lines · Tom Rini
Quoted 46 lines · Simon Glass
Hi Tom,
Quoted 42 lines · Tom Rini
Quoted 6 lines · Simon Glass
Hi,
Quoted 3 lines · Tom Rini
Quoted 1 line · Heinrich Schuchardt
On 1/19/22 02:43, Simon Glass wrote:
[snip]
Quoted 24 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +9
-0+Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Quoted 4 lines
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
No one is talking about removing anything else. But a major part of your motivation here seems to be "discovering what to boot where is a pain" and that's solved (or at least defined, I'm poking Ilias about the status of that off-list). And I want to emphasize discover.
Quoted 7 lines
Quoted 3 lines
But only if you use EFI boot manager, right? Even then I'm not sure we have a deterministic way of listing the available bootdevs, which is something that this series provides.
I'll let someone else that knows the EFI boot manager code / design speak to this. But yes, for the discoverable case I'm not seeing where "use EFI boot manager" isn't the reasonable answer.
With bootdev you have a proper driver and device tree node where configuration can be provided. The default ordering for bootdevs can be provided. We can deal with the quirks of particular subsystems, like MMC. I think there will be other benefits apparent as this all matures.
But let's see. Perhaps it doesn't really matter anyway, since it seems that EFI boot manager is doing its own thing for now.
Quoted 44 lines
Quoted 28 lines
Quoted 5 lines
Quoted 3 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
Not at all.
OK, good.
Quoted 14 lines
Quoted 6 lines
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
I don't know about buildroot off-hand, but I've had OpenEmbedded spit out UEFI-compatible aarch64 images no problem. If you're talking about embedded Debian/Ubuntu/Fedora, that goes back up to "wants UEFI boot flow". Armbian is the biggest distro I know of off-hand that doesn't do UEFI boot for U-Boot targets and I would love to talk with someone there and find out why (but I guess it's all the 32bit platforms).
Quoted 5 lines
But I'd also say the vast majority of embedded devices don't need the complexity you're adding here, but DO need the ability to implement A/B things as easily in U-Boot as they can in grub. And that in turn is because it's a pain to modify the default environment in U-Boot and easy to drop in another script for grub.
Quoted 4 lines
My feeling is the complexity is already there, just in scripts, which are harder to understand (from personal experience trying to understand what they do) and don't have tests. They are also very hard to build on top of (e.g. verified boot).
Yes, the scripts that live in the environment based boot flow is complex. It's also been a huge step forward from what we had before and has been a great help.
Quoted 3 lines
I can't really say that this series is more complex than EFI bootmgr, if that is what you are suggesting. I think the bootdev uclass is well-motivated and will prove useful even for EFI.
No, what I'm suggesting is that I see this as "current boot script stuff is too complex, lets replace it". And I also see the big part of the complexity there being the discover where to boot from side of things.
Quoted 5 lines
Quoted 1 line
OK, so shall we replace the scripts, or not?
I'm still looking to be convinced that something is better than the scripts, or that the problem is the scripts and not the pain involved with modifying the U-Boot environment.
Well luckily, someone has gone to all the trouble of providing an alternative that we can try :-)
Quoted 15 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Also A/B/recovery is a lot easier to implement in code than in scripts. I have linked to the proposed design there.
Show me what implementing Mender or RAUC or swupdate looks like with your proposal. Those are some of the real A/B use cases today and have had to take various approaches to dealing with our environment, and also supporting x86 and so started dealing with grub.
Quoted 5 lines
That sounds like an interesting project. For mendor I found this:
More scripts...
Quoted 8 lines
Yes. Mender, RAUC and swupdate (iirc) all have some form of environment based bootcmd to Do The Right Thing and boot A or B or detect failure and fall back. Show me how what you're doing improves integration for that case. That's a case that's not covered by "use UEFI boot manager" directly. I know for Mender a huge pain point for integration is "drop _this_ script in to the default environment". RAUC is similar. Show me something that makes that much easier to integrate, like it is with grub.
The obvious answer would be to create a boot method for Mender. In that you can do anything, including using the standard bootmethods to obtain things to boot, etc. Also perhaps a 'recovery' bootdev which is invoked last, when other things have failed, or first if recovery mode is selected. Both could be done without any scripting, so could be enabled on any board with just enabling CONFIG_MENDER, I suspect.
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 5 lines
Anyway if we can agree that we are not going to disable the non-EFI flows, then how about we focus on replacing the distro boot scripts, dropping the
config.hfiles, and leave EFI bootmgr out of this discussion?The primary use case for the distro boot work is EFI boot, and the "make this logic clearer" solution is "use EFI bootmgr". That's where we get stuck in a loop here. There's no "the distro must create .." because the distro is already creating what's needed.
Quoted 6 lines
Quoted 2 lines
So let me ask again. Is EFI bootmgr the only thing U-Boot is going to support? I thought you said no.
Maybe we're talking at cross purposes. I'm not going to drop booti/bootm/bootz/bootelf. I'm not going to drop setting bootcmd to whatever the user / board developer knows is best for them.
Maybe. My confusion is that EFI seems to be blocking progress in the general booting domain. When innovation is suggested, the answer is 'well EFI does this so why bother'. When the boot scripts are mentioned, we can apparently limp along with them and iterate there, since EFI is the only thing that matters anyway.
Perhaps the real difference here is that I am not focused on EFI as the solution to all things. I know that is where many distros are and I believe you feel I am wasting my time. But that is where I am. From my vantage point I see a lot of improvements we can make with booting, independent of EFI.
Quoted 6 lines
Quoted 2 lines
Are you saying you want to keep the environment boot scripts, or not?
As I said in the previous iteration on this series, I'm not convinced this is a win over other clean-ups that can be done with what we have today, or that it solves the problems that I often see popping up.
Previously you were worried about the size growth. I am pretty confident this will make a lot of boot-related things more structured and easier over the medium term. But we do need something to build on. I believe the concepts are sound, and applicable to various boot scenarios. In fact I think the lack of a 'bootdev' is something we should have thought to create a while back.
I certainly think it is better than building more and more on the boot scripts.
Regards,
Simon
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Quoted 151 lines · Simon Glass
Hi Tom,
Quoted 115 lines · Tom Rini
Quoted 113 lines · Simon Glass
Hi Tom,
Quoted 48 lines · Tom Rini
Quoted 46 lines · Simon Glass
Hi Tom,
Quoted 42 lines · Tom Rini
Quoted 6 lines · Simon Glass
Hi,
Quoted 3 lines · Tom Rini
Quoted 1 line · Heinrich Schuchardt
On 1/19/22 02:43, Simon Glass wrote:
[snip]
Quoted 24 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +9
-0+Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Quoted 4 lines
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
No one is talking about removing anything else. But a major part of your motivation here seems to be "discovering what to boot where is a pain" and that's solved (or at least defined, I'm poking Ilias about the status of that off-list). And I want to emphasize discover.
Quoted 7 lines
Quoted 3 lines
But only if you use EFI boot manager, right? Even then I'm not sure we have a deterministic way of listing the available bootdevs, which is something that this series provides.
I'll let someone else that knows the EFI boot manager code / design speak to this. But yes, for the discoverable case I'm not seeing where "use EFI boot manager" isn't the reasonable answer.
With bootdev you have a proper driver and device tree node where configuration can be provided. The default ordering for bootdevs can be provided. We can deal with the quirks of particular subsystems, like MMC. I think there will be other benefits apparent as this all matures.
But let's see. Perhaps it doesn't really matter anyway, since it seems that EFI boot manager is doing its own thing for now.
Quoted 44 lines
Quoted 28 lines
Quoted 5 lines
Quoted 3 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
Not at all.
OK, good.
Quoted 14 lines
Quoted 6 lines
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
I don't know about buildroot off-hand, but I've had OpenEmbedded spit out UEFI-compatible aarch64 images no problem. If you're talking about embedded Debian/Ubuntu/Fedora, that goes back up to "wants UEFI boot flow". Armbian is the biggest distro I know of off-hand that doesn't do UEFI boot for U-Boot targets and I would love to talk with someone there and find out why (but I guess it's all the 32bit platforms).
Quoted 5 lines
But I'd also say the vast majority of embedded devices don't need the complexity you're adding here, but DO need the ability to implement A/B things as easily in U-Boot as they can in grub. And that in turn is because it's a pain to modify the default environment in U-Boot and easy to drop in another script for grub.
Quoted 4 lines
My feeling is the complexity is already there, just in scripts, which are harder to understand (from personal experience trying to understand what they do) and don't have tests. They are also very hard to build on top of (e.g. verified boot).
Yes, the scripts that live in the environment based boot flow is complex. It's also been a huge step forward from what we had before and has been a great help.
Quoted 3 lines
I can't really say that this series is more complex than EFI bootmgr, if that is what you are suggesting. I think the bootdev uclass is well-motivated and will prove useful even for EFI.
No, what I'm suggesting is that I see this as "current boot script stuff is too complex, lets replace it". And I also see the big part of the complexity there being the discover where to boot from side of things.
Quoted 5 lines
Quoted 1 line
OK, so shall we replace the scripts, or not?
I'm still looking to be convinced that something is better than the scripts, or that the problem is the scripts and not the pain involved with modifying the U-Boot environment.
Well luckily, someone has gone to all the trouble of providing an alternative that we can try :-)
Quoted 15 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Also A/B/recovery is a lot easier to implement in code than in scripts. I have linked to the proposed design there.
Show me what implementing Mender or RAUC or swupdate looks like with your proposal. Those are some of the real A/B use cases today and have had to take various approaches to dealing with our environment, and also supporting x86 and so started dealing with grub.
Quoted 5 lines
That sounds like an interesting project. For mendor I found this:
More scripts...
Quoted 8 lines
Yes. Mender, RAUC and swupdate (iirc) all have some form of environment based bootcmd to Do The Right Thing and boot A or B or detect failure and fall back. Show me how what you're doing improves integration for that case. That's a case that's not covered by "use UEFI boot manager" directly. I know for Mender a huge pain point for integration is "drop _this_ script in to the default environment". RAUC is similar. Show me something that makes that much easier to integrate, like it is with grub.
Quoted 6 lines
The obvious answer would be to create a boot method for Mender. In that you can do anything, including using the standard bootmethods to obtain things to boot, etc. Also perhaps a 'recovery' bootdev which is invoked last, when other things have failed, or first if recovery mode is selected. Both could be done without any scripting, so could be enabled on any board with just enabling
CONFIG_MENDER, I suspect.
OK. So please show that this will improve things for this case, rather than speculate.
Quoted 23 lines
Quoted 10 lines
Quoted 10 lines
Quoted 9 lines
Quoted 4 lines
Anyway if we can agree that we are not going to disable the non-EFI flows, then how about we focus on replacing the distro boot scripts, dropping the
config.hfiles, and leave EFI bootmgr out of this discussion?The primary use case for the distro boot work is EFI boot, and the "make this logic clearer" solution is "use EFI bootmgr". That's where we get stuck in a loop here. There's no "the distro must create .." because the distro is already creating what's needed.
Quoted 6 lines
Quoted 2 lines
So let me ask again. Is EFI bootmgr the only thing U-Boot is going to support? I thought you said no.
Maybe we're talking at cross purposes. I'm not going to drop booti/bootm/bootz/bootelf. I'm not going to drop setting bootcmd to whatever the user / board developer knows is best for them.
Maybe. My confusion is that EFI seems to be blocking progress in the general booting domain. When innovation is suggested, the answer is 'well EFI does this so why bother'. When the boot scripts are mentioned, we can apparently limp along with them and iterate there, since EFI is the only thing that matters anyway.
Quoted 5 lines
Perhaps the real difference here is that I am not focused on EFI as the solution to all things. I know that is where many distros are and I believe you feel I am wasting my time. But that is where I am. From my vantage point I see a lot of improvements we can make with booting, independent of EFI.
My high level concern is that yes, I don't see this as improving anything yet. This isn't an improvement over what EFI has for booting generic distributions. And this one of the areas where the boot scripts complex, but can be simplified. Another area where they could be simplified is for any of the existing A/B style update mechanisms. That's an interesting case that could show value here.
Quoted 6 lines
Quoted 5 lines
Quoted 1 line
Are you saying you want to keep the environment boot scripts, or not?
As I said in the previous iteration on this series, I'm not convinced this is a win over other clean-ups that can be done with what we have today, or that it solves the problems that I often see popping up.
Quoted 8 lines
Previously you were worried about the size growth. I am pretty confident this will make a lot of boot-related things more structured and easier over the medium term. But we do need something to build on. I believe the concepts are sound, and applicable to various boot scenarios. In fact I think the lack of a 'bootdev' is something we should have thought to create a while back.
I certainly think it is better than building more and more on the boot scripts.
Alright, so rpi_3_32b grew as:
arm: (for 1/1 boards) all +6908.0 data +920.0 rodata -2664.0 text +8652.0
rpi_3_32b : all +6908 data +920 rodata -2664 text +8652
u-boot: add: 101/0, grow: 3/-2 bytes: 8662/-160 (8502)with this series, and I corrected the minor problems due to '@return' becoming "Return:". That's a problem. Environment space is cheap (it's a file, or it needs to have some pretty big these days alignment requirements to have physical redundancy, if you need that). The biggest problem I see with boot scripts is that defining them in a header file where we have to deal with escaping stuff in a header, and you resolved that with the environment cleanup series you did before. The series (that I keep failing to find the time to reply to, but was happy to see!) that updates hush to a modern copy is another good step in the right direction. Being able to write the script but more as plain text rather than escaped strings in C is I suspect why Armbian does what it does.
Signature · 1 line
Tom
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Hi Tom,
Quoted 160 lines · Tom Rini
Quoted 151 lines · Simon Glass
Hi Tom,
Quoted 115 lines · Tom Rini
Quoted 113 lines · Simon Glass
Hi Tom,
Quoted 48 lines · Tom Rini
Quoted 46 lines · Simon Glass
Hi Tom,
Quoted 42 lines · Tom Rini
Quoted 6 lines · Simon Glass
Hi,
Quoted 3 lines · Tom Rini
Quoted 1 line · Heinrich Schuchardt
On 1/19/22 02:43, Simon Glass wrote:
[snip]
Quoted 24 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
(quoted diff) +9
-0+Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
Review
Quoted 4 lines
(quoted diff) +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Quoted 4 lines
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
No one is talking about removing anything else. But a major part of your motivation here seems to be "discovering what to boot where is a pain" and that's solved (or at least defined, I'm poking Ilias about the status of that off-list). And I want to emphasize discover.
Quoted 7 lines
Quoted 3 lines
But only if you use EFI boot manager, right? Even then I'm not sure we have a deterministic way of listing the available bootdevs, which is something that this series provides.
I'll let someone else that knows the EFI boot manager code / design speak to this. But yes, for the discoverable case I'm not seeing where "use EFI boot manager" isn't the reasonable answer.
With bootdev you have a proper driver and device tree node where configuration can be provided. The default ordering for bootdevs can be provided. We can deal with the quirks of particular subsystems, like MMC. I think there will be other benefits apparent as this all matures.
But let's see. Perhaps it doesn't really matter anyway, since it seems that EFI boot manager is doing its own thing for now.
Quoted 44 lines
Quoted 28 lines
Quoted 5 lines
Quoted 3 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
Not at all.
OK, good.
Quoted 14 lines
Quoted 6 lines
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
I don't know about buildroot off-hand, but I've had OpenEmbedded spit out UEFI-compatible aarch64 images no problem. If you're talking about embedded Debian/Ubuntu/Fedora, that goes back up to "wants UEFI boot flow". Armbian is the biggest distro I know of off-hand that doesn't do UEFI boot for U-Boot targets and I would love to talk with someone there and find out why (but I guess it's all the 32bit platforms).
Quoted 5 lines
But I'd also say the vast majority of embedded devices don't need the complexity you're adding here, but DO need the ability to implement A/B things as easily in U-Boot as they can in grub. And that in turn is because it's a pain to modify the default environment in U-Boot and easy to drop in another script for grub.
Quoted 4 lines
My feeling is the complexity is already there, just in scripts, which are harder to understand (from personal experience trying to understand what they do) and don't have tests. They are also very hard to build on top of (e.g. verified boot).
Yes, the scripts that live in the environment based boot flow is complex. It's also been a huge step forward from what we had before and has been a great help.
Quoted 3 lines
I can't really say that this series is more complex than EFI bootmgr, if that is what you are suggesting. I think the bootdev uclass is well-motivated and will prove useful even for EFI.
No, what I'm suggesting is that I see this as "current boot script stuff is too complex, lets replace it". And I also see the big part of the complexity there being the discover where to boot from side of things.
Quoted 5 lines
Quoted 1 line
OK, so shall we replace the scripts, or not?
I'm still looking to be convinced that something is better than the scripts, or that the problem is the scripts and not the pain involved with modifying the U-Boot environment.
Well luckily, someone has gone to all the trouble of providing an alternative that we can try :-)
Quoted 15 lines
Quoted 9 lines
Quoted 8 lines
Quoted 3 lines
Also A/B/recovery is a lot easier to implement in code than in scripts. I have linked to the proposed design there.
Show me what implementing Mender or RAUC or swupdate looks like with your proposal. Those are some of the real A/B use cases today and have had to take various approaches to dealing with our environment, and also supporting x86 and so started dealing with grub.
Quoted 5 lines
That sounds like an interesting project. For mendor I found this:
More scripts...
Quoted 8 lines
Yes. Mender, RAUC and swupdate (iirc) all have some form of environment based bootcmd to Do The Right Thing and boot A or B or detect failure and fall back. Show me how what you're doing improves integration for that case. That's a case that's not covered by "use UEFI boot manager" directly. I know for Mender a huge pain point for integration is "drop _this_ script in to the default environment". RAUC is similar. Show me something that makes that much easier to integrate, like it is with grub.
Quoted 6 lines
The obvious answer would be to create a boot method for Mender. In that you can do anything, including using the standard bootmethods to obtain things to boot, etc. Also perhaps a 'recovery' bootdev which is invoked last, when other things have failed, or first if recovery mode is selected. Both could be done without any scripting, so could be enabled on any board with just enabling
CONFIG_MENDER, I suspect.
Quoted 2 lines
OK. So please show that this will improve things for this case, rather than speculate.
Can you define improvement? You want me to implement Mender before this series can go in?
Quoted 30 lines
Quoted 24 lines
Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Quoted 5 lines
Anyway if we can agree that we are not going to disable the non-EFI flows, then how about we focus on replacing the distro boot scripts, dropping the
config.hfiles, and leave EFI bootmgr out of this discussion?The primary use case for the distro boot work is EFI boot, and the "make this logic clearer" solution is "use EFI bootmgr". That's where we get stuck in a loop here. There's no "the distro must create .." because the distro is already creating what's needed.
Quoted 6 lines
Quoted 2 lines
So let me ask again. Is EFI bootmgr the only thing U-Boot is going to support? I thought you said no.
Maybe we're talking at cross purposes. I'm not going to drop booti/bootm/bootz/bootelf. I'm not going to drop setting bootcmd to whatever the user / board developer knows is best for them.
Maybe. My confusion is that EFI seems to be blocking progress in the general booting domain. When innovation is suggested, the answer is 'well EFI does this so why bother'. When the boot scripts are mentioned, we can apparently limp along with them and iterate there, since EFI is the only thing that matters anyway.
Quoted 5 lines
Perhaps the real difference here is that I am not focused on EFI as the solution to all things. I know that is where many distros are and I believe you feel I am wasting my time. But that is where I am. From my vantage point I see a lot of improvements we can make with booting, independent of EFI.
Quoted 6 lines
My high level concern is that yes, I don't see this as improving anything yet. This isn't an improvement over what EFI has for booting generic distributions. And this one of the areas where the boot scripts complex, but can be simplified. Another area where they could be simplified is for any of the existing A/B style update mechanisms. That's an interesting case that could show value here.
Hmm.
Quoted 14 lines
Quoted 14 lines
Quoted 6 lines
Quoted 2 lines
Are you saying you want to keep the environment boot scripts, or not?
As I said in the previous iteration on this series, I'm not convinced this is a win over other clean-ups that can be done with what we have today, or that it solves the problems that I often see popping up.
Previously you were worried about the size growth. I am pretty confident this will make a lot of boot-related things more structured and easier over the medium term. But we do need something to build on. I believe the concepts are sound, and applicable to various boot scenarios. In fact I think the lack of a 'bootdev' is something we should have thought to create a while back.
Quoted 8 lines
Quoted 1 line
I certainly think it is better than building more and more on the boot scripts.
Alright, so
rpi_3_32bgrew as:arm: (for 1/1 boards) all +6908.0 data +920.0 rodata -2664.0 text +8652.0 rpi_3_32b : all +6908 data +920 rodata -2664 text +8652 u-boot: add: 101/0, grow: 3/-2 bytes: 8662/-160 (8502)with this series, and I corrected the minor problems due to '@return' becoming "Return:". That's a problem. Environment space is cheap (it's
Do you mean the 7KB overall growth is a problem? If so, that seems unfair. Just EFI_LOADER has added that much each year since 2019 (as far back as I checked). I actually thought 7KB was a great result and was very pleased with it.
Quoted 5 lines
a file, or it needs to have some pretty big these days alignment requirements to have physical redundancy, if you need that). The biggest problem I see with boot scripts is that defining them in a header file where we have to deal with escaping stuff in a header, and you resolved that with the environment cleanup series you did before.
I shudder to think how one would do distro_bootcmd in that, if that is what you are suggesting.
Quoted 5 lines
The series (that I keep failing to find the time to reply to, but was happy to see!) that updates hush to a modern copy is another good step in the right direction. Being able to write the script but more as plain text rather than escaped strings in C is I suspect why Armbian does what it does.
So, the scripts are preferable to this series?
Regards,
Simon
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
In reply to Tom RiniReally late to the party but...
Quoted 35 lines · Tom Rini
Quoted 6 lines · Simon Glass
Hi,
Quoted 3 lines · Tom Rini
Quoted 1 line · Heinrich Schuchardt
On 1/19/22 02:43, Simon Glass wrote:
[snip]
Quoted 26 lines
Quoted 18 lines
Quoted 9 lines
Quoted 9 lines
doc/develop/bootstd.rst new file +9
-0+Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
Quoted 7 lines
Quoted 2 lines
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
No one is talking about removing anything else. But a major part of your motivation here seems to be "discovering what to boot where is a pain" and that's solved (or at least defined, I'm poking Ilias about the status of that off-list). And I want to emphasize discover.
There's this [1] which I am happy to either ping Akashi-san or pick it myself if it makes anyone life easier. Most of the concerns in that thread are valid imho, but they also are not to hard to solve (famous last words).
[...]
[1] https://lore.kernel.org/u-boot/[email protected]/#t
Thanks and apologies for the *really* delayed reply. /Ilias
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
In reply to Simon GlassQuoted 91 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 08:20:17 -0700Hi,
Quoted 74 lines · Tom Rini
Quoted 63 lines · Heinrich Schuchardt
Quoted 62 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +14
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
Quoted 8 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
And U-Boot supports a wide variety of CPUs and some of those don't even have official UEFI support.
However, on arm64 (and possibly riscv64) even the embedded folks should seriously consider using the UEFI bootflow. Linux now supports physical address randomization when loaded via the UEFI stub, which is something that can't really be implemented using the legacy boot path. Note that you don't have to use a separate UEFI bootloader as U-Boot can directly boot kernels with the UEFI stub.
Quoted 4 lines
Also Heinrich your comment says 'U-Boot has to offer UEFI booting out of the box'. Which bit of this series is in conflict with that? What exactly is "completely wrong" ?? Is it just the wording that is confusing?
Possibly. The documentation seems to suggest that OSes have to specify a bootflow for U-Boot. Whereas one of the main advantages of the UEFI bootflow is that this allows OSes not to care whether we're booted by U-Boot, EDK2 or a closed source firmware implementation. I think the docs should say that the bootflow can be customized by an OS, but that in general this isn't necessary.
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Hi Mark,
Quoted 104 lines · Mark Kettenis
Quoted 92 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 08:20:17 -0700Hi,
Quoted 74 lines · Tom Rini
Quoted 63 lines · Heinrich Schuchardt
Quoted 62 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +14
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
Quoted 8 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
And U-Boot supports a wide variety of CPUs and some of those don't even have official UEFI support.
Quoted 6 lines
However, on arm64 (and possibly riscv64) even the embedded folks should seriously consider using the UEFI bootflow. Linux now supports physical address randomization when loaded via the UEFI stub, which is something that can't really be implemented using the legacy boot path. Note that you don't have to use a separate UEFI bootloader as U-Boot can directly boot kernels with the UEFI stub.
'legacy'? Isn't it just a case of relocating the kernel to a random address? I'm pretty sure U-Boot can do that :-)
Re direct boot, the issue seems to me that distros really want to use grub. I think a lot of people talk about direct boot, but it doesn't seem to be happening?
Quoted 6 lines
Quoted 5 lines
Also Heinrich your comment says 'U-Boot has to offer UEFI booting out of the box'. Which bit of this series is in conflict with that? What exactly is "completely wrong" ?? Is it just the wording that is confusing?
Quoted 6 lines
Possibly. The documentation seems to suggest that OSes have to specify a bootflow for U-Boot. Whereas one of the main advantages of the UEFI bootflow is that this allows OSes not to care whether we're booted by U-Boot, EDK2 or a closed source firmware implementation. I think the docs should say that the bootflow can be customized by an OS, but that in general this isn't necessary.
The definition of a bootflow is pretty broad. In the case of grub, it isn't even visible to U-Boot so there is a bootflow ('bootmeth_efi' in this series) but no actual file (grub.cfg) is visible to U-Boot other than the grub.efi that it boots. But if grub is not used, then the bootflow may be a file.
We could perhaps use the next U-Boot contributor call to discuss it.
Regards,
Simon
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Quoted 117 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 09:53:37 -0700Hi Mark,
Quoted 104 lines · Mark Kettenis
Quoted 92 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 08:20:17 -0700Hi,
Quoted 74 lines · Tom Rini
Quoted 63 lines · Heinrich Schuchardt
Quoted 62 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +14
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
Quoted 8 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
And U-Boot supports a wide variety of CPUs and some of those don't even have official UEFI support.
Quoted 6 lines
However, on arm64 (and possibly riscv64) even the embedded folks should seriously consider using the UEFI bootflow. Linux now supports physical address randomization when loaded via the UEFI stub, which is something that can't really be implemented using the legacy boot path. Note that you don't have to use a separate UEFI bootloader as U-Boot can directly boot kernels with the UEFI stub.
Quoted 2 lines
'legacy'? Isn't it just a case of relocating the kernel to a random address? I'm pretty sure U-Boot can do that :-)
The problem is that the legacy boot protocol for the Linux arm64 kernel requires a 2MB aligned kernel base, which reduces the number of randomized bits. That also means that virtual addresses are not fully randomized as the kernel uses large mappings to map itself. My understanding is that the UEFI stub can relocate the kernel to any 64K aligned address. I suppose it is possible to add code to achieve the same thing for the legacy boot path, but I don't think the arm64 maintainers are really interested in doing that.
But yes, U-Boot should certainly try to load arm64 kernels at a random address instead hardcoding the load address ;)
Quoted 3 lines
Re direct boot, the issue seems to me that distros really want to use grub. I think a lot of people talk about direct boot, but it doesn't seem to be happening?
I don't think direct boot makes sense for distros. If you want to support all variations of UEFI firmware you'll need to install your kernel on a FAT filesystem. And that doesn't work well if you let your package manager manage the kernel. Using grub is attractive because x86 users are familliar with it and it offers an interface to boot different kernels.
I think direct boot is targeted more at the embedded world or perhaps virtualized environments.
Quoted 23 lines
Quoted 11 lines
Quoted 4 lines
Also Heinrich your comment says 'U-Boot has to offer UEFI booting out of the box'. Which bit of this series is in conflict with that? What exactly is "completely wrong" ?? Is it just the wording that is confusing?
Possibly. The documentation seems to suggest that OSes have to specify a bootflow for U-Boot. Whereas one of the main advantages of the UEFI bootflow is that this allows OSes not to care whether we're booted by U-Boot, EDK2 or a closed source firmware implementation. I think the docs should say that the bootflow can be customized by an OS, but that in general this isn't necessary.
The definition of a bootflow is pretty broad. In the case of grub, it isn't even visible to U-Boot so there is a bootflow ('
bootmeth_efi' in this series) but no actual file (grub.cfg) is visible to U-Boot other than the grub.efi that it boots. But if grub is not used, then the bootflow may be a file.We could perhaps use the next U-Boot contributor call to discuss it.
Regards,
Simon
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Quoted 129 lines · Mark Kettenis
Quoted 117 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 09:53:37 -0700Hi Mark,
Quoted 104 lines · Mark Kettenis
Quoted 92 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 08:20:17 -0700Hi,
Quoted 74 lines · Tom Rini
Quoted 63 lines · Heinrich Schuchardt
Quoted 62 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +14
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
Quoted 8 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
And U-Boot supports a wide variety of CPUs and some of those don't even have official UEFI support.
Quoted 6 lines
However, on arm64 (and possibly riscv64) even the embedded folks should seriously consider using the UEFI bootflow. Linux now supports physical address randomization when loaded via the UEFI stub, which is something that can't really be implemented using the legacy boot path. Note that you don't have to use a separate UEFI bootloader as U-Boot can directly boot kernels with the UEFI stub.
Quoted 2 lines
'legacy'? Isn't it just a case of relocating the kernel to a random address? I'm pretty sure U-Boot can do that :-)
The problem is that the legacy boot protocol for the Linux arm64 kernel requires a 2MB aligned kernel base, which reduces the number of randomized bits. That also means that virtual addresses are not fully randomized as the kernel uses large mappings to map itself. My understanding is that the UEFI stub can relocate the kernel to any 64K aligned address. I suppose it is possible to add code to achieve the same thing for the legacy boot path, but I don't think the arm64 maintainers are really interested in doing that.
Quoted 2 lines
But yes, U-Boot should certainly try to load arm64 kernels at a random address instead hardcoding the load address ;)
Well, it sounds like "bootefi" should be used over "booti" directly, these days on aarch64 kernels.
Signature · 1 line
Tom
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
In reply to Mark KettenisHi Mark,
Quoted 130 lines · Mark Kettenis
Quoted 118 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 09:53:37 -0700Hi Mark,
Quoted 104 lines · Mark Kettenis
Quoted 92 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 08:20:17 -0700Hi,
Quoted 74 lines · Tom Rini
Quoted 63 lines · Heinrich Schuchardt
Quoted 62 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +14
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
Quoted 8 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
And U-Boot supports a wide variety of CPUs and some of those don't even have official UEFI support.
Quoted 6 lines
However, on arm64 (and possibly riscv64) even the embedded folks should seriously consider using the UEFI bootflow. Linux now supports physical address randomization when loaded via the UEFI stub, which is something that can't really be implemented using the legacy boot path. Note that you don't have to use a separate UEFI bootloader as U-Boot can directly boot kernels with the UEFI stub.
Quoted 2 lines
'legacy'? Isn't it just a case of relocating the kernel to a random address? I'm pretty sure U-Boot can do that :-)
The problem is that the legacy boot protocol for the Linux arm64 kernel requires a 2MB aligned kernel base, which reduces the number of randomized bits. That also means that virtual addresses are not fully randomized as the kernel uses large mappings to map itself. My understanding is that the UEFI stub can relocate the kernel to any 64K aligned address. I suppose it is possible to add code to achieve the same thing for the legacy boot path, but I don't think the arm64 maintainers are really interested in doing that.
Quoted 2 lines
But yes, U-Boot should certainly try to load arm64 kernels at a random address instead hardcoding the load address ;)
This is simply a design decision. Linux wants to be able to do everything in its own tree, hence the decompression code, ALSR, etc. I'm not suggesting we change it, just that it could be done if people wanted it.
Another example is x86 kernels. U-Boot supports putting those in a FIT (even an uncompressed 64-bit kernel) which is helpful for signing / verified boot.
Quoted 12 lines
Quoted 4 lines
Re direct boot, the issue seems to me that distros really want to use grub. I think a lot of people talk about direct boot, but it doesn't seem to be happening?
I don't think direct boot makes sense for distros. If you want to support all variations of UEFI firmware you'll need to install your kernel on a FAT filesystem. And that doesn't work well if you let your package manager manage the kernel. Using grub is attractive because x86 users are familliar with it and it offers an interface to boot different kernels.
Quoted 2 lines
I think direct boot is targeted more at the embedded world or perhaps virtualized environments.
Sounds right. But I keep asking if people have just given up on embedded/custom flows and want U-Boot to just be a UEFI runner?
Quoted 13 lines
Quoted 13 lines
Quoted 12 lines
Quoted 5 lines
Also Heinrich your comment says 'U-Boot has to offer UEFI booting out of the box'. Which bit of this series is in conflict with that? What exactly is "completely wrong" ?? Is it just the wording that is confusing?
Possibly. The documentation seems to suggest that OSes have to specify a bootflow for U-Boot. Whereas one of the main advantages of the UEFI bootflow is that this allows OSes not to care whether we're booted by U-Boot, EDK2 or a closed source firmware implementation. I think the docs should say that the bootflow can be customized by an OS, but that in general this isn't necessary.
Quoted 7 lines
Quoted 7 lines
The definition of a bootflow is pretty broad. In the case of grub, it isn't even visible to U-Boot so there is a bootflow ('
bootmeth_efi' in this series) but no actual file (grub.cfg) is visible to U-Boot other than the grub.efi that it boots. But if grub is not used, then the bootflow may be a file.We could perhaps use the next U-Boot contributor call to discuss it.
Regards,
SImon
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Quoted 120 lines · Simon Glass
Hi Mark,
Quoted 117 lines · Mark Kettenis
Quoted 117 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 09:53:37 -0700Hi Mark,
Quoted 110 lines · Mark Kettenis
Quoted 92 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 08:20:17 -0700Hi,
Quoted 74 lines · Tom Rini
Quoted 63 lines · Heinrich Schuchardt
Quoted 62 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +14
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
Quoted 8 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
And U-Boot supports a wide variety of CPUs and some of those don't even have official UEFI support.
However, on arm64 (and possibly riscv64) even the embedded folks should seriously consider using the UEFI bootflow. Linux now supports physical address randomization when loaded via the UEFI stub, which is something that can't really be implemented using the legacy boot path. Note that you don't have to use a separate UEFI bootloader as U-Boot can directly boot kernels with the UEFI stub.
You could set kaslr-seed in the device-tree using one of our hardware RNG drivers. This would allow address randomization when booting via the legacy entry point.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
'legacy'? Isn't it just a case of relocating the kernel to a random address? I'm pretty sure U-Boot can do that :-)
Instead of 'legacy' you could call it vendor lock in.
If a firmware does not support UEFI you cannot boot other operating systems than Linux, e.g. BSD.
Quoted 13 lines
Quoted 10 lines
The problem is that the legacy boot protocol for the Linux arm64 kernel requires a 2MB aligned kernel base, which reduces the number of randomized bits. That also means that virtual addresses are not fully randomized as the kernel uses large mappings to map itself. My understanding is that the UEFI stub can relocate the kernel to any 64K aligned address. I suppose it is possible to add code to achieve the same thing for the legacy boot path, but I don't think the arm64 maintainers are really interested in doing that.
Quoted 2 lines
But yes, U-Boot should certainly try to load arm64 kernels at a random address instead hardcoding the load address ;)
Quoted 20 lines
This is simply a design decision. Linux wants to be able to do everything in its own tree, hence the decompression code, ALSR, etc. I'm not suggesting we change it, just that it could be done if people wanted it.
Another example is x86 kernels. U-Boot supports putting those in a FIT (even an uncompressed 64-bit kernel) which is helpful for signing / verified boot.
Quoted 11 lines
Quoted 4 lines
Re direct boot, the issue seems to me that distros really want to use grub. I think a lot of people talk about direct boot, but it doesn't seem to be happening?
I don't think direct boot makes sense for distros. If you want to support all variations of UEFI firmware you'll need to install your kernel on a FAT filesystem. And that doesn't work well if you let your package manager manage the kernel. Using grub is attractive because x86 users are familliar with it and it offers an interface to boot different kernels.
Ilias has added the possibility to add the intird path to the UEFI boot option. The gap is that U-Boot does not support SetVariables() and hence you cannot update the boot option from the OS.
Quoted 12 lines
Quoted 3 lines
I think direct boot is targeted more at the embedded world or perhaps virtualized environments.
Sounds right. But I keep asking if people have just given up on embedded/custom flows and want U-Boot to just be a UEFI runner?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Also Heinrich your comment says 'U-Boot has to offer UEFI booting out of the box'. Which bit of this series is in conflict with that? What exactly is "completely wrong" ?? Is it just the wording that is confusing?
I didn't comment your code. I disagreed to the specific sentence in the documentation regarding the work of distros.
There should be no distro specific work needed to get UEFI boot enabled. It should simply work out of the box in the default configuration like it does today.
Best regards
Heinrich
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Possibly. The documentation seems to suggest that OSes have to specify a bootflow for U-Boot. Whereas one of the main advantages of the UEFI bootflow is that this allows OSes not to care whether we're booted by U-Boot, EDK2 or a closed source firmware implementation. I think the docs should say that the bootflow can be customized by an OS, but that in general this isn't necessary.
Quoted 7 lines
Quoted 7 lines
The definition of a bootflow is pretty broad. In the case of grub, it isn't even visible to U-Boot so there is a bootflow ('
bootmeth_efi' in this series) but no actual file (grub.cfg) is visible to U-Boot other than the grub.efi that it boots. But if grub is not used, then the bootflow may be a file.We could perhaps use the next U-Boot contributor call to discuss it.
Regards,
SImon
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
Hi Heinrich,
Quoted 192 lines · Heinrich Schuchardt
Quoted 120 lines · Simon Glass
Hi Mark,
Quoted 117 lines · Mark Kettenis
Quoted 117 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 09:53:37 -0700Hi Mark,
Quoted 110 lines · Mark Kettenis
Quoted 92 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 08:20:17 -0700Hi,
Quoted 74 lines · Tom Rini
Quoted 63 lines · Heinrich Schuchardt
Quoted 62 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +14
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
Quoted 8 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
And U-Boot supports a wide variety of CPUs and some of those don't even have official UEFI support.
However, on arm64 (and possibly riscv64) even the embedded folks should seriously consider using the UEFI bootflow. Linux now supports physical address randomization when loaded via the UEFI stub, which is something that can't really be implemented using the legacy boot path. Note that you don't have to use a separate UEFI bootloader as U-Boot can directly boot kernels with the UEFI stub.
You could set kaslr-seed in the device-tree using one of our hardware RNG drivers. This would allow address randomization when booting via the legacy entry point.
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
'legacy'? Isn't it just a case of relocating the kernel to a random address? I'm pretty sure U-Boot can do that :-)
Instead of 'legacy' you could call it vendor lock in.
If a firmware does not support UEFI you cannot boot other operating systems than Linux, e.g. BSD.Quoted 13 lines
Quoted 10 lines
The problem is that the legacy boot protocol for the Linux arm64 kernel requires a 2MB aligned kernel base, which reduces the number of randomized bits. That also means that virtual addresses are not fully randomized as the kernel uses large mappings to map itself. My understanding is that the UEFI stub can relocate the kernel to any 64K aligned address. I suppose it is possible to add code to achieve the same thing for the legacy boot path, but I don't think the arm64 maintainers are really interested in doing that.
Quoted 2 lines
But yes, U-Boot should certainly try to load arm64 kernels at a random address instead hardcoding the load address ;)
Quoted 20 lines
This is simply a design decision. Linux wants to be able to do everything in its own tree, hence the decompression code, ALSR, etc. I'm not suggesting we change it, just that it could be done if people wanted it.
Another example is x86 kernels. U-Boot supports putting those in a FIT (even an uncompressed 64-bit kernel) which is helpful for signing / verified boot.
Quoted 11 lines
Quoted 4 lines
Re direct boot, the issue seems to me that distros really want to use grub. I think a lot of people talk about direct boot, but it doesn't seem to be happening?
I don't think direct boot makes sense for distros. If you want to support all variations of UEFI firmware you'll need to install your kernel on a FAT filesystem. And that doesn't work well if you let your package manager manage the kernel. Using grub is attractive because x86 users are familliar with it and it offers an interface to boot different kernels.
Ilias has added the possibility to add the intird path to the UEFI boot option. The gap is that U-Boot does not support
SetVariables()and hence you cannot update the boot option from the OS.Quoted 12 lines
Quoted 3 lines
I think direct boot is targeted more at the embedded world or perhaps virtualized environments.
Sounds right. But I keep asking if people have just given up on embedded/custom flows and want U-Boot to just be a UEFI runner?
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Also Heinrich your comment says 'U-Boot has to offer UEFI booting out of the box'. Which bit of this series is in conflict with that? What exactly is "completely wrong" ?? Is it just the wording that is confusing?
Quoted 6 lines
I didn't comment your code. I disagreed to the specific sentence in the documentation regarding the work of distros.
There should be no distro specific work needed to get UEFI boot enabled. It should simply work out of the box in the default configuration like it does today.
...which is what this series does, to the extent that things are implemented. What are you getting at? There is no special file to write or anything different from what is there today.
Regards,
Simon
Re: [PATCH v3 30/31] bootstd: doc: Add documentation
In reply to Heinrich SchuchardtQuoted 125 lines
Date: Fri, 21 Jan 2022 23:05:34 +0100
From: Heinrich Schuchardt <[email protected]>Quoted 120 lines · Simon Glass
Hi Mark,
Quoted 117 lines · Mark Kettenis
Quoted 117 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 09:53:37 -0700Hi Mark,
Quoted 110 lines · Mark Kettenis
Quoted 92 lines
From: Simon Glass <[email protected]>
Date: Fri, 21 Jan 2022 08:20:17 -0700Hi,
Quoted 74 lines · Tom Rini
Quoted 63 lines · Heinrich Schuchardt
Quoted 62 lines · Simon Glass
Add documentation for this feature, including the commands and full devicetree bindings.
Signed-off-by Simon Glass <[email protected]>---
Changes in v3:
- Update docs for "bootmeths" and "boot_targets" env varsMAINTAINERS | 4 + doc/develop/bootstd.rst | 638 ++++++++++++++++++++++++++ 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 | 108 +++++ doc/usage/index.rst | 3 + 11 files changed, 1376 insertions(+)create mode 100644
doc/develop/bootstd.rstcreate mode 100644doc/device-tree-bindings/bootmeth.txtcreate mode 100644doc/usage/bootdev.rst
create mode 100644doc/usage/bootflow.rstcreate mode 100644doc/usage/bootmeth.rstMAINTAINERS +4
-0@@ -669,6 +669,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.hdoc/develop/bootstd.rst new file +14
-0@@ -0,0 +1,638 @@ +.. SPDX-License-Identifier: GPL-2.0+: + +U-Boot Standard Boot +==================== + +Introduction +------------ + +Standard boot provides a built-in way for U-Boot to automatically boot +an Operating System without custom scripting and other customisation. It +introduces the following concepts: + + - bootdev - a device which can hold or access a distro (e.g. MMC, Ethernet) + - bootmeth - a method to scan a bootdev to find bootflows (e.g. distro boot)Quoted 8 lines
doc/develop/bootstd.rst line 18
Quoted 4 lines
doc/develop/bootstd.rst new file +4
-0+ - bootflow - a description of how to boot (provided by the distro) + +For Linux, the distro (Linux distribution, e.g. Debian, Fedora) is responsible +for creating a bootflow for each kernel combination that it wants to offer.This gets it completely wrong. There is one standardized boot flow: UEFI. All major distros support this. U-Boot has to offer UEFI booting out of the box.
Quoted 5 lines
I want to jump up and down and emphasize this part as well. While I believe our UEFI bootmgr is still missing the normal scan code, that's something that has been promised to be implemented. And that turns the bootcmd for platforms that just want to support modern off the shelf distros in to something fairly small.
Sigh...
UEFI is a bootflow in this model, one of many. If we don't support the others, then U-Boot is not U-Boot anymore, it is just EFI Boot.
Quoted 8 lines
If we get EFI bootmgr going, then are you saying you want to disable everything else?
You say 'major distros' but there are many that don't use it, particularly in the embedded space. I'll go out on a limb and say that the vast majority of embedded devices in the world don't use it. Are you really saying we should drop support for everything else? Even the distro stuff supports other options.
And U-Boot supports a wide variety of CPUs and some of those don't even have official UEFI support.
However, on arm64 (and possibly riscv64) even the embedded folks should seriously consider using the UEFI bootflow. Linux now supports physical address randomization when loaded via the UEFI stub, which is something that can't really be implemented using the legacy boot path. Note that you don't have to use a separate UEFI bootloader as U-Boot can directly boot kernels with the UEFI stub.
Quoted 3 lines
You could set kaslr-seed in the device-tree using one of our hardware RNG drivers. This would allow address randomization when booting via the legacy entry point.
No quite. Setting kaslr-seed will only do randomization of virtual addresses. But because the bottom 21 bits of the virtual address have to match the bottom 21 bits of the physical address, which isn't randomized, the number of randomized bits in your virtual addresses will be somewhat limited. With EFISTUB booting, physical addresses are also randomized giving you more randomized bits in your virtual addresses. This is what ardb pointed out when we were discussing Ilias's patch to remove kaslr-seed from the device tree.
This points out another downside of legacy booting. As far as I can tell you have to run the kaslrseed command to set kaslr-seed in the device tree. Unless it is already set by a prior boot stage of course. But none of the boards in the U-Boot tree enable that command. Whereas support for EFI_RNG_PROTOCOL is enabled automatically if DM_RNG is enabled.
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
'legacy'? Isn't it just a case of relocating the kernel to a random address? I'm pretty sure U-Boot can do that :-)
Instead of 'legacy' you could call it vendor lock in.
If a firmware does not support UEFI you cannot boot other operating systems than Linux, e.g. BSD.
Well yes. That is why I keep fighting for enabling EFI_LOADER support for as many arm/arm64/riscv64 boards as possible. ;)
Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
The problem is that the legacy boot protocol for the Linux arm64 kernel requires a 2MB aligned kernel base, which reduces the number of randomized bits. That also means that virtual addresses are not fully randomized as the kernel uses large mappings to map itself. My understanding is that the UEFI stub can relocate the kernel to any 64K aligned address. I suppose it is possible to add code to achieve the same thing for the legacy boot path, but I don't think the arm64 maintainers are really interested in doing that.
But yes, U-Boot should certainly try to load arm64 kernels at a random address instead hardcoding the load address ;)
PATCH v3 31/31 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 | 39 ++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-)
boot/Kconfig +2 -1
@@ -1124,7 +1124,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 +2 -37
@@ -133,47 +133,12 @@"fdt_addr_r=0x02600000\0" \ "ramdisk_addr_r=0x02700000\0" -#if CONFIG_IS_ENABLED (CMD_MMC ) -#define BOOT_TARGET_MMC (func) \ - func(MMC, mmc, 0) \ - func(MMC, mmc, 1) \ - func(MMC, mmc, 2) -#else -#define BOOT_TARGET_MMC (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_USB ) -#define BOOT_TARGET_USB (func) func(USB, usb, 0) -#else -#define BOOT_TARGET_USB (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_PXE ) -#define BOOT_TARGET_PXE (func) func(PXE, pxe, na) -#else -#define BOOT_TARGET_PXE (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_DHCP ) -#define BOOT_TARGET_DHCP (func) func(DHCP, dhcp, na) -#else -#define BOOT_TARGET_DHCP (func) -#endif - -#define BOOT_TARGET_DEVICES (func) \ - BOOT_TARGET_MMC(func) \ - BOOT_TARGET_USB(func) \ - BOOT_TARGET_PXE(func) \ - BOOT_TARGET_DHCP(func) - -#include <config_distro_bootcmd.h> -#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ + "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \ ENV_DEVICE_SETTINGS \ ENV_DFU_SETTINGS \ - ENV_MEM_LAYOUT_SETTINGS \ - BOOTENV + ENV_MEM_LAYOUT_SETTINGS#endif
Signature · 1 line
2.34.1.703.g22d0c6ccf7-goog
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 61 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
boot/Kconfig | 3 ++- include/configs/rpi.h | 39 ++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-)boot/Kconfig +2
-1@@ -1124,7 +1124,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 +0
-28@@ -133,47 +133,12 @@"fdt_addr_r=0x02600000\0" \"ramdisk_addr_r=0x02700000\0" -#if CONFIG_IS_ENABLED (CMD_MMC ) -#define BOOT_TARGET_MMC (func) \ - func(MMC, mmc, 0) \ - func(MMC, mmc, 1) \ - func(MMC, mmc, 2) -#else -#define BOOT_TARGET_MMC (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_USB ) -#define BOOT_TARGET_USB (func) func(USB, usb, 0) -#else -#define BOOT_TARGET_USB (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_PXE ) -#define BOOT_TARGET_PXE (func) func(PXE, pxe, na) -#else -#define BOOT_TARGET_PXE (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_DHCP ) -#define BOOT_TARGET_DHCP (func) func(DHCP, dhcp, na) -#else -#define BOOT_TARGET_DHCP (func) -#endif - -#define BOOT_TARGET_DEVICES (func) \
include/configs/rpi.h line 138
Quoted 10 lines
include/configs/rpi.h +1
-7- BOOT_TARGET_MMC(func) \ - BOOT_TARGET_USB(func) \ - BOOT_TARGET_PXE(func) \ - BOOT_TARGET_DHCP(func) - -#include <config_distro_bootcmd.h> -#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ + "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \
We have the indirect defines to func(...) everywhere so that if a feature is disabled we still build + function, as otherwise it's a loud link error. I assume with this we just get a try and fail move to the next target at run time, yes?
Signature · 1 line
Tom
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Hi Tom,
Quoted 71 lines · Tom Rini
Quoted 68 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
boot/Kconfig | 3 ++- include/configs/rpi.h | 39 ++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-)boot/Kconfig +2
-1@@ -1124,7 +1124,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 +0
-35@@ -133,47 +133,12 @@"fdt_addr_r=0x02600000\0" \"ramdisk_addr_r=0x02700000\0" -#if CONFIG_IS_ENABLED (CMD_MMC ) -#define BOOT_TARGET_MMC (func) \ - func(MMC, mmc, 0) \ - func(MMC, mmc, 1) \ - func(MMC, mmc, 2) -#else -#define BOOT_TARGET_MMC (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_USB ) -#define BOOT_TARGET_USB (func) func(USB, usb, 0) -#else -#define BOOT_TARGET_USB (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_PXE ) -#define BOOT_TARGET_PXE (func) func(PXE, pxe, na) -#else -#define BOOT_TARGET_PXE (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_DHCP ) -#define BOOT_TARGET_DHCP (func) func(DHCP, dhcp, na) -#else -#define BOOT_TARGET_DHCP (func) -#endif - -#define BOOT_TARGET_DEVICES (func) \ - BOOT_TARGET_MMC(func) \ - BOOT_TARGET_USB(func) \ - BOOT_TARGET_PXE(func) \ - BOOT_TARGET_DHCP(func) - -#include <config_distro_bootcmd.h> -
Quoted 8 lines
include/configs/rpi.h line 138
Quoted 3 lines
include/configs/rpi.h +1
-0#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ + "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \We have the indirect defines to func(...) everywhere so that if a feature is disabled we still build + function, as otherwise it's a loud link error. I assume with this we just get a try and fail move to the next target at run time, yes?
Yes, that's right. But I hope that boards actually set up the boot targets correctly so that only those that are actually supported are enabled.
This series has the basic functionality but once we have it in I need to look at more individual cases, like all the devicetree variations. As you can imagine it is tricky to convert hundreds of boards all at one, but I plan to start with a few that I can test.
Regards,
Simon
Quoted 3 lines
--
Tom
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 83 lines · Simon Glass
Hi Tom,
Quoted 71 lines · Tom Rini
Quoted 68 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
boot/Kconfig | 3 ++- include/configs/rpi.h | 39 ++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-)boot/Kconfig +2
-1@@ -1124,7 +1124,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 +0
-35@@ -133,47 +133,12 @@"fdt_addr_r=0x02600000\0" \"ramdisk_addr_r=0x02700000\0" -#if CONFIG_IS_ENABLED (CMD_MMC ) -#define BOOT_TARGET_MMC (func) \ - func(MMC, mmc, 0) \ - func(MMC, mmc, 1) \ - func(MMC, mmc, 2) -#else -#define BOOT_TARGET_MMC (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_USB ) -#define BOOT_TARGET_USB (func) func(USB, usb, 0) -#else -#define BOOT_TARGET_USB (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_PXE ) -#define BOOT_TARGET_PXE (func) func(PXE, pxe, na) -#else -#define BOOT_TARGET_PXE (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_DHCP ) -#define BOOT_TARGET_DHCP (func) func(DHCP, dhcp, na) -#else -#define BOOT_TARGET_DHCP (func) -#endif - -#define BOOT_TARGET_DEVICES (func) \ - BOOT_TARGET_MMC(func) \ - BOOT_TARGET_USB(func) \ - BOOT_TARGET_PXE(func) \ - BOOT_TARGET_DHCP(func) - -#include <config_distro_bootcmd.h> -Quoted 8 lines
include/configs/rpi.h line 138
Quoted 3 lines
include/configs/rpi.h +1
-0#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ + "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \We have the indirect defines to func(...) everywhere so that if a feature is disabled we still build + function, as otherwise it's a loud link error. I assume with this we just get a try and fail move to the next target at run time, yes?
Quoted 3 lines
Yes, that's right. But I hope that boards actually set up the boot targets correctly so that only those that are actually supported are enabled.
What do you mean? They always do that, even today, which is why we have those #ifdef's in the distro boot board code. If the user ends up disabling something, it should still build and work. And honestly, given that dependencies are now in Kconfig, the distro_boot.h stuff could get away with dropping all of the "Enabled_foo_without_CONFIG_CMD_foo" stuff I bet.
Quoted 4 lines
This series has the basic functionality but once we have it in I need to look at more individual cases, like all the devicetree variations. As you can imagine it is tricky to convert hundreds of boards all at one, but I plan to start with a few that I can test.
Right, I'm just trying to make sure we have as much apples-to-apples understanding of both ways.
Signature · 1 line
Tom
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Hi Tom,
Quoted 89 lines · Tom Rini
Quoted 83 lines · Simon Glass
Hi Tom,
Quoted 71 lines · Tom Rini
Quoted 68 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
boot/Kconfig | 3 ++- include/configs/rpi.h | 39 ++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-)boot/Kconfig +2
-1@@ -1124,7 +1124,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 +0
-35@@ -133,47 +133,12 @@"fdt_addr_r=0x02600000\0" \"ramdisk_addr_r=0x02700000\0" -#if CONFIG_IS_ENABLED (CMD_MMC ) -#define BOOT_TARGET_MMC (func) \ - func(MMC, mmc, 0) \ - func(MMC, mmc, 1) \ - func(MMC, mmc, 2) -#else -#define BOOT_TARGET_MMC (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_USB ) -#define BOOT_TARGET_USB (func) func(USB, usb, 0) -#else -#define BOOT_TARGET_USB (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_PXE ) -#define BOOT_TARGET_PXE (func) func(PXE, pxe, na) -#else -#define BOOT_TARGET_PXE (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_DHCP ) -#define BOOT_TARGET_DHCP (func) func(DHCP, dhcp, na) -#else -#define BOOT_TARGET_DHCP (func) -#endif - -#define BOOT_TARGET_DEVICES (func) \ - BOOT_TARGET_MMC(func) \ - BOOT_TARGET_USB(func) \ - BOOT_TARGET_PXE(func) \ - BOOT_TARGET_DHCP(func) - -#include <config_distro_bootcmd.h> -Quoted 8 lines
include/configs/rpi.h line 138
Quoted 3 lines
include/configs/rpi.h +1
-0#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ + "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \We have the indirect defines to func(...) everywhere so that if a feature is disabled we still build + function, as otherwise it's a loud link error. I assume with this we just get a try and fail move to the next target at run time, yes?
Quoted 3 lines
Yes, that's right. But I hope that boards actually set up the boot targets correctly so that only those that are actually supported are enabled.
Quoted 6 lines
What do you mean? They always do that, even today, which is why we have those #ifdef's in the distro boot board code. If the user ends up disabling something, it should still build and work. And honestly, given that dependencies are now in
Kconfig, thedistro_boot.hstuff could get away with dropping all of the "Enabled_foo_without_CONFIG_CMD_foo" stuff I bet.
Then I don't think I understand your original question. With bootstd if USB is disabled (for example) then the USB bootdev won't exist so it won't look at USB. It is not so much a link error, just that the device is not there.
Quoted 8 lines
Quoted 5 lines
This series has the basic functionality but once we have it in I need to look at more individual cases, like all the devicetree variations. As you can imagine it is tricky to convert hundreds of boards all at one, but I plan to start with a few that I can test.
Right, I'm just trying to make sure we have as much apples-to-apples understanding of both ways.
OK.
Regards,
Simon
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 99 lines · Simon Glass
Hi Tom,
Quoted 89 lines · Tom Rini
Quoted 83 lines · Simon Glass
Hi Tom,
Quoted 71 lines · Tom Rini
Quoted 68 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
boot/Kconfig | 3 ++- include/configs/rpi.h | 39 ++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-)boot/Kconfig +2
-1@@ -1124,7 +1124,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 +0
-35@@ -133,47 +133,12 @@"fdt_addr_r=0x02600000\0" \"ramdisk_addr_r=0x02700000\0" -#if CONFIG_IS_ENABLED (CMD_MMC ) -#define BOOT_TARGET_MMC (func) \ - func(MMC, mmc, 0) \ - func(MMC, mmc, 1) \ - func(MMC, mmc, 2) -#else -#define BOOT_TARGET_MMC (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_USB ) -#define BOOT_TARGET_USB (func) func(USB, usb, 0) -#else -#define BOOT_TARGET_USB (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_PXE ) -#define BOOT_TARGET_PXE (func) func(PXE, pxe, na) -#else -#define BOOT_TARGET_PXE (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_DHCP ) -#define BOOT_TARGET_DHCP (func) func(DHCP, dhcp, na) -#else -#define BOOT_TARGET_DHCP (func) -#endif - -#define BOOT_TARGET_DEVICES (func) \ - BOOT_TARGET_MMC(func) \ - BOOT_TARGET_USB(func) \ - BOOT_TARGET_PXE(func) \ - BOOT_TARGET_DHCP(func) - -#include <config_distro_bootcmd.h> -Quoted 8 lines
include/configs/rpi.h line 138
Quoted 3 lines
include/configs/rpi.h +1
-0#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ + "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \We have the indirect defines to func(...) everywhere so that if a feature is disabled we still build + function, as otherwise it's a loud link error. I assume with this we just get a try and fail move to the next target at run time, yes?
Quoted 3 lines
Yes, that's right. But I hope that boards actually set up the boot targets correctly so that only those that are actually supported are enabled.
Quoted 6 lines
What do you mean? They always do that, even today, which is why we have those #ifdef's in the distro boot board code. If the user ends up disabling something, it should still build and work. And honestly, given that dependencies are now in
Kconfig, thedistro_boot.hstuff could get away with dropping all of the "Enabled_foo_without_CONFIG_CMD_foo" stuff I bet.
Quoted 4 lines
Then I don't think I understand your original question. With bootstd if USB is disabled (for example) then the USB bootdev won't exist so it won't look at USB. It is not so much a link error, just that the device is not there.
I mean, with "boot_targets=mmc0 mmc1 usb0 pxe dhcp0" but CONFIG_MMC disabled, bootstd will gracefully fail, gracefully fail, boot from USB.
Signature · 1 line
Tom
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 103 lines
Date: Wed, 19 Jan 2022 11:21:17 -0500
From: Tom Rini <[email protected]>Quoted 99 lines · Simon Glass
Hi Tom,
Quoted 95 lines · Tom Rini
Quoted 83 lines · Simon Glass
Hi Tom,
Quoted 71 lines · Tom Rini
Quoted 68 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
boot/Kconfig | 3 ++- include/configs/rpi.h | 39 ++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-)boot/Kconfig +2
-1@@ -1124,7 +1124,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 +0
-35@@ -133,47 +133,12 @@"fdt_addr_r=0x02600000\0" \"ramdisk_addr_r=0x02700000\0" -#if CONFIG_IS_ENABLED (CMD_MMC ) -#define BOOT_TARGET_MMC (func) \ - func(MMC, mmc, 0) \ - func(MMC, mmc, 1) \ - func(MMC, mmc, 2) -#else -#define BOOT_TARGET_MMC (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_USB ) -#define BOOT_TARGET_USB (func) func(USB, usb, 0) -#else -#define BOOT_TARGET_USB (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_PXE ) -#define BOOT_TARGET_PXE (func) func(PXE, pxe, na) -#else -#define BOOT_TARGET_PXE (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_DHCP ) -#define BOOT_TARGET_DHCP (func) func(DHCP, dhcp, na) -#else -#define BOOT_TARGET_DHCP (func) -#endif - -#define BOOT_TARGET_DEVICES (func) \ - BOOT_TARGET_MMC(func) \ - BOOT_TARGET_USB(func) \ - BOOT_TARGET_PXE(func) \ - BOOT_TARGET_DHCP(func) - -#include <config_distro_bootcmd.h> -Quoted 8 lines
include/configs/rpi.h line 138
Quoted 3 lines
include/configs/rpi.h +1
-0#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ + "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \We have the indirect defines to func(...) everywhere so that if a feature is disabled we still build + function, as otherwise it's a loud link error. I assume with this we just get a try and fail move to the next target at run time, yes?
Quoted 3 lines
Yes, that's right. But I hope that boards actually set up the boot targets correctly so that only those that are actually supported are enabled.
What do you mean? They always do that, even today, which is why we have those #ifdef's in the distro boot board code. If the user ends up disabling something, it should still build and work. And honestly, given that dependencies are now in
Kconfig, thedistro_boot.hstuff could get away with dropping all of the "Enabled_foo_without_CONFIG_CMD_foo" stuff I bet.
Quoted 7 lines
Quoted 4 lines
Then I don't think I understand your original question. With bootstd if USB is disabled (for example) then the USB bootdev won't exist so it won't look at USB. It is not so much a link error, just that the device is not there.
I mean, with "boot_targets=mmc0 mmc1 usb0 pxe dhcp0" but
CONFIG_MMCdisabled, bootstd will gracefully fail, gracefully fail, boot from USB.
Even if it gracefully fails, wouldn't it be better if the boot_targets environment variable would correctly reflect the devices that are actually avialable to boot from. We already have the logic to construct that list. So why are we throwing that logic away?
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
()Hi Mark,
Quoted 109 lines · Mark Kettenis
Quoted 109 lines
Date: Wed, 19 Jan 2022 11:21:17 -0500
From: Tom Rini <[email protected]>Quoted 103 lines · Simon Glass
Hi Tom,
Quoted 89 lines · Tom Rini
Quoted 83 lines · Simon Glass
Hi Tom,
Quoted 71 lines · Tom Rini
Quoted 68 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
boot/Kconfig | 3 ++- include/configs/rpi.h | 39 ++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-)boot/Kconfig +2
-1@@ -1124,7 +1124,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 +0
-35@@ -133,47 +133,12 @@"fdt_addr_r=0x02600000\0" \"ramdisk_addr_r=0x02700000\0" -#if CONFIG_IS_ENABLED (CMD_MMC ) -#define BOOT_TARGET_MMC (func) \ - func(MMC, mmc, 0) \ - func(MMC, mmc, 1) \ - func(MMC, mmc, 2) -#else -#define BOOT_TARGET_MMC (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_USB ) -#define BOOT_TARGET_USB (func) func(USB, usb, 0) -#else -#define BOOT_TARGET_USB (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_PXE ) -#define BOOT_TARGET_PXE (func) func(PXE, pxe, na) -#else -#define BOOT_TARGET_PXE (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_DHCP ) -#define BOOT_TARGET_DHCP (func) func(DHCP, dhcp, na) -#else -#define BOOT_TARGET_DHCP (func) -#endif - -#define BOOT_TARGET_DEVICES (func) \ - BOOT_TARGET_MMC(func) \ - BOOT_TARGET_USB(func) \ - BOOT_TARGET_PXE(func) \ - BOOT_TARGET_DHCP(func) - -#include <config_distro_bootcmd.h> -Quoted 8 lines
include/configs/rpi.h line 138
Quoted 3 lines
include/configs/rpi.h +1
-0#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ + "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \We have the indirect defines to func(...) everywhere so that if a feature is disabled we still build + function, as otherwise it's a loud link error. I assume with this we just get a try and fail move to the next target at run time, yes?
Quoted 3 lines
Yes, that's right. But I hope that boards actually set up the boot targets correctly so that only those that are actually supported are enabled.
Quoted 6 lines
What do you mean? They always do that, even today, which is why we have those #ifdef's in the distro boot board code. If the user ends up disabling something, it should still build and work. And honestly, given that dependencies are now in
Kconfig, thedistro_boot.hstuff could get away with dropping all of the "Enabled_foo_without_CONFIG_CMD_foo" stuff I bet.Then I don't think I understand your original question. With bootstd if USB is disabled (for example) then the USB bootdev won't exist so it won't look at USB. It is not so much a link error, just that the device is not there.
Quoted 7 lines
Quoted 2 lines
I mean, with "boot_targets=mmc0 mmc1 usb0 pxe dhcp0" but
CONFIG_MMCdisabled, bootstd will gracefully fail, gracefully fail, boot from USB.Even if it gracefully fails, wouldn't it be better if the
boot_targetsenvironment variable would correctly reflect the devices that are actually avialable to boot from. We already have the logic to construct that list. So why are we throwing that logic away?
Well, the availability of bootdevs provides the same information. You can see that by looking at the definition of BOOT_TARGET_DEVICES above.
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Regards,
Simon
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
So it doesn't really matter how the general list is sorted, but sorting by the speed of the interface sounds.. strange.
-michael
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 7 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 8 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
So it doesn't really matter how the general list is sorted, but sorting by the speed of the interface sounds.. strange.
From a security standpoint "removable" vs. "non-removable" is what really matters. You don't really want someone to plug a usb key or SD card into your device and accidentally boot from it.
Also, changing the default boot order for an already supported device is probably going to cause problems. Something to keep in mind when devices get converted to the new mechanism.
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
Quoted 7 lines
Quoted 3 lines
So it doesn't really matter how the general list is sorted, but sorting by the speed of the interface sounds.. strange.
From a security standpoint "removable" vs. "non-removable" is what really matters. You don't really want someone to plug a usb key or SD card into your device and accidentally boot from it.
Yes, this should be easy enough to set up. From what I've seen so far, people tend to put the MMC devices next to each other in priority, with USB and network later.
But I still think having a sane default makes sense rather than making every board do this explicitly.
Quoted 4 lines
Also, changing the default boot order for an already supported device is probably going to cause problems. Something to keep in mind when devices get converted to the new mechanism.
Well conversion is a different thing. We should be able to make sure the order is the same as before, perhaps with a runtime check, e.g. adding an env variable which provides the expected order.
Regards,
Simon
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Signature · 1 line
Tom
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 26 lines
Date: Thu, 20 Jan 2022 13:30:47 -0500
From: Tom Rini <[email protected]>Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
Quoted 8 lines
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Something like that. I remember a lot of issues when boards were switched over to DM_MMC and the boot order changed. I believe this ended up beging solved by having aliases in the device tree.
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Hi Mark,
Quoted 33 lines · Mark Kettenis
Quoted 33 lines
Date: Thu, 20 Jan 2022 13:30:47 -0500
From: Tom Rini <[email protected]>Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 6 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Something like that. I remember a lot of issues when boards were switched over to
DM_MMCand the boot order changed. I believe this ended up beging solved by having aliases in the device tree.
The bootdevs use the same aliases so the ordering should remain the same in that sense.
Regards,
Simon
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
In reply to Tom RiniHi Tom,
Quoted 24 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
Quoted 8 lines
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the boot_targets variable. I'd just like to avoid that being required for 'normal' boards and situations.
Regards,
Simon
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 33 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 8 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the
boot_targetsvariable. I'd just like to avoid that being required for 'normal' boards and situations.
I think setting things via the environment to have correct defaults is a must. I mean, yes, OK, if there's some device tree binding that we can use that describes this, sure, that's choice A. But choice B would probably be environment strings. Probe and hope is choice C, or more like last resort, imho.
Signature · 1 line
Tom
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Hi Tom,
Quoted 44 lines · Tom Rini
Quoted 33 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 8 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the
boot_targetsvariable. I'd just like to avoid that being required for 'normal' boards and situations.
Quoted 5 lines
I think setting things via the environment to have correct defaults is a must. I mean, yes, OK, if there's some device tree binding that we can use that describes this, sure, that's choice A. But choice B would probably be environment strings. Probe and hope is choice C, or more like last resort, imho.
Well the boot_targets var is implemented in this series.
The question is whether we force platforms to define it, or have a way to handle things gracefully by default.
Regards,
Simon
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 53 lines · Simon Glass
Hi Tom,
Quoted 44 lines · Tom Rini
Quoted 33 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 8 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the
boot_targetsvariable. I'd just like to avoid that being required for 'normal' boards and situations.Quoted 5 lines
I think setting things via the environment to have correct defaults is a must. I mean, yes, OK, if there's some device tree binding that we can use that describes this, sure, that's choice A. But choice B would probably be environment strings. Probe and hope is choice C, or more like last resort, imho.
Quoted 4 lines
Well the
boot_targetsvar is implemented in this series.The question is whether we force platforms to define it, or have a way to handle things gracefully by default.
I think we need to force it to be defined until / unless there's some agreed on standard to provide that information at run time.
Signature · 1 line
Tom
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Hi Tom,
Quoted 55 lines · Tom Rini
Quoted 53 lines · Simon Glass
Hi Tom,
Quoted 49 lines · Tom Rini
Quoted 33 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 8 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the
boot_targetsvariable. I'd just like to avoid that being required for 'normal' boards and situations.I think setting things via the environment to have correct defaults is a must. I mean, yes, OK, if there's some device tree binding that we can use that describes this, sure, that's choice A. But choice B would probably be environment strings. Probe and hope is choice C, or more like last resort, imho.
Quoted 7 lines
Quoted 4 lines
Well the
boot_targetsvar is implemented in this series.The question is whether we force platforms to define it, or have a way to handle things gracefully by default.
I think we need to force it to be defined until / unless there's some agreed on standard to provide that information at run time.
Well we can do that with a cut-down distro header with some macros, I suppose?
Regards,
Simon
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 60 lines · Simon Glass
Hi Tom,
Quoted 57 lines · Tom Rini
Quoted 55 lines · Simon Glass
Hi Tom,
Quoted 44 lines · Tom Rini
Quoted 33 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 8 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the
boot_targetsvariable. I'd just like to avoid that being required for 'normal' boards and situations.Quoted 5 lines
I think setting things via the environment to have correct defaults is a must. I mean, yes, OK, if there's some device tree binding that we can use that describes this, sure, that's choice A. But choice B would probably be environment strings. Probe and hope is choice C, or more like last resort, imho.
Well the
boot_targetsvar is implemented in this series.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The question is whether we force platforms to define it, or have a way to handle things gracefully by default.
I think we need to force it to be defined until / unless there's some agreed on standard to provide that information at run time.
Well we can do that with a cut-down distro header with some macros, I suppose?
Sorry? I mean, when I said standard above, and since you had mentioned from the device tree before (I thought..) I mean get some property defined and accepted and use that for first best path. Then keep using boot_targets and make sure it's documented (and in help, etc) that boards should define that in their default environment for a preferred fallback default boot order. The final fall back of "probe and guess" might need an off switch for securing systems, I'm not sure.
Signature · 1 line
Tom
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Hi Tom,
Quoted 65 lines · Tom Rini
Quoted 63 lines · Simon Glass
Hi Tom,
Quoted 60 lines · Tom Rini
Quoted 57 lines · Simon Glass
Hi Tom,
Quoted 44 lines · Tom Rini
Quoted 33 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 8 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the
boot_targetsvariable. I'd just like to avoid that being required for 'normal' boards and situations.Quoted 5 lines
I think setting things via the environment to have correct defaults is a must. I mean, yes, OK, if there's some device tree binding that we can use that describes this, sure, that's choice A. But choice B would probably be environment strings. Probe and hope is choice C, or more like last resort, imho.
Well the
boot_targetsvar is implemented in this series.The question is whether we force platforms to define it, or have a way to handle things gracefully by default.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I think we need to force it to be defined until / unless there's some agreed on standard to provide that information at run time.
Well we can do that with a cut-down distro header with some macros, I suppose?
Sorry? I mean, when I said standard above, and since you had mentioned from the device tree before (I thought..) I mean get some property defined and accepted and use that for first best path. Then keep using
I think this discussion is a bit beyond the scope of this series. You are talking about the policy for the bootdev selection. So far, implemented in this series, we have, in order of preference:
- boot_targets env var
- bootdev-order device tree property (which you are referring to here)
- priority order (as announced by each bootdev, i.e. it can depend on removable flags, etc.)
- alias order (using device tree)
- simple sequence order (position in device tree, or order in which devices were bound)
I think that is enough to be getting on with. My point above was that if we want to define the boot_targets env var in a header file as now, we could.
Quoted 4 lines
boot_targetsand make sure it's documented (and in help, etc) that boards should define that in their default environment for a preferred fallback default boot order. The final fall back of "probe and guess" might need an off switch for securing systems, I'm not sure.
Yes we need to be careful about that. But for now my intent is to make it possible to migrate from the scripts. Once we have the basics in place we can expand it and I suspect people will find it a lot easier to work with.
Also see BOOTFLOWF_FIXED for example, which isn't implemented, but is intended to allow devices to be filtered based on whether they are internal to the device or not.
Regards,
Simon
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Quoted 101 lines
From: Simon Glass <[email protected]>
Date: Thu, 20 Jan 2022 20:12:41 -0700Hi Tom,
Quoted 65 lines · Tom Rini
Quoted 63 lines · Simon Glass
Hi Tom,
Quoted 60 lines · Tom Rini
Quoted 57 lines · Simon Glass
Hi Tom,
Quoted 44 lines · Tom Rini
Quoted 33 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 8 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the
boot_targetsvariable. I'd just like to avoid that being required for 'normal' boards and situations.Quoted 5 lines
I think setting things via the environment to have correct defaults is a must. I mean, yes, OK, if there's some device tree binding that we can use that describes this, sure, that's choice A. But choice B would probably be environment strings. Probe and hope is choice C, or more like last resort, imho.
Well the
boot_targetsvar is implemented in this series.The question is whether we force platforms to define it, or have a way to handle things gracefully by default.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I think we need to force it to be defined until / unless there's some agreed on standard to provide that information at run time.
Well we can do that with a cut-down distro header with some macros, I suppose?
Sorry? I mean, when I said standard above, and since you had mentioned from the device tree before (I thought..) I mean get some property defined and accepted and use that for first best path. Then keep using
I think this discussion is a bit beyond the scope of this series. You are talking about the policy for the bootdev selection. So far, implemented in this series, we have, in order of preference:
-
boot_targetsenv var
- bootdev-order device tree property (which you are referring to here)
- priority order (as announced by each bootdev, i.e. it can depend on removable flags, etc.)
- alias order (using device tree)
- simple sequence order (position in device tree, or order in which devices were bound)I think that is enough to be getting on with. My point above was that if we want to define the
boot_targetsenv var in a header file as now, we could.Quoted 4 lines
boot_targetsand make sure it's documented (and in help, etc) that boards should define that in their default environment for a preferred fallback default boot order. The final fall back of "probe and guess" might need an off switch for securing systems, I'm not sure.
Quoted 8 lines
Yes we need to be careful about that. But for now my intent is to make it possible to migrate from the scripts. Once we have the basics in place we can expand it and I suspect people will find it a lot easier to work with.
Also see
BOOTFLOWF_FIXEDfor example, which isn't implemented, but is intended to allow devices to be filtered based on whether they are internal to the device or not.
I think what is important here is that when a board gets converted to the new mechanism, the order remains the same as before. With the approach taken by Simon that will take some effort. That's why I thought that keeping the existing macros but redefining them to just produce the boot_targets environment variable instead of the complicated script we have now would be a good idea.
Regarding encoding the boot order in the device tree, I must say that the proposed bindings look a bit strange to me with the use of compatible strings for things that are essentially user-settable options. I also don't entirely see why boot device selection should be u-boot-specific. There actually is a precedent here set by Open Firmware. In Open Firmware you select the boot order by setting the "boot-device" variable that appears as a property of the /options node in the device tree. This variable is a list of boot devices very similar to the boot_targets variable that U-Boot has. The items in this list are separated by spaces (like boot_targets) and the are in principle full device tree paths specifying devices. But aliases (as defined in the /aliases node) can be used as well.
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Hi Mark,
Quoted 111 lines · Mark Kettenis
Quoted 102 lines
From: Simon Glass <[email protected]>
Date: Thu, 20 Jan 2022 20:12:41 -0700Hi Tom,
Quoted 65 lines · Tom Rini
Quoted 63 lines · Simon Glass
Hi Tom,
Quoted 60 lines · Tom Rini
Quoted 57 lines · Simon Glass
Hi Tom,
Quoted 44 lines · Tom Rini
Quoted 33 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of
the device, so the board would only need to intervene (with an env var
or a devicetree property) when that is wrong.Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 8 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the
boot_targetsvariable. I'd just like to avoid that being required for 'normal' boards and situations.Quoted 5 lines
I think setting things via the environment to have correct defaults is a must. I mean, yes, OK, if there's some device tree binding that we can use that describes this, sure, that's choice A. But choice B would probably be environment strings. Probe and hope is choice C, or more like last resort, imho.
Well the
boot_targetsvar is implemented in this series.The question is whether we force platforms to define it, or have a way to handle things gracefully by default.
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
I think we need to force it to be defined until / unless there's some agreed on standard to provide that information at run time.
Well we can do that with a cut-down distro header with some macros, I suppose?
Sorry? I mean, when I said standard above, and since you had mentioned from the device tree before (I thought..) I mean get some property defined and accepted and use that for first best path. Then keep using
I think this discussion is a bit beyond the scope of this series. You are talking about the policy for the bootdev selection. So far, implemented in this series, we have, in order of preference:
-
boot_targetsenv var
- bootdev-order device tree property (which you are referring to here)
- priority order (as announced by each bootdev, i.e. it can depend on removable flags, etc.)
- alias order (using device tree)
- simple sequence order (position in device tree, or order in which devices were bound)I think that is enough to be getting on with. My point above was that if we want to define the
boot_targetsenv var in a header file as now, we could.Quoted 4 lines
boot_targetsand make sure it's documented (and in help, etc) that boards should define that in their default environment for a preferred fallback default boot order. The final fall back of "probe and guess" might need an off switch for securing systems, I'm not sure.Quoted 8 lines
Yes we need to be careful about that. But for now my intent is to make it possible to migrate from the scripts. Once we have the basics in place we can expand it and I suspect people will find it a lot easier to work with.
Also see
BOOTFLOWF_FIXEDfor example, which isn't implemented, but is intended to allow devices to be filtered based on whether they are internal to the device or not.
Quoted 6 lines
I think what is important here is that when a board gets converted to the new mechanism, the order remains the same as before. With the approach taken by Simon that will take some effort. That's why I thought that keeping the existing macros but redefining them to just produce the
boot_targetsenvironment variable instead of the complicated script we have now would be a good idea.
Your comment above is why I suggested keeping some macros but just produced that one env var from them.
Quoted 13 lines
Regarding encoding the boot order in the device tree, I must say that the proposed bindings look a bit strange to me with the use of compatible strings for things that are essentially user-settable options. I also don't entirely see why boot device selection should be u-boot-specific. There actually is a precedent here set by Open Firmware. In Open Firmware you select the boot order by setting the "boot-device" variable that appears as a property of the /options node in the device tree. This variable is a list of boot devices very similar to the
boot_targetsvariable that U-Boot has. The items in this list are separated by spaces (likeboot_targets) and the are in" principle full device tree paths specifying devices. But aliases (as defined in the /aliases node) can be used as well.
Which compatible strings are you referring to?
There is a "bootdev-order" property which sounds like "boot-device", except that it is a string list, not a space-separated string.
Regards,
Simon
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
In reply to Simon GlassQuoted 73 lines · Simon Glass
Hi Tom,
Quoted 70 lines · Tom Rini
Quoted 67 lines · Simon Glass
Hi Tom,
Quoted 55 lines · Tom Rini
Quoted 53 lines · Simon Glass
Hi Tom,
Quoted 49 lines · Tom Rini
Quoted 33 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of the device, so the board would only need to intervene (with an env var or a devicetree property) when that is wrong.
Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 8 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the
boot_targetsvariable. I'd just like to avoid that being required for 'normal' boards and situations.I think setting things via the environment to have correct defaults is a must. I mean, yes, OK, if there's some device tree binding that we can use that describes this, sure, that's choice A. But choice B would probably be environment strings. Probe and hope is choice C, or more like last resort, imho.
Quoted 7 lines
Quoted 4 lines
Well the
boot_targetsvar is implemented in this series.The question is whether we force platforms to define it, or have a way to handle things gracefully by default.
I think we need to force it to be defined until / unless there's some agreed on standard to provide that information at run time.
Well we can do that with a cut-down distro header with some macros, I suppose?
Quoted 7 lines
Quoted 3 lines
Sorry? I mean, when I said standard above, and since you had mentioned from the device tree before (I thought..) I mean get some property defined and accepted and use that for first best path. Then keep using
I think this discussion is a bit beyond the scope of this series. You are talking about the policy for the bootdev selection. So far, implemented in this series, we have, in order of preference:
I still owe comments on the concept, but I want to make sure we don't end up in another case where we ad-hoc something for device tree and keep building off of it without it being made official.
Signature · 1 line
Tom
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
Hi Tom,
Quoted 79 lines · Tom Rini
Quoted 77 lines · Simon Glass
Hi Tom,
Quoted 73 lines · Tom Rini
Quoted 60 lines · Simon Glass
Hi Tom,
Quoted 57 lines · Tom Rini
Quoted 55 lines · Simon Glass
Hi Tom,
Quoted 44 lines · Tom Rini
Quoted 33 lines · Simon Glass
Hi Tom,
Quoted 30 lines · Tom Rini
Quoted 17 lines · Simon Glass
Hi Mark,
Quoted 8 lines · Mark Kettenis
Quoted 8 lines
From: Michael Walle <[email protected]>
Date: Thu, 20 Jan 2022 09:35:44 +0100Quoted 3 lines
The bootdevs have a natural priority, based on the assumed speed of
the device, so the board would only need to intervene (with an env var
or a devicetree property) when that is wrong.Quoted 5 lines
Quoted 5 lines
Does this make sense in general? The default boot order for a board should depend on what is available on board (or on the carrier board) and what is pluggable. I doubt there can be a sane default, so almost all boards will have to define its own boot order anyway.
Quoted 4 lines
Please can you be more specific about what you the problem is here? If the board does not have a device then it will not exist in driver model (or will not probe) and it won't have a bootdev (or it won't probe). That seems to be equivalent to me.
So, I'm not sure how much of a problem it is, since the board can still define the default probe order via environment. But pick any random SoC with more than 1 SD/MMC set of lines on the chip. Youboard may put the first as SD slot and second as eMMC and Myboard may do the opposite and both are going to probe in the same order since it's the same chip.
Quoted 8 lines
Quoted 2 lines
That's what I think Mark is getting at with it not really making sense to just rely on probe order as what to try.
Doesn't the 'non-removable' flag describe this feature of the hardware?
If you don't want to rely on the normal ordering, you can set the
boot_targetsvariable. I'd just like to avoid that being required for 'normal' boards and situations.Quoted 5 lines
I think setting things via the environment to have correct defaults is a must. I mean, yes, OK, if there's some device tree binding that we can use that describes this, sure, that's choice A. But choice B would probably be environment strings. Probe and hope is choice C, or more like last resort, imho.
Well the
boot_targetsvar is implemented in this series.Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
The question is whether we force platforms to define it, or have a way to handle things gracefully by default.
I think we need to force it to be defined until / unless there's some agreed on standard to provide that information at run time.
Well we can do that with a cut-down distro header with some macros, I suppose?
Sorry? I mean, when I said standard above, and since you had mentioned from the device tree before (I thought..) I mean get some property defined and accepted and use that for first best path. Then keep using
Quoted 7 lines
Quoted 3 lines
I think this discussion is a bit beyond the scope of this series. You are talking about the policy for the bootdev selection. So far, implemented in this series, we have, in order of preference:
I still owe comments on the concept, but I want to make sure we don't end up in another case where we ad-hoc something for device tree and keep building off of it without it being made official.
Yes, the bootstd node itself is currently ad-hoc, as are the bootdev devices and bootmeth. Of course all of these are optional and don't appear in .dts files for now, but we should still add bindings for them.
Regards,
Simon
Re: [PATCH v3 31/31] RFC: Switch rpi over to use bootstd
In reply to Tom RiniHi Tom,
Quoted 101 lines · Tom Rini
Quoted 99 lines · Simon Glass
Hi Tom,
Quoted 95 lines · Tom Rini
Quoted 83 lines · Simon Glass
Hi Tom,
Quoted 71 lines · Tom Rini
Quoted 68 lines · Simon Glass
Switch this over, for testing purposes.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
boot/Kconfig | 3 ++- include/configs/rpi.h | 39 ++------------------------------------- 2 files changed, 4 insertions(+), 38 deletions(-)boot/Kconfig +2
-1@@ -1124,7 +1124,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 +0
-35@@ -133,47 +133,12 @@"fdt_addr_r=0x02600000\0" \"ramdisk_addr_r=0x02700000\0" -#if CONFIG_IS_ENABLED (CMD_MMC ) -#define BOOT_TARGET_MMC (func) \ - func(MMC, mmc, 0) \ - func(MMC, mmc, 1) \ - func(MMC, mmc, 2) -#else -#define BOOT_TARGET_MMC (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_USB ) -#define BOOT_TARGET_USB (func) func(USB, usb, 0) -#else -#define BOOT_TARGET_USB (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_PXE ) -#define BOOT_TARGET_PXE (func) func(PXE, pxe, na) -#else -#define BOOT_TARGET_PXE (func) -#endif - -#if CONFIG_IS_ENABLED (CMD_DHCP ) -#define BOOT_TARGET_DHCP (func) func(DHCP, dhcp, na) -#else -#define BOOT_TARGET_DHCP (func) -#endif - -#define BOOT_TARGET_DEVICES (func) \ - BOOT_TARGET_MMC(func) \ - BOOT_TARGET_USB(func) \ - BOOT_TARGET_PXE(func) \ - BOOT_TARGET_DHCP(func) - -#include <config_distro_bootcmd.h> -Quoted 8 lines
include/configs/rpi.h line 138
Quoted 3 lines
include/configs/rpi.h +1
-0#define CONFIG_EXTRA_ENV_SETTINGS \ "dhcpuboot=usb start; dhcp u-boot.uimg; bootm\0" \ + "boot_targets=mmc0 mmc1 usb0 pxe dhcp\0" \We have the indirect defines to func(...) everywhere so that if a feature is disabled we still build + function, as otherwise it's a loud link error. I assume with this we just get a try and fail move to the next target at run time, yes?
Quoted 3 lines
Yes, that's right. But I hope that boards actually set up the boot targets correctly so that only those that are actually supported are enabled.
What do you mean? They always do that, even today, which is why we have those #ifdef's in the distro boot board code. If the user ends up disabling something, it should still build and work. And honestly, given that dependencies are now in
Kconfig, thedistro_boot.hstuff could get away with dropping all of the "Enabled_foo_without_CONFIG_CMD_foo" stuff I bet.
Quoted 7 lines
Quoted 4 lines
Then I don't think I understand your original question. With bootstd if USB is disabled (for example) then the USB bootdev won't exist so it won't look at USB. It is not so much a link error, just that the device is not there.
I mean, with "boot_targets=mmc0 mmc1 usb0 pxe dhcp0" but
CONFIG_MMCdisabled, bootstd will gracefully fail, gracefully fail, boot from USB.
It should do (you get a warning like 'Unknown uclass 'mmc' in label'). I'll add a test case for it.
Regards,
Simon
Quoted 19 lines
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.
Quoted 6 lines
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.
I wanted to give this a try, but I only get the following output:
=> setenv boot_targets usb0
=> bootflow scan -lb
Scanning for bootflows in all bootdevs
Seq Method State Uclass Part Name Filename --- ----------- ------ -------- ---- ------------------------ ----------------
Unknown seq 0 for label 'usb0'
--- ----------- ------ -------- ---- ------------------------ ---------------- (0 bootflows, 0 valid)
where usb0 is a debian installation medium.
-michael
Hi Michael,
Quoted 32 lines · Michael Walle
Quoted 20 lines
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.
Quoted 6 lines
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.
I wanted to give this a try, but I only get the following output:
=> setenv
boot_targetsusb0
=> bootflow scan -lb
Scanning for bootflows in all bootdevs
Quoted 7 lines
Seq Method State Uclass Part Name Filename --- ----------- ------ -------- ---- ------------------------ ----------------Unknown seq 0 for label 'usb0'
--- ----------- ------ -------- ---- ------------------------ ---------------- (0 bootflows, 0 valid)where usb0 is a debian installation medium.
Yes that's not working yet. Can you try an mmc device for testing?
I will take a look at USB at some point. There are about 4 remaining to do as well as various edge cases.
Regards,
Simon
Hi,
Am 2022-01-19 15:56, schrieb Simon Glass:
Quoted 41 lines · Michael Walle
Quoted 40 lines
Quoted 20 lines
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.
Quoted 6 lines
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.
I wanted to give this a try, but I only get the following output:
=> setenv
boot_targetsusb0
=> bootflow scan -lb
Scanning for bootflows in all bootdevsSeq Method State Uclass Part Name Filename --- ----------- ------ -------- ---- ----------------------------------------
Unknown seq 0 for label 'usb0'
--- ----------- ------ -------- ---- ------------------------
----------------
(0 bootflows, 0 valid)
Quoted 3 lines
Quoted 1 line
where usb0 is a debian installation medium.
Yes that's not working yet. Can you try an mmc device for testing?
Ok thanks for confirming. Yes I can test with a sd card, but I'll probably do it when there is support for loading a device tree by the fdtfile.
-michael
Hi Michael,
Quoted 46 lines · Michael Walle
Hi,
Am 2022-01-19 15:56, schrieb Simon Glass:
Quoted 42 lines · Michael Walle
Quoted 41 lines
Quoted 20 lines
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.
Quoted 6 lines
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.
I wanted to give this a try, but I only get the following output:
=> setenv
boot_targetsusb0
=> bootflow scan -lb
Scanning for bootflows in all bootdevs
Seq Method State Uclass Part Name
Filename
--- ----------- ------ -------- ---- ------------------------
----------------
Unknown seq 0 for label 'usb0'
--- ----------- ------ -------- ---- ------------------------
----------------
(0 bootflows, 0 valid)
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
where usb0 is a debian installation medium.
Yes that's not working yet. Can you try an mmc device for testing?
Ok thanks for confirming. Yes I can test with a sd card, but I'll probably do it when there is support for loading a device tree by the fdtfile.
Yes I need to look at that one.
Regards,
SImon
Hi Michael,
Quoted 52 lines · Simon Glass
Hi Michael,
Quoted 48 lines · Michael Walle
Hi,
Am 2022-01-19 15:56, schrieb Simon Glass:
Quoted 44 lines · Michael Walle
Quoted 42 lines
Quoted 20 lines
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.
Quoted 6 lines
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.
I wanted to give this a try, but I only get the following output:
=> setenv
boot_targetsusb0
=> bootflow scan -lb
Scanning for bootflows in all bootdevs
Seq Method State Uclass Part Name
Filename
--- ----------- ------ -------- ---- ------------------------
----------------
Unknown seq 0 for label 'usb0'
--- ----------- ------ -------- ---- ------------------------
----------------
(0 bootflows, 0 valid)where usb0 is a debian installation medium.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
Yes that's not working yet. Can you try an mmc device for testing?
Ok thanks for confirming. Yes I can test with a sd card, but I'll probably do it when there is support for loading a device tree by the fdtfile.
Yes I need to look at that one.
Can you please point me to the OS image you are using.
I have added basic USB support in the v4 series.
Regards,
Simon
Hi Simon,
Am 2022-03-06 04:08, schrieb Simon Glass:
Quoted 49 lines · Simon Glass
Quoted 48 lines · Michael Walle
Quoted 47 lines
Am 2022-01-19 15:56, schrieb Simon Glass:
Quoted 45 lines · Michael Walle
Quoted 41 lines
Quoted 20 lines
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.
Quoted 6 lines
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.
I wanted to give this a try, but I only get the following output:
=> setenv
boot_targetsusb0
=> bootflow scan -lb
Scanning for bootflows in all bootdevs
Seq Method State Uclass Part Name
Filename
--- ----------- ------ -------- ---- ------------------------
----------------
Unknown seq 0 for label 'usb0'
--- ----------- ------ -------- ---- ------------------------
----------------
(0 bootflows, 0 valid)Quoted 1 line
where usb0 is a debian installation medium.
Yes that's not working yet. Can you try an mmc device for testing?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Ok thanks for confirming. Yes I can test with a sd card, but I'll probably do it when there is support for loading a device tree by the fdtfile.
Yes I need to look at that one.
Can you please point me to the OS image you are using.
I'm not testing this on a raspberry pi, if that's what you had in mind.
but for what it's worth, the image i'm building is for a kontron sl28 board and it is based on vanilla buildroot. the config and be found at the vanilla buildroot repo:
configs/kontron_smarc_sal28_defconfig
-michael
Quoted 1 line
I have added basic USB support in the v4 series.
Hi Michael,
Quoted 61 lines · Michael Walle
Hi Simon,
Am 2022-03-06 04:08, schrieb Simon Glass:
Quoted 49 lines · Simon Glass
Quoted 48 lines · Michael Walle
Quoted 47 lines
Am 2022-01-19 15:56, schrieb Simon Glass:
Quoted 45 lines · Michael Walle
Quoted 41 lines
Quoted 20 lines
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.
Quoted 6 lines
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.
I wanted to give this a try, but I only get the following output:
=> setenv
boot_targetsusb0
=> bootflow scan -lb
Scanning for bootflows in all bootdevs
Seq Method State Uclass Part Name
Filename
--- ----------- ------ -------- ---- ------------------------
----------------
Unknown seq 0 for label 'usb0'
--- ----------- ------ -------- ---- ------------------------
----------------
(0 bootflows, 0 valid)Quoted 1 line
where usb0 is a debian installation medium.
Yes that's not working yet. Can you try an mmc device for testing?
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Ok thanks for confirming. Yes I can test with a sd card, but I'll probably do it when there is support for loading a device tree by the fdtfile.
Yes I need to look at that one.
Can you please point me to the OS image you are using.
Quoted 7 lines
I'm not testing this on a raspberry pi, if that's what you had in mind.
but for what it's worth, the image i'm building is for a kontron sl28 board and it is based on vanilla buildroot. the config and be found at the vanilla buildroot repo:
configs/kontron_smarc_sal28_defconfig
OK, thanks. I'll spin up buildroot at some point.
For now I am just going to send the base series. The conversion needs to be done case by case with manual testing on specific distros and boards, so I'll worry about that we have something in there.
Regards,
Simon