public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Added a tftp command
@ 2009-03-31 22:44 kevin.morfitt at fearnside-systems.co.uk
  2009-03-31 23:01 ` Mike Frysinger
  2009-03-31 23:20 ` Kumar Gala
  0 siblings, 2 replies; 7+ messages in thread
From: kevin.morfitt at fearnside-systems.co.uk @ 2009-03-31 22:44 UTC (permalink / raw)
  To: u-boot

Adds a "tftp" command that gets a specified file from a TFTP Server and 
stores it in RAM at a specified RAM address. Most of the code already 
exists in board-specific form (eg in board/hymod) but this patch 
extracts it and makes it available as a standard u-boot command.

Signed-off-by: Kevin Morfitt <kevin.morfitt@fearnside-systems.co.uk>
---
 common/cmd_tftp.c            |   59 
++++++++++++++++++++++++++++++++++++++++++
 doc/README.tftp              |   29 ++++++++++++++++++++
 include/config_cmd_all.h     |    1 +
 include/config_cmd_default.h |    1 +
 4 files changed, 90 insertions(+), 0 deletions(-)
 create mode 100755 common/cmd_tftp.c
 create mode 100755 doc/README.tftp

diff --git a/common/cmd_tftp.c b/common/cmd_tftp.c
new file mode 100755
index 0000000..7aa5d0a
--- /dev/null
+++ b/common/cmd_tftp.c
@@ -0,0 +1,59 @@
+/*
+ * (C) Copyright 2009
+ * Kevin Morfitt, Fearnside Systems Ltd, 
<kevin.morfitt@fearnside-systems.co.uk>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <net.h>
+
+static int get_file_tftp(struct cmd_tbl_s *cmftp, int flag, int argc,
+            char *argv[]);
+
+U_BOOT_CMD(
+    tftp, 3, 0, get_file_tftp,
+    "tftp\t- Upload a file via TFTP",
+    "<address> <file name> - Upload <file name> to <address> via TFTP"
+);
+
+static int get_file_tftp(struct cmd_tbl_s *cmftp, int flag,
+            int argc, char *argv[])
+{
+    load_addr = simple_strtoul(argv[1], NULL, 16);
+    copy_filename(BootFile, argv[2], sizeof (BootFile));
+    NetBootFileXferSize = 0;
+
+    debug("TFTP: Filename: %s Address: 0x%08X\n", BootFile,
+        (unsigned int)load_addr);
+
+    if (NetLoop (TFTP) <= 0) {
+        printf("ERROR: tftp transfer failed\n");
+        return -1;
+    }
+
+    if (NetBootFileXferSize == 0) {
+        printf("ERROR: Can't determine file size\n");
+        return -1;
+    }
+
+    printf("File transfer succeeded - file size %lu bytes\n",
+        NetBootFileXferSize);
+    return 0;
+}
diff --git a/doc/README.tftp b/doc/README.tftp
new file mode 100755
index 0000000..d13603a
--- /dev/null
+++ b/doc/README.tftp
@@ -0,0 +1,29 @@
+Get a file from a TFTP server
+=============================
+
+Overview
+--------
+
+The "tftp" command allows a user retrieve a file from a TFTP server and 
store
+it in RAM. The RAM load address and the filename are passed via the 
command
+line and the TFTP server address is that defined by the "serverip" 
environment
+variable.
+
+Enabling the command
+--------------------
+
+The command is enabled in the build by the CONFIG_CMD_TFTP macro:
+
+#define CONFIG_CMD_TFTP        1
+
+Using the command
+-----------------
+
+The format of the command is:
+
+    tftp <address> <file name>
+
+where:
+
+    <address> is the address of the RAM buffer used to receive the file
+    <file name> is the name of the file to be retrieved via tftp
diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h
index db1f55c..a7129d4 100644
--- a/include/config_cmd_all.h
+++ b/include/config_cmd_all.h
@@ -78,6 +78,7 @@
 #define CONFIG_CMD_SNTP        /* SNTP support            */
 #define CONFIG_CMD_SPI        /* SPI utility            */
 #define CONFIG_CMD_TERMINAL    /* built-in Serial Terminal    */
+#define CONFIG_CMD_TFTP        /* Get file via TFTP        */
 #define CONFIG_CMD_UNIVERSE    /* Tundra Universe Support    */
 #define CONFIG_CMD_UNZIP    /* unzip from memory to memory    */
 #define CONFIG_CMD_USB        /* USB Support            */
diff --git a/include/config_cmd_default.h b/include/config_cmd_default.h
index 3667602..cee6a1c 100644
--- a/include/config_cmd_default.h
+++ b/include/config_cmd_default.h
@@ -37,6 +37,7 @@
 #define CONFIG_CMD_NFS        /* NFS support            */
 #define CONFIG_CMD_RUN        /* run command in env variable    */
 #define CONFIG_CMD_SETGETDCR    /* DCR support on 4xx        */
+#define CONFIG_CMD_TFTP        /* Get file via TFTP        */
 #define CONFIG_CMD_XIMG        /* Load part of Multi Image    */
 
 #endif    /* _CONFIG_CMD_DEFAULT_H */
-- 
1.6.0.6

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH] Added a tftp command
  2009-03-31 22:44 [U-Boot] [PATCH] Added a tftp command kevin.morfitt at fearnside-systems.co.uk
@ 2009-03-31 23:01 ` Mike Frysinger
  2009-03-31 23:40   ` kevin.morfitt at fearnside-systems.co.uk
  2009-03-31 23:20 ` Kumar Gala
  1 sibling, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2009-03-31 23:01 UTC (permalink / raw)
  To: u-boot

On Tuesday 31 March 2009 18:44:21 kevin.morfitt at fearnside-systems.co.uk wrote:
> Adds a "tftp" command that gets a specified file from a TFTP Server and
> stores it in RAM at a specified RAM address. Most of the code already
> exists in board-specific form (eg in board/hymod) but this patch
> extracts it and makes it available as a standard u-boot command.

your patch is horribly word wrapped.  ignoring that, how is this any different 
from the "tftpboot" command ?  i use "t <addr> <file>" to load arbitrary files 
via tftp to arbitrary addresses all the time.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090331/17106b95/attachment.pgp 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH] Added a tftp command
  2009-03-31 22:44 [U-Boot] [PATCH] Added a tftp command kevin.morfitt at fearnside-systems.co.uk
  2009-03-31 23:01 ` Mike Frysinger
@ 2009-03-31 23:20 ` Kumar Gala
  2009-03-31 23:47   ` kevin.morfitt at fearnside-systems.co.uk
  1 sibling, 1 reply; 7+ messages in thread
From: Kumar Gala @ 2009-03-31 23:20 UTC (permalink / raw)
  To: u-boot


On Mar 31, 2009, at 5:44 PM, kevin.morfitt at fearnside-systems.co.uk  
wrote:

> Adds a "tftp" command that gets a specified file from a TFTP Server  
> and
> stores it in RAM at a specified RAM address. Most of the code already
> exists in board-specific form (eg in board/hymod) but this patch
> extracts it and makes it available as a standard u-boot command.
>
> Signed-off-by: Kevin Morfitt <kevin.morfitt@fearnside-systems.co.uk>
> ---
> common/cmd_tftp.c            |   59
> ++++++++++++++++++++++++++++++++++++++++++
> doc/README.tftp              |   29 ++++++++++++++++++++
> include/config_cmd_all.h     |    1 +
> include/config_cmd_default.h |    1 +
> 4 files changed, 90 insertions(+), 0 deletions(-)
> create mode 100755 common/cmd_tftp.c
> create mode 100755 doc/README.tftp

I'm quite confused.  We already have support for this.  I'm pretty  
sure I use it almost daily.

- k

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH] Added a tftp command
  2009-03-31 23:01 ` Mike Frysinger
@ 2009-03-31 23:40   ` kevin.morfitt at fearnside-systems.co.uk
  2009-03-31 23:48     ` Mike Frysinger
  0 siblings, 1 reply; 7+ messages in thread
From: kevin.morfitt at fearnside-systems.co.uk @ 2009-03-31 23:40 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> On Tuesday 31 March 2009 18:44:21 kevin.morfitt at fearnside-systems.co.uk wrote:
>   
>> Adds a "tftp" command that gets a specified file from a TFTP Server and
>> stores it in RAM at a specified RAM address. Most of the code already
>> exists in board-specific form (eg in board/hymod) but this patch
>> extracts it and makes it available as a standard u-boot command.
>>     
>
> your patch is horribly word wrapped.  ignoring that, how is this any different 
> from the "tftpboot" command ?  i use "t <addr> <file>" to load arbitrary files 
> via tftp to arbitrary addresses all the time.
> -mike
>   
"tftpboot" loads the file then if "autostart" is "yes" it automatically 
boots from the load address. The patch just loads the file then stops. 
When programming a board I use it to copy images across before I program 
them into flash. In effect, it does the same thing as setting 
"autostart" to "off" then using "tftpboot".

I'm new to creating patches which I think explains the horrible word 
wrapping.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH] Added a tftp command
  2009-03-31 23:20 ` Kumar Gala
@ 2009-03-31 23:47   ` kevin.morfitt at fearnside-systems.co.uk
  0 siblings, 0 replies; 7+ messages in thread
From: kevin.morfitt at fearnside-systems.co.uk @ 2009-03-31 23:47 UTC (permalink / raw)
  To: u-boot

Kumar Gala wrote:
>
> On Mar 31, 2009, at 5:44 PM, kevin.morfitt at fearnside-systems.co.uk wrote:
>
>> Adds a "tftp" command that gets a specified file from a TFTP Server and
>> stores it in RAM at a specified RAM address. Most of the code already
>> exists in board-specific form (eg in board/hymod) but this patch
>> extracts it and makes it available as a standard u-boot command.
>>
>> Signed-off-by: Kevin Morfitt <kevin.morfitt@fearnside-systems.co.uk>
>> ---
>> common/cmd_tftp.c            |   59
>> ++++++++++++++++++++++++++++++++++++++++++
>> doc/README.tftp              |   29 ++++++++++++++++++++
>> include/config_cmd_all.h     |    1 +
>> include/config_cmd_default.h |    1 +
>> 4 files changed, 90 insertions(+), 0 deletions(-)
>> create mode 100755 common/cmd_tftp.c
>> create mode 100755 doc/README.tftp
>
> I'm quite confused.  We already have support for this.  I'm pretty 
> sure I use it almost daily.
>
> - k
So do I but I'm working with a u-boot my customer has modified to add it 
as a board-specific command. When I tried to use it on a new board with 
the latest u-boot  I found it wasn't a standard u-boot command. It's 
almost identical to "tftpboot" except that if "autostart" is set to 
"yes" "tftpboot" automatically boots from the file after it's downloaded 
it but "tftp" doesn't. I use it to copy images across then manually 
program them into flash.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH] Added a tftp command
  2009-03-31 23:40   ` kevin.morfitt at fearnside-systems.co.uk
@ 2009-03-31 23:48     ` Mike Frysinger
  2009-04-01  4:39       ` Ben Warren
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Frysinger @ 2009-03-31 23:48 UTC (permalink / raw)
  To: u-boot

On Tuesday 31 March 2009 19:40:27 kevin.morfitt at fearnside-systems.co.uk wrote:
> Mike Frysinger wrote:
> > On Tuesday 31 March 2009 18:44:21 kevin.morfitt wrote:
> >> Adds a "tftp" command that gets a specified file from a TFTP Server and
> >> stores it in RAM at a specified RAM address. Most of the code already
> >> exists in board-specific form (eg in board/hymod) but this patch
> >> extracts it and makes it available as a standard u-boot command.
> >
> > your patch is horribly word wrapped.  ignoring that, how is this any
> > different from the "tftpboot" command ?  i use "t <addr> <file>" to load
> > arbitrary files via tftp to arbitrary addresses all the time.
>
> "tftpboot" loads the file then if "autostart" is "yes" it automatically
> boots from the load address. The patch just loads the file then stops.
> When programming a board I use it to copy images across before I program
> them into flash. In effect, it does the same thing as setting
> "autostart" to "off" then using "tftpboot".

so dont set autostart ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090331/adf44aaa/attachment-0001.pgp 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH] Added a tftp command
  2009-03-31 23:48     ` Mike Frysinger
@ 2009-04-01  4:39       ` Ben Warren
  0 siblings, 0 replies; 7+ messages in thread
From: Ben Warren @ 2009-04-01  4:39 UTC (permalink / raw)
  To: u-boot

Mike Frysinger wrote:
> On Tuesday 31 March 2009 19:40:27 kevin.morfitt at fearnside-systems.co.uk wrote:
>   
>> Mike Frysinger wrote:
>>     
>>> On Tuesday 31 March 2009 18:44:21 kevin.morfitt wrote:
>>>       
>>>> Adds a "tftp" command that gets a specified file from a TFTP Server and
>>>> stores it in RAM at a specified RAM address. Most of the code already
>>>> exists in board-specific form (eg in board/hymod) but this patch
>>>> extracts it and makes it available as a standard u-boot command.
>>>>         
>>> your patch is horribly word wrapped.  ignoring that, how is this any
>>> different from the "tftpboot" command ?  i use "t <addr> <file>" to load
>>> arbitrary files via tftp to arbitrary addresses all the time.
>>>       
>> "tftpboot" loads the file then if "autostart" is "yes" it automatically
>> boots from the load address. The patch just loads the file then stops.
>> When programming a board I use it to copy images across before I program
>> them into flash. In effect, it does the same thing as setting
>> "autostart" to "off" then using "tftpboot".
>>     
>
> so dont set autostart ?
> -mike
>   
>   
Yeah, seriously.  Just script it.

regards,
Ben

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2009-04-01  4:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-31 22:44 [U-Boot] [PATCH] Added a tftp command kevin.morfitt at fearnside-systems.co.uk
2009-03-31 23:01 ` Mike Frysinger
2009-03-31 23:40   ` kevin.morfitt at fearnside-systems.co.uk
2009-03-31 23:48     ` Mike Frysinger
2009-04-01  4:39       ` Ben Warren
2009-03-31 23:20 ` Kumar Gala
2009-03-31 23:47   ` kevin.morfitt at fearnside-systems.co.uk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox