Patchwork [U-Boot,8/8] tftpput: add tftpput command

login
register
mail settings
Submitter Simon Glass
Date Oct. 22, 2011, 4:51 a.m.
Message ID <1319259100-11376-9-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/121138/
State New, archived
Headers show

Comments

Simon Glass - Oct. 22, 2011, 4:51 a.m.
This adds a command to start a tftp put transfer.

Signed-off-by: Simon Glass <sjg@chromium.org>
---
 common/cmd_net.c         |   23 +++++++++++++++++++++++
 include/config_cmd_all.h |    1 +
 2 files changed, 24 insertions(+), 0 deletions(-)

Patch

diff --git a/common/cmd_net.c b/common/cmd_net.c
index f610385..f89a24b 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -52,6 +52,22 @@  U_BOOT_CMD(
 	"[loadAddress] [[hostIPaddr:]bootfilename]"
 );
 
+#ifdef CONFIG_CMD_TFTPPUT
+int do_tftpput(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	int ret;
+
+	ret = netboot_common(TFTPPUT, cmdtp, argc, argv);
+	return ret;
+}
+
+U_BOOT_CMD(
+	tftpput,	4,	1,	do_tftpput,
+	"TFTP put command, for uploading files to a server",
+	"Address Size [[hostIPaddr:]filename]"
+);
+#endif
+
 #ifdef CONFIG_CMD_TFTPSRV
 static int do_tftpsrv(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
 {
@@ -203,6 +219,13 @@  static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
 
 		break;
 
+#ifdef CONFIG_CMD_TFTPPUT
+	case 4:
+		save_addr = strict_strtoul(argv[1], NULL, 16);
+		save_size = strict_strtoul(argv[2], NULL, 16);
+		copy_filename(BootFile, argv[3], sizeof(BootFile));
+		break;
+#endif
 	default:
 		show_boot_progress (-80);
 		return cmd_usage(cmdtp);
diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h
index 9716f9c..7fa8661 100644
--- a/include/config_cmd_all.h
+++ b/include/config_cmd_all.h
@@ -82,6 +82,7 @@ 
 #define CONFIG_CMD_SOURCE	/* "source" command support	*/
 #define CONFIG_CMD_SPI		/* SPI utility			*/
 #define CONFIG_CMD_TERMINAL	/* built-in Serial Terminal	*/
+#define CONFIG_CMD_TFTPPUT	/* TFTP upload			*/
 #define CONFIG_CMD_UBI		/* UBI Support			*/
 #define CONFIG_CMD_UBIFS	/* UBIFS Support		*/
 #define CONFIG_CMD_UNIVERSE	/* Tundra Universe Support	*/