# HG changeset patch # User Michael Spacefalcon # Date 1378006931 0 # Node ID 336f5cc96810c2cee7d3dc96b79c2506164490e0 # Parent 1f035187e98fcdaae903f67882c696b9919a2669 fc-loadtool flash program-bin: smarter progress indication diff -r 1f035187e98f -r 336f5cc96810 loadtools/flprogbin.c --- a/loadtools/flprogbin.c Sun Sep 01 01:33:28 2013 +0000 +++ b/loadtools/flprogbin.c Sun Sep 01 03:42:11 2013 +0000 @@ -8,6 +8,7 @@ #include #include #include +#include #include "flash.h" extern struct flash_bank_info flash_bank_info[2]; @@ -16,13 +17,14 @@ char **argv; { struct flash_bank_info *bi; - u_long flashoff, fileoff, len; + u_long flashoff, fileoff, len, origlen, bytesdone; char *strtoul_endp; FILE *binf; struct stat filestat; char *targv[4], shortarg[10], longarg[513]; u_char databuf[256]; int reclen, cc; + time_t curtime, last_time; if (argc < 4 || argc > 6) { inv: fprintf(stderr, @@ -122,7 +124,10 @@ targv[1] = shortarg; targv[2] = longarg; targv[3] = 0; - printf("Programming flash, each \'.\' = 256 bytes of data\n"); + printf("Programming flash: %lu (0x%lx) bytes\n", len, len); + origlen = len; + bytesdone = 0; + last_time = 0; while (len) { if (len >= 256) reclen = 256; @@ -148,8 +153,15 @@ } flashoff += reclen; len -= reclen; - putchar('.'); - fflush(stdout); + bytesdone += reclen; + cc = bytesdone * 100 / origlen; + time(&curtime); + if (curtime != last_time || cc == 100) { + printf("\r0x%lx bytes programmed (%i%%)", + bytesdone, cc); + fflush(stdout); + } + last_time = curtime; } putchar('\n'); fclose(binf); diff -r 1f035187e98f -r 336f5cc96810 loadtools/flutil.c --- a/loadtools/flutil.c Sun Sep 01 01:33:28 2013 +0000 +++ b/loadtools/flutil.c Sun Sep 01 03:42:11 2013 +0000 @@ -139,7 +139,7 @@ u_char *dp; char *s; - for (dp = bin, s = strbuf, i =0; i < nwords; dp += 2, s += 4, i++) { + for (dp = bin, s = strbuf, i = 0; i < nwords; dp += 2, s += 4, i++) { if (m0src) { sprintf(s, "%02X", dp[0]); sprintf(s + 2, "%02X", dp[1]);