Fix stk500 page write (Program Page command). This is supported after

all on non-paged-memory parts.  The problem was that the page size was
defaulting to 256 (maximum for the stk500), but the timeout for a
response from the stk500 before declaring it dead was only 0.5
seconds.  But it takes much longer than 0.5 seconds to program 256
bytes, so we just weren't waiting long enough.

Fix this in two ways - increase the timeout to 5 seconds, and decrease
the page size to 16 bytes for non-paged parts.  The programming time
for 16 bytes is short enough to provide the user with some feedback
that something is happening.


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@260 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
bdean 2003-03-05 04:30:20 +00:00
parent 6e9bdf2a6e
commit 86dbad54c5
2 changed files with 18 additions and 24 deletions

32
avr.c
View File

@ -677,24 +677,6 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
pgm->err_led(pgm, OFF);
if ((strcmp(m->desc, "flash")==0) || (strcmp(m->desc, "eeprom")==0)) {
if (pgm->paged_write != NULL) {
/*
* the programmer supports a paged mode write, perhaps more
* efficiently than we can read it directly, so use its routine
* instead
*/
if (m->paged) {
return pgm->paged_write(pgm, p, m, m->page_size, size);
}
#if 0
else {
return pgm->paged_write(pgm, p, m, 32 /*pgm->page_size*/, size);
}
#endif
}
}
printed = 0;
werror = 0;
@ -704,12 +686,24 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
}
else if (size > wsize) {
fprintf(stderr,
"%s: WARNING: %d bytes requested, but memory region is only %d bytes\n"
"%s: WARNING: %d bytes requested, but memory region is only %d"
"bytes\n"
"%sOnly %d bytes will actually be written\n",
progname, size, wsize,
progbuf, wsize);
}
if ((strcmp(m->desc, "flash")==0) || (strcmp(m->desc, "eeprom")==0)) {
if (pgm->paged_write != NULL) {
/*
* the programmer supports a paged mode write, perhaps more
* efficiently than we can read it directly, so use its routine
* instead
*/
return pgm->paged_write(pgm, p, m, m->page_size, size);
}
}
for (i=0; i<wsize; i++) {
data = m->buf[i];
if (verbose) {

View File

@ -109,8 +109,8 @@ static int stk500_recv(PROGRAMMER * pgm, char * buf, int n)
int nfds;
int rc;
timeout.tv_sec = 0;
timeout.tv_usec = 500000;
timeout.tv_sec = 5;
timeout.tv_usec = 0;
while (n) {
FD_ZERO(&rfds);
@ -511,6 +511,8 @@ static int stk500_initialize(PROGRAMMER * pgm, AVRPART * p)
retry:
tries++;
memset(buf, 0, sizeof(buf));
/*
* set device programming parameters
*/
@ -879,9 +881,7 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
unsigned int n;
if (page_size == 0) {
fprintf(stderr, "%s: stk500_paged_write(): invalid page size = %d\n",
progname, page_size);
return -1;
page_size = 16;
}
if (strcmp(m->desc, "flash") == 0) {