[U-Boot] [PATCH 7/8] dfu: command: Provide support for 'dfutftp' command to handle receiving data via TFTP

Lukasz Majewski l.majewski at majess.pl
Sun Jul 12 17:30:43 CEST 2015


The new 'dfutftp' command has syntax similar to 'dfu' command.
This new command however, requires some extra env variables to allow
update_tftp() code to work properly. For more explanation, please consult
./doc/README.dfutftp

Signed-off-by: Lukasz Majewski <l.majewski at majess.pl>
---
 common/Makefile      |  1 +
 common/cmd_dfutftp.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 common/cmd_dfutftp.c

diff --git a/common/Makefile b/common/Makefile
index d6c1d48..483905c 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -211,6 +211,7 @@ obj-$(CONFIG_UPDATE_TFTP) += update.o
 obj-$(CONFIG_USB_KEYBOARD) += usb_kbd.o
 obj-$(CONFIG_CMD_DFU) += cmd_dfu.o
 obj-$(CONFIG_CMD_GPT) += cmd_gpt.o
+obj-$(CONFIG_CMD_DFUTFTP) += cmd_dfutftp.o
 
 # Power
 obj-$(CONFIG_CMD_PMIC) += cmd_pmic.o
diff --git a/common/cmd_dfutftp.c b/common/cmd_dfutftp.c
new file mode 100644
index 0000000..2b75a09
--- /dev/null
+++ b/common/cmd_dfutftp.c
@@ -0,0 +1,43 @@
+/*
+ * cmd_dfutftp.c -- dfutftp command
+ *
+ * Copyright (C) 2015
+ * Lukasz Majewski <l.majewski at majess.pl>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <net.h>
+
+static
+int do_dfutftp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	unsigned long addr = 0;
+
+	if (argc < 4 || argc > 5)
+		return CMD_RET_USAGE;
+
+	char *interface = argv[2];
+	char *devstring = argv[3];
+
+	if (argc == 5)
+		addr = simple_strtoul(argv[4], NULL, 0);
+
+	/* Below env variables are descibed in detail at ./doc/README.dfutftp */
+	setenv("update_tftp_exec_at_boot", "true");
+	setenv("update_tftp_dfu", "true");
+	setenv("update_tftp_dfu_interface", interface);
+	setenv("update_tftp_dfu_devstring", devstring);
+
+	return update_tftp(addr);
+}
+
+U_BOOT_CMD(dfutftp, CONFIG_SYS_MAXARGS, 1, do_dfutftp,
+	   "Device Firmware Upgrade via TFTP",
+	   "<ETH_controller> <interface> <dev>\n"
+	   "  - device firmware upgrade via <ETH_controller>\n"
+	   "    using TFTP protocol on device <dev>, attached\n"
+	   "    to interface <interface>\n"
+	   "    [addr] - address where FIT image has been stored\n"
+);
-- 
2.1.4



More information about the U-Boot mailing list