-
Notifications
You must be signed in to change notification settings - Fork 174
Extended parameters (-x and -E) improvements
#1844
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
aebf970
5e4a9a7
0d7524d
c3d97e9
94e968a
12c41f2
cda52a3
c1a0378
568bb8e
313c8b4
f37e593
df5d1fe
41e7d81
9658908
95b4e78
3c679b1
297d256
38da070
77db93b
a874b52
92a2729
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -37,6 +37,45 @@ | |
| #include "stk500.h" | ||
| #include "arduino.h" | ||
|
|
||
| static int arduino_parseextparms(const PROGRAMMER *pgm, const LISTID extparms) { | ||
| const char *extended_param; | ||
| int attempts; | ||
| int rv = 0; | ||
|
|
||
| for (LNODEID ln = lfirst(extparms); ln; ln = lnext(ln)) { | ||
| extended_param = ldata(ln); | ||
|
|
||
| if (sscanf(extended_param, "attempts=%2d", &attempts) == 1) { | ||
| PDATA(pgm)->retry_attempts = attempts; | ||
| pmsg_info("setting number of retry attempts to %d\n", attempts); | ||
| continue; | ||
| } | ||
|
|
||
| if(str_starts(extended_param, "no_autoreset")) { | ||
| if(!str_eq(extended_param, "no_autoreset")) { | ||
| pmsg_error("invalid -xno_autoreset value %s. Use -xno_autoreset\n", extended_param); | ||
| rv = -1; | ||
| break; | ||
| } | ||
MCUdude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| PDATA(pgm)->autoreset = false; | ||
| continue; | ||
| } | ||
|
|
||
| if (str_eq(extended_param, "help")) { | ||
| msg_error("%s -c %s extended options:\n", progname, pgmid); | ||
| msg_error(" -xattempts=<arg> Specify no. connection retry attempts\n"); | ||
MCUdude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| msg_error(" -xno_autoreset Don't toggle RTS/DTR lines on port open to prevent a hardware reset\n"); | ||
| msg_error(" -xhelp Show this help menu and exit\n"); | ||
| return LIBAVRDUDE_EXIT; | ||
| } | ||
|
|
||
| pmsg_error("invalid extended parameter '%s'\n", extended_param); | ||
MCUdude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| rv = -1; | ||
| } | ||
|
|
||
| return rv; | ||
| } | ||
|
|
||
| /* read signature bytes - arduino version */ | ||
| static int arduino_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m) { | ||
| unsigned char buf[32]; | ||
|
|
@@ -85,28 +124,28 @@ static int arduino_open(PROGRAMMER *pgm, const char *port) { | |
| return -1; | ||
| } | ||
|
|
||
| // This code assumes a negative-logic USB to TTL serial adapter | ||
| // Set RTS/DTR high to discharge the series-capacitor, if present | ||
| serial_set_dtr_rts(&pgm->fd, 0); | ||
| /* | ||
| * Long wait needed for optiboot: otherwise the second of two bootloader | ||
| * calls in quick succession fails: | ||
| * | ||
| * avrdude -c arduino -qqp m328p -U x.hex; avrdude -c arduino -qqp m328p -U x.hex | ||
| */ | ||
| usleep(250 * 1000); | ||
| // Pull the RTS/DTR line low to reset AVR | ||
| serial_set_dtr_rts(&pgm->fd, 1); | ||
| // Max 100 us: charging a cap longer creates a high reset spike above Vcc | ||
| usleep(100); | ||
| // Set the RTS/DTR line back to high, so direct connection to reset works | ||
| serial_set_dtr_rts(&pgm->fd, 0); | ||
|
|
||
| usleep(100 * 1000); | ||
|
|
||
| /* | ||
| * drain any extraneous input | ||
| */ | ||
| if(PDATA(pgm)->autoreset) { | ||
| // This code assumes a negative-logic USB to TTL serial adapter | ||
| // Set RTS/DTR high to discharge the series-capacitor, if present | ||
| serial_set_dtr_rts(&pgm->fd, 0); | ||
| /* | ||
| * Long wait needed for optiboot: otherwise the second of two bootloader | ||
| * calls in quick succession fails: | ||
| * | ||
| * avrdude -c arduino -qqp m328p -U x.hex; avrdude -c arduino -qqp m328p -U x.hex | ||
| */ | ||
| usleep(250 * 1000); | ||
| // Pull the RTS/DTR line low to reset AVR | ||
| serial_set_dtr_rts(&pgm->fd, 1); | ||
| // Max 100 us: charging a cap longer creates a high reset spike above Vcc | ||
| usleep(100); | ||
| // Set the RTS/DTR line back to high, so direct connection to reset works | ||
| serial_set_dtr_rts(&pgm->fd, 0); | ||
|
|
||
| usleep(100 * 1000); | ||
| } | ||
|
|
||
| // Drain any extraneous input | ||
| stk500_drain(pgm, 0); | ||
|
|
||
| if (stk500_getsync(pgm) < 0) | ||
|
|
@@ -115,7 +154,7 @@ static int arduino_open(PROGRAMMER *pgm, const char *port) { | |
| return 0; | ||
| } | ||
|
|
||
| static void arduino_close(PROGRAMMER * pgm) | ||
| static void arduino_close(PROGRAMMER *pgm) | ||
MCUdude marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| serial_close(&pgm->fd); | ||
| pgm->fd.ifd = -1; | ||
|
|
@@ -131,9 +170,12 @@ void arduino_initpgm(PROGRAMMER *pgm) { | |
| stk500_initpgm(pgm); | ||
|
|
||
| strcpy(pgm->type, "Arduino"); | ||
| PDATA(&pgm)->autoreset = true; // Auto-reset enabled by default | ||
|
||
|
|
||
| pgm->read_sig_bytes = arduino_read_sig_bytes; | ||
| pgm->open = arduino_open; | ||
| pgm->close = arduino_close; | ||
| pgm->parseextparams = arduino_parseextparms; | ||
|
|
||
| cx->avr_disableffopt = 1; // Disable trailing 0xff removal | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.