[RFC PATCH 19/20] boot: bootmeth: openwrt: add openwrt_boot_script hook for bootconf
Daniel Golle
daniel at makrotopia.org
Mon Feb 16 22:24:20 CET 2026
Some boards need to probe hardware at boot time to determine the
correct FIT configuration. For example, the BPi-R3 checks whether
SPI-NAND or SPI-NOR is present and selects the matching FIT config
overlay accordingly.
Add an optional script hook: if the environment variable
openwrt_boot_script is set, its content is executed as a U-Boot
command string right before bootconf is read. This lets board
configurations assemble the correct bootconf value dynamically:
setenv openwrt_boot_script 'if nand info; then
setenv bootconf $bootconf_base#$bootconf_emmc#$bootconf_nand;
else
setenv bootconf $bootconf_base#$bootconf_emmc#$bootconf_nor;
fi'
The hook runs once per boot attempt, after the image loader is set up
but before bootm_run() is called.
Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
boot/bootmeth_openwrt.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/boot/bootmeth_openwrt.c b/boot/bootmeth_openwrt.c
index e1f47b58f61..d448697fe08 100644
--- a/boot/bootmeth_openwrt.c
+++ b/boot/bootmeth_openwrt.c
@@ -12,6 +12,7 @@
#include <bootflow.h>
#include <bootm.h>
#include <bootmeth.h>
+#include <command.h>
#include <dm.h>
#include <env.h>
#include <image.h>
@@ -113,6 +114,17 @@ static int openwrt_boot(struct udevice *dev, struct bootflow *bflow)
bootm_init(&bmi);
bmi.loader = &ldr;
+ /*
+ * Optional script hook: run the command in openwrt_boot_script
+ * before reading bootconf. Boards use this to probe hardware
+ * and assemble the correct FIT configuration string, e.g.:
+ *
+ * setenv openwrt_boot_script 'if nand info; then ...'
+ */
+ conf = env_get("openwrt_boot_script");
+ if (conf)
+ run_command(conf, 0);
+
/* FIT config selection via #conf suffix */
conf = env_get("bootconf");
if (conf) {
--
2.53.0
More information about the U-Boot
mailing list