Wed 09 Apr 2008 04:05:52 PM UTC, original submission:
in avr.c, the cycle counter is only increased and written back when the "chip_erase" function returns 0.
int avr_chip_erase(PROGRAMMER * pgm, AVRPART * p)
{
[...]
rc = pgm->chip_erase(pgm, p);
/*
* Don't update the cycle counter, if erase failed
*/
if (do_cycles && (rc >= 0)) {
However, the stk500v2 module returns not 0 but the number of bytes received from the Programmer (+6) when the chip erase command is executed.
stk500v2.c:
in function stk500v2_chip_erase():
result = stk500v2_command(pgm, buf, 7, sizeof(buf));
[...]
return result;
and in function stk500v2_command():
[...]
status = stk500v2_recv(pgm,buf,maxlen);
// if we got a successful readback, return
if (status > 0) {
[...]
if (buf[1] == STATUS_CMD_OK)
return status;
and in function stk500v2_recv():
[...]
return (int)(msglen+6);
The following patch works for me and my stk500v2, although I am not sure if might have side effects for other programmers.
Index: avr.c
===================================================================
RCS file: /sources/avrdude/avrdude/avr.c,v
retrieving revision 1.74
diff -u -r1.74 avr.c
--- avr.c 16 May 2007 20:15:13 -0000 1.74
+++ avr.c 9 Apr 2008 16:03:43 -0000
@@ -798,7 +798,7 @@
/*
* Don't update the cycle counter, if erase failed
*/
- if (do_cycles && (rc == 0)) {
+ if (do_cycles && (rc >= 0)) {
cycles++;
fprintf(stderr, "%s: erase-rewrite cycle count is now %d\n",
progname, cycles);
|