comparison loadtools/flprogbin.c @ 612:52980e3a51c7

fc-loadtool: added operation time reporting to flash program-bin
author Mychaela Falconia <falcon@freecalypso.org>
date Mon, 24 Feb 2020 21:56:53 +0000
parents 0dd2c87c1b63
children b43d8c2725b9
comparison
equal deleted inserted replaced
611:c847d742ab38 612:52980e3a51c7
25 FILE *binf; 25 FILE *binf;
26 struct stat filestat; 26 struct stat filestat;
27 char *targv[4], shortarg[10], longarg[513]; 27 char *targv[4], shortarg[10], longarg[513];
28 u_char databuf[256]; 28 u_char databuf[256];
29 int reclen, cc, i; 29 int reclen, cc, i;
30 time_t curtime, last_time; 30 time_t initial_time, curtime, last_time;
31 unsigned duration, mm, ss;
31 32
32 if (argc < 4 || argc > 6) { 33 if (argc < 4 || argc > 6) {
33 inv: fprintf(stderr, 34 inv: fprintf(stderr,
34 "usage: %s %s flash-offset binfile [file-offset [length]]\n", 35 "usage: %s %s flash-offset binfile [file-offset [length]]\n",
35 argv[0], argv[1]); 36 argv[0], argv[1]);
137 printf("Programming flash: %lu (0x%lx) bytes\n", len, len); 138 printf("Programming flash: %lu (0x%lx) bytes\n", len, len);
138 origlen = len; 139 origlen = len;
139 bytesdone = 0; 140 bytesdone = 0;
140 last_time = 0; 141 last_time = 0;
141 crcaccum = 0xFFFFFFFF; 142 crcaccum = 0xFFFFFFFF;
143 time(&initial_time);
142 while (len) { 144 while (len) {
143 if (len >= 256) 145 if (len >= 256)
144 reclen = 256; 146 reclen = 256;
145 else 147 else
146 reclen = len; 148 reclen = len;
177 } 179 }
178 last_time = curtime; 180 last_time = curtime;
179 } 181 }
180 putchar('\n'); 182 putchar('\n');
181 fclose(binf); 183 fclose(binf);
184 duration = last_time - initial_time;
185 mm = duration / 60;
186 ss = duration - mm * 60;
187 printf("Operation completed in %um%us\n", mm, ss);
182 188
183 /* reset flash to read mode */ 189 /* reset flash to read mode */
184 if (bi->ops->reset_cmd(bi) < 0) 190 if (bi->ops->reset_cmd(bi) < 0)
185 return(-1); 191 return(-1);
186 printf("Verifying CRC-32 of programmed flash area\n"); 192 printf("Verifying CRC-32 of programmed flash area\n");