FreeCalypso > hg > freecalypso-tools
comparison loadtools/flmisc.c @ 616:4be92bcd1535
fc-loadtool: added operation time reporting to flash erase
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 25 Feb 2020 02:43:05 +0000 |
parents | 0dd2c87c1b63 |
children | cd48bc4c5460 |
comparison
equal
deleted
inserted
replaced
615:39b74c39d914 | 616:4be92bcd1535 |
---|---|
6 #include <stdio.h> | 6 #include <stdio.h> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <string.h> | 8 #include <string.h> |
9 #include <strings.h> | 9 #include <strings.h> |
10 #include <stdlib.h> | 10 #include <stdlib.h> |
11 #include <time.h> | |
11 #include "flash.h" | 12 #include "flash.h" |
12 | 13 |
13 extern struct flash_bank_info flash_bank_info[2]; | 14 extern struct flash_bank_info flash_bank_info[2]; |
14 | 15 |
15 flashcmd_blankchk(argc, argv, bank) | 16 flashcmd_blankchk(argc, argv, bank) |
127 struct flash_bank_info *bi; | 128 struct flash_bank_info *bi; |
128 u_long offset, len; | 129 u_long offset, len; |
129 char *strtoul_endp; | 130 char *strtoul_endp; |
130 struct sector_info *startsec, *endsec, *sp; | 131 struct sector_info *startsec, *endsec, *sp; |
131 int stat; | 132 int stat; |
133 time_t start_time, finish_time; | |
134 unsigned duration, mm, ss; | |
132 | 135 |
133 if (argc != 4) { | 136 if (argc != 4) { |
134 inv: fprintf(stderr, "usage: %s %s hex-start-offset hex-length\n", | 137 inv: fprintf(stderr, "usage: %s %s hex-start-offset hex-length\n", |
135 argv[0], argv[1]); | 138 argv[0], argv[1]); |
136 return(-1); | 139 return(-1); |
164 if (get_flash_sector_table(bank) < 0) | 167 if (get_flash_sector_table(bank) < 0) |
165 return(-1); | 168 return(-1); |
166 if (get_flash_sector_range(bi, offset, len, &startsec, &endsec) < 0) | 169 if (get_flash_sector_range(bi, offset, len, &startsec, &endsec) < 0) |
167 return(-1); | 170 return(-1); |
168 printf("Erasing %d sector(s)\n", endsec - startsec); | 171 printf("Erasing %d sector(s)\n", endsec - startsec); |
172 time(&start_time); | |
169 for (sp = startsec; sp < endsec; sp++) { | 173 for (sp = startsec; sp < endsec; sp++) { |
170 stat = bi->ops->erase_sector(bi, sp); | 174 stat = bi->ops->erase_sector(bi, sp); |
171 if (stat) | 175 if (stat) |
172 return(stat); | 176 return(stat); |
173 putchar('.'); | 177 putchar('.'); |
174 fflush(stdout); | 178 fflush(stdout); |
175 } | 179 } |
180 time(&finish_time); | |
176 putchar('\n'); | 181 putchar('\n'); |
182 duration = finish_time - start_time; | |
183 mm = duration / 60; | |
184 ss = duration - mm * 60; | |
185 printf("Operation completed in %um%us\n", mm, ss); | |
177 return(0); | 186 return(0); |
178 } | 187 } |
179 | 188 |
180 flashcmd_quickprog(argc, argv, bank) | 189 flashcmd_quickprog(argc, argv, bank) |
181 char **argv; | 190 char **argv; |