* stk500.c: If writing flash, skip empty pages in paged write.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@369 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Eric Weddington 2003-09-16 20:40:13 +00:00
parent 5a7b88a1a9
commit 7511dfd0c3
2 changed files with 31 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2003-09-16 Eric B. Weddington <eric@ecentral.com>
* stk500.c: If writing flash, skip empty pages in paged write.
2003-09-06 Theodore A. Roth <troth@openavr.org> 2003-09-06 Theodore A. Roth <troth@openavr.org>
* NEWS: Add 'Current:' header. * NEWS: Add 'Current:' header.

View File

@ -50,6 +50,9 @@ extern int do_cycles;
static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value); static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value);
static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value); static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value);
static void stk500_print_parms1(PROGRAMMER * pgm, char * p); static void stk500_print_parms1(PROGRAMMER * pgm, char * p);
static int stk500_is_page_empty(unsigned int address, int page_size,
const unsigned char *buf);
static int stk500_send(PROGRAMMER * pgm, char * buf, size_t len) static int stk500_send(PROGRAMMER * pgm, char * buf, size_t len)
{ {
@ -687,6 +690,7 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int i; int i;
int tries; int tries;
unsigned int n; unsigned int n;
int flash;
if (page_size == 0) { if (page_size == 0) {
page_size = 128; page_size = 128;
@ -694,9 +698,11 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
if (strcmp(m->desc, "flash") == 0) { if (strcmp(m->desc, "flash") == 0) {
memtype = 'F'; memtype = 'F';
flash = 1;
} }
else if (strcmp(m->desc, "eeprom") == 0) { else if (strcmp(m->desc, "eeprom") == 0) {
memtype = 'E'; memtype = 'E';
flash = 0;
} }
else { else {
return -2; return -2;
@ -731,6 +737,13 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
for (addr = 0; addr < n; addr += page_size) { for (addr = 0; addr < n; addr += page_size) {
report_progress (addr, n_bytes, NULL); report_progress (addr, n_bytes, NULL);
/* Only skip on empty page if programming flash. */
if (flash) {
if (stk500_is_page_empty(addr, page_size, m->buf)) {
continue;
}
}
tries = 0; tries = 0;
retry: retry:
tries++; tries++;
@ -778,6 +791,20 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
return n; return n;
} }
static int stk500_is_page_empty(unsigned int address, int page_size,
const unsigned char *buf)
{
int i;
for(i = 0; i < page_size; i++) {
if(buf[address + i] != 0xFF) {
/* Page is not empty. */
return(0);
}
}
/* Page is empty. */
return(1);
}
static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, static int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int page_size, int n_bytes) int page_size, int n_bytes)