comparison loadtools/flprogsrec.c @ 617:97fe41e9242a

fc-loadtool: added operation time reporting to flash program-m0
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 25 Feb 2020 07:01:28 +0000
parents 0dd2c87c1b63
children 9c5b0629e346
comparison
equal deleted inserted replaced
616:4be92bcd1535 617:97fe41e9242a
5 5
6 #include <sys/types.h> 6 #include <sys/types.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <time.h>
10 #include "flash.h" 11 #include "flash.h"
11 #include "srecreader.h" 12 #include "srecreader.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
18 struct flash_bank_info *bi; 19 struct flash_bank_info *bi;
19 struct srecreader srr; 20 struct srecreader srr;
20 char *targv[4], shortarg[10], longarg[513]; 21 char *targv[4], shortarg[10], longarg[513];
21 int resp; 22 int resp;
22 unsigned long rec_count; 23 unsigned long rec_count;
24 time_t start_time, finish_time;
25 unsigned duration, mm, ss;
23 26
24 if (flash_detect(bank, 0) < 0) 27 if (flash_detect(bank, 0) < 0)
25 return(-1); 28 return(-1);
26 bi = flash_bank_info + bank; 29 bi = flash_bank_info + bank;
27 srr.filename = imgfile; 30 srr.filename = imgfile;
62 continue; 65 continue;
63 fprintf(stderr, 66 fprintf(stderr,
64 "Warning: S0 record found in line %d of %s (expected in line 1 only)\n", 67 "Warning: S0 record found in line %d of %s (expected in line 1 only)\n",
65 srr.lineno, srr.filename); 68 srr.lineno, srr.filename);
66 continue; 69 continue;
67 } else if (srr.record_type == '7') 70 } else if (srr.record_type == '7') {
71 time(&finish_time);
68 break; 72 break;
69 else if (srr.record_type != '3') { 73 } else if (srr.record_type != '3') {
70 fprintf(stderr, 74 fprintf(stderr,
71 "Warning: unsupported S%c record type in line %d of %s\n", 75 "Warning: unsupported S%c record type in line %d of %s\n",
72 srr.record_type, srr.lineno, srr.filename); 76 srr.record_type, srr.lineno, srr.filename);
73 continue; 77 continue;
74 } 78 }
97 "%s line %d: goes past the end of the flash bank\n", 101 "%s line %d: goes past the end of the flash bank\n",
98 srr.filename, srr.lineno); 102 srr.filename, srr.lineno);
99 fclose(srr.openfile); 103 fclose(srr.openfile);
100 return(-1); 104 return(-1);
101 } 105 }
102 if (!rec_count) 106 if (!rec_count) {
103 printf("Programming flash, each \'.\' is 100 S-records\n"); 107 printf("Programming flash, each \'.\' is 100 S-records\n");
108 time(&start_time);
109 }
104 sprintf(shortarg, "%lx", (u_long) srr.addr); 110 sprintf(shortarg, "%lx", (u_long) srr.addr);
105 build_flashw_hex_string(srr.record + 5, longarg, 111 build_flashw_hex_string(srr.record + 5, longarg,
106 srr.datalen >> 1, is_m0); 112 srr.datalen >> 1, is_m0);
107 tpinterf_make_cmd(targv); 113 tpinterf_make_cmd(targv);
108 if (tpinterf_send_cmd() < 0) { 114 if (tpinterf_send_cmd() < 0) {
126 fprintf(stderr, 132 fprintf(stderr,
127 "%s line %d: S7 without any preceding S3 data records\n", 133 "%s line %d: S7 without any preceding S3 data records\n",
128 srr.filename, srr.lineno); 134 srr.filename, srr.lineno);
129 return(-1); 135 return(-1);
130 } 136 }
131 printf("\nProgramming complete\n"); 137 duration = finish_time - start_time;
138 mm = duration / 60;
139 ss = duration - mm * 60;
140 printf("\nOperation completed in %um%us\n", mm, ss);
132 return(0); 141 return(0);
133 } 142 }
134 143
135 flashcmd_program_srec(argc, argv, bank) 144 flashcmd_program_srec(argc, argv, bank)
136 char **argv; 145 char **argv;