AVR32
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@851 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
e6928c77cf
commit
7c4dc335ca
|
@ -267,17 +267,18 @@ static int ihex2b(char * infile, FILE * inf,
|
||||||
{
|
{
|
||||||
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;
|
||||||
struct ihexrec ihex;
|
struct ihexrec ihex;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
lineno = 0;
|
lineno = 0;
|
||||||
buf = outbuf;
|
buf = outbuf;
|
||||||
baseaddr = 0;
|
baseaddr = 0;
|
||||||
maxaddr = 0;
|
maxaddr = 0;
|
||||||
|
offsetaddr = 0;
|
||||||
|
|
||||||
while (fgets((char *)buffer,MAX_LINE_LEN,inf)!=NULL) {
|
while (fgets((char *)buffer,MAX_LINE_LEN,inf)!=NULL) {
|
||||||
lineno++;
|
lineno++;
|
||||||
|
@ -301,28 +302,28 @@ 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 */
|
||||||
baseaddr = (ihex.data[0] << 8 | ihex.data[1]) << 4;
|
// note: shift values use to be 8 and 4 - the first had to be wrong
|
||||||
|
baseaddr = (ihex.data[0] << 12 | ihex.data[1]) << 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3: /* start segment address record */
|
case 3: /* start segment address record */
|
||||||
|
@ -330,7 +331,8 @@ static int ihex2b(char * infile, FILE * inf,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
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] << 24 | ihex.data[1]) << 16;
|
||||||
|
if(offsetaddr == 0) offsetaddr = baseaddr;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5: /* start linear address record */
|
case 5: /* start linear address record */
|
||||||
|
@ -353,7 +355,7 @@ static int ihex2b(char * infile, FILE * inf,
|
||||||
"file \"%s\"\n",
|
"file \"%s\"\n",
|
||||||
progname, infile);
|
progname, infile);
|
||||||
|
|
||||||
return maxaddr;
|
return maxaddr-offsetaddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue