Redo most of r851 and r880, respectively, minus the bugs. ;-)
(Submitted by dhoerl) git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@929 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
4e53f3451e
commit
befb4dc9cc
|
@ -1,8 +1,8 @@
|
||||||
2010-01-18 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
2010-01-18 David Hoerl <dhoerl@mac.com>
|
||||||
|
|
||||||
bug #28660: Problem with loading intel hex rom files that exceed
|
bug #28660: Problem with loading intel hex rom files that exceed
|
||||||
0x10000 bytes
|
0x10000 bytes
|
||||||
* fileio.c: Revert the changes from r851 and r880, respectively.
|
* fileio.c: Fix two byte shifts.
|
||||||
|
|
||||||
2010-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
2010-01-15 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||||
|
|
||||||
|
|
17
fileio.c
17
fileio.c
|
@ -261,13 +261,12 @@ static int ihex_readrec(struct ihexrec * ihex, char * rec)
|
||||||
* If an error occurs, return -1.
|
* If an error occurs, return -1.
|
||||||
*
|
*
|
||||||
* */
|
* */
|
||||||
|
|
||||||
static int ihex2b(char * infile, FILE * inf,
|
static int ihex2b(char * infile, FILE * inf,
|
||||||
unsigned char * outbuf, int bufsize)
|
unsigned char * outbuf, int bufsize)
|
||||||
{
|
{
|
||||||
char buffer [ MAX_LINE_LEN ];
|
char buffer [ MAX_LINE_LEN ];
|
||||||
unsigned char * buf;
|
unsigned char * buf;
|
||||||
unsigned int nextaddr, baseaddr, maxaddr;
|
unsigned int nextaddr, baseaddr, maxaddr, offsetaddr;
|
||||||
int i;
|
int i;
|
||||||
int lineno;
|
int lineno;
|
||||||
int len;
|
int len;
|
||||||
|
@ -278,6 +277,8 @@ static int ihex2b(char * infile, FILE * inf,
|
||||||
buf = outbuf;
|
buf = outbuf;
|
||||||
baseaddr = 0;
|
baseaddr = 0;
|
||||||
maxaddr = 0;
|
maxaddr = 0;
|
||||||
|
offsetaddr = 0;
|
||||||
|
nextaddr = 0;
|
||||||
|
|
||||||
while (fgets((char *)buffer,MAX_LINE_LEN,inf)!=NULL) {
|
while (fgets((char *)buffer,MAX_LINE_LEN,inf)!=NULL) {
|
||||||
lineno++;
|
lineno++;
|
||||||
|
@ -301,24 +302,23 @@ static int ihex2b(char * infile, FILE * inf,
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (ihex.rectyp) {
|
switch (ihex.rectyp) {
|
||||||
|
|
||||||
case 0: /* data record */
|
case 0: /* data record */
|
||||||
nextaddr = ihex.loadofs + baseaddr;
|
nextaddr = ihex.loadofs + baseaddr;
|
||||||
if (nextaddr + ihex.reclen > bufsize) {
|
if ((nextaddr + ihex.reclen) > (bufsize+offsetaddr)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: ERROR: address 0x%04x out of range at line %d of %s\n",
|
"%s: ERROR: address 0x%04x out of range at line %d of %s\n",
|
||||||
progname, nextaddr+ihex.reclen, lineno, infile);
|
progname, nextaddr+ihex.reclen, lineno, infile);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
for (i=0; i<ihex.reclen; i++) {
|
for (i=0; i<ihex.reclen; i++) {
|
||||||
buf[nextaddr+i] = ihex.data[i];
|
buf[nextaddr+i-offsetaddr] = ihex.data[i];
|
||||||
}
|
}
|
||||||
if (nextaddr+ihex.reclen > maxaddr)
|
if (nextaddr+ihex.reclen > maxaddr)
|
||||||
maxaddr = nextaddr+ihex.reclen;
|
maxaddr = nextaddr+ihex.reclen;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* end of file record */
|
case 1: /* end of file record */
|
||||||
return maxaddr;
|
return maxaddr-offsetaddr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2: /* extended segment address record */
|
case 2: /* extended segment address record */
|
||||||
|
@ -331,6 +331,7 @@ static int ihex2b(char * infile, FILE * inf,
|
||||||
|
|
||||||
case 4: /* extended linear address record */
|
case 4: /* extended linear address record */
|
||||||
baseaddr = (ihex.data[0] << 8 | ihex.data[1]) << 16;
|
baseaddr = (ihex.data[0] << 8 | ihex.data[1]) << 16;
|
||||||
|
if(nextaddr == 0) offsetaddr = baseaddr; // if provided before any data, then remember it
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: /* start linear address record */
|
case 5: /* start linear address record */
|
||||||
|
@ -353,10 +354,9 @@ static int ihex2b(char * infile, FILE * inf,
|
||||||
"file \"%s\"\n",
|
"file \"%s\"\n",
|
||||||
progname, infile);
|
progname, infile);
|
||||||
|
|
||||||
return maxaddr;
|
return maxaddr-offsetaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int b2srec(unsigned char * inbuf, int bufsize,
|
static int b2srec(unsigned char * inbuf, int bufsize,
|
||||||
int recsize, int startaddr,
|
int recsize, int startaddr,
|
||||||
char * outfile, FILE * outf)
|
char * outfile, FILE * outf)
|
||||||
|
@ -1153,6 +1153,7 @@ int fileio(int op, char * filename, FILEFMT format,
|
||||||
if (format != FMT_IMM && !using_stdio) {
|
if (format != FMT_IMM && !using_stdio) {
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue