Commit 8b7cc5c6 authored by Guillaume Tucker's avatar Guillaume Tucker Committed by Ricardo Cañuelo Navarro
Browse files

cli: tftpboot: enable DHCP for TFTP IP and boot image



Allow the special value "dhcp" for the TFTP server IP address and the
boot image path arguments to send DHCP requests rather than using
static values.

BUG=none
BRANCH=master
TEST=flash netboot, configure DHCP server, tftpboot dhcp dhcp cmdline.txt

Change-Id: I9f5f3c2df80bbabd9e289ef43e51373a0f53f2c8
Signed-off-by: Guillaume Tucker's avatarGuillaume Tucker <guillaume.tucker@collabora.com>
Reviewed-on: https://chromium-review.googlesource.com/893185


Commit-Ready: Guillaume Tucker <guillaume.tucker@gmail.com>
Tested-by: default avatarGuillaume Tucker <guillaume.tucker@gmail.com>
Reviewed-by: default avatarJulius Werner <jwerner@chromium.org>
parent d4420e70
......@@ -28,26 +28,33 @@
static void * const payload = (void *)(uintptr_t)CONFIG_KERNEL_START;
static const char DHCP[] = "dhcp";
int do_tftpboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
char *address;
char *bootfile;
char *argsfile;
uip_ipaddr_t tftp_ip;
uip_ipaddr_t *tftp_ip_arg;
if (argc != 4)
return CMD_RET_USAGE;
address = argv[1];
bootfile = argv[2];
bootfile = (!strcmp(argv[2], DHCP)) ? NULL : argv[2];
argsfile = argv[3];
if (!uiplib_ipaddrconv(address, &tftp_ip)) {
if (!strcmp(address, DHCP)) {
tftp_ip_arg = NULL;
} else if (!uiplib_ipaddrconv(address, &tftp_ip)) {
printf("Invalid IPv4 address: %s\n", address);
return CMD_RET_USAGE;
} else {
tftp_ip_arg = &tftp_ip;
}
netboot(&tftp_ip, bootfile, argsfile, NULL);
netboot(tftp_ip_arg, bootfile, argsfile, NULL);
/* netboot() only returns if it failed */
......@@ -57,5 +64,8 @@ int do_tftpboot(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
U_BOOT_CMD(
tftpboot, 4, 1,
"boot image via network using TFTP protocol",
"[host IP addr] [boot file] [args file]"
"[host IP addr] [boot file] [args file]\n"
"\n"
"The IP address and boot file can take the \"dhcp\" special value\n"
"to send DHCP requests rather than using static values."
);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment