[PATCH v2 15/17] boot: Run global bootmeths after all bootdevs are exhausted

Simon Glass sjg at chromium.org
Wed Oct 1 23:26:40 CEST 2025


When there are no more bootdevs we should still go through the global
bootmeths, since some may not have yet been used, if their priority has
not yet come up.

Add a final check for this at the end of the iterator.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

(no changes since v1)

 boot/bootflow.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/boot/bootflow.c b/boot/bootflow.c
index 1070ed542ce..a57272b7100 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -417,6 +417,18 @@ static int iter_incr(struct bootflow_iter *iter)
 			return 0;
 		}
 
+		/* if this was the final global bootmeth check, we are done */
+		if (iter->cur_prio == BOOTDEVP_COUNT) {
+			log_debug("-> done global bootmeths\n");
+
+			/* print the same message as bootflow_iter_set_dev() */
+			if ((iter->flags & (BOOTFLOWIF_SHOW |
+					    BOOTFLOWIF_SINGLE_DEV)) ==
+					    BOOTFLOWIF_SHOW)
+				printf("No more bootdevs\n");
+			return BF_NO_MORE_DEVICES;
+		}
+
 		/*
 		 * Don't move to the next dev as we haven't tried this
 		 * one yet!
@@ -528,6 +540,17 @@ static int iter_incr(struct bootflow_iter *iter)
 			ret = prepare_bootdev(iter, dev, method_flags, true);
 	}
 
+	if (IS_ENABLED(CONFIG_BOOTMETH_GLOBAL) && ret) {
+		log_debug("no more bootdevs, trying global\n");
+
+		/* allow global bootmeths with any priority */
+		iter->cur_prio = BOOTDEVP_COUNT;
+		if (!next_glob_bootmeth(iter)) {
+			log_debug("-> next method '%s'\n", iter->method->name);
+			return 0;
+		}
+	}
+
 	/* if there are no more bootdevs, give up */
 	if (ret) {
 		log_debug("-> no more bootdevs\n");
-- 
2.43.0



More information about the U-Boot mailing list