"Das U-Boot" Source Tree
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

bootstd: make it possible to use tftp for netboot with standardboot

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.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Benjamin Hahn <B.Hahn@phytec.de>

authored by

Benjamin Hahn and committed by
Tom Rini
fae6c54d 8506cf58

+43 -3
+5 -1
boot/bootmeth_script.c
··· 129 129 if (!fname) 130 130 return log_msg_ret("dhc", -EINVAL); 131 131 132 - ret = dhcp_run(addr, fname, true); 132 + if (IS_ENABLED(CONFIG_CMD_TFTPBOOT) && env_get_yesno("ip_dyn") == 0) 133 + ret = tftpb_run(addr, fname); 134 + else 135 + ret = dhcp_run(addr, fname, true); 136 + 133 137 if (ret) 134 138 return log_msg_ret("dhc", ret); 135 139
+4
doc/develop/bootstd/overview.rst
··· 262 262 fdtoverlay_addr_r (needed if overlays are used) 263 263 Address at which to load the overlay for the FDT, e.g. 0x02000000 264 264 265 + ip_dyn 266 + Use dynamic IP (dhcp) or static IP (tftp) for loading the bootscript over 267 + ethernet. Default is dhcp. e.g. no 268 + 265 269 kernel_addr_r 266 270 Address at which to load the kernel, e.g. 0x02080000 267 271
+4 -2
doc/develop/bootstd/script.rst
··· 12 12 `filename-prefixes` property in the bootstd device. 13 13 14 14 For a network device, the filename is obtained from the `boot_script_dhcp` 15 - environment variable and the file is read using tftp. It must be in the 16 - top-level directory of the tftp server. 15 + environment variable. By setting the `ip_dyn` environment variable it can be 16 + decided if dynamic ip (dhcp command) or static ip (tftp command) is used for 17 + reading the file. By default dhcp is used. The file must be in the top-level 18 + directory of the tftp server. 17 19 18 20 In either case (file or network), the bootmeth searches for the file and creates 19 21 a bootflow if found. The bootmeth searches for "boot.scr.uimg" first, then
+9
include/net-common.h
··· 491 491 int do_dhcp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); 492 492 493 493 /** 494 + * tftpb_run() - Run TFTP on the current ethernet device 495 + * 496 + * @addr: Address to load the file into 497 + * @fname: Filename of file to load (NULL to use the default filename) 498 + * @return 0 if OK, -ENOENT if ant file was not found 499 + */ 500 + int tftpb_run(ulong addr, const char *fname); 501 + 502 + /** 494 503 * do_ping - Run the ping command 495 504 * 496 505 * @cmdtp: Unused
+21
net/net-common.c
··· 83 83 return 0; 84 84 } 85 85 #endif 86 + 87 + #if defined(CONFIG_CMD_TFTPBOOT) 88 + int tftpb_run(ulong addr, const char *fname) 89 + { 90 + char *tftp_argv[] = {"tftpboot", NULL, (char *)fname, NULL}; 91 + struct cmd_tbl cmdtp = {}; /* dummy */ 92 + char file_addr[17] = {0}; 93 + 94 + log_debug("addr=%lx, fname=%s\n", addr, fname); 95 + sprintf(file_addr, "%lx", addr); 96 + tftp_argv[1] = file_addr; 97 + 98 + int result = do_tftpb(&cmdtp, 0, fname ? 3 : 2, tftp_argv); 99 + 100 + if (result) 101 + return log_msg_ret("res", -ENOENT); 102 + 103 + return 0; 104 + } 105 + 106 + #endif