Patchwork [U-Boot,v2,6/6] TFTP: add tftpsrv command

login
register
mail settings
Submitter Luca Ceresoli
Date April 18, 2011, 4:19 p.m.
Message ID <1303143594-5345-7-git-send-email-luca.ceresoli@comelit.it>
Download mbox | patch
Permalink /patch/91801/
State Superseded
Headers show

Comments

Luca Ceresoli - April 18, 2011, 4:19 p.m.
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
---
Changes in v2: none.

 README           |    1 +
 common/cmd_net.c |   14 ++++++++++++++
 include/net.h    |    3 ++-
 net/net.c        |   10 ++++++++--
 4 files changed, 25 insertions(+), 3 deletions(-)
Detlev Zundel - April 19, 2011, 2:39 p.m.
Hi Luca,

> Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
> Cc: Wolfgang Denk <wd@denx.de>
> ---
> Changes in v2: none.

Acked-by: Detlev Zundel <dzu@denx.de>
Mike Frysinger - April 30, 2011, 4:32 a.m.
On Monday, April 18, 2011 12:19:54 Luca Ceresoli wrote:
> +#ifdef CONFIG_CMD_TFTPSRV
> +int do_tftpsrv(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

should be static

> +U_BOOT_CMD(
> +	tftpsrv,	2,	1,	do_tftpsrv,
> +	"boot image via network acting as a TFTP server",
> +	"[loadAddress]"
> +);

the desc is a bit confusing.  how about:
	act as a TFTP server and boot the first received file
-mike
Mike Frysinger - May 4, 2011, 7:02 a.m.
On Mon, Apr 18, 2011 at 12:19, Luca Ceresoli wrote:
> +int do_tftpsrv(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

static
-mike

Patch

diff --git a/README b/README
index b9b0fcb..83dcb2a 100644
--- a/README
+++ b/README
@@ -685,6 +685,7 @@  The following options need to be configured:
 					  (requires CONFIG_CMD_MEMORY)
 		CONFIG_CMD_SOURCE	  "source" command Support
 		CONFIG_CMD_SPI		* SPI serial bus support
+		CONFIG_CMD_TFTPSRV	* TFTP transfer in server mode
 		CONFIG_CMD_USB		* USB support
 		CONFIG_CMD_VFD		* VFD support (TRAB)
 		CONFIG_CMD_CDP		* Cisco Discover Protocol support
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 8c6f5c8..053162a 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -52,6 +52,20 @@  U_BOOT_CMD(
 	"[loadAddress] [[hostIPaddr:]bootfilename]"
 );
 
+#ifdef CONFIG_CMD_TFTPSRV
+int do_tftpsrv(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	return netboot_common(TFTPSRV, cmdtp, argc, argv);
+}
+
+U_BOOT_CMD(
+	tftpsrv,	2,	1,	do_tftpsrv,
+	"boot image via network acting as a TFTP server",
+	"[loadAddress]"
+);
+#endif
+
+
 #ifdef CONFIG_CMD_RARP
 int do_rarpb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
diff --git a/include/net.h b/include/net.h
index 01f7159..018a744 100644
--- a/include/net.h
+++ b/include/net.h
@@ -364,7 +364,8 @@  extern int		NetState;		/* Network loop state		*/
 extern int		NetRestartWrap;		/* Tried all network devices	*/
 #endif
 
-typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP } proto_t;
+typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
+	       TFTPSRV } proto_t;
 
 /* from net/net.c */
 extern char	BootFile[128];			/* Boot File name		*/
diff --git a/net/net.c b/net/net.c
index 132f99b..17eb06f 100644
--- a/net/net.c
+++ b/net/net.c
@@ -388,7 +388,11 @@  restart:
 			/* always use ARP to get server ethernet address */
 			TftpStart();
 			break;
-
+#ifdef CONFIG_CMD_TFTPSRV
+		case TFTPSRV:
+			TftpStartServer();
+			break;
+#endif
 #if defined(CONFIG_CMD_DHCP)
 		case DHCP:
 			BootpTry = 0;
@@ -1731,7 +1735,9 @@  static int net_check_prereq (proto_t protocol)
 #if defined(CONFIG_CMD_PING) || defined(CONFIG_CMD_SNTP)
     common:
 #endif
-
+#ifdef CONFIG_CMD_TFTPSRV
+	case TFTPSRV:
+#endif
 		if (NetOurIP == 0) {
 			puts ("*** ERROR: `ipaddr' not set\n");
 			return (1);