Hi Daniel, On Mon, 16 Feb 2026 at 14:24, Daniel Golle <[email protected]> wrote: > > 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 <[email protected]> > --- > 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
Down the track it would be nice to build this into bootstd too, as we are trying to avoid scripts. Regards, Simon

