diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 2e66c360..9d4f8dbd 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -40,6 +40,7 @@ # usbvendor = ; # USB Vendor Name # usbproduct = ; # USB Product Name # usbsn = ; # USB Serial Number +# hvupdi_support = , , ...; # UPDI HV Variants Support # # To invert a bit, use = ~ , the spaces are important. # For a pin list all pins must be inverted. @@ -630,6 +631,7 @@ programmer desc = "SerialUPDI"; type = "serialupdi"; connection_type = serial; + hvupdi_support = 1; ; programmer @@ -1177,6 +1179,7 @@ programmer type = "jtagice3_updi"; connection_type = usb; usbpid = 0x2110, 0x2140; + hvupdi_support = 1; ; programmer @@ -1209,6 +1212,7 @@ programmer type = "jtagice3_updi"; connection_type = usb; usbpid = 0x2111; + hvupdi_support = 1; ; programmer @@ -1233,6 +1237,7 @@ programmer type = "jtagice3_updi"; connection_type = usb; usbpid = 0x2145; + hvupdi_support = 1; ; programmer @@ -1257,6 +1262,7 @@ programmer type = "jtagice3_updi"; connection_type = usb; usbpid = 0x2141; + hvupdi_support = 1; ; programmer @@ -1297,6 +1303,7 @@ programmer type = "jtagice3_updi"; connection_type = usb; usbpid = 0x2144; + hvupdi_support = 0, 1; ; programmer @@ -1321,6 +1328,7 @@ programmer type = "jtagice3_updi"; connection_type = usb; usbpid = 0x2177, 0x2178, 0x2179; + hvupdi_support = 0, 1, 2; ; programmer @@ -1345,6 +1353,7 @@ programmer type = "jtagice3_updi"; connection_type = usb; usbpid = 0x217F, 0x2180, 0x2181; + hvupdi_support = 1; ; programmer @@ -1369,6 +1378,7 @@ programmer type = "jtagice3_updi"; connection_type = usb; usbpid = 0x2175; + hvupdi_support = 1; ; programmer @@ -1737,6 +1747,7 @@ programmer type = "jtagmkii_pdi"; connection_type = serial; baudrate = 115200; + hvupdi_support = 1; ; # diff --git a/src/config_gram.y b/src/config_gram.y index 126b9b54..5db2a475 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -81,6 +81,7 @@ static int pin_name; %token K_DEFAULT_SERIAL %token K_DESC %token K_FAMILY_ID +%token K_HVUPDI_SUPPORT %token K_HVUPDI_VARIANT %token K_DEVICECODE %token K_STK500_DEVCODE @@ -547,6 +548,7 @@ prog_parm_usb: free_token($3); } } + K_HVUPDI_SUPPORT TKN_EQUAL hvupdi_support_list ; usb_pid_list: @@ -577,6 +579,34 @@ usb_pid_list: } ; +hvupdi_support_list: + TKN_NUMBER { + { + /* overwrite pids, so clear the existing entries */ + ldestroy_cb(current_prog->hvupdi_support, free); + current_prog->hvupdi_support = lcreat(NULL, 0); + } + { + int *ip = malloc(sizeof(int)); + if (ip) { + *ip = $1->value.number; + ladd(current_prog->hvupdi_support, ip); + } + free_token($1); + } + } | + hvupdi_support_list TKN_COMMA TKN_NUMBER { + { + int *ip = malloc(sizeof(int)); + if (ip) { + *ip = $3->value.number; + ladd(current_prog->hvupdi_support, ip); + } + free_token($3); + } + } +; + pin_number_non_empty: TKN_NUMBER { if(0 != assign_pin(pin_name, $1, 0)) YYABORT; } | diff --git a/src/jtag3.c b/src/jtag3.c index 5a333991..efb9b702 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -1253,14 +1253,20 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p) } } - // Generate 12V UPDI pulse if user asks for it and hardware supports it + // Generate UPDI high-voltage pulse if user asks for it and hardware supports it + LNODEID hvupdi_support; if (p->flags & AVRPART_HAS_UPDI && PDATA(pgm)->use_hvupdi == true && - (p->hvupdi_variant == HV_UPDI_VARIANT_0 || - p->hvupdi_variant == HV_UPDI_VARIANT_2)) { - avrdude_message(MSG_NOTICE, "%s: Sending HV pulse to %s pin\n", - progname, p->hvupdi_variant == HV_UPDI_VARIANT_0 ? "UPDI" : "RESET"); - parm[0] = PARM3_UPDI_HV_SIMPLE_PULSE; + p->hvupdi_variant != HV_UPDI_VARIANT_1) { + for (hvupdi_support = lfirst(pgm->hvupdi_support); hvupdi_support != NULL; hvupdi_support = lnext(hvupdi_support)) { + unsigned int sup = (unsigned int)(*(int *)(ldata(hvupdi_support))); + if(sup == p->hvupdi_variant) { + avrdude_message(MSG_NOTICE, "%s: Sending HV pulse to targets %s pin\n", + progname, p->hvupdi_variant == HV_UPDI_VARIANT_0 ? "UPDI" : "RESET"); + parm[0] = PARM3_UPDI_HV_SIMPLE_PULSE; + break; + } + } if (jtag3_setparm(pgm, SCOPE_AVR, 3, PARM3_OPT_12V_UPDI_ENABLE, parm, 1) < 0) return -1; } diff --git a/src/lexer.l b/src/lexer.l index dd5c081a..1693886c 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -159,6 +159,7 @@ hventerstabdelay { yylval=NULL; return K_HVENTERSTABDELAY; } hvleavestabdelay { yylval=NULL; return K_HVLEAVESTABDELAY; } hvsp_controlstack { yylval=NULL; return K_HVSP_CONTROLSTACK; } hvspcmdexedelay { yylval=NULL; return K_HVSPCMDEXEDELAY; } +hvupdi_support { yylval=NULL; return K_HVUPDI_SUPPORT; } hvupdi_variant { yylval=NULL; return K_HVUPDI_VARIANT; } id { yylval=NULL; return K_ID; } idr { yylval=NULL; return K_IDR; } diff --git a/src/libavrdude.h b/src/libavrdude.h index c3e89a7e..4a7a66b0 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -719,6 +719,7 @@ typedef struct programmer_t { int lineno; /* config file line number */ void *cookie; /* for private use by the programmer */ char flag; /* for private use of the programmer */ + LISTID hvupdi_support; /* List of UPDI HV variants the tool supports. See HV_UPDI_VARIANT_ */ } PROGRAMMER; #ifdef __cplusplus