On Tue, Sep 23, 2025 at 03:43:09PM +0200, Benjamin Hahn wrote: > Add the option to load the bootscript with the tftp command (static IP) > instead of the dhcp command (dynamic IP). For this a new function > tftpb_run similar to dhcp_run, is needed. The selection of which command > to use can be done with the ip_dyn environment variable, which can be > set to yes or no. The ip_dyn variable was chosen as it is already in use > on the imx platforms. > Also edit the bootstd doc. > > Signed-off-by: Benjamin Hahn <[email protected]> > --- > Changes in v2: > - fix build error when CONFIG_CMD_TFTPBOOT is not activated > - Link to v1: > https://lore.kernel.org/r/[email protected] > --- > boot/bootmeth_script.c | 8 ++++++++ > cmd/net.c | 18 ++++++++++++++++++ > doc/develop/bootstd/overview.rst | 4 ++++ > doc/develop/bootstd/script.rst | 6 ++++-- > include/net-common.h | 8 ++++++++ > 5 files changed, 42 insertions(+), 2 deletions(-) > > diff --git a/boot/bootmeth_script.c b/boot/bootmeth_script.c > index 020cb8a7aec0..fd15b1ac1a20 100644 > --- a/boot/bootmeth_script.c > +++ b/boot/bootmeth_script.c > @@ -129,7 +129,15 @@ static int script_read_bootflow_net(struct bootflow > *bflow) > if (!fname) > return log_msg_ret("dhc", -EINVAL); > > +#ifdef CONFIG_CMD_TFTPBOOT > + if (env_get_yesno("ip_dyn") == 0) > + ret = tftpb_run(addr, fname); > + else > + ret = dhcp_run(addr, fname, true); > +#else > ret = dhcp_run(addr, fname, true); > +#endif /* CONFIG_CMD_TFTPBOOT */
This is a case where IS_ENABLED(CONFIG..) is helpful as we can do:
if (IS_ENABLED(CONFIG_CMD_TFTPBOOT) && env_get_yesno("ip_dyn") == 0)
ret = tftpb_run(addr, fname);
else
ret = dhcp_run(addr, fname, true);
And when CONFIG_CMD_TFTPBOOT isn't set the compiler optimizes this to
just the dhcp_run call.
--
Tom
signature.asc
Description: PGP signature

