mirror of
https://github.com/mariusgreuel/avrdude.git
synced 2025-09-28 06:55:27 +00:00
Merge pull request #855 from MCUdude/fix-arduino-retry-attempts
Fix Arduino retry attempts
This commit is contained in:
12
src/stk500.c
12
src/stk500.c
@@ -111,6 +111,14 @@ int stk500_getsync(PROGRAMMER * pgm)
|
|||||||
max_sync_attempts = MAX_SYNC_ATTEMPTS;
|
max_sync_attempts = MAX_SYNC_ATTEMPTS;
|
||||||
|
|
||||||
for (attempt = 0; attempt < max_sync_attempts; attempt++) {
|
for (attempt = 0; attempt < max_sync_attempts; attempt++) {
|
||||||
|
// Restart Arduino bootloader for every sync attempt
|
||||||
|
if (strcmp(pgm->type, "Arduino") == 0 && attempt > 0) {
|
||||||
|
serial_set_dtr_rts(&pgm->fd, 0); // Set DTR and RTS low
|
||||||
|
usleep(250*1000);
|
||||||
|
serial_set_dtr_rts(&pgm->fd, 1); // Set DTR and RTS back to high
|
||||||
|
usleep(50*1000);
|
||||||
|
stk500_drain(pgm, 0);
|
||||||
|
}
|
||||||
stk500_send(pgm, buf, 2);
|
stk500_send(pgm, buf, 2);
|
||||||
stk500_recv(pgm, resp, 1);
|
stk500_recv(pgm, resp, 1);
|
||||||
if (resp[0] == Resp_STK_INSYNC){
|
if (resp[0] == Resp_STK_INSYNC){
|
||||||
@@ -615,8 +623,8 @@ static int stk500_parseextparms(PROGRAMMER * pgm, LISTID extparms)
|
|||||||
|
|
||||||
if (sscanf(extended_param, "attempts=%2d", &attempts) == 1) {
|
if (sscanf(extended_param, "attempts=%2d", &attempts) == 1) {
|
||||||
PDATA(pgm)->retry_attempts = attempts;
|
PDATA(pgm)->retry_attempts = attempts;
|
||||||
avrdude_message(MSG_INFO, "%s: serialupdi_parseextparms(): invalid extended parameter '%s'\n",
|
avrdude_message(MSG_INFO, "%s: Setting number of retry attempts to %d\n",
|
||||||
progname, extended_param);
|
progname, attempts);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user