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

Submitted by:  None
Submitted on:  Wed 09 Apr 2008 04:05:52 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Priority: 5 - NormalItem Group: None
Status: FixedPrivacy: Public
Assigned to: Joerg Wunsch <joerg_wunsch>Originator Name: Thomas Holland
Originator Email: -unavailable-Open/Closed: Closed
Release: NoneProgrammer 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>
Project AdministratorIn charge of this item.
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

 

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 04 Nov 2008 01:16:31 PM UTCjoerg_wunschStatusNone=>Fixed
      Assigned toNone=>joerg_wunsch
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1