Added a tftp command
PATCH 1/1 Added a tftp command
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.
--- 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
common/cmd_tftp.c new file +3 -0
@@ -0,0 +1,59 @@ +/* +* (C) Copyright 2009 +* Kevin Morfitt, Fearnside Systems Ltd,
<[email protected]>
+ *
+ * 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;
+}
doc/README.tftp new file +7 -0
@@ -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
include/config_cmd_all.h +1 -0
@@ -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 */
include/config_cmd_default.h +1 -0
@@ -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 */
Signature · 1 line
1.6.0.6
PATCH 1/1 Added a tftp command
Quoted 4 lines · On Tuesday 31 March 2009 18:44:21 kevin.morfitt at fearnside-systems.co.uk…
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
PATCH 1/1 Added a tftp command
In reply to kevin.morfitt at fearnside-systems.co.ukQuoted 10 lines · kevin.morfitt at fearnside-systems.co.uk
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 <[email protected]>---
common/cmd_tftp.c| 59
++++++++++++++++++++++++++++++++++++++++++
Quoted 6 lines
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
PATCH 1/1 Added a tftp command
In reply to Mike FrysingerQuoted 8 lines · Mike Frysinger
Quoted 5 lines · On Tuesday 31 March 2009 18:44:21 kevin.morfitt at fearnside-systems.co.uk…
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.
Quoted 5 lines
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.
PATCH 1/1 Added a tftp command
In reply to Kumar GalaQuoted 19 lines · Kumar Gala
Quoted 9 lines · kevin.morfitt at fearnside-systems.co.uk
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 <[email protected]>---
common/cmd_tftp.c| 59
++++++++++++++++++++++++++++++++++++++++++Quoted 6 lines
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
Quoted 4 lines
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.
PATCH 1/1 Added a tftp command
In reply to kevin.morfitt at fearnside-systems.co.ukQuoted 11 lines · On Tuesday 31 March 2009 19:40:27 kevin.morfitt at fearnside-systems.co.uk…
Quoted 9 lines · Mike Frysinger
Quoted 4 lines · 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.
Quoted 5 lines
"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
PATCH 1/1 Added a tftp command
Quoted 22 lines · Mike Frysinger
Quoted 13 lines · On Tuesday 31 March 2009 19:40:27 kevin.morfitt at fearnside-systems.co.uk…
Quoted 11 lines · Mike Frysinger
Quoted 5 lines · 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.
Quoted 6 lines
"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".
Quoted 4 lines
so dont set autostart ?
-mike
Yeah, seriously. Just script it.
regards,
Ben