On Thu 13 Aug 2009 18:01, Wolfgang Denk pondered: > Dear Robin Getz, > In message <200908131747.20194.rg...@blackfin.uclinux.org> you wrote: > > The better thing to do (IMHO) - would be to print out the proper number of > > hashes, depending on the size of the file (and implement RFC 2349 at the > > same > > time) - not the number of packets (which is what happens today)... > > Agreed. Patches welcome!
Something like this? - If turned on (CONFIG_TFTP_TSIZE), asks for the size of the file. - if receives the file size, prints out the percentage of the file downloaded. - when done, prints 100% - if it doesn't receive the file size (the server doesn't support RFC 2349, prints standard hash marks. Comments welcome... diff --git a/net/tftp.c b/net/tftp.c index 9544691..56db247 100644 --- a/net/tftp.c +++ b/net/tftp.c @@ -66,6 +66,9 @@ static ulong TftpLastBlock; /* last packet sequence number received */ static ulong TftpBlockWrap; /* count of sequence number wraparounds */ static ulong TftpBlockWrapOffset; /* memory offset due to wrapping */ static int TftpState; +#ifdef CONFIG_TFTP_TSIZE +static int TftpTsize; /* Tsize */ +#endif #define STATE_RRQ 1 #define STATE_DATA 2 @@ -212,6 +215,10 @@ TftpSend (void) sprintf((char *)pkt, "%lu", TIMEOUT / 1000); debug("send option \"timeout %s\"\n", (char *)pkt); pkt += strlen((char *)pkt) + 1; +#ifdef CONFIG_TFTP_TSIZE + pkt += sprintf((char *)pkt,"tsize%c%d", 0,0); + pkt += strlen((char *)pkt) + 1; +#endif /* try for more effic. blk size */ pkt += sprintf((char *)pkt,"blksize%c%d%c", 0,TftpBlkSizeOption,0); @@ -321,8 +328,14 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) simple_strtoul((char*)pkt+i+8,NULL,10); debug("Blocksize ack: %s, %d\n", (char*)pkt+i+8,TftpBlkSize); - break; } +#ifdef CONFIG_TFTP_TSIZE + if (strcmp ((char*)pkt+i,"tsize") == 0) { + TftpTsize = simple_strtoul((char*)pkt+i+6,NULL,10); + debug("size = %s, %d\n", + (char*)pkt+i+6, TftpTsize); + } +#endif } #ifdef CONFIG_MCAST_TFTP parse_multicast_oack((char *)pkt,len-1); @@ -348,7 +361,14 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) TftpBlockWrap++; TftpBlockWrapOffset += TftpBlkSize * TFTP_SEQUENCE_SIZE; printf ("\n\t %lu MB received\n\t ", TftpBlockWrapOffset>>20); - } else { + } +#ifdef CONFIG_TFTP_TSIZE + else if (TftpTsize) { + + printf("%2d\b\b", NetBootFileXferSize * 100 / TftpTsize); + } +#endif + else { if (((TftpBlock - 1) % 10) == 0) { puts_quiet("#"); } else if ((TftpBlock % (10 * HASHES_PER_LINE)) == 0) { @@ -442,6 +462,11 @@ TftpHandler (uchar * pkt, unsigned dest, unsigned src, unsigned len) * We received the whole thing. Try to * run it. */ +#ifdef CONFIG_TFTP_TSIZE + if (TftpTsize) + puts("100%"); +#endif + puts_quiet("\ndone\n"); #ifdef CONFIG_TFTP_TIME end_time = get_timer(0); @@ -550,6 +579,9 @@ TftpStart (void) #ifdef CONFIG_TFTP_TIME start_time = get_timer(0); #endif +#ifdef CONFIG_TFTP_TSIZE + TftpTsize = 0; +#endif TftpTimeoutMSecs = TftpRRQTimeoutMSecs; TftpTimeoutCountMax = TftpRRQTimeoutCountMax; _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot