* stk500.c (stk500_paged_write): Limit blocks written to no bigger
than memory device size. (stk500_paged_write): Send whole block at once. (stk500_paged_load): Limit blocks read to no bigger than memory device size. [Contributed by Bill Somerville <bill@classdesign.com>, this fixes bug #5713.] git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@376 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
c1e0721545
commit
f5cb51e1bf
|
@ -1,5 +1,14 @@
|
|||
2003-10-13 Bill Somerville <bill@classdesign.com>
|
||||
|
||||
* stk500.c (stk500_paged_write): Limit blocks written to no bigger
|
||||
than memory device size.
|
||||
(stk500_paged_write): Send whole block at once.
|
||||
(stk500_paged_load): Limit blocks read to no bigger than memory
|
||||
device size.
|
||||
[This fixes bug #5713.]
|
||||
|
||||
2003-10-13 Eric B. Weddington <eric@ecentral.com>
|
||||
|
||||
|
||||
*avrdude.conf.in: Fix for unterminated character error.
|
||||
|
||||
2003-10-13 Eric B. Weddington <eric@ecentral.com>
|
||||
|
|
|
@ -687,7 +687,7 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
int memtype;
|
||||
unsigned int addr;
|
||||
int a_div;
|
||||
int i;
|
||||
int block_size;
|
||||
int tries;
|
||||
unsigned int n;
|
||||
int flash;
|
||||
|
@ -738,9 +738,16 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
for (addr = 0; addr < n; addr += page_size) {
|
||||
report_progress (addr, n_bytes, NULL);
|
||||
|
||||
if (addr + page_size > n_bytes) {
|
||||
block_size = n_bytes % page_size;
|
||||
}
|
||||
else {
|
||||
block_size = page_size;
|
||||
}
|
||||
|
||||
/* Only skip on empty page if programming flash. */
|
||||
if (flash) {
|
||||
if (stk500_is_page_empty(addr, page_size, m->buf)) {
|
||||
if (stk500_is_page_empty(addr, block_size, m->buf)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -749,14 +756,13 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
tries++;
|
||||
stk500_loadaddr(pgm, addr/a_div);
|
||||
buf[0] = Cmnd_STK_PROG_PAGE;
|
||||
buf[1] = (page_size >> 8) & 0xff;
|
||||
buf[2] = page_size & 0xff;
|
||||
buf[1] = (block_size >> 8) & 0xff;
|
||||
buf[2] = block_size & 0xff;
|
||||
buf[3] = memtype;
|
||||
stk500_send(pgm, buf, 4);
|
||||
for (i=0; i<page_size; i++) {
|
||||
buf[0] = m->buf[addr + i];
|
||||
stk500_send(pgm, buf, 1);
|
||||
}
|
||||
|
||||
stk500_send(pgm, &m->buf[addr], block_size);
|
||||
|
||||
buf[0] = Sync_CRC_EOP;
|
||||
stk500_send(pgm, buf, 1);
|
||||
|
||||
|
@ -788,7 +794,7 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
return n_bytes;
|
||||
}
|
||||
|
||||
static int stk500_is_page_empty(unsigned int address, int page_size,
|
||||
|
@ -815,6 +821,7 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
int a_div;
|
||||
int tries;
|
||||
unsigned int n;
|
||||
int block_size;
|
||||
|
||||
if (strcmp(m->desc, "flash") == 0) {
|
||||
memtype = 'F';
|
||||
|
@ -846,13 +853,21 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
|
||||
for (addr = 0; addr < n; addr += page_size) {
|
||||
report_progress (addr, n_bytes, NULL);
|
||||
|
||||
if (addr + page_size > n_bytes) {
|
||||
block_size = n_bytes % page_size;
|
||||
}
|
||||
else {
|
||||
block_size = page_size;
|
||||
}
|
||||
|
||||
tries = 0;
|
||||
retry:
|
||||
tries++;
|
||||
stk500_loadaddr(pgm, addr/a_div);
|
||||
buf[0] = Cmnd_STK_READ_PAGE;
|
||||
buf[1] = (page_size >> 8) & 0xff;
|
||||
buf[2] = page_size & 0xff;
|
||||
buf[1] = (block_size >> 8) & 0xff;
|
||||
buf[2] = block_size & 0xff;
|
||||
buf[3] = memtype;
|
||||
buf[4] = Sync_CRC_EOP;
|
||||
stk500_send(pgm, buf, 5);
|
||||
|
@ -875,7 +890,7 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
return -4;
|
||||
}
|
||||
|
||||
stk500_recv(pgm, &m->buf[addr], page_size);
|
||||
stk500_recv(pgm, &m->buf[addr], block_size);
|
||||
|
||||
stk500_recv(pgm, buf, 1);
|
||||
if (buf[0] != Resp_STK_OK) {
|
||||
|
@ -887,7 +902,7 @@ static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
}
|
||||
}
|
||||
|
||||
return n;
|
||||
return n_bytes;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue