From f67c35744e7522a61ff1d67efef4adc27278e1b0 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 26 Jun 2022 00:13:56 +0200 Subject: [PATCH] add support for "-x hvupdi" that triggers HV UPDI --- src/jtag3.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/jtag3.c b/src/jtag3.c index 4e3ef8c2..976291f4 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -71,6 +71,9 @@ struct pdata /* Start address of Xmega boot area */ unsigned long boot_start; + /* Flag for triggering HV UPDI */ + bool use_hvupdi; + /* Function to set the appropriate clock parameter */ int (*set_sck)(PROGRAMMER *, unsigned char *); }; @@ -1249,10 +1252,12 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p) } } - parm[0] = PARM3_UPDI_HV_SIMPLE_PULSE; - if (jtag3_setparm(pgm, SCOPE_AVR, 3, PARM3_OPT_12V_UPDI_ENABLE, parm, 1) < 0) - return -1; - + // Generate 12V UPDI pulse if user asks for it and hardware supports it + if(p->flags & AVRPART_HAS_UPDI && PDATA(pgm)->use_hvupdi == true && p->hvupdi_variant == 0) { + parm[0] = PARM3_UPDI_HV_SIMPLE_PULSE; + if (jtag3_setparm(pgm, SCOPE_AVR, 3, PARM3_OPT_12V_UPDI_ENABLE, parm, 1) < 0) + return -1; + } u16_to_b2(xd.default_min_div1_voltage, DEFAULT_MINIMUM_CHARACTERISED_DIV1_VOLTAGE_MV); u16_to_b2(xd.default_min_div2_voltage, DEFAULT_MINIMUM_CHARACTERISED_DIV2_VOLTAGE_MV); u16_to_b2(xd.default_min_div4_voltage, DEFAULT_MINIMUM_CHARACTERISED_DIV4_VOLTAGE_MV); @@ -1477,6 +1482,10 @@ static int jtag3_parseextparms(PROGRAMMER * pgm, LISTID extparms) continue; } + else if (matches(extended_param, "hvupdi") || matches(extended_param, "hvupdi=1")) { + PDATA(pgm)->use_hvupdi = true; + continue; + } avrdude_message(MSG_INFO, "%s: jtag3_parseextparms(): invalid extended parameter '%s'\n", progname, extended_param); @@ -2601,6 +2610,7 @@ void jtag3_updi_initpgm(PROGRAMMER * pgm) * mandatory functions */ pgm->initialize = jtag3_initialize; + pgm->parseextparams = jtag3_parseextparms; pgm->display = jtag3_display; pgm->enable = jtag3_enable; pgm->disable = jtag3_disable;