patch #5708 avrdude should make 10 synchronization attempts instead of just one

* stk500.c (stk500_getsync): Loop 10 times trying to get in
sync with the programmer.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1223 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch 2013-09-13 14:59:15 +00:00
parent 5d95ada0e1
commit bbc0e35dfe
3 changed files with 20 additions and 7 deletions

View File

@ -1,3 +1,9 @@
2013-09-13 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
patch #5708 avrdude should make 10 synchronization attempts instead of just one
* stk500.c (stk500_getsync): Loop 10 times trying to get in
sync with the programmer.
2013-09-13 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2013-09-13 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
Contributed by Ricardo Martins: Contributed by Ricardo Martins:

1
NEWS
View File

@ -105,6 +105,7 @@ Current:
- bug #28344: chip_erase_delay too short for ATmega324P, 644, 644P, and 1284P - bug #28344: chip_erase_delay too short for ATmega324P, 644, 644P, and 1284P
- bug #34277: avrdude reads wrong byte order if using avr911 (aka butterfly) - bug #34277: avrdude reads wrong byte order if using avr911 (aka butterfly)
- bug #35456: The progress bar for STK500V2 programmer is "wrong". - bug #35456: The progress bar for STK500V2 programmer is "wrong".
- patch #5708 avrdude should make 10 synchronization attempts instead of just one
* Keep track of input file contents * Keep track of input file contents

View File

@ -44,6 +44,7 @@
#include "serial.h" #include "serial.h"
#define STK500_XTAL 7372800U #define STK500_XTAL 7372800U
#define MAX_SYNC_ATTEMPTS 10
static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value); static int stk500_getparm(PROGRAMMER * pgm, unsigned parm, unsigned * value);
static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value); static int stk500_setparm(PROGRAMMER * pgm, unsigned parm, unsigned value);
@ -80,6 +81,7 @@ int stk500_drain(PROGRAMMER * pgm, int display)
int stk500_getsync(PROGRAMMER * pgm) int stk500_getsync(PROGRAMMER * pgm)
{ {
unsigned char buf[32], resp[32]; unsigned char buf[32], resp[32];
int attempt;
/* /*
* get in sync */ * get in sync */
@ -95,13 +97,17 @@ int stk500_getsync(PROGRAMMER * pgm)
stk500_send(pgm, buf, 2); stk500_send(pgm, buf, 2);
stk500_drain(pgm, 0); stk500_drain(pgm, 0);
stk500_send(pgm, buf, 2); for (attempt = 0; attempt < MAX_SYNC_ATTEMPTS; attempt++) {
if (stk500_recv(pgm, resp, 1) < 0) stk500_send(pgm, buf, 2);
return -1; stk500_recv(pgm, resp, 1);
if (resp[0] != Resp_STK_INSYNC) { if (resp[0] == Resp_STK_INSYNC){
break;
}
fprintf(stderr, fprintf(stderr,
"%s: stk500_getsync(): not in sync: resp=0x%02x\n", "%s: stk500_getsync() attempt %d of %d: not in sync: resp=0x%02x\n",
progname, resp[0]); progname, attempt + 1, MAX_SYNC_ATTEMPTS, resp[0]);
}
if (attempt == MAX_SYNC_ATTEMPTS) {
stk500_drain(pgm, 0); stk500_drain(pgm, 0);
return -1; return -1;
} }