Skip to content
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

Clean up and simplify hvupdi handling, and set default hvupdi_variant… #3

Merged
merged 3 commits into from
Jul 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/avrpart.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ AVRPART * avr_new_part(void)
memset(p->signature, 0xFF, 3);
p->ctl_stack_type = CTL_STACK_NONE;
p->ocdrev = -1;
p->hvupdi_variant = -1;

p->mem = lcreat(NULL, 0);
p->mem_alias = lcreat(NULL, 0);
Expand Down
22 changes: 11 additions & 11 deletions src/jtag3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,18 +1254,21 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
}

// Generate UPDI high-voltage pulse if user asks for it and hardware supports it
LNODEID hvupdi_support;
LNODEID support;
if (p->flags & AVRPART_HAS_UPDI &&
PDATA(pgm)->use_hvupdi == true &&
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) {
parm[0] = PARM3_UPDI_HV_NONE;
for (support = lfirst(pgm->hvupdi_support); support != NULL; support = lnext(support)) {
if(*(int *) ldata(support) == 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 (parm[0] == PARM3_UPDI_HV_NONE)
avrdude_message(MSG_INFO, "%s: %s does not support sending HV pulse to target %s\n",
progname, pgm->desc, p->desc);
}
if (jtag3_setparm(pgm, SCOPE_AVR, 3, PARM3_OPT_12V_UPDI_ENABLE, parm, 1) < 0)
return -1;
Expand Down Expand Up @@ -1496,8 +1499,8 @@ static int jtag3_parseextparms(PROGRAMMER * pgm, LISTID extparms)
continue;
}

else if ((matches(extended_param, "hvupdi") || matches(extended_param, "hvupdi=1")) &&
(matches(ldata(lfirst(pgm->id)), "pickit4_updi") || matches(ldata(lfirst(pgm->id)), "powerdebugger_updi"))) {
else if ((strcmp(extended_param, "hvupdi") == 0) &&
(lsize(pgm->hvupdi_support) > 1)) {
PDATA(pgm)->use_hvupdi = true;
continue;
}
Expand Down Expand Up @@ -1650,12 +1653,9 @@ 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);
}
for (ln = lfirst(pgm->hvupdi_support); ln; ln = lnext(ln))
avrdude_message(MSG_NOTICE2, " %d", *(int *) ldata(ln));
avrdude_message(MSG_NOTICE2, "\n", progname);

if (jtag3_open_common(pgm, port) < 0)
Expand Down