FreeCalypso > hg > freecalypso-sw
annotate loadtools/flprogsrec.c @ 401:7ceeec049be4
fc-loadtool flash: bank configurations for CFI
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 15 Jun 2014 20:24:51 +0000 |
parents | f027c6fbe37e |
children | a212b4968b29 |
rev | line source |
---|---|
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * In this module we are going to implement the flash program-srec and |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * flash program-m0 commands: programming flash using S-record files |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 * as the data source. |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 */ |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <sys/types.h> |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdio.h> |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <stdint.h> |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <stdlib.h> |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "flash.h" |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "srecreader.h" |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 extern struct flash_bank_info flash_bank_info[2]; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 flashcmd_progsrec_gen(bank, imgfile, is_m0) |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 char *imgfile; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 struct flash_bank_info *bi; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 struct srecreader srr; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 char *targv[4], shortarg[10], longarg[513]; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 int resp; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 unsigned long rec_count; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
25 if (flash_get_cfi(bank) < 0) |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
26 return(-1); |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
27 bi = flash_bank_info + bank; |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
28 if (bi->cfi->cmdset_style != 2) { |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
29 fprintf(stderr, |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
30 "error: this command is currently only implemented for AMD-style flash\n"); |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
31 return(-1); |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
32 } |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 srr.filename = imgfile; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 resp = open_srec_file(&srr); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 if (resp < 0) |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 return(resp); |
205
cd12d1049f91
fc-loadtool: flash ID check moved into flash info, added to erase and program
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
106
diff
changeset
|
37 resp = flash_id_check(bank, 0); |
cd12d1049f91
fc-loadtool: flash ID check moved into flash info, added to erase and program
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
106
diff
changeset
|
38 if (resp) { |
cd12d1049f91
fc-loadtool: flash ID check moved into flash info, added to erase and program
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
106
diff
changeset
|
39 fclose(srr.openfile); |
cd12d1049f91
fc-loadtool: flash ID check moved into flash info, added to erase and program
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
106
diff
changeset
|
40 return(resp); |
cd12d1049f91
fc-loadtool: flash ID check moved into flash info, added to erase and program
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
106
diff
changeset
|
41 } |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 sprintf(shortarg, "%lx", (u_long) bi->base_addr); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 targv[0] = "AMFB"; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 targv[1] = shortarg; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 targv[2] = 0; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 printf("Setting flash base address: %s %s\n", targv[0], targv[1]); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 tpinterf_make_cmd(targv); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 if (tpinterf_send_cmd() < 0) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 resp = tpinterf_pass_output(1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 if (resp) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 return(resp); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 targv[0] = "AMFW"; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 targv[1] = shortarg; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 targv[2] = longarg; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 targv[3] = 0; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 for (rec_count = 0; ; ) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 if (read_s_record(&srr) < 0) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 /* error msg already printed */ |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 if (srr.record_type == '0') { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 if (srr.lineno == 1) |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 continue; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 "Warning: S0 record found in line %d of %s (expected in line 1 only)\n", |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 srr.lineno, srr.filename); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 continue; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 } else if (srr.record_type == '7') |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 break; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 else if (srr.record_type != '3') { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
77 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 "Warning: unsupported S%c record type in line %d of %s\n", |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 srr.record_type, srr.lineno, srr.filename); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 continue; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 /* must be S3 */ |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 if (s3s7_get_addr_data(&srr) < 0) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 /* error msg already printed */ |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 if (srr.datalen < 1) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
89 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 "%s line %d: S3 record of zero data length ignored\n", |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 srr.filename, srr.lineno); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 continue; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 if (srr.addr & 1 || srr.datalen & 1) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
95 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 "%s line %d: violates word alignment requirement\n", |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 srr.filename, srr.lineno); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
99 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
100 } |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
101 srr.addr &= bi->cfi->total_size - 1; |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
102 if (srr.addr + srr.datalen > bi->cfi->total_size) { |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
103 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 "%s line %d: goes past the end of the flash bank\n", |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 srr.filename, srr.lineno); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
108 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
109 if (!rec_count) |
106
ae4921a3aa33
fc-loadtool program-{m0,srec}: more usable progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
110 printf("Programming flash, each \'.\' is 100 S-records\n"); |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
111 sprintf(shortarg, "%lx", (u_long) srr.addr); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 build_flashw_hex_string(srr.record + 5, longarg, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 srr.datalen >> 1, is_m0); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 tpinterf_make_cmd(targv); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 if (tpinterf_send_cmd() < 0) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
118 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 resp = tpinterf_pass_output(8); /* 8 s timeout */ |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 if (resp) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 return(resp); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
123 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
124 rec_count++; |
106
ae4921a3aa33
fc-loadtool program-{m0,srec}: more usable progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
125 if (rec_count % 100 == 0) { |
ae4921a3aa33
fc-loadtool program-{m0,srec}: more usable progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
126 putchar('.'); |
ae4921a3aa33
fc-loadtool program-{m0,srec}: more usable progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
127 fflush(stdout); |
ae4921a3aa33
fc-loadtool program-{m0,srec}: more usable progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
128 } |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 /* got S7 */ |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 if (!rec_count) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
133 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 "%s line %d: S7 without any preceding S3 data records\n", |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 srr.filename, srr.lineno); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 printf("\nProgramming complete\n"); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 return(0); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 flashcmd_program_srec(argc, argv, bank) |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 char **argv; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
145 if (argc != 3) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 fprintf(stderr, "usage: %s %s image.srec\n", argv[0], argv[1]); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
148 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 return flashcmd_progsrec_gen(bank, argv[2], 0); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 flashcmd_program_m0(argc, argv, bank) |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 char **argv; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
155 if (argc != 3) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 fprintf(stderr, "usage: %s %s image.m0\n", argv[0], argv[1]); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
158 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
159 return flashcmd_progsrec_gen(bank, argv[2], 1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
160 } |