FreeCalypso > hg > freecalypso-sw
annotate loadtools/flprogsrec.c @ 923:10b4bed10192
gsm-fw/L1: fix for the DSP patch corruption bug
The L1 code we got from the LoCosto fw contains a feature for DSP CPU load
measurement. This feature is a LoCosto-ism, i.e., not applicable to earlier
DBB chips (Calypso) with their respective earlier DSP ROMs. Most of the
code dealing with that feature is conditionalized as #if (DSP >= 38),
but one spot was missed, and the MCU code was writing into an API word
dealing with this feature. In TCS211 this DSP API word happens to be
used by the DSP code patch, hence that write was corrupting the patched
DSP code.
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 19 Oct 2015 17:13:56 +0000 |
parents | 81d387690063 |
children |
rev | line source |
---|---|
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
405
a212b4968b29
fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
2 * This module implements the flash program-srec and flash program-m0 commands: |
a212b4968b29
fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
3 * programming flash using S-record files as the data source. |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
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 #include <sys/types.h> |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdio.h> |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdint.h> |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <stdlib.h> |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "flash.h" |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "srecreader.h" |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 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
|
14 |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 flashcmd_progsrec_gen(bank, imgfile, is_m0) |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 char *imgfile; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 struct flash_bank_info *bi; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 struct srecreader srr; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 char *targv[4], shortarg[10], longarg[513]; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 int resp; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 unsigned long rec_count; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 |
400
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
24 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
|
25 return(-1); |
f027c6fbe37e
fc-loadtool flash: first round of refactoring for CFI
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
205
diff
changeset
|
26 bi = flash_bank_info + bank; |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 srr.filename = imgfile; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 resp = open_srec_file(&srr); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 if (resp < 0) |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 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
|
31 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
|
32 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
|
33 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
|
34 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
|
35 } |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 sprintf(shortarg, "%lx", (u_long) bi->base_addr); |
405
a212b4968b29
fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
37 targv[0] = bi->ops->loadagent_setbase_cmd; |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 targv[1] = shortarg; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 targv[2] = 0; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 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
|
41 tpinterf_make_cmd(targv); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 if (tpinterf_send_cmd() < 0) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 resp = tpinterf_pass_output(1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 if (resp) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 return(resp); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 } |
410
81d387690063
Intel flash: clear SR before programming
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
405
diff
changeset
|
51 if (bi->ops->prep_for_program(bi) < 0) { |
81d387690063
Intel flash: clear SR before programming
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
405
diff
changeset
|
52 fclose(srr.openfile); |
81d387690063
Intel flash: clear SR before programming
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
405
diff
changeset
|
53 return(-1); |
81d387690063
Intel flash: clear SR before programming
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
405
diff
changeset
|
54 } |
405
a212b4968b29
fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
55 targv[0] = bi->ops->loadagent_program_cmd; |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 targv[1] = shortarg; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 targv[2] = longarg; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 targv[3] = 0; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 for (rec_count = 0; ; ) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 if (read_s_record(&srr) < 0) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 /* error msg already printed */ |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 if (srr.record_type == '0') { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 if (srr.lineno == 1) |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 continue; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 "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
|
70 srr.lineno, srr.filename); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 continue; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 } else if (srr.record_type == '7') |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 break; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 else if (srr.record_type != '3') { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 "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
|
77 srr.record_type, srr.lineno, srr.filename); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
78 continue; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
79 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
80 /* must be S3 */ |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
81 if (s3s7_get_addr_data(&srr) < 0) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
82 /* error msg already printed */ |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
83 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
84 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
85 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
86 if (srr.datalen < 1) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
87 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
88 "%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
|
89 srr.filename, srr.lineno); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
90 continue; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
91 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
92 if (srr.addr & 1 || srr.datalen & 1) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
93 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
94 "%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
|
95 srr.filename, srr.lineno); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
96 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
97 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
98 } |
405
a212b4968b29
fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
99 srr.addr &= bi->geom->total_size - 1; |
a212b4968b29
fc-loadtool flash: another refactoring: geometry vs. command set
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
400
diff
changeset
|
100 if (srr.addr + srr.datalen > bi->geom->total_size) { |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
101 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
102 "%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
|
103 srr.filename, srr.lineno); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
104 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
105 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
106 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
107 if (!rec_count) |
106
ae4921a3aa33
fc-loadtool program-{m0,srec}: more usable progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
108 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
|
109 sprintf(shortarg, "%lx", (u_long) srr.addr); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
110 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
|
111 srr.datalen >> 1, is_m0); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
112 tpinterf_make_cmd(targv); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
113 if (tpinterf_send_cmd() < 0) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
114 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
115 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
116 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
117 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
|
118 if (resp) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
119 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
120 return(resp); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
121 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
122 rec_count++; |
106
ae4921a3aa33
fc-loadtool program-{m0,srec}: more usable progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
123 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
|
124 putchar('.'); |
ae4921a3aa33
fc-loadtool program-{m0,srec}: more usable progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
125 fflush(stdout); |
ae4921a3aa33
fc-loadtool program-{m0,srec}: more usable progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
99
diff
changeset
|
126 } |
99
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
127 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
128 /* got S7 */ |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
129 fclose(srr.openfile); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
130 if (!rec_count) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
131 fprintf(stderr, |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
132 "%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
|
133 srr.filename, srr.lineno); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
134 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
135 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
136 printf("\nProgramming complete\n"); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
137 return(0); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
138 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
139 |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
140 flashcmd_program_srec(argc, argv, bank) |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
141 char **argv; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
142 { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
143 if (argc != 3) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
144 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
|
145 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
146 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
147 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
|
148 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
149 |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
150 flashcmd_program_m0(argc, argv, bank) |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
151 char **argv; |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
152 { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
153 if (argc != 3) { |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
154 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
|
155 return(-1); |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
156 } |
b78db17bfc85
fc-loadtool: flash program-{m0,srec} implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
157 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
|
158 } |