Merge pull request #2 from janegilruud/hv-updi

Add HVUPDI_SUPPORT list for programmers.
This commit is contained in:
Hans 2022-07-07 20:12:43 +02:00 committed by GitHub
commit 913509d6e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 71 additions and 8 deletions

View File

@ -40,6 +40,7 @@
# usbvendor = <vendorname>; # USB Vendor Name
# usbproduct = <productname>; # USB Product Name
# usbsn = <serialno>; # USB Serial Number
# hvupdi_support = <num> [, <num>, ... ] ; # UPDI HV Variants Support
#
# To invert a bit, use = ~ <num>, 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;
;
#

View File

@ -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
@ -476,7 +477,8 @@ prog_parm :
current_prog->baudrate = $3->value.number;
free_token($3);
}
}
} |
prog_parm_updi
;
prog_parm_type:
@ -577,6 +579,38 @@ usb_pid_list:
}
;
prog_parm_updi:
K_HVUPDI_SUPPORT TKN_EQUAL hvupdi_support_list
;
hvupdi_support_list:
TKN_NUMBER {
{
/* overwrite list entries, 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; }
|

View File

@ -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;
}
@ -1643,6 +1649,15 @@ static int jtag3_open_updi(PROGRAMMER * pgm, char * port)
{
avrdude_message(MSG_NOTICE2, "%s: jtag3_open_updi()\n", progname);
LNODEID ln;
unsigned int hv_sup;
avrdude_message(MSG_NOTICE2, "%s: HV UPDI support:", progname);
for (ln = lfirst(pgm->hvupdi_support); ln; ln = lnext(ln)) {
hv_sup = (unsigned int)(*(int *)ldata(ln));
avrdude_message(MSG_NOTICE2, " %d", hv_sup);
}
avrdude_message(MSG_NOTICE2, "\n", progname);
if (jtag3_open_common(pgm, port) < 0)
return -1;

View File

@ -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; }

View File

@ -206,7 +206,7 @@ typedef struct avrpart {
char desc[AVR_DESCLEN]; /* long part name */
char id[AVR_IDLEN]; /* short part name */
char family_id[AVR_FAMILYIDLEN+1]; /* family id in the SIB (avr8x) */
int hvupdi_variant; /* 12V pulse on UPDI pin, no pin or RESET pin */
int hvupdi_variant; /* HV pulse on UPDI pin, no pin or RESET pin */
int stk500_devcode; /* stk500 device code */
int avr910_devcode; /* avr910 device code */
int chip_erase_delay; /* microseconds */
@ -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

View File

@ -83,6 +83,7 @@ PROGRAMMER * pgm_new(void)
pgm->lineno = 0;
pgm->baudrate = 0;
pgm->initpgm = NULL;
pgm->hvupdi_support = lcreat(NULL, 0);
for (i=0; i<N_PINS; i++) {
pgm->pinno[i] = 0;