diff --git a/src/fileio.c b/src/fileio.c index 754e267b..1c81682d 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -1446,16 +1446,17 @@ static int fmt_autodetect(char * fname) -int fileio(int op, char * filename, FILEFMT format, +int fileio(int oprwv, char * filename, FILEFMT format, struct avrpart * p, char * memtype, int size) { - int rc; + int op, rc; FILE * f; char * fname; struct fioparms fio; AVRMEM * mem; int using_stdio; + op = oprwv == FIO_READ_FOR_VERIFY? FIO_READ: oprwv; mem = avr_locate_mem(p, memtype); if (mem == NULL) { avrdude_message(MSG_INFO, "fileio(): memory type \"%s\" not configured for device \"%s\"\n", @@ -1585,8 +1586,8 @@ int fileio(int op, char * filename, FILEFMT format, return -1; } - /* on reading flash set the size to location of highest non-0xff byte */ - if (rc > 0 && op == FIO_READ) { + /* on reading flash other than for verify set the size to location of highest non-0xff byte */ + if (rc > 0 && oprwv == FIO_READ) { int hiaddr = avr_mem_hiaddr(mem); if(hiaddr < rc) /* if trailing-0xff not disabled */ diff --git a/src/libavrdude.h b/src/libavrdude.h index d8d5739a..73083932 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -826,7 +826,8 @@ struct fioparms { enum { FIO_READ, - FIO_WRITE + FIO_WRITE, + FIO_READ_FOR_VERIFY, }; #ifdef __cplusplus @@ -835,7 +836,7 @@ extern "C" { char * fmtstr(FILEFMT format); -int fileio(int op, char * filename, FILEFMT format, +int fileio(int oprwv, char * filename, FILEFMT format, struct avrpart * p, char * memtype, int size); #ifdef __cplusplus diff --git a/src/update.c b/src/update.c index 15002549..d3c208fc 100644 --- a/src/update.c +++ b/src/update.c @@ -341,7 +341,7 @@ int do_op(PROGRAMMER * pgm, struct avrpart * p, UPDATE * upd, enum updateflags f progname, mem->desc, alias_mem_desc, upd->filename); } - rc = fileio(FIO_READ, upd->filename, upd->format, p, upd->memtype, -1); + rc = fileio(FIO_READ_FOR_VERIFY, upd->filename, upd->format, p, upd->memtype, -1); if (rc < 0) { avrdude_message(MSG_INFO, "%s: read from file '%s' failed\n", progname, upd->filename);