[PATCH] bootstd: Adjust the default bootmeth order

Simon Glass sjg at chromium.org
Sun Aug 20 00:49:35 CEST 2023


The existing distro scripts check extlinux and scripts before EFI. Adjust
the default ordering to do the same, to avoid breaking existing flows.

Add some documentation, mentioning that this order will likely change in
future.

Signed-off-by: Simon Glass <sjg at chromium.org>
Reported-by: Da Xue <da at libre.computer>
---

 boot/bootmeth_extlinux.c | 3 ++-
 boot/bootmeth_script.c   | 3 ++-
 doc/develop/bootstd.rst  | 8 +++++++-
 test/boot/bootflow.c     | 4 ++--
 4 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/boot/bootmeth_extlinux.c b/boot/bootmeth_extlinux.c
index 6b2b84003836..aa2a4591ebd7 100644
--- a/boot/bootmeth_extlinux.c
+++ b/boot/bootmeth_extlinux.c
@@ -184,7 +184,8 @@ static const struct udevice_id extlinux_bootmeth_ids[] = {
 	{ }
 };
 
-U_BOOT_DRIVER(bootmeth_extlinux) = {
+/* Put an number before 'extlinux' to provide a default ordering */
+U_BOOT_DRIVER(bootmeth_1extlinux) = {
 	.name		= "bootmeth_extlinux",
 	.id		= UCLASS_BOOTMETH,
 	.of_match	= extlinux_bootmeth_ids,
diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c
index a4050c384dfa..58c57a2d4b5b 100644
--- a/boot/bootmeth_script.c
+++ b/boot/bootmeth_script.c
@@ -243,7 +243,8 @@ static const struct udevice_id script_bootmeth_ids[] = {
 	{ }
 };
 
-U_BOOT_DRIVER(bootmeth_script) = {
+/* Put an number before 'script' to provide a default ordering */
+U_BOOT_DRIVER(bootmeth_2script) = {
 	.name		= "bootmeth_script",
 	.id		= UCLASS_BOOTMETH,
 	.of_match	= script_bootmeth_ids,
diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst
index 7a2a69fdfcec..4000b950b600 100644
--- a/doc/develop/bootstd.rst
+++ b/doc/develop/bootstd.rst
@@ -132,6 +132,9 @@ above bootdev scanning.
 Controlling ordering
 --------------------
 
+By default, faster bootdevs (or those which are assumed to be faster) are used
+first, since they are more likely to be able to boot the device quickly.
+
 Several options are available to control the ordering of boot scanning:
 
 
@@ -151,6 +154,10 @@ bootdevs and their sequence numbers.
 bootmeths
 ~~~~~~~~~
 
+By default bootmeths are checked in name order. Use `bootmeth list` to see the
+ordering. Note that the `extlinux` and `script` bootmeth is first, to preserve the behaviour
+used by the old distro scripts.
+
 This environment variable can be used to control the list of bootmeths used and
 their ordering for example::
 
@@ -164,7 +171,6 @@ controlled by aliases.
 The :ref:`usage/cmd/bootmeth:bootmeth command` (`bootmeth order`) operates in
 the same way as setting this variable.
 
-
 Bootdev uclass
 --------------
 
diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c
index 8a4e090e9bcf..1c91a942e989 100644
--- a/test/boot/bootflow.c
+++ b/test/boot/bootflow.c
@@ -27,7 +27,7 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-extern U_BOOT_DRIVER(bootmeth_script);
+extern U_BOOT_DRIVER(bootmeth_2script);
 
 static int inject_response(struct unit_test_state *uts)
 {
@@ -525,7 +525,7 @@ static int prep_mmc4_bootdev(struct unit_test_state *uts)
 
 	/* Enable the script bootmeth too */
 	ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd));
-	ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_script),
+	ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_2script),
 				"bootmeth_script", 0, ofnode_null(), &dev));
 
 	/* Change the order to include mmc4 */
-- 
2.42.0.rc1.204.g551eb34607-goog



More information about the U-Boot mailing list