bugAVR Downloader/UploaDEr - Bugs: bug #22882, Erase Cycle Counter does not work...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #22882: Erase Cycle Counter does not work for stk500v2

Submitter:  None
Submitted:  Wed 09 Apr 2008 04:05:52 PM UTC
   
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  None
Status:  Fixed Privacy:  Public
Assigned to:  joerg_wunsch Originator Name:  Thomas Holland
Originator Email:  -email is unavailable- Open/Closed:  Closed
Release:  None Programmer hardware: 
Device type: 

Tue 04 Nov 2008 01:16:31 PM UTC, comment #1: 

It appears the chip_erase() function is supposed to return 0
for success, and -1 for failure, so I rather patched
stk500v2_chip_erase(), and stk500hv_chip_erase(), respectively
to return 0 for success.

Joerg Wunsch <joerg_wunsch>
Group administrator
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);

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by joerg_wunsch (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2008-11-04 joerg_wunsch StatusNone Fixed
        Assigned toNone joerg_wunsch
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code