URL:
  <http://savannah.nongnu.org/bugs/?22882>

                 Summary: Erase Cycle Counter does not work for stk500v2
                 Project: AVR Downloader/UploaDEr
            Submitted by: None
            Submitted on: Mittwoch 09.04.2008 um 16:05 UTC
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
         Originator Name: Thomas Holland
        Originator Email: [EMAIL PROTECTED]
             Open/Closed: Open
         Discussion Lock: Any

    _______________________________________________________

Details:

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);





    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?22882>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/



_______________________________________________
avrdude-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avrdude-dev

Reply via email to