FreeCalypso > hg > fc-usbser-tools
annotate cp2102/intel_hex_in.c @ 102:4f72e09fb698
doc/CP2102-EEPROM-tools: complete for now
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 28 Sep 2023 21:13:33 +0000 |
parents | 842cff427588 |
children |
rev | line source |
---|---|
55
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module implements a function for reading CP2102 EEPROM images |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * in the Intel HEX format which we've copied from cp210x-program-1.0, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * the Python-language tool from 2014. |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/types.h> |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <ctype.h> |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <string.h> |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <strings.h> |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <stdio.h> |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdlib.h> |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "cp210x_defs.h" |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 extern u_char eeprom[SIZE_EEPROM]; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 static int |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 decode_hex_digit(c) |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 if (c >= '0' && c <= '9') |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 return(c - '0'); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 if (c >= 'A' && c <= 'F') |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 return(c - 'A' + 10); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 if (c >= 'a' && c <= 'f') |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 return(c - 'a' + 10); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 return(-1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 static int |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 decode_hex_byte(str) |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 char *str; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 int u, l; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 u = decode_hex_digit(str[0]); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 l = decode_hex_digit(str[1]); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 return (u << 4) | l; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 void |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 read_intel_hex(filename) |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 char *filename; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 FILE *inf; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 char linebuf[1024], *cp; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 int lineno; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 unsigned eeprom_offset; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 unsigned payload_len, record_len, n; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 u_char record[21], csum; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 unsigned record_addr, expect_addr; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 inf = fopen(filename, "r"); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 if (!inf) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 perror(filename); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 eeprom_offset = 0; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 if (!index(linebuf, '\n')) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 fprintf(stderr, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 "%s line %d: too long or missing newline\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 filename, lineno); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 if (linebuf[0] != ':') |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 continue; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 if (!isxdigit(linebuf[1]) || !isxdigit(linebuf[2])) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 inv_record: fprintf(stderr, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 "%s line %d: invalid Intex HEX record\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 filename, lineno); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 payload_len = decode_hex_byte(linebuf + 1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 if (payload_len > 16) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 bad_payload_len: fprintf(stderr, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 "%s line %d: unsupported payload length\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 filename, lineno); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 record_len = payload_len + 5; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 cp = linebuf + 1; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 csum = 0; |
56
842cff427588
cp2102: fix Intel HEX read/write bugs
Mychaela Falconia <falcon@freecalypso.org>
parents:
55
diff
changeset
|
83 for (n = 0; n < record_len; n++) { |
55
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 if (!isxdigit(cp[0]) || !isxdigit(cp[1])) |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 goto inv_record; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 record[n] = decode_hex_byte(cp); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 cp += 2; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 csum += record[n]; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 if (csum) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 fprintf(stderr, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 "%s line %d: bad Intel HEX record checksum\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 filename, lineno); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 if (record[3] == 0x00) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 if (payload_len != 16) |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 goto bad_payload_len; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 if (eeprom_offset >= SIZE_EEPROM) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 fprintf(stderr, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 "%s line %d: data continues past valid EEPROM size\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 filename, lineno); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 record_addr = (record[1] << 8) | record[2]; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 expect_addr = EEPROM_START_ADDR + eeprom_offset; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 if (record_addr != expect_addr) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 fprintf(stderr, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 "%s line %d: record addr is %04X, but we expect %04X\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 filename, lineno, record_addr, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 expect_addr); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 bcopy(record + 4, eeprom + eeprom_offset, 16); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 eeprom_offset += 16; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 } else if (record[3] == 0x01) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 if (payload_len) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 fprintf(stderr, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 "%s line %d: nonzero payload length in end-marker record\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 filename, lineno); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 if (eeprom_offset < SIZE_EEPROM) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 fprintf(stderr, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 "%s line %d: end-marker without full data\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 filename, lineno); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 break; |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 } else { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 fprintf(stderr, |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 "%s line %d: unsupported Intel HEX record type\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 filename, lineno); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 fclose(inf); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 if (!eeprom_offset) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 fprintf(stderr, "error: no Intel HEX EEPROM data found in %s\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 filename); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 if (eeprom_offset < SIZE_EEPROM) { |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 fprintf(stderr, "error: %s contains truncated data\n", |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 filename); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 exit(1); |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 } |
c0084bf153e5
cp2102: Intel HEX reading implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 } |