From 28be45d8b6308f66b39f116f4923de38cdaa1218 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sat, 29 Jan 2022 19:53:42 +0100 Subject: [PATCH 1/2] Fix Ardino sync attempts In order for the Arduino bootloader to re-sync with Avrdude, the microcontroller needs to be reset to start the bootloader again. --- src/stk500.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/stk500.c b/src/stk500.c index 44f1c739..0aef1947 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -111,6 +111,14 @@ int stk500_getsync(PROGRAMMER * pgm) max_sync_attempts = MAX_SYNC_ATTEMPTS; 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_recv(pgm, resp, 1); if (resp[0] == Resp_STK_INSYNC){ From 7144a9f2ae11a07e7e5817b843dbbbd2d6c236ef Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sat, 29 Jan 2022 19:56:26 +0100 Subject: [PATCH 2/2] Replace incorrect warning message Was mistakenly added in PR #854. --- src/stk500.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stk500.c b/src/stk500.c index 0aef1947..cb270036 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -623,8 +623,8 @@ static int stk500_parseextparms(PROGRAMMER * pgm, LISTID extparms) if (sscanf(extended_param, "attempts=%2d", &attempts) == 1) { PDATA(pgm)->retry_attempts = attempts; - avrdude_message(MSG_INFO, "%s: serialupdi_parseextparms(): invalid extended parameter '%s'\n", - progname, extended_param); + avrdude_message(MSG_INFO, "%s: Setting number of retry attempts to %d\n", + progname, attempts); continue; }