[U-Boot] [PATCH v2 7/9] dfu: command: Extend "dfu" command to handle receiving data via TFTP

Lukasz Majewski l.majewski at majess.pl
Sat Jul 25 10:11:15 CEST 2015


The "dfu" command has been extended to support transfers via TFTP protocol.

Signed-off-by: Lukasz Majewski <l.majewski at majess.pl>
---
Changes for v2:
- Remove "dfutftp" command
- Modify "dfu" command to support optional [tftp] parameter
- Only one flag (CONFIG_DFU_TFTP) needs to be enabled
---
 common/cmd_dfu.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
index 857148f..aea466b 100644
--- a/common/cmd_dfu.c
+++ b/common/cmd_dfu.c
@@ -1,6 +1,9 @@
 /*
  * cmd_dfu.c -- dfu command
  *
+ * Copyright (C) 2015
+ * Lukasz Majewski <l.majewski at majess.pl>
+ *
  * Copyright (C) 2012 Samsung Electronics
  * authors: Andrzej Pietrasiewicz <andrzej.p at samsung.com>
  *	    Lukasz Majewski <l.majewski at samsung.com>
@@ -13,6 +16,9 @@
 #include <dfu.h>
 #include <g_dnl.h>
 #include <usb.h>
+#ifdef CONFIG_DFU_TFTP
+#include <net.h>
+#endif
 
 static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
@@ -26,7 +32,18 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	char *devstring = argv[3];
 
 	int ret, i = 0;
+#ifdef CONFIG_DFU_TFTP
+	unsigned long addr = 0;
+	if (!strcmp(usb_controller, "tftp")) {
+		usb_controller = argv[2];
+		interface = argv[3];
+		devstring = argv[4];
+		if (argc == 6)
+			addr = simple_strtoul(argv[5], NULL, 0);
 
+		return update_tftp(addr, interface, devstring);
+	}
+#endif
 	ret = dfu_init_env_entities(interface, devstring);
 	if (ret)
 		goto done;
@@ -84,9 +101,17 @@ done:
 
 U_BOOT_CMD(dfu, CONFIG_SYS_MAXARGS, 1, do_dfu,
 	"Device Firmware Upgrade",
+#ifdef CONFIG_DFU_TFTP
+	"[tftp] <USB_controller> <interface> <dev> [list] [addr]\n"
+#else
 	"<USB_controller> <interface> <dev> [list]\n"
+#endif
 	"  - device firmware upgrade via <USB_controller>\n"
 	"    on device <dev>, attached to interface\n"
 	"    <interface>\n"
 	"    [list] - list available alt settings\n"
+#ifdef CONFIG_DFU_TFTP
+	"    [tftp] - use TFTP protocol to download data\n"
+	"    [addr] - address where FIT image has been stored\n"
+#endif
 );
-- 
2.1.4



More information about the U-Boot mailing list