From patchwork Mon Apr 18 16:19:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luca Ceresoli X-Patchwork-Id: 91801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id AB53AB6EEE for ; Tue, 19 Apr 2011 02:21:34 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1C5662826A; Mon, 18 Apr 2011 18:20:59 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id OWHXJy3101yb; Mon, 18 Apr 2011 18:20:58 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2C48428280; Mon, 18 Apr 2011 18:20:36 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3647C28213 for ; Mon, 18 Apr 2011 18:20:28 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id odmizFDLKnka for ; Mon, 18 Apr 2011 18:20:27 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from com-exc-01.comelit.it (mail.comelit.it [217.56.59.218]) by theia.denx.de (Postfix) with ESMTP id A6EE42825F for ; Mon, 18 Apr 2011 18:20:21 +0200 (CEST) Received: from wallace.comelit.it ([172.20.0.53]) by com-exc-01.comelit.it with Microsoft SMTPSVC(6.0.3790.4675); Mon, 18 Apr 2011 18:20:20 +0200 From: Luca Ceresoli To: u-boot@lists.denx.de Date: Mon, 18 Apr 2011 18:19:54 +0200 Message-Id: <1303143594-5345-7-git-send-email-luca.ceresoli@comelit.it> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1302796377-3321-1-git-send-email-luca.ceresoli@comelit.it> References: <1302796377-3321-1-git-send-email-luca.ceresoli@comelit.it> X-OriginalArrivalTime: 18 Apr 2011 16:20:20.0537 (UTC) FILETIME=[832DAA90:01CBFDE4] X-TM-AS-Product-Ver: SMEX-8.6.0.1168-6.500.1024-18080.006 X-TM-AS-Result: No--8.114200-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No Cc: Luca Ceresoli Subject: [U-Boot] [PATCH v2 6/6] TFTP: add tftpsrv command X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Signed-off-by: Luca Ceresoli Cc: Wolfgang Denk Acked-by: Detlev Zundel --- 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(-) 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);