Fix -Y option. Reported by Joerg Wunsch.
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@153 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
4f818a067b
commit
1d33dc00ba
11
avr.c
11
avr.c
|
@ -823,6 +823,7 @@ int avr_chip_erase(int fd, AVRPART * p)
|
||||||
unsigned char cmd[4];
|
unsigned char cmd[4];
|
||||||
unsigned char res[4];
|
unsigned char res[4];
|
||||||
int cycles;
|
int cycles;
|
||||||
|
int rc;
|
||||||
|
|
||||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||||
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
|
fprintf(stderr, "chip erase instruction not defined for part \"%s\"\n",
|
||||||
|
@ -830,13 +831,13 @@ int avr_chip_erase(int fd, AVRPART * p)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
cycles = avr_get_cycle_count(fd, p);
|
rc = avr_get_cycle_count(fd, p, &cycles);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* only print out the current cycle count if we aren't going to
|
* only print out the current cycle count if we aren't going to
|
||||||
* display it below
|
* display it below
|
||||||
*/
|
*/
|
||||||
if (!do_cycles && ((cycles != -1) && (cycles != 0x00ffff))) {
|
if (!do_cycles && ((rc >= 0) && (cycles != 0xffffffff))) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: current erase-rewrite cycle count is %d%s\n",
|
"%s: current erase-rewrite cycle count is %d%s\n",
|
||||||
progname, cycles,
|
progname, cycles,
|
||||||
|
@ -1042,7 +1043,7 @@ int avr_verify(AVRPART * p, AVRPART * v, char * memtype, int size)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int avr_get_cycle_count(int fd, AVRPART * p)
|
int avr_get_cycle_count(int fd, AVRPART * p, int * cycles)
|
||||||
{
|
{
|
||||||
AVRMEM * a;
|
AVRMEM * a;
|
||||||
int cycle_count;
|
int cycle_count;
|
||||||
|
@ -1092,7 +1093,9 @@ int avr_get_cycle_count(int fd, AVRPART * p)
|
||||||
(((unsigned int)v3) << 8) |
|
(((unsigned int)v3) << 8) |
|
||||||
v4;
|
v4;
|
||||||
|
|
||||||
return cycle_count;
|
*cycles = cycle_count;
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
2
avr.h
2
avr.h
|
@ -167,7 +167,7 @@ void avr_mem_display(char * prefix, FILE * f, AVRMEM * m, int type,
|
||||||
|
|
||||||
void avr_display(FILE * f, AVRPART * p, char * prefix, int verbose);
|
void avr_display(FILE * f, AVRPART * p, char * prefix, int verbose);
|
||||||
|
|
||||||
int avr_get_cycle_count(int fd, AVRPART * p);
|
int avr_get_cycle_count(int fd, AVRPART * p, int * cycles);
|
||||||
|
|
||||||
int avr_put_cycle_count(int fd, AVRPART * p, int cycles);
|
int avr_put_cycle_count(int fd, AVRPART * p, int cycles);
|
||||||
|
|
||||||
|
|
12
main.c
12
main.c
|
@ -115,7 +115,7 @@ char ** modules[N_MODULES] = {
|
||||||
&term_version
|
&term_version
|
||||||
};
|
};
|
||||||
|
|
||||||
char * version = "2.1.3";
|
char * version = "2.1.4";
|
||||||
|
|
||||||
char * main_version = "$Id$";
|
char * main_version = "$Id$";
|
||||||
|
|
||||||
|
@ -909,8 +909,8 @@ int main(int argc, char * argv [])
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set_cycles != -1) {
|
if (set_cycles != -1) {
|
||||||
cycles = avr_get_cycle_count(fd, p);
|
rc = avr_get_cycle_count(fd, p, &cycles);
|
||||||
if (cycles != -1) {
|
if (rc == 0) {
|
||||||
/*
|
/*
|
||||||
* only attempt to update the cycle counter if we can actually
|
* only attempt to update the cycle counter if we can actually
|
||||||
* read the old value
|
* read the old value
|
||||||
|
@ -943,11 +943,11 @@ int main(int argc, char * argv [])
|
||||||
* repeat it if an erase was done. Also, don't display this if we
|
* repeat it if an erase was done. Also, don't display this if we
|
||||||
* set the cycle count (due to -Y).
|
* set the cycle count (due to -Y).
|
||||||
*
|
*
|
||||||
* see if the cycle count in the last two bytes of eeprom seems
|
* see if the cycle count in the last four bytes of eeprom seems
|
||||||
* reasonable
|
* reasonable
|
||||||
*/
|
*/
|
||||||
cycles = avr_get_cycle_count(fd, p);
|
rc = avr_get_cycle_count(fd, p, &cycles);
|
||||||
if ((cycles != -1) && (cycles != 0x00ffff)) {
|
if ((rc >= 0) && (cycles != 0xffffffff)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: current erase-rewrite cycle count is %d%s\n",
|
"%s: current erase-rewrite cycle count is %d%s\n",
|
||||||
progname, cycles,
|
progname, cycles,
|
||||||
|
|
Loading…
Reference in New Issue