FreeCalypso > hg > freecalypso-tools
annotate loadtools/flprogsrec.c @ 731:d89b72f2181b
doc/TIFFS-IVA-usage: new decode facility documented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Fri, 28 Aug 2020 05:56:13 +0000 |
parents | 185c9bf208d3 |
children |
rev | line source |
---|---|
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements the flash program-srec and flash program-m0 commands: |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * programming flash using S-record files as the data source. |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdint.h> |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdlib.h> |
617
97fe41e9242a
fc-loadtool: added operation time reporting to flash program-m0
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
10 #include <time.h> |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
11 #include <unistd.h> |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "flash.h" |
652
d42534e5ac02
loadtools: discontig.h split out of flash.h
Mychaela Falconia <falcon@freecalypso.org>
parents:
629
diff
changeset
|
13 #include "discontig.h" |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "srecreader.h" |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
16 extern int target_fd; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
17 |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 extern struct flash_bank_info flash_bank_info[2]; |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
19 extern uint32_t crc32_table[]; |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
21 read_srec_img_for_flash(imgfile, is_m0, bank_size, reglistp, regcountp, |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
22 totalp, tmpfilep) |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
23 char *imgfile; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
24 uint32_t bank_size, *totalp; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
25 struct discontig_prog *reglistp; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
26 unsigned *regcountp; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
27 FILE **tmpfilep; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
28 { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
29 struct srecreader srr; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
30 struct discontig_prog *regp; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
31 unsigned regcount; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
32 uint32_t total_len; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
33 char tmpfilename[] = "/tmp/fc-loadtoolXXXXXX"; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
34 int rc, tmpfd, i, c; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
35 FILE *tmpfile; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
36 |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
37 printf("Reading S-record image from %s\n", imgfile); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 srr.filename = imgfile; |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
39 rc = open_srec_file(&srr); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
40 if (rc < 0) |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
41 return(rc); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
42 tmpfd = mkstemp(tmpfilename); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
43 if (tmpfd < 0) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
44 fprintf(stderr, "unable to get temp file via mkstemp()\n"); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 fclose(srr.openfile); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
48 unlink(tmpfilename); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
49 tmpfile = fdopen(tmpfd, "w+"); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
50 if (!tmpfile) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
51 perror("fdopen"); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
52 close(tmpfd); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 fclose(srr.openfile); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
56 regp = reglistp; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
57 regcount = 0; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
58 total_len = 0; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
59 for (;;) { |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 if (read_s_record(&srr) < 0) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 /* error msg already printed */ |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 fclose(srr.openfile); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
63 fclose(tmpfile); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 if (srr.record_type == '0') { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 if (srr.lineno == 1) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 continue; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 fprintf(stderr, |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
70 "error: S0 record found in line %d of %s (expected in line 1 only)\n", |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 srr.lineno, srr.filename); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
72 fclose(srr.openfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
73 fclose(tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
74 return(-1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
75 } else if (srr.record_type == '7') |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 break; |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
77 else if (srr.record_type != '3') { |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 fprintf(stderr, |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
79 "error: unsupported S%c record type in line %d of %s\n", |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 srr.record_type, srr.lineno, srr.filename); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
81 fclose(srr.openfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
82 fclose(tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
83 return(-1); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 /* must be S3 */ |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 if (s3s7_get_addr_data(&srr) < 0) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 /* error msg already printed */ |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 fclose(srr.openfile); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
89 fclose(tmpfile); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 if (srr.datalen < 1) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 fprintf(stderr, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 "%s line %d: S3 record of zero data length ignored\n", |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 srr.filename, srr.lineno); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 continue; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 if (srr.addr & 1 || srr.datalen & 1) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 fprintf(stderr, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 "%s line %d: violates word alignment requirement\n", |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 srr.filename, srr.lineno); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 fclose(srr.openfile); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
103 fclose(tmpfile); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
106 srr.addr &= bank_size - 1; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
107 if (srr.addr + srr.datalen > bank_size) { |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 fprintf(stderr, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 "%s line %d: goes past the end of the flash bank\n", |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 srr.filename, srr.lineno); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 fclose(srr.openfile); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
112 fclose(tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
113 return(-1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
114 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
115 /* is this the first record of the first region? */ |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
116 if (!regcount) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
117 regp->start = srr.addr; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
118 regp->end = srr.addr; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
119 regp->crc = 0xFFFFFFFF; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
120 regcount = 1; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
121 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
122 if (srr.addr < regp->end) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
123 fprintf(stderr, "%s line %d: address going backwards\n", |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
124 srr.filename, srr.lineno); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
125 fclose(srr.openfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
126 fclose(tmpfile); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
129 if (srr.addr != regp->end) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
130 if (regcount >= MAX_SREC_REGIONS) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
131 fprintf(stderr, |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
132 "error: %s has too many discontiguous regions\n", |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
133 imgfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
134 fclose(srr.openfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
135 fclose(tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
136 return(-1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
137 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
138 regp++; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
139 regcount++; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
140 regp->start = srr.addr; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
141 regp->end = srr.addr; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
142 regp->crc = 0xFFFFFFFF; |
617
97fe41e9242a
fc-loadtool: added operation time reporting to flash program-m0
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
143 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
144 /* take in the payload */ |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
145 if (is_m0) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
146 for (i = 0; i < srr.datalen; i += 2) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
147 c = srr.record[i+6]; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
148 regp->crc = crc32_table[regp->crc & 0xFF ^ c] |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
149 ^ (regp->crc >> 8); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
150 putc(c, tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
151 c = srr.record[i+5]; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
152 regp->crc = crc32_table[regp->crc & 0xFF ^ c] |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
153 ^ (regp->crc >> 8); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
154 putc(c, tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
155 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
156 } else { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
157 for (i = 0; i < srr.datalen; i++) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
158 c = srr.record[i+5]; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
159 regp->crc = crc32_table[regp->crc & 0xFF ^ c] |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
160 ^ (regp->crc >> 8); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
161 putc(c, tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
162 } |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
164 regp->end += srr.datalen; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
165 total_len += srr.datalen; |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 /* got S7 */ |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 fclose(srr.openfile); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
169 if (!regcount) { |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 fprintf(stderr, |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 "%s line %d: S7 without any preceding S3 data records\n", |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 srr.filename, srr.lineno); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
173 fclose(tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
174 return(-1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
175 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
176 /* good read */ |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
177 if (regcount == 1) |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
178 printf("Got %lu (0x%lx) bytes in one contiguous region\n", |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
179 (u_long) total_len, (u_long) total_len); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
180 else |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
181 printf("Got %lu (0x%lx) bytes in %u discontiguous regions\n", |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
182 (u_long) total_len, (u_long) total_len, regcount); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
183 *regcountp = regcount; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
184 *totalp = total_len; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
185 *tmpfilep = tmpfile; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
186 return(0); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
187 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
188 |
670
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
666
diff
changeset
|
189 flashcmd_progsrec_gen(bank, imgfile, is_m0, with_erase) |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
190 char *imgfile; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
191 { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
192 struct flash_bank_info *bi; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
193 struct discontig_prog regions[MAX_SREC_REGIONS], *regp; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
194 unsigned nregions, reg; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
195 uint32_t total_len, bytesdone, addr, len; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
196 FILE *tmpfile; |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
197 char *targv[3], shortarg[10]; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
198 u_char databuf[2048 + 7], ackbyte; |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
199 int reclen, cc, rc; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
200 time_t initial_time, curtime, last_time; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
201 unsigned duration, mm, ss; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
202 u_long crc_from_target; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
203 |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
204 if (flash_detect(bank, 0) < 0) |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
205 return(-1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
206 bi = flash_bank_info + bank; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
207 rc = read_srec_img_for_flash(imgfile, is_m0, bi->geom->total_size, |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
208 regions, &nregions, &total_len, &tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
209 if (rc < 0) |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
210 return(rc); |
670
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
666
diff
changeset
|
211 if (with_erase) { |
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
666
diff
changeset
|
212 rc = erase_sectors_for_prog(bi, regions, nregions); |
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
666
diff
changeset
|
213 if (rc < 0) { |
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
666
diff
changeset
|
214 fclose(tmpfile); |
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
666
diff
changeset
|
215 return(rc); |
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
666
diff
changeset
|
216 } |
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
666
diff
changeset
|
217 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
218 sprintf(shortarg, "%lx", (u_long) bi->base_addr); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
219 targv[0] = bi->ops->loadagent_setbase_cmd; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
220 targv[1] = shortarg; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
221 targv[2] = 0; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
222 printf("Setting flash base address: %s %s\n", targv[0], targv[1]); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
223 tpinterf_make_cmd(targv); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
224 if (tpinterf_send_cmd() < 0) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
225 fclose(tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
226 return(-1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
227 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
228 rc = tpinterf_pass_output(1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
229 if (rc) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
230 fclose(tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
231 return(rc); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
232 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
233 if (bi->ops->prep_for_program(bi) < 0) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
234 fclose(tmpfile); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
235 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
236 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
237 rewind(tmpfile); |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
238 targv[0] = bi->ops->loadagent_binmode_cmd; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
239 targv[1] = 0; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
240 tpinterf_make_cmd(targv); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
241 if (tpinterf_send_cmd() < 0) { |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
242 fclose(tmpfile); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
243 return(-1); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
244 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
245 printf("Programming flash\n"); |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
246 databuf[0] = 0x01; |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
247 bytesdone = 0; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
248 last_time = 0; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
249 time(&initial_time); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
250 for (reg = 0, regp = regions; reg < nregions; reg++, regp++) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
251 addr = regp->start; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
252 len = regp->end - addr; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
253 while (len) { |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
254 if (len >= 2048) |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
255 reclen = 2048; |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
256 else |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
257 reclen = len; |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
258 cc = fread(databuf + 7, 1, reclen, tmpfile); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
259 if (cc != reclen) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
260 fclose(tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
261 fprintf(stderr, |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
262 "error reading from temp file!\n"); |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
263 /* don't leave loadagent in binary flash mode */ |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
264 databuf[0] = 0x04; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
265 write(target_fd, databuf, 1); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
266 tpinterf_pass_output(1); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
267 return(-1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
268 } |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
269 /* binary flash write command to loadagent */ |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
270 databuf[1] = addr >> 24; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
271 databuf[2] = addr >> 16; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
272 databuf[3] = addr >> 8; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
273 databuf[4] = addr; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
274 databuf[5] = reclen >> 8; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
275 databuf[6] = reclen; |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
276 cc = write(target_fd, databuf, reclen + 7); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
277 if (cc != reclen + 7) { |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
278 fclose(tmpfile); |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
279 perror("binary write to target"); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
280 return(-1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
281 } |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
282 rc = collect_binblock_from_target(&ackbyte, 1, 8); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
283 if (rc) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
284 fclose(tmpfile); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
285 return(rc); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
286 } |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
287 if (ackbyte == 0x15) { /* NAK */ |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
288 fclose(tmpfile); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
289 tpinterf_pass_output(1); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
290 return(-1); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
291 } |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
292 if (ackbyte != 0x06) { /* ACK */ |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
293 fclose(tmpfile); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
294 fprintf(stderr, |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
295 "binary protocol error: bad ack 0x%02X\n", |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
296 ackbyte); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
297 return(-1); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
298 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
299 addr += reclen; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
300 len -= reclen; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
301 bytesdone += reclen; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
302 cc = bytesdone * 100 / total_len; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
303 time(&curtime); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
304 if (curtime != last_time || cc == 100) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
305 printf("\r0x%lx bytes programmed (%i%%)", |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
306 bytesdone, cc); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
307 fflush(stdout); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
308 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
309 last_time = curtime; |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
310 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
311 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
312 putchar('\n'); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
313 fclose(tmpfile); |
666
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
314 databuf[0] = 0x04; /* EOT */ |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
315 write(target_fd, databuf, 1); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
316 rc = collect_binblock_from_target(&ackbyte, 1, 1); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
317 if (rc) |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
318 return(rc); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
319 time(&last_time); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
320 if (ackbyte != '=') { |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
321 fprintf(stderr, "error: \'=\' not received as expected\n"); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
322 return(-1); |
51bcfb251b23
fc-loadtool flash program-m0 changed to use binary protocol
Mychaela Falconia <falcon@freecalypso.org>
parents:
655
diff
changeset
|
323 } |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
324 duration = last_time - initial_time; |
617
97fe41e9242a
fc-loadtool: added operation time reporting to flash program-m0
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
325 mm = duration / 60; |
97fe41e9242a
fc-loadtool: added operation time reporting to flash program-m0
Mychaela Falconia <falcon@freecalypso.org>
parents:
506
diff
changeset
|
326 ss = duration - mm * 60; |
692
185c9bf208d3
loadtools operation time reporting: two digits for seconds
Mychaela Falconia <falcon@freecalypso.org>
parents:
670
diff
changeset
|
327 printf("Operation completed in %um%02us\n", mm, ss); |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
328 |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
329 /* reset flash to read mode */ |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
330 if (bi->ops->reset_cmd(bi) < 0) |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
331 return(-1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
332 printf("Verifying CRC-32 of %u programmed region(s)\n", nregions); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
333 for (reg = 0, regp = regions; reg < nregions; reg++, regp++) { |
629
0f70fe9395c4
fc-loadtool: bug in the new program-m0 CRC-32 verification
Mychaela Falconia <falcon@freecalypso.org>
parents:
628
diff
changeset
|
334 rc = crc32_on_target((u_long) (bi->base_addr + regp->start), |
628
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
335 (u_long) (regp->end - regp->start), |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
336 &crc_from_target); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
337 if (rc < 0) |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
338 return(rc); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
339 if (crc_from_target != regp->crc) { |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
340 fprintf(stderr, "error: CRC mismatch!\n"); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
341 return(-1); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
342 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
343 putchar('.'); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
344 fflush(stdout); |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
345 } |
9c5b0629e346
fc-loadtool SREC programming revamp implemented, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
617
diff
changeset
|
346 putchar('\n'); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 return(0); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 flashcmd_program_srec(argc, argv, bank) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 char **argv; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 if (argc != 3) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 fprintf(stderr, "usage: %s %s image.srec\n", argv[0], argv[1]); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 } |
670
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
666
diff
changeset
|
357 return flashcmd_progsrec_gen(bank, argv[2], 0, argv[1][0] == 'e'); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 } |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 flashcmd_program_m0(argc, argv, bank) |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 char **argv; |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
362 { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 if (argc != 3) { |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 fprintf(stderr, "usage: %s %s image.m0\n", argv[0], argv[1]); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 return(-1); |
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 } |
670
815c3f8bcff1
fc-loadtool: flash e-program-m0 and e-program-srec implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
666
diff
changeset
|
367 return flashcmd_progsrec_gen(bank, argv[2], 1, argv[1][0] == 'e'); |
0
e7502631a0f9
initial import from freecalypso-sw rev 1033:5ab737ac3ad7
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 } |