avrdude: Reduce retries to make timeout time more reasonable

This commit is contained in:
Vojtech Kral 2018-05-22 12:54:46 +02:00 committed by bubnikv
parent 478488972c
commit 1602ddd56c
2 changed files with 7 additions and 12 deletions

View File

@ -737,7 +737,7 @@ extern bool cancel_flag;
#define RETURN_IF_CANCEL() \ #define RETURN_IF_CANCEL() \
do { \ do { \
if (cancel_flag) { \ if (cancel_flag) { \
avrdude_message(MSG_INFO, "%s(): Cancelled, exiting...\n", __func__); \ avrdude_message(MSG_INFO, "avrdude: %s(): Cancelled, exiting...\n", __func__); \
return -99; \ return -99; \
} \ } \
} while (0) } while (0)

View File

@ -79,7 +79,7 @@
#define SERIAL_TIMEOUT 2 #define SERIAL_TIMEOUT 2
// Retry count // Retry count
#define RETRIES 5 #define RETRIES 0
#if 0 #if 0
#define DEBUG(...) avrdude_message(MSG_INFO, __VA_ARGS__) #define DEBUG(...) avrdude_message(MSG_INFO, __VA_ARGS__)
@ -745,7 +745,7 @@ static int stk500v2_recv(PROGRAMMER * pgm, unsigned char *msg, size_t maxsize) {
static int stk500v2_getsync_internal(PROGRAMMER * pgm, int retries) { int stk500v2_getsync(PROGRAMMER * pgm) {
int tries = 0; int tries = 0;
unsigned char buf[1], resp[32]; unsigned char buf[1], resp[32];
int status; int status;
@ -804,7 +804,7 @@ retry:
progname, pgmname[PDATA(pgm)->pgmtype]); progname, pgmname[PDATA(pgm)->pgmtype]);
return 0; return 0;
} else { } else {
if (tries > retries) { if (tries > RETRIES) {
avrdude_message(MSG_INFO, "%s: stk500v2_getsync(): can't communicate with device: resp=0x%02x\n", avrdude_message(MSG_INFO, "%s: stk500v2_getsync(): can't communicate with device: resp=0x%02x\n",
progname, resp[0]); progname, resp[0]);
return -6; return -6;
@ -814,7 +814,7 @@ retry:
// or if we got a timeout // or if we got a timeout
} else if (status == -1) { } else if (status == -1) {
if (tries > retries) { if (tries > RETRIES) {
avrdude_message(MSG_INFO, "%s: stk500v2_getsync(): timeout communicating with programmer\n", avrdude_message(MSG_INFO, "%s: stk500v2_getsync(): timeout communicating with programmer\n",
progname); progname);
return -1; return -1;
@ -823,7 +823,7 @@ retry:
// or any other error // or any other error
} else { } else {
if (tries > retries) { if (tries > RETRIES) {
avrdude_message(MSG_INFO, "%s: stk500v2_getsync(): error communicating with programmer: (%d)\n", avrdude_message(MSG_INFO, "%s: stk500v2_getsync(): error communicating with programmer: (%d)\n",
progname,status); progname,status);
} else } else
@ -833,11 +833,6 @@ retry:
return 0; return 0;
} }
int stk500v2_getsync(PROGRAMMER * pgm) {
// This is to avoid applying RETRIES exponentially
return stk500v2_getsync_internal(pgm, RETRIES);
}
static int stk500v2_command(PROGRAMMER * pgm, unsigned char * buf, static int stk500v2_command(PROGRAMMER * pgm, unsigned char * buf,
size_t len, size_t maxlen) { size_t len, size_t maxlen) {
int i; int i;
@ -947,7 +942,7 @@ retry:
} }
// otherwise try to sync up again // otherwise try to sync up again
status = stk500v2_getsync_internal(pgm, 1); status = stk500v2_getsync(pgm);
if (status != 0) { if (status != 0) {
if (tries > RETRIES) { if (tries > RETRIES) {
avrdude_message(MSG_INFO, "%s: stk500v2_command(): failed miserably to execute command 0x%02x\n", avrdude_message(MSG_INFO, "%s: stk500v2_command(): failed miserably to execute command 0x%02x\n",