Make the s-record output routine work like the raw and intel hex
output routines (don't optimize away 0xff data before and after non 0xff data). Also, fix a bug where the data contents sometimes weren't written out completely. Initial bug reported by Tom Harris <TomH@optiscan.com>. Fixes provided by Alexey V.Levdikov <tsar@kemford.com>. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@330 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
1fa0b23de1
commit
e0026ff0fd
|
@ -360,11 +360,10 @@ int b2srec(unsigned char * inbuf, int bufsize,
|
||||||
char * outfile, FILE * outf)
|
char * outfile, FILE * outf)
|
||||||
{
|
{
|
||||||
unsigned char * buf;
|
unsigned char * buf;
|
||||||
unsigned int nextaddr, stopaddr;
|
unsigned int nextaddr;
|
||||||
int n, nbytes, addr_width;
|
int n, nbytes, addr_width;
|
||||||
int i;
|
int i;
|
||||||
unsigned char cksum;
|
unsigned char cksum;
|
||||||
unsigned char startf, stopf ,emptyf;
|
|
||||||
|
|
||||||
char * tmpl=0;
|
char * tmpl=0;
|
||||||
|
|
||||||
|
@ -374,38 +373,10 @@ int b2srec(unsigned char * inbuf, int bufsize,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nextaddr = startaddr;
|
||||||
buf = inbuf;
|
buf = inbuf;
|
||||||
nextaddr = 0;
|
nbytes = 0;
|
||||||
stopaddr = 0;
|
|
||||||
startf = 0;
|
|
||||||
stopf = 0;
|
|
||||||
|
|
||||||
/* search for ranges of 'real' data */
|
|
||||||
for (i=startaddr; i<bufsize; i++) {
|
|
||||||
if (buf[i] == 0xff) {
|
|
||||||
if (startf == 0)
|
|
||||||
continue;
|
|
||||||
else if (stopf == 0) {
|
|
||||||
stopf = 1;
|
|
||||||
stopaddr = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (startf == 0) {
|
|
||||||
startf = 1;
|
|
||||||
nextaddr = i;
|
|
||||||
while (nextaddr % recsize != 0)
|
|
||||||
nextaddr --;
|
|
||||||
}
|
|
||||||
else if (stopf == 1) {
|
|
||||||
stopf = 0;
|
|
||||||
stopaddr = bufsize;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nbytes = i;
|
|
||||||
|
|
||||||
bufsize = stopaddr - nextaddr;
|
|
||||||
addr_width = 0;
|
addr_width = 0;
|
||||||
|
|
||||||
while (bufsize) {
|
while (bufsize) {
|
||||||
|
@ -435,17 +406,6 @@ int b2srec(unsigned char * inbuf, int bufsize,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip the lines filled with 0xff */
|
|
||||||
emptyf = 1;
|
|
||||||
for (i=nextaddr; i<nextaddr + n; i++) {
|
|
||||||
if (buf[i] != 0xff) {
|
|
||||||
emptyf=0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (emptyf != 1) {
|
|
||||||
|
|
||||||
fprintf(outf, tmpl, n + addr_width + 1, nextaddr);
|
fprintf(outf, tmpl, n + addr_width + 1, nextaddr);
|
||||||
|
|
||||||
cksum += n + addr_width + 1;
|
cksum += n + addr_width + 1;
|
||||||
|
@ -460,9 +420,9 @@ int b2srec(unsigned char * inbuf, int bufsize,
|
||||||
|
|
||||||
cksum = 0xff - cksum;
|
cksum = 0xff - cksum;
|
||||||
fprintf(outf, "%02X\n", cksum);
|
fprintf(outf, "%02X\n", cksum);
|
||||||
}
|
|
||||||
|
|
||||||
nextaddr += n;
|
nextaddr += n;
|
||||||
|
nbytes +=n;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* advance to next 'recsize' bytes */
|
/* advance to next 'recsize' bytes */
|
||||||
|
|
Loading…
Reference in New Issue