FreeCalypso > hg > freecalypso-sw
diff loadtools/flprogbin.c @ 95:336f5cc96810
fc-loadtool flash program-bin: smarter progress indication
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 01 Sep 2013 03:42:11 +0000 |
parents | 98f855e58c9f |
children | cd12d1049f91 |
line wrap: on
line diff
--- 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 <stdio.h> #include <stdint.h> #include <stdlib.h> +#include <time.h> #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);