• R/O
  • SSH
  • HTTPS

avrdude: Commit


Commit MetaInfo

Revision1467 (tree)
Time2020-02-17 03:19:14
Authorgottfried

Log Message

changed programmer.id from stringlist to std::string
added device and part list to help

Change Summary

Incremental Difference

--- trunk/config_gram.y (revision 1466)
+++ trunk/config_gram.y (revision 1467)
@@ -271,9 +271,10 @@
271271 prog_def :
272272 prog_decl prog_parms
273273 {
274- PROGRAMMER * existing_prog;
275- char * id;
276- if (lsize(current_prog->id) == 0) {
274+ PROGRAMMER *existing_prog;
275+ const char *id;
276+ if (current_prog->id.size() == 0)
277+ {
277278 yyerror("required parameter id not specified");
278279 YYABORT;
279280 }
@@ -281,9 +282,10 @@
281282 yyerror("programmer type not specified");
282283 YYABORT;
283284 }
284- id = static_cast<char*>(ldata(lfirst(current_prog->id)));
285+ id = current_prog->id.c_str();
285286 existing_prog = locate_programmer(programmers, id);
286- if (existing_prog) {
287+ if (existing_prog)
288+ {
287289 { /* temporarly set lineno to lineno of programmer start */
288290 int temp = lineno; lineno = current_prog->lineno;
289291 yywarning("programmer %s overwrites previous definition %s:%d.",
@@ -443,17 +445,21 @@
443445 K_ID TKN_EQUAL string_list {
444446 {
445447 TOKEN * t;
446- char *s;
447448 int do_yyabort = 0;
448- while (lsize(string_list)) {
449+ while (lsize(string_list))
450+ {
449451 t = static_cast<TOKEN*>(lrmv_n(string_list, 1));
450- if (!do_yyabort) {
451- s = dup_string(t->value.string);
452- if (s == NULL) {
452+ if (!do_yyabort)
453+ {
454+ const char *s = t->value.string;
455+ if (s == NULL)
456+ {
453457 do_yyabort = 1;
454- } else {
455- ladd(current_prog->id, s);
456458 }
459+ else
460+ {
461+ current_prog->id = s;
462+ }
457463 }
458464 /* if do_yyabort == 1 just make the list empty */
459465 free_token(t);
--- trunk/jtag3.cpp (revision 1466)
+++ trunk/jtag3.cpp (revision 1467)
@@ -857,35 +857,38 @@
857857 }
858858
859859
860-int jtag3_getsync(PROGRAMMER * pgm, int mode) {
860+ int jtag3_getsync(PROGRAMMER *pgm, int mode)
861+ {
862+ unsigned char buf[3], *resp;
861863
862- unsigned char buf[3], *resp;
864+ avrdude_message(MSG_DEBUG, "%s: jtag3_getsync()\n", progname);
863865
864- avrdude_message(MSG_DEBUG, "%s: jtag3_getsync()\n", progname);
866+ /* XplainedMini boards do not need this, and early revisions had a
867+ * firmware bug where they complained about it. */
868+ if(pgm->flag & PGM_FL_IS_EDBG)
869+ {
870+ if(strcmp(pgm->id.c_str(), "xplainedmini_updi") != 0)
871+ {
872+ if(jtag3_edbg_prepare(pgm) < 0)
873+ {
874+ return -1;
875+ }
876+ }
877+ }
865878
866- /* XplainedMini boards do not need this, and early revisions had a
867- * firmware bug where they complained about it. */
868- if (pgm->flag & PGM_FL_IS_EDBG) {
869- if (strcmp(static_cast<const char*>(pgm->id), "xplainedmini_updi") != 0) {
870- if (jtag3_edbg_prepare(pgm) < 0) {
871- return -1;
872- }
873- }
874- }
879+ /* Get the sign-on information. */
880+ buf[0] = SCOPE_GENERAL;
881+ buf[1] = CMD3_SIGN_ON;
882+ buf[2] = 0;
875883
876- /* Get the sign-on information. */
877- buf[0] = SCOPE_GENERAL;
878- buf[1] = CMD3_SIGN_ON;
879- buf[2] = 0;
884+ if(jtag3_command(pgm, buf, 3, &resp, "sign-on") < 0)
885+ return -1;
880886
881- if (jtag3_command(pgm, buf, 3, &resp, "sign-on") < 0)
882- return -1;
887+ free(resp);
883888
884- free(resp);
889+ return 0;
890+ }
885891
886- return 0;
887-}
888-
889892 /*
890893 * issue the 'chip erase' command to the AVR device
891894 */
@@ -1568,19 +1571,21 @@
15681571 buf[1] = CMD3_SIGN_OFF;
15691572 buf[2] = buf[3] = 0;
15701573
1571- if (jtag3_command(pgm, buf, 3, &resp, "AVR sign-off") >= 0)
1574+ if(jtag3_command(pgm, buf, 3, &resp, "AVR sign-off") >= 0)
15721575 free(resp);
15731576
15741577 buf[0] = SCOPE_GENERAL;
15751578 buf[1] = CMD3_SIGN_OFF;
15761579
1577- if (jtag3_command(pgm, buf, 4, &resp, "sign-off") >= 0)
1580+ if(jtag3_command(pgm, buf, 4, &resp, "sign-off") >= 0)
15781581 free(resp);
15791582
15801583 /* XplainedMini boards do not need this, and early revisions had a
15811584 * firmware bug where they complained about it. */
1582- if (pgm->flag & PGM_FL_IS_EDBG) {
1583- if (strcmp(static_cast<char*>(pgm->id), "xplainedmini_updi") != 0) {
1585+ if(pgm->flag & PGM_FL_IS_EDBG)
1586+ {
1587+ if(strcmp(pgm->id.c_str(), "xplainedmini_updi") != 0)
1588+ {
15841589 jtag3_edbg_signoff(pgm);
15851590 }
15861591 }
--- trunk/libavrdude.h (revision 1466)
+++ trunk/libavrdude.h (revision 1467)
@@ -26,6 +26,7 @@
2626 #include <limits.h>
2727 #include <stdbool.h>
2828 #include <vector>
29+#include <string>
2930
3031 /* lets try to select at least 32 bits */
3132 #include <stdint.h>
@@ -611,8 +612,9 @@
611612 CONNTYPE_USB
612613 } conntype_t;
613614
614-typedef struct programmer_t {
615- LISTID id;
615+typedef struct programmer_t
616+{
617+ std::string id;
616618 char desc[PGM_DESCLEN];
617619 char type[PGM_TYPELEN];
618620 char port[PGM_PORTLEN];
--- trunk/main.cpp (revision 1466)
+++ trunk/main.cpp (revision 1467)
@@ -132,6 +132,9 @@
132132 " -q Quell progress output. -q -q for less.\n"
133133 " -l logfile Use logfile rather than stderr for diagnostics.\n"
134134 " -? Display this usage.\n"
135+ " -p? Display parts.\n"
136+ " -c? Display programmers.\n"
137+ " -c?type Display programmer types.\n"
135138 "\navrdude version %s, URL: <http://savannah.nongnu.org/projects/avrdude/>\n"
136139 ,progname, version);
137140 }
--- trunk/pgm.cpp (revision 1466)
+++ trunk/pgm.cpp (revision 1467)
@@ -108,7 +108,6 @@
108108 pgm->cookie = 0;
109109 pgm->flag = 0;
110110
111- pgm->id = lcreat(NULL, 0);
112111 pgm->usbpid = lcreat(NULL, 0);
113112 pgm->desc[0] = 0;
114113 pgm->type[0] = 0;
@@ -174,9 +173,7 @@
174173
175174 void pgm_free(PROGRAMMER * const p)
176175 {
177- ldestroy_cb(p->id, free);
178176 ldestroy_cb(p->usbpid, free);
179- p->id = NULL;
180177 p->usbpid = NULL;
181178 /* this is done by pgm_teardown, but usually cookie is not set to NULL */
182179 /* if (p->cookie !=NULL) {
@@ -198,7 +195,7 @@
198195
199196 //memcpy(pgm, src, sizeof(*pgm));
200197
201- pgm->id = lcreat(NULL, 0);
198+ pgm->id.clear();
202199 pgm->usbpid = lcreat(NULL, 0);
203200
204201 for (ln = lfirst(src->usbpid); ln; ln = lnext(ln)) {
@@ -296,12 +293,10 @@
296293 for(std::vector<PROGRAMMER>::iterator ln1 = programmers.begin(); ln1 != programmers.end(); ++ln1)
297294 {
298295 PROGRAMMER *p = &(*ln1);
299- for(LNODEID ln2 = lfirst(p->id); ln2; ln2 = lnext(ln2))
300- {
301- const char *id = static_cast<const char*>(ldata(ln2));
302- if(strcasecmp(configid, id) == 0)
303- return p; //found = 1;
304- }
296+ const char *id = p->id.c_str();
297+
298+ if(strcasecmp(configid, id) == 0)
299+ return p; //found = 1;
305300 }
306301
307302 return NULL;
@@ -322,10 +317,8 @@
322317 for(std::vector<PROGRAMMER>::const_iterator ln1 = programmers.cbegin(); ln1 != programmers.cend(); ++ln1)
323318 {
324319 const PROGRAMMER *p = &(*ln1);
325- for(LNODEID ln2 = lfirst(p->id); ln2; ln2=lnext(ln2))
326- {
327- cb(static_cast<const char*>(ldata(ln2)), p->desc, p->config_file, p->lineno, cookie);
328- }
320+
321+ cb(p->id.c_str(), p->desc, p->config_file, p->lineno, cookie);
329322 }
330323 }
331324
@@ -334,8 +327,8 @@
334327 */
335328 bool sort_programmer_compare(PROGRAMMER &p1,PROGRAMMER &p2)
336329 {
337- const char *id1 = static_cast<char*>(ldata(lfirst(p1.id)));
338- const char *id2 = static_cast<char*>(ldata(lfirst(p2.id)));
330+ const char *id1 = p1.id.c_str();
331+ const char *id2 = p2.id.c_str();
339332
340333 return strncasecmp(id1, id2, AVR_IDLEN) < 0;
341334 }
--- trunk/stk500.cpp (revision 1466)
+++ trunk/stk500.cpp (revision 1467)
@@ -420,7 +420,7 @@
420420 stk500_getparm(pgm, Parm_STK_SW_MINOR, &min);
421421
422422 // MIB510 does not need extparams
423- if (strcmp(static_cast<const char*>(ldata(lfirst(pgm->id))), "mib510") == 0)
423+ if (strcmp(pgm->id.c_str(), "mib510") == 0)
424424 n_extparms = 0;
425425 else if ((maj > 1) || ((maj == 1) && (min > 10)))
426426 n_extparms = 4;
@@ -667,7 +667,7 @@
667667 stk500_drain(pgm, 0);
668668
669669 // MIB510 init
670- if (strcmp(static_cast<const char*>(ldata(lfirst(pgm->id))), "mib510") == 0 &&
670+ if (strcmp(pgm->id.c_str(), "mib510") == 0 &&
671671 mib510_isp(pgm, 1) != 0)
672672 return -1;
673673
@@ -681,7 +681,7 @@
681681 static void stk500_close(PROGRAMMER * pgm)
682682 {
683683 // MIB510 close
684- if (strcmp(static_cast<const char*>(ldata(lfirst(pgm->id))), "mib510") == 0)
684+ if (strcmp(pgm->id.c_str(), "mib510") == 0)
685685 (void)mib510_isp(pgm, 0);
686686
687687 serial_close(&pgm->fd);
@@ -793,7 +793,7 @@
793793
794794 for (; addr < n; addr += block_size) {
795795 // MIB510 uses fixed blocks size of 256 bytes
796- if (strcmp(static_cast<const char*>(ldata(lfirst(pgm->id))), "mib510") == 0) {
796+ if (strcmp(pgm->id.c_str(), "mib510") == 0) {
797797 block_size = 256;
798798 } else {
799799 if (n - addr < page_size)
@@ -892,7 +892,7 @@
892892 n = addr + n_bytes;
893893 for (; addr < n; addr += block_size) {
894894 // MIB510 uses fixed blocks size of 256 bytes
895- if (strcmp(static_cast<const char*>(ldata(lfirst(pgm->id))), "mib510") == 0) {
895+ if (strcmp(pgm->id.c_str(), "mib510") == 0) {
896896 block_size = 256;
897897 } else {
898898 if (n - addr < page_size)
@@ -937,7 +937,7 @@
937937 if (stk500_recv(pgm, buf, 1) < 0)
938938 return -1;
939939
940- if(strcmp(static_cast<const char*>(ldata(lfirst(pgm->id))), "mib510") == 0) {
940+ if(strcmp(pgm->id.c_str(), "mib510") == 0) {
941941 if (buf[0] != Resp_STK_INSYNC) {
942942 avrdude_message(MSG_INFO, "\n%s: stk500_paged_load(): (a) protocol error, "
943943 "expect=0x%02x, resp=0x%02x\n",
--- trunk/usbasp.cpp (revision 1466)
+++ trunk/usbasp.cpp (revision 1467)
@@ -481,8 +481,9 @@
481481 vid = pgm->usbvid? pgm->usbvid: USBASP_SHARED_VID;
482482 if (usbOpenDevice(&PDATA(pgm)->usbhandle, vid, pgm->usbvendor, pid, pgm->usbproduct) != 0) {
483483 /* try alternatives */
484- if(strcasecmp(static_cast<const char*>(ldata(lfirst(pgm->id))), "usbasp") == 0) {
485- /* for id usbasp autodetect some variants */
484+ if(strcasecmp(pgm->id.c_str(), "usbasp") == 0)
485+ {
486+ /* for id usbasp autodetect some variants */
486487 if(strcasecmp(port, "nibobee") == 0) {
487488 avrdude_message(MSG_INFO, "%s: warning: Using \"-C usbasp -P nibobee\" is deprecated,"
488489 "use \"-C nibobee\" instead.\n",
Show on old repository browser