avrdude cycle counter funktioniert nicht

#837683
Lesenswert?

Hallo,

ich habe gerade mal den avrdude erase cycle counter ausprobiert und 
irgendwie scheint das nicht so zu funktionieren wie ich mir das 
vorgestellt habe.

Also zuerst setzt ich den Counter auf einen Wert:
1
C:\DOKUME~1\Thomas>avrdude -pm8515 -cstk500v2 -Y 20
2

3
avrdude: AVR device initialized and ready to accept instructions
4

5
Reading | ################################################## | 100% 0.00s
6

7
avrdude: Device signature = 0x1e9306
8
avrdude: setting erase-rewrite cycle count to 20
9

10
avrdude: safemode: Fuses OK
11

12
avrdude done.  Thank you.
Soweit - so gut, in den letzten vier bytes des eeproms steht jetzt 20.
1
C:\DOKUME~1\Thomas>avrdude -pm8515 -cstk500v2 -t
2

3
avrdude: AVR device initialized and ready to accept instructions
4

5
Reading | ################################################## | 100% 0.02s
6

7
avrdude: Device signature = 0x1e9306
8
avrdude: current erase-rewrite cycle count is 20 (if being tracked)
9
avrdude> dump eeprom 508 4
10
>>> dump eeprom 508 4
11
01fc  00 00 00 14                                       |....            |
12

13
avrdude>

Wenn ich aber ein chip erase mache, dann wird der counter wieder 
gnadenlos überschrieben:
1
>avrdude -pm8515 -cstk500v2 -y -e
2
vrdude: AVR device initialized and ready to accept instructions
3

4
Reading | ################################################## | 100% 0.00s
5

6
avrdude: Device signature = 0x1e9306
7
avrdude: erasing chip
8

9
avrdude: safemode: Fuses OK
10

11
avrdude done.  Thank you.
12

13
C:\DOKUME~1\Thomas>avrdude -pm8515 -cstk500v2 -t
14

15
avrdude: AVR device initialized and ready to accept instructions
16

17
Reading | ################################################## | 100% 0.00s
18

19
avrdude: Device signature = 0x1e9306
20
avrdude> dump eeprom 508 4
21
>>> dump eeprom 508 4
22
01fc  ff ff ff ff                                       |....            |
23

24
avrdude>

Mach ich was falsch oder hat avrdude 'ne macke? Ich habe mir auch den 
Sourcecode zu avrdude angeschaut und da sieht alles auf dem ersten Blick 
gut aus - vor dem Chip Erase wird der cycle counter gelesen und nach dem 
erase wieder zurückgeschrieben (avr.c:786ff)

Any ideas?

Gruss

Thomas

P.S. Bevor jemand sagt das ich den Counter nicht brauche: Es geht um 
mein AVR Eclipse Plugin, bei dem ich Support für den Cycle Counter 
grundsätzlich vorgesehen hatte.
Persönliche Seite #837748
Lesenswert?

Hast du schon -e in Kombination mit -y getestet?
1
-y 
2
Tells AVRDUDE to use the last four bytes of the connected parts' EEPROM memory to track the number of times the device has been erased. When this option is used and the `-e' flag is specified to generate a chip erase, the previous counter will be saved before the chip erase, it is then incremented, and written back after the erase cycle completes. Presumably, the device would only be erased just before being programmed, and thus, this can be utilized to give an indication of how many erase-rewrite cycles the part has undergone. Since the FLASH memory can only endure a finite number of erase-rewrite cycles, one can use this option to track when a part is nearing the limit. The typical limit for Atmel AVR FLASH is 1000 cycles. Of course, if the application needs the last four bytes of EEPROM memory, this option should not be used.
http://www.nongnu.org/avrdude/user-manual/avrdude_4.html#SEC4
#838050
Lesenswert?

Ja mann wrote:
> Du mußt vermutlich das Fuse-Bit "Preserve EEPROM...." setzen.

Nein, daran lag es nicht.

Es sieht doch nach einem Bug in avrdude aus.

Ich habe cygwin installiert, avrdude compiliert, den debugger 
angeschmissen und gesehen, dass in stk500v2.c in
1
static int stk500v2_command(PROGRAMMER * pgm, unsigned char * buf, size_t len, size_t maxlen)
als Statuscode nicht 0 für Erfolg sondern die Anzahl der empfangenen 
Bytes zurückgegeben wird
1
  // attempt to read the status back
2
  status = stk500v2_recv(pgm,buf,maxlen);
3

4
  // if we got a successful readback, return
5
  if (status > 0) {
6
    DEBUG(" = %d\n",status);
7
    if (status < 2) {
8
      fprintf(stderr, "%s: stk500v2_command(): short reply\n", progname);
9
      return -1;
10
    }
11
    if (buf[1] == STATUS_CMD_OK)
12
      return status;

Ein paar Ebenen höher beisst sich das aber mit dem code von avr.c, da in
1
int avr_chip_erase(PROGRAMMER * pgm, AVRPART * p)
der cycle counter nur zurückgeschrieben wird, wenn der returncode genau 
0 ist.
1
  rc = pgm->chip_erase(pgm, p);
2

3
  /*
4
   * Don't update the cycle counter, if erase failed
5
   */
6
  if (do_cycles && (rc == 0)) {

Wenn ich "(rc == 0)" durch "(rc >= 0)" ersetze funktioniert der cycle 
count  zumindest für meinen stk500v2 wieder wie beschrieben.

Ich werde mal ein Bugreport an die avrdude Developer absetzen.

brgds

Thomas
#838411
Lesenswert?

Jörg Wunsch wrote:
> Danke, nun muss ich nur mal sehen, wann ich endlich mal Zeit für
> all die aufgelaufenen avrdude-Dinge finden werde...

:-)

Ich muss mich jetzt auch erst mal wieder von avrdude losreißen und mich 
mal um mein AVR Eclipse Plugin kümmern.

Würde ja gerne etwas mehr bei avrdude helfen, aber bei den meisten 
offenen Bugs in avrdude reicht mir schon die Überschrift, um zu wissen 
dass es meine Zeit-Kapazitäten übersteigt würde :-)

Vielleicht wenn das AVR Eclipse Plugin fertig ist...

LG

Thomas

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren