Commit 7a83af07aef3c924cfb2d36e68eea8b86d22f2a1

Authored by Luca Ceresoli
Committed by Wolfgang Denk
1 parent e59e35620a

TFTP: add tftpsrv command

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
Acked-by: Detlev Zundel <dzu@denx.de>

Showing 4 changed files with 26 additions and 2 deletions Side-by-side Diff

... ... @@ -709,6 +709,7 @@
709 709 (requires CONFIG_CMD_MEMORY)
710 710 CONFIG_CMD_SOURCE "source" command Support
711 711 CONFIG_CMD_SPI * SPI serial bus support
  712 + CONFIG_CMD_TFTPSRV * TFTP transfer in server mode
712 713 CONFIG_CMD_USB * USB support
713 714 CONFIG_CMD_VFD * VFD support (TRAB)
714 715 CONFIG_CMD_CDP * Cisco Discover Protocol support
... ... @@ -52,6 +52,23 @@
52 52 "[loadAddress] [[hostIPaddr:]bootfilename]"
53 53 );
54 54  
  55 +#ifdef CONFIG_CMD_TFTPSRV
  56 +static int do_tftpsrv(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
  57 +{
  58 + return netboot_common(TFTPSRV, cmdtp, argc, argv);
  59 +}
  60 +
  61 +U_BOOT_CMD(
  62 + tftpsrv, 2, 1, do_tftpsrv,
  63 + "act as a TFTP server and boot the first received file",
  64 + "[loadAddress]\n"
  65 + "Listen for an incoming TFTP transfer, receive a file and boot it.\n"
  66 + "The transfer is aborted if a transfer has not been started after\n"
  67 + "about 50 seconds or if Ctrl-C is pressed."
  68 +);
  69 +#endif
  70 +
  71 +
55 72 #ifdef CONFIG_CMD_RARP
56 73 int do_rarpb (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
57 74 {
... ... @@ -364,7 +364,8 @@
364 364 extern int NetRestartWrap; /* Tried all network devices */
365 365 #endif
366 366  
367   -typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP } proto_t;
  367 +typedef enum { BOOTP, RARP, ARP, TFTP, DHCP, PING, DNS, NFS, CDP, NETCONS, SNTP,
  368 + TFTPSRV } proto_t;
368 369  
369 370 /* from net/net.c */
370 371 extern char BootFile[128]; /* Boot File name */
... ... @@ -423,7 +423,11 @@
423 423 /* always use ARP to get server ethernet address */
424 424 TftpStart();
425 425 break;
426   -
  426 +#ifdef CONFIG_CMD_TFTPSRV
  427 + case TFTPSRV:
  428 + TftpStartServer();
  429 + break;
  430 +#endif
427 431 #if defined(CONFIG_CMD_DHCP)
428 432 case DHCP:
429 433 BootpTry = 0;
... ... @@ -1791,6 +1795,7 @@
1791 1795 /* Fall through */
1792 1796  
1793 1797 case NETCONS:
  1798 + case TFTPSRV:
1794 1799 if (NetOurIP == 0) {
1795 1800 puts("*** ERROR: `ipaddr' not set\n");
1796 1801 return 1;