]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
TFTP: add tftpsrv command
authorLuca Ceresoli <luca.ceresoli@comelit.it>
Tue, 17 May 2011 00:03:40 +0000 (00:03 +0000)
committerWolfgang Denk <wd@denx.de>
Thu, 19 May 2011 19:38:32 +0000 (21:38 +0200)
Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>
README
common/cmd_net.c
include/net.h
net/net.c

diff --git a/README b/README
index 6f3748d6dc4c2a8d4ce491d92420acffa9e42d36..ed73981b94817bfb434d1de245a8b014823ab223 100644 (file)
--- a/README
+++ b/README
@@ -709,6 +709,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
index 8c6f5c8c3dd29d57c65bb896581708c44746d415..b2c9355a21abe2db2622b03be5a0b9a8b87370fd 100644 (file)
@@ -52,6 +52,23 @@ U_BOOT_CMD(
        "[loadAddress] [[hostIPaddr:]bootfilename]"
 );
 
+#ifdef CONFIG_CMD_TFTPSRV
+static 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,
+       "act as a TFTP server and boot the first received file",
+       "[loadAddress]\n"
+       "Listen for an incoming TFTP transfer, receive a file and boot it.\n"
+       "The transfer is aborted if a transfer has not been started after\n"
+       "about 50 seconds or if Ctrl-C is pressed."
+);
+#endif
+
+
 #ifdef CONFIG_CMD_RARP
 int do_rarpb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
index 01f7159a0781aae480d55d1fc3373e6197c12b9e..018a74402c8357f55e3c63777cb49be4514ccd78 100644 (file)
@@ -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               */
index 2abf87929b935d62ebabde49093af9c0ee6c5fc2..7a93542122cb14be38c276e3d4a23d8cc1d8b91a 100644 (file)
--- a/net/net.c
+++ b/net/net.c
@@ -423,7 +423,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;
@@ -1791,6 +1795,7 @@ common:
                /* Fall through */
 
        case NETCONS:
+       case TFTPSRV:
                if (NetOurIP == 0) {
                        puts("*** ERROR: `ipaddr' not set\n");
                        return 1;