FreeCalypso > hg > freecalypso-sw
annotate loadtools/ltdump.c @ 96:57b8dbb029c2
fc-loadtool: GTA0x flash support
author | Michael Spacefalcon <msokolov@ivan.Harhan.ORG> |
---|---|
date | Sun, 01 Sep 2013 04:18:32 +0000 |
parents | 1f035187e98f |
children | b3ed63722eb5 |
rev | line source |
---|---|
35
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * This module implements the dump2bin and dump2srec functionality |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 * of fc-loadtool. |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 */ |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <sys/types.h> |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <stdio.h> |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <stdint.h> |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <string.h> |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <strings.h> |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include <stdlib.h> |
94
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
12 #include <time.h> |
35
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
14 extern uint32_t crc32_table[]; |
35
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 extern char target_response_line[]; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 crc32_on_target(area_base, area_len, retptr) |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 u_long area_base, area_len, *retptr; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 { |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 char arg1[10], arg2[10], *argv[4]; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 int stat; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 char *strtoul_endp; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 sprintf(arg1, "%lx", area_base); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 sprintf(arg2, "%lx", area_len); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 argv[0] = "crc32"; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 argv[1] = arg1; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 argv[2] = arg2; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 argv[3] = 0; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 tpinterf_make_cmd(argv); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 if (tpinterf_send_cmd() < 0) |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 return(-1); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 stat = tpinterf_capture_output_oneline(10); /* 10 s timeout */ |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 if (stat != 1) { |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 errout: fprintf(stderr, "error: malformed response to crc32 command\n"); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 return(-1); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 } |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 if (strlen(target_response_line) != 8) |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 goto errout; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 *retptr = strtoul(target_response_line, &strtoul_endp, 16); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 if (strtoul_endp != target_response_line + 8) |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 goto errout; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 return(0); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 } |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 cmd_crc32(argc, argv) |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 char **argv; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 { |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 u_long area_base, area_len; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 char *strtoul_endp; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 u_long crc_result; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 int stat; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
54 area_base = strtoul(argv[1], &strtoul_endp, 16); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 if (*strtoul_endp) { |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 inv: fprintf(stderr, "usage: crc32 hex-start hex-len\n"); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 return(-1); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 } |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 area_len = strtoul(argv[2], &strtoul_endp, 16); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 if (*strtoul_endp) |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 goto inv; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 stat = crc32_on_target(area_base, area_len, &crc_result); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 if (stat == 0) |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 printf("%08lX\n", crc_result); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 return(stat); |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 } |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
68 /* the actual dump facility */ |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
69 |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
70 static FILE *dump_outfile; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
71 static int dump_save_srec; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
72 static uint32_t dump_nextaddr, dump_crcaccum; |
94
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
73 static uint32_t dump_total_len, dump_progress_len; |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
74 static u_char dump_binrec[0x86]; |
94
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
75 static time_t dump_last_time; |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
76 |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
77 static |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
78 dump_receiver(line) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
79 char *line; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
80 { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
81 int i, b; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
82 u_char sr_cksum; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
83 uint32_t addr_from_srec; |
94
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
84 time_t curtime; |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
85 |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
86 if (strncmp(line, "S385", 4)) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
87 fprintf(stderr, |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
88 "error: target response is not the expected S385...\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
89 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
90 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
91 for (i = 0; i < 0x86; i++) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
92 b = decode_hex_byte(line + i*2 + 2); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
93 if (b < 0) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
94 fprintf(stderr, |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
95 "data from target: S-record hex decode error\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
96 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
97 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
98 dump_binrec[i] = b; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
99 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
100 sr_cksum = 0; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
101 for (i = 0; i < 0x86; i++) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
102 sr_cksum += dump_binrec[i]; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
103 if (sr_cksum != 0xFF) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
104 fprintf(stderr, "data from target: bad S-record checksum\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
105 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
106 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
107 /* basic S-record format OK; now verify the address */ |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
108 addr_from_srec = ((uint32_t) dump_binrec[1] << 24) | |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
109 ((uint32_t) dump_binrec[2] << 16) | |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
110 ((uint32_t) dump_binrec[3] << 8) | |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
111 (uint32_t) dump_binrec[4]; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
112 if (addr_from_srec != dump_nextaddr) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
113 fprintf(stderr, |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
114 "error: S3 record from target has the wrong address\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
115 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
116 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
117 /* all checks passed - save it */ |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
118 if (dump_save_srec) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
119 fprintf(dump_outfile, "%s\n", line); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
120 else |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
121 fwrite(dump_binrec + 5, 1, 0x80, dump_outfile); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
122 /* update running CRC */ |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
123 for (i = 0; i < 0x80; i++) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
124 dump_crcaccum = crc32_table[dump_crcaccum & 0xFF ^ |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
125 dump_binrec[i+5]] ^ |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
126 (dump_crcaccum >> 8); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
127 /* progress indication */ |
94
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
128 dump_progress_len += 0x80; |
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
129 i = dump_progress_len * 100 / dump_total_len; |
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
130 time(&curtime); |
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
131 if (curtime != dump_last_time || i == 100) { |
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
132 printf("\rRx %lu out of %lu bytes (%i%%)", |
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
133 (u_long) dump_progress_len, (u_long) dump_total_len, i); |
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
134 fflush(stdout); |
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
135 } |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
136 dump_nextaddr += 0x80; |
94
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
137 dump_last_time = curtime; |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
138 return(1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
139 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
140 |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
141 loadtool_memdump(start_addr, area_len, filename, fmt_srec) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
142 u_long start_addr, area_len; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
143 char *filename; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
144 { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
145 u_long target_crc_init, target_crc_fin; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
146 char *target_argv[4], target_arg1[10], target_arg2[10]; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
147 int stat; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
148 |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
149 if (start_addr & 0x7F || area_len & 0x7F) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
150 fprintf(stderr, |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
151 "error: implementation limit: 128-byte alignment required\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
152 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
153 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
154 printf("Requesting initial CRC-32 of the area from target...\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
155 stat = crc32_on_target(start_addr, area_len, &target_crc_init); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
156 if (stat) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
157 return(stat); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
158 printf("got %08lX\n", target_crc_init); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
159 dump_outfile = fopen(filename, "w"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
160 if (!dump_outfile) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
161 perror(filename); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
162 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
163 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
164 dump_save_srec = fmt_srec; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
165 dump_nextaddr = start_addr; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
166 dump_crcaccum = 0xFFFFFFFF; |
94
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
167 dump_total_len = area_len; |
1f035187e98f
fc-loadtool dump2{bin,srec}: smarter progress indication
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
36
diff
changeset
|
168 dump_progress_len = 0; |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
169 |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
170 printf("Requesting memory dump...\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
171 sprintf(target_arg1, "%lx", start_addr); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
172 sprintf(target_arg2, "%lx", area_len); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
173 target_argv[0] = "DUMP"; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
174 target_argv[1] = target_arg1; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
175 target_argv[2] = target_arg2; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
176 target_argv[3] = 0; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
177 tpinterf_make_cmd(target_argv); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
178 stat = tpinterf_send_cmd(); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
179 if (stat < 0) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
180 fclose(dump_outfile); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
181 return(stat); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
182 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
183 stat = tpinterf_capture_output(2, dump_receiver); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
184 fclose(dump_outfile); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
185 if (stat < 0) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
186 return(stat); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
187 putchar('\n'); /* after lots of dots */ |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
188 |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
189 /* sanity checks */ |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
190 if (dump_nextaddr != start_addr + area_len) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
191 fprintf(stderr, |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
192 "error: received dump length does not match expected\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
193 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
194 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
195 if (dump_crcaccum != (uint32_t) target_crc_init) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
196 fprintf(stderr, "error: CRC mismatch (computed %lX)\n", |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
197 (u_long) dump_crcaccum); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
198 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
199 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
200 printf("Requesting another CRC-32 of the area from target...\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
201 stat = crc32_on_target(start_addr, area_len, &target_crc_fin); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
202 if (stat) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
203 return(stat); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
204 if (target_crc_fin == target_crc_init) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
205 printf("match, dump successful\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
206 return(0); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
207 } else { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
208 fprintf(stderr, "mismatch: got %lX this time\n", |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
209 target_crc_fin); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
210 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
211 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
212 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
213 |
35
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
214 cmd_dump2bin(argc, argv) |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
215 char **argv; |
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
216 { |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
217 u_long area_base, area_len; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
218 char *strtoul_endp; |
35
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
219 |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
220 area_base = strtoul(argv[1], &strtoul_endp, 16); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
221 if (*strtoul_endp) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
222 inv: fprintf(stderr, "usage: dump2bin hex-start hex-len outfile\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
223 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
224 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
225 area_len = strtoul(argv[2], &strtoul_endp, 16); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
226 if (*strtoul_endp) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
227 goto inv; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
228 return loadtool_memdump(area_base, area_len, argv[3], 0); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
229 } |
35
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
230 |
36
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
231 cmd_dump2srec(argc, argv) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
232 char **argv; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
233 { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
234 u_long area_base, area_len; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
235 char *strtoul_endp; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
236 |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
237 area_base = strtoul(argv[1], &strtoul_endp, 16); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
238 if (*strtoul_endp) { |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
239 inv: fprintf(stderr, "usage: dump2srec hex-start hex-len outfile\n"); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
240 return(-1); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
241 } |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
242 area_len = strtoul(argv[2], &strtoul_endp, 16); |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
243 if (*strtoul_endp) |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
244 goto inv; |
65111e6eee9e
loadtool: dump2bin and dump2srec implemented
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
35
diff
changeset
|
245 return loadtool_memdump(area_base, area_len, argv[3], 1); |
35
05af070c4b60
loadtool: preparations for dump2bin and dump2srec
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
246 } |