[U-Boot-Users] Adding a number of options to control the user feedback during a TFTP operation

Jon Diekema jon.diekema at smiths-aerospace.com
Wed Oct 15 03:03:37 CEST 2003


Product:
                                                                                                                 
- u-boot
                                                                                                                 
Version:
                                                                                                                 
- 1.0.0-pre
                                                                                                                 
CHANGELOG:
                                                                                                                 
- Adding a number of options to control the user feedback during a TFTP
operation:
      CFG_TFTP_BLINK_STATUS_ON_DATA_IN
      CFG_TFTP_BLOCKS_PER_HASH
      CFG_TFTP_HASHES_PER_FLASH
      CFG_TFTP_HASHES_PER_LINE
      CFG_TFTP_PROGESS_QUIET
      CFG_TFTP_TIMEOUT_COUNT
                                                                                                                 
Patched files:
                                                                                                                 
- README
- net/tftp.c


------------------\\----------------------\\----------------------------
Jon Diekema        |                       | Smiths Aerospace
(616) 241-8310     |                       | 3290 Patterson Avenue, SE
 jon.diekema at smiths-aerospace.com          \\  Grand Rapids, MI 49512

******************************************
The information contained in, or attached to, this e-mail, may contain confidential information and is intended solely for the use of the individual or entity to whom they are addressed and may be subject to legal privilege.  If you have received this e-mail in error you should notify the sender immediately by reply e-mail, delete the message from your system and notify your system manager.  Please do not copy it for any purpose, or disclose its contents to any other person.  The views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company.  The recipient should check this e-mail and any attachments for the presence of viruses.  The company accepts no liability for any damage caused, directly or indirectly, by any virus transmitted in this email.
******************************************
-------------- next part --------------
Product:

- u-boot

Version:

- 1.0.0-pre

CHANGELOG:

- Adding a number of options to control the user feedback during a TFTP operation:
      CFG_TFTP_BLINK_STATUS_ON_DATA_IN
      CFG_TFTP_BLOCKS_PER_HASH
      CFG_TFTP_HASHES_PER_FLASH
      CFG_TFTP_HASHES_PER_LINE
      CFG_TFTP_PROGESS_QUIET
      CFG_TFTP_TIMEOUT_COUNT

CVS Comments:

- Adding a number of options to control the user feedback during a TFTP operation:
      CFG_TFTP_BLINK_STATUS_ON_DATA_IN
      CFG_TFTP_BLOCKS_PER_HASH
      CFG_TFTP_HASHES_PER_FLASH
      CFG_TFTP_HASHES_PER_LINE
      CFG_TFTP_PROGESS_QUIET
      CFG_TFTP_TIMEOUT_COUNT

Patched files:

- README
- net/tftp.c


--- README       2003-10-14 07:12:06.000000000 -0400
+++ README       2003-10-14 20:50:25.000000000 -0400
@@ -1765,6 +1769,32 @@ use the "saveenv" command to store a val
 - CFG_FAULT_MII_ADDR:
                MII address of the PHY to check for the Ethernet link state.
  
+- CFG_TFTP_BLINK_STATUS_ON_DATA_IN
+                Blink or toggle the status LED based on incoming data.
+
+- CFG_TFTP_BLOCKS_PER_HASH:
+                For every XX blocks, output a '#' to signify that the
+               tftp command is making progress on the file transfer.
+               The default value is 10.
+
+- CFG_TFTP_HASHES_PER_FLASH:
+                For every '#' hashes, flash the status LED.
+               The default value is 200.
+
+- CFG_TFTP_HASHES_PER_LINE:
+               Only output XX '#'s per line during the tftp file transfer.
+               The default value is 65.
+
+- CFG_TFTP_PROGESS_QUIET:
+                Suppress the progress displays '#'s from the tftp
+               command based on the quiet environment variable.
+
+- CFG_TFTP_TIMEOUT_COUNT:
+               This variable defines how many timeouts TFTP will
+               allow before it gives up.  If this isn't defined, then
+               the value of 2 * CONFIG_NET_RETRY_COUNT is used instead.
+
+
 Low Level (hardware related) configuration options:
 ---------------------------------------------------
  

--- net/tftp.c	2003-10-14 07:12:13.000000000 -0400
+++ net/tftp.c	2003-10-14 18:35:44.000000000 -0400
@@ -9,20 +9,38 @@
 #include <net.h>
 #include "tftp.h"
 #include "bootp.h"
+#include "console.h"
+
+#ifdef CONFIG_STATUS_LED
+#include <status_led.h>
+#endif
 
 #undef	ET_DEBUG
 
 #if (CONFIG_COMMANDS & CFG_CMD_NET)
 
 #define WELL_KNOWN_PORT	69		/* Well known TFTP port #		*/
-#define TIMEOUT		5		/* Seconds to timeout for a lost pkt	*/
-#ifndef	CONFIG_NET_RETRY_COUNT
-# define TIMEOUT_COUNT	10		/* # of timeouts before giving up  */
+#define TIMEOUT		2		/* Seconds to timeout for a lost pkt	*/
+
+#ifdef CFG_TFTP_TIMEOUT_COUNT           /* # of timeouts before giving up       */
+#   define TIMEOUT_COUNT CFG_TFTP_TIMEOUT_COUNT 
 #else
-# define TIMEOUT_COUNT  (CONFIG_NET_RETRY_COUNT * 2)
+#   ifndef CONFIG_NET_RETRY_COUNT
+#       define TIMEOUT_COUNT	10	/* # of timeouts before giving up       */
+#   else
+#       define TIMEOUT_COUNT    (CONFIG_NET_RETRY_COUNT * 2)
+#   endif                               /* # of timeouts before giving up       */
+#endif /* CFG_TFTP_TIMEOUT_COUNT */
+
+#ifndef CFG_TFTP_HASHES_PER_LINE
+#define CFG_TFTP_HASHES_PER_LINE 65     /* Number of '#' hashes per line 	*/
+#endif
+#ifndef CFG_TFTP_BLOCKS_PER_HASH
+#define CFG_TFTP_BLOCKS_PER_HASH 10     /* For every XX blocks, output a '#'    */
+#endif
+#ifndef CFG_TFTP_HASHES_PER_FLASH       /* For every '#' hashes, flash the      */
+#define CFG_TFTP_HASHES_PER_FLASH 200   /* status LED                           */ 
 #endif
-					/* (for checking the image size)	*/
-#define HASHES_PER_LINE	65		/* Number of "loading" hashes per line	*/
 
 /*
  *	TFTP operations.
@@ -196,9 +214,28 @@ TftpHandler (uchar * pkt, unsigned dest,
 			return;
 		len -= 2;
 		TftpBlock = ntohs(*(ushort *)pkt);
-		if (((TftpBlock - 1) % 10) == 0) {
+		if (((TftpBlock - 1) % CFG_TFTP_BLOCKS_PER_HASH) == 0) {
+#ifdef CFG_TFTP_PROGESS_QUIET
+		        if (!is_console_quiet())
+#endif
 			putc ('#');
-		} else if ((TftpBlock % (10 * HASHES_PER_LINE)) == 0) {
+#ifdef CFG_TFTP_BLINK_STATUS_ON_DATA_IN
+#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
+ 			/*
+			 * Blink the status LED based on incoming data
+			 */
+ 			if (((TftpBlock - 1) % CFG_TFTP_HASHES_PER_FLASH) == 0) {
+ 				status_led_set(STATUS_LED_BOOT, STATUS_LED_ON);
+ 			} else {
+ 				status_led_set(STATUS_LED_BOOT, STATUS_LED_OFF);
+ 			}
+#endif
+#endif /* CFG_TFTP_BLINK_STATUS_ON_DATA_IN */
+		} else if ((TftpBlock % 
+			   (CFG_TFTP_BLOCKS_PER_HASH * CFG_TFTP_HASHES_PER_LINE)) == 0) {
+#ifdef CFG_TFTP_PROGESS_QUIET
+		        if (!is_console_quiet())
+#endif
 			puts ("\n\t ");
 		}
 
@@ -264,6 +301,15 @@ TftpHandler (uchar * pkt, unsigned dest,
 static void
 TftpTimeout (void)
 {
+#ifdef CFG_TFTP_BLINK_STATUS_ON_DATA_IN
+#if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT)
+	/* 
+	 * Restore the blinking behavior on timeout 
+	 */
+	status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING);
+#endif
+#endif /* CFG_TFTP_BLINK_STATUS_ON_DATA_IN */
+
 	if (++TftpTimeoutCount > TIMEOUT_COUNT) {
 		puts ("\nRetry count exceeded; starting again\n");
 		NetStartAgain ();
@@ -294,6 +340,9 @@ TftpStart (void)
 		tftp_filename = BootFile;
 	}
 
+#ifdef CFG_TFTP_STATUS_QUIET
+	if (!is_console_quiet()) {
+#endif
 	puts ("TFTP from server ");	print_IPaddr (NetServerIP);
 	puts ("; our IP address is ");	print_IPaddr (NetOurIP);
 
@@ -319,7 +368,13 @@ TftpStart (void)
 	putc ('\n');
 
 	printf ("Load address: 0x%lx\n", load_addr);
+#ifdef CFG_TFTP_STATUS_QUIET
+	}
+#endif
 
+#ifdef CFG_TFTP_PROGESS_QUIET
+	if (!is_console_quiet())
+#endif
 	puts ("Loading: *\b");
 
 	NetSetTimeout (TIMEOUT * CFG_HZ, TftpTimeout);




More information about the U-Boot mailing list