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

Add support for high-voltage UPDI #1015

Merged
merged 19 commits into from
Jul 18, 2022
Merged

Add support for high-voltage UPDI #1015

merged 19 commits into from
Jul 18, 2022

Conversation

MCUdude
Copy link
Collaborator

@MCUdude MCUdude commented Jun 26, 2022

This PR provides high-voltage UPDI support for the PICkit 4 and the Power Debugger.
It works perfectly with my hardware, but I would be very grateful if others also can test if they have compatible hardware.

$ ./avrdude -cpickit4_updi -pattiny1616 -Usyscfg0:r:-:h

         Vtarget                      : 5.08 V
         JTAG clock megaAVR/program   : 1000 kHz
         JTAG clock megaAVR/debug     : 100 kHz
         PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.



$ ./avrdude -cpickit4_updi -pattiny1616 -Usyscfg0:r:-:h -x hvupdi

         Vtarget                      : 5.08 V
         JTAG clock megaAVR/program   : 1000 kHz
         JTAG clock megaAVR/debug     : 100 kHz
         PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9421 (probably t1616)
avrdude: reading fuse5/syscfg0 memory:

Reading | ################################################## | 100% 0.01s

avrdude: writing output file "<stdout>"
0xf2

avrdude done.  Thank you.

Closes #861

@MCUdude MCUdude added the enhancement New feature or request label Jun 26, 2022
@MCUdude MCUdude requested a review from dl8dtl June 26, 2022 17:56
@MCUdude MCUdude mentioned this pull request Jun 28, 2022
@MCUdude
Copy link
Collaborator Author

MCUdude commented Jun 28, 2022

Thanks for the PR @janegilruud!

I guess the following code snippet should be updated to add support for HV UPDI type 2 targets as well?
Done!

    // 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 == HV_UPDI_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;
    }

EDIT: And we're not going to do anything with the xd.hvupdi_variant variable? Is it just a nice-to-have flag for possible future use?

@janegilruud
Copy link
Contributor

Yes, we should update that snippet. As I mentioned in #861 (comment) we could add a hvupdi_variant parameter to the programmers description too, and check if the target hvupdi_variant is present in the programmers hvupdi_variant-list.

@janegilruud
Copy link
Contributor

The xd.hvupdi_variant is passed to the tool in the following code line (jtag3.c:~1293): if (jtag3_setparm(pgm, SCOPE_AVR, 2, PARM3_DEVICEDESC, (unsigned char *)&xd, sizeof xd) < 0)

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jun 28, 2022

Thanks. I think this PR is ready then!

@stefanrueger
Copy link
Collaborator

stefanrueger commented Jun 29, 2022

@MCUdude The grammar change looks good and is self-documenting (grammar variable same name as struct component, etc). Tiny request, though: please rename K_HVUPDI_IMPLEMENTATION to K_HVUPDI_VARIANT
as the lexer tokens in AVRDUDE virtually always are K_<upper case of string>.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jun 29, 2022

Thanks for the input @stefanrueger! I've updated the PR and replaced K_HVUPDI_IMPLEMENTATION with K_HVUPDI_VARIANT.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jul 1, 2022

@janegilruud from what I can tell, the Pickit4 still outputs its 12V pulse on the UPDI pin (pin 4 on PK4 the programmer) instead of on the RESET pin (pin 6 on the PK4 programmer) with this PR.

However, the same happens when using pymcuprog as well with the following command:
pymcuprog ping -tpickit4 -davr64ea28 -Hsimple-unsafe-pulse

Note that I don't own any DD or EA hardware (wish I did), but my tongue says that there must be a HV pulse on the UPDI pin when trying to communicate with an EA target, even when using pymcuprog. (I'm currently on vacation and only brought essentials, so I can't measure the UPDI pin with my oscilloscope).

Here are the Pickit4 information Avrdude prints:

         Programmer Type : JTAGICE3_UPDI
         Description     : MPLAB(R) PICkit 4 in UPDI mode
         ICE HW version  : 4
         ICE FW version  : 1.13 (rel. 236)
         Serial number   : 
         Vtarget         : 5.07 V
         JTAG clock megaAVR/program   : 1000 kHz
         JTAG clock megaAVR/debug     : 100 kHz
         PDI/UPDI clock Xmega/megaAVR : 100 kHz

@janegilruud
Copy link
Contributor

Update PICkit4 to latest FW. It is now possible to update with Microchip Studio too.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jul 4, 2022

@janegilruud I only brought a mac on vacation, so I can only update the tool through MPLAB X. I'm very happy to hear Microchip Studio finally can be used to update the PK4 (and SNAP as well?). IMO, MPLAB X is not nearly as intuitive and elegant as MS7. I hope it doesn't get discontinued in favor of MPLAB.

After updating it, the latest version seems to be 1.14.268

(From Avrdude)

Programmer Type : JTAGICE3_UPDI
         Description     : MPLAB(R) PICkit 4 in UPDI mode
         ICE HW version  : 4
         ICE FW version  : 1.14 (rel. 268)
         Serial number   : 
         Vtarget         : 0.04 V
         JTAG clock megaAVR/program   : 1000 kHz
         JTAG clock megaAVR/debug     : 100 kHz
         PDI/UPDI clock Xmega/megaAVR : 100 kHz

The RESET line (PK4 pin 6) on the PK4 appears to be "dead" relative to GND when trying HVUPDI with "variant 2" targets.
However, I experience the same when using MPLAB X IDE/IPE as well.

@janegilruud
Copy link
Contributor

With FW 1.14 you successfully updated the tool.

With the latest FW in PK4 this branch should be able to send a UPDI HV pulse on the first pin on the PK4, provided that the target is a device with hvupdi_variant = 2; in avrdude.conf.
The connection should be (if we start counting on '1' on the PK4 connector):
PK4 pin 1 -> Target _RESET
PK4 pin 2 -> Target VCC
PK4 pin 3 -> Target GND
PK4 pin 4 -> Target UPDI

MPLAB X IDE/IPE 6.00 does not support this, so that won't work. The latest Studio do, but that won't help you much while you only have a Mac. (And yes, Studio can update Snap too.)

How do you measure the pulse? Have you brought a oscilloscope on vacation? :-)

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jul 5, 2022

How do you measure the pulse? Have you brought an oscilloscope on vacation? :-)

I did, once! But my wife won't let me anymore. She says that I'm supposed to "leave the geek stuff at home" when going on vacation. I have no idea why 😉

janegilruud from what I can tell, the Pickit4 still outputs its 12V pulse on the UPDI pin (pin 4 on PK4 the programmer) instead of on the RESET pin (pin 6 on the PK4 programmer) with this PR.

The connection should be (if we start counting on '1' on the PK4 connector):
PK4 pin 1 -> Target _RESET
PK4 pin 2 -> Target VCC
PK4 pin 3 -> Target GND
PK4 pin 4 -> Target UPDI

That explains it! For some reason, I've always thought that the HV pulse is outputted on the PK4's RESET pin (pin 6) instead of pin one. I'll give it a try tomorrow.

I'm home for a few days, so I can verify this with an oscilloscope and post some screenshots for good measure.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jul 6, 2022

Here are a few screenshots from my oscilloscope.

The first one is the HVUPDI sequence for an AVR32DD14. The yellow trace is PICkit4's pin 1 (MCLR), and the light blue trace is pin 4 (UPDI)
DS1Z_QuickPrint2

The second screenshot shows the HVUPDI sequence for an ATtiny1616 (Note the tiny HV spike on the UPDI line). The traces represent the same signal as in the previous screenshot.

DS1Z_QuickPrint3

I think everything looks perfectly fine, and this PR is probably ready to be merged.

@janegilruud
Copy link
Contributor

Sorry, I missed the part of your comment about looking at PK4 pin 6, but I still think it was necessary to update the FW.

Anyway, the screenshots look good :-)

@janegilruud
Copy link
Contributor

@MCUdude, I created a PR to your branch, have you looked at it?

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jul 6, 2022

@janegilruud thanks for the PR. I can't get it to work, see my comment here MCUdude#2 (comment).

Update PICkit4 to latest FW. It is now possible to update with Microchip Studio too.

Out of curiosity. To convert a PK4 or a SNAP from PIC to AVR mode is this just a simple command, or is the tool reflashed by MPLABX/MS7? If it's just a simple command, this is something that would be neat to either implement here or create a simple FOSS CLI tool that does just this.

@janegilruud
Copy link
Contributor

janegilruud commented Jul 7, 2022

Out of curiosity. To convert a PK4 or a SNAP from PIC to AVR mode is this just a simple command, or is the tool reflashed by MPLABX/MS7? If it's just a simple command, this is something that would be neat to either implement here or create a simple FOSS CLI tool that does just this.

It's "just a simple" command. Yes, I agree there should be an option outside the IDEs.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jul 7, 2022

It's "just a simple" command. Yes, I agree there should be an option outside the IDEs.

Great, that means it's possible for tools like Avrdude to "quickly" switch to AVR mode. My dream would be something like this:

$ avrdude -c pickit4_updi -p atmega4809

avrdude: Detected PICkit4 programmer in PIC mode. Do you want to switch to AVR mode? (Y/n)
Y
avrdude: PICkit4 programmer switched to AVR mode.
avrdude: Please reconnect the programmer for the changes to take effect

avrdude done.  Thank you.

Jan Egil Ruud and others added 2 commits July 7, 2022 12:23
Copy link
Collaborator

@stefanrueger stefanrueger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is easy to read and to easy to follow. I don't have the kit to check the hardware effect of the changes, but this has been done elsewhere with osci-shots to prove the functionality correct. Particularly good that the documentation has been updated, too!

I have only a few (very small) comments below. In my opinion the PR can be merged without addressing them.

Why is sup below unsigned int?

avrdude/src/jtag3.c

Lines 1262 to 1263 in 913509d

unsigned int sup = (unsigned int)(*(int *)(ldata(hvupdi_support)));
if(sup == p->hvupdi_variant) {

p->hvupdi_variant is of type int. These lines could be shortened to sth like

        if(*(int *) ldata(hvupdi_support) == p->hvupdi_variant) {

and you might get one fewer compiler warning (integer comparison of different signedness or some such). Similarly, why not shorten

avrdude/src/jtag3.c

Lines 1653 to 1658 in 913509d

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

to sth like

  avrdude_message(MSG_NOTICE2, "%s: HV UPDI support:", progname);
  for (ln = lfirst(pgm->hvupdi_support); ln; ln = lnext(ln))
    avrdude_message(MSG_NOTICE2, " %d", *(int *) ldata(ln));

else if ((matches(extended_param, "hvupdi") || matches(extended_param, "hvupdi=1")) &&

If I understand this correctly, matches(extended_param, "hvupdi") implies matches(extended_param, "hvupdi=1"), so is sufficient in the or clause. I know that the documentation does only mentions -xhvupdi and not -xhvupdi=.... However, if the code allows the user to supply -xhvupdi=0 might they expect the functionality to be switched off? Maybe do a quick check with different -x arguments to see whether the current parsing is how you want it to be.

(matches(ldata(lfirst(pgm->id)), "pickit4_updi") || matches(ldata(lfirst(pgm->id)), "powerdebugger_updi"))) {

Is the match against the programmer names necessary and useful? If so OK. It's not uncommon that techniques like these are used in AVRDUDE, but in general I would have an (ever so slight) preference to use properties of programmers rather than the name of the programmer.

All things considered, this PR is a smashing solution to a difficult problem, so yes please go for merging it.

@janegilruud
Copy link
Contributor

janegilruud commented Jul 11, 2022

Why is sup below unsigned int?

Just old habit. No good reason. Should be changed to int to reduce warnings and simplify.

Is the match against the programmer names necessary and useful?

With the introduction of hvupdi_support, no. What needs to be matched when setting use_hvupdi is that hvupdi_variant of the target is present in the programmers hvupdi_support list.

Regarding the hvupdi types, I know it is not very intuitive, but 0 is HV on the UPDI pin, 2 is HV on the _RESET pin and 1 is "off" (no HV). Sorry for this mess. I guess you could let the user specify the hvupdi type, but it's really not necessary. The target has only one type so the type is sort of implied for the selected target.

Jan Egil Ruud and others added 3 commits July 11, 2022 15:26
…The hvupdi type is implied by the part configuration.
Clean up and simplify hvupdi handling, and set default hvupdi_variant
@MCUdude
Copy link
Collaborator Author

MCUdude commented Jul 12, 2022

Thank you @janegilruud for your extensive work, and @stefanrueger for providing excellent feedback!
I believe this PR is ready to be merged now.

@mcuee
Copy link
Collaborator

mcuee commented Oct 31, 2022

@MCUdude
Do we need 1.14 FW? I tried to use HV UPDI to get my bricked AVR64DD32 Curiosity Nano. It did not work but I noticed my PICkit 4 FW version is 1.13.

C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c pickit4_updi -p avr64dd32 -Usyscfg0:r:-:h -x hvupdi -v

avrdude: Version 7.0-20221026 (a101899)
         Copyright (c) Brian Dean, http://www.bdmicro.com/
         Copyright (c) Joerg Wunsch

         System wide configuration file is C:\work\avr\avrdude_test\avrdude_bin\avrdude.conf

         Using Port                    : usb
         Using Programmer              : pickit4_updi
avrdude: found CMSIS-DAP compliant device, using EDBG protocol
         AVR Part                      : AVR64DD32
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           fuse0       wdtcfg      0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse1       bodcfg      0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse2       osccfg      0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse4       tcd0cfg     0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse5       syscfg0     0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse6       syscfg1     0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse7       codesize    0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse8       bootsize    0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuses                   0     0     0    0 no          9   16      0     0     0 0x00 0x00
           lock                    0     0     0    0 no          4    1      0     0     0 0x00 0x00
           tempsense               0     0     0    0 no          2    1      0     0     0 0x00 0x00
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
           prodsig                 0     0     0    0 no        125  125      0     0     0 0x00 0x00
           sernum                  0     0     0    0 no         16    1      0     0     0 0x00 0x00
           userrow     usersig     0     0     0    0 no         32   32      0     0     0 0x00 0x00
           data                    0     0     0    0 no          0    1      0     0     0 0x00 0x00
           eeprom                  0     0     0    0 no        256    1      0     0     0 0x00 0x00
           flash                   0     0     0    0 no      65536  512      0     0     0 0x00 0x00

         Programmer Type : JTAGICE3_UPDI
         Description     : MPLAB(R) PICkit 4 in UPDI mode
         ICE HW version  : 4
         ICE FW version  : 1.13 (rel. 236)
         Serial number   :
         Vtarget         : 3.29 V
         JTAG clock megaAVR/program   : 1000 kHz
         JTAG clock megaAVR/debug     : 100 kHz
         PDI/UPDI clock Xmega/megaAVR : 100 kHz
avrdude jtag3_initialize() error: MPLAB(R) PICkit 4 in UPDI mode does not support sending HV pulse to target AVR64DD32
avrdude main() error: initialization failed, rc=-1
        - double check the connections and try again
        - use -B to set lower ISP clock frequency, e.g. -B 200kHz
        - use -F to override this check


avrdude done.  Thank you.

(py39venv) C:\work\avr\avrdude_test\avrdude_bin> pymcuprog ping -tpickit4 -davr64dd32 -Hsimple-unsafe-pulse
Connecting to any pickit4
Connected to MPLAB PICkit 4 CMSIS-DAP from Microchip Technology Incorporated (serial number BUR200973052)
Debugger firmware version 1.13.236
Debugger hardware revision 4
pyedbglib.protocols.jtagice3protocol - ERROR - JTAGICE3 error response code 0x1C: 'AVR8_FAILURE_FRAMING_ERROR: Framing error'
pymcuprog.pymcuprog - ERROR - Operation failed with Jtagice3ResponseError: AVR8_FAILURE_FRAMING_ERROR: Framing error

@MCUdude
Copy link
Collaborator Author

MCUdude commented Oct 31, 2022

Yes, I believe you need 2.14 for HV UPDI to work. @mcuee I'll look at the other issues you've tagged me in very soon!

@mcuee
Copy link
Collaborator

mcuee commented Oct 31, 2022

Yes, I believe you need 1.14 for HV UPDI to work. @mcuee I'll look at the other issues you've tagged me in very soon!

Somehow I still have a problem. pymcuprog seems to work, but not avrdude.

(py39venv) C:\work\avr\avrdude_test\avrdude_bin> pymcuprog ping -tpickit4 -davr64dd32 -Hsimple-unsafe-pulse
Connecting to any pickit4
Connected to MPLAB PICkit 4 CMSIS-DAP from Microchip Technology Incorporated (serial number BUR200973052)
Debugger firmware version 1.14.268
Debugger hardware revision 4
Pinging device...
Ping response: 1E961A
Done.

(py39venv) C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_git -c pickit4_updi -p avr64dd32 -Usyscfg0:r:-:h -x hvupdi -v

avrdude_git: Version 7.0-20221026 (a101899)
             Copyright (c) Brian Dean, http://www.bdmicro.com/
             Copyright (c) Joerg Wunsch

             System wide configuration file is C:\work\avr\avrdude_test\avrdude_bin\avrdude.conf

             Using Port                    : usb
             Using Programmer              : pickit4_updi
avrdude_git: found CMSIS-DAP compliant device, using EDBG protocol
             AVR Part                      : AVR64DD32
             RESET disposition             : dedicated
             RETRY pulse                   : SCK
             Serial program mode           : yes
             Parallel program mode         : yes
             Memory Detail                 :

                                               Block Poll               Page                       Polled
               Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
               ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
               fuse0       wdtcfg      0     0     0    0 no          1    1      0     0     0 0x00 0x00
               fuse1       bodcfg      0     0     0    0 no          1    1      0     0     0 0x00 0x00
               fuse2       osccfg      0     0     0    0 no          1    1      0     0     0 0x00 0x00
               fuse4       tcd0cfg     0     0     0    0 no          1    1      0     0     0 0x00 0x00
               fuse5       syscfg0     0     0     0    0 no          1    1      0     0     0 0x00 0x00
               fuse6       syscfg1     0     0     0    0 no          1    1      0     0     0 0x00 0x00
               fuse7       codesize    0     0     0    0 no          1    1      0     0     0 0x00 0x00
               fuse8       bootsize    0     0     0    0 no          1    1      0     0     0 0x00 0x00
               fuses                   0     0     0    0 no          9   16      0     0     0 0x00 0x00
               lock                    0     0     0    0 no          4    1      0     0     0 0x00 0x00
               tempsense               0     0     0    0 no          2    1      0     0     0 0x00 0x00
               signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
               prodsig                 0     0     0    0 no        125  125      0     0     0 0x00 0x00
               sernum                  0     0     0    0 no         16    1      0     0     0 0x00 0x00
               userrow     usersig     0     0     0    0 no         32   32      0     0     0 0x00 0x00
               data                    0     0     0    0 no          0    1      0     0     0 0x00 0x00
               eeprom                  0     0     0    0 no        256    1      0     0     0 0x00 0x00
               flash                   0     0     0    0 no      65536  512      0     0     0 0x00 0x00

             Programmer Type : JTAGICE3_UPDI
             Description     : MPLAB(R) PICkit 4 in UPDI mode
             ICE HW version  : 4
             ICE FW version  : 1.14 (rel. 268)
             Serial number   :
             Vtarget         : 3.29 V
             JTAG clock megaAVR/program   : 1000 kHz
             JTAG clock megaAVR/debug     : 100 kHz
             PDI/UPDI clock Xmega/megaAVR : 100 kHz
avrdude_git jtag3_initialize() error: MPLAB(R) PICkit 4 in UPDI mode does not support sending HV pulse to target AVR64DD32
avrdude_git main() error: initialization failed, rc=-1
            - double check the connections and try again
            - use -B to set lower ISP clock frequency, e.g. -B 200kHz
            - use -F to override this check


avrdude_git done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Oct 31, 2022

Any I can unlock the device now.

(py39venv) C:\work\avr\avrdude_test\avrdude_bin> pymcuprog ping -tpickit4 -davr64dd32 -Hsimple-unsafe-pulse -C
Connecting to any pickit4
Connected to MPLAB PICkit 4 CMSIS-DAP from Microchip Technology Incorporated (serial number BUR200973052)
Debugger firmware version 1.14.268
Debugger hardware revision 4
Pinging device...
Ping response: 1E961A
Done.
(py39venv) C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_git -c pickit4_updi -p avr64dd32 -Usyscfg0:r:-:h

             Vtarget                      : 3.29 V
             JTAG clock megaAVR/program   : 1000 kHz
             JTAG clock megaAVR/debug     : 100 kHz
             PDI/UPDI clock Xmega/megaAVR : 100 kHz
avrdude_git: AVR device initialized and ready to accept instructions
avrdude_git: device signature = 0x1e961a (probably avr64dd32)
avrdude_git: reading fuse5/syscfg0 memory ...
avrdude_git: writing output file <stdout>
0xc5

avrdude_git done.  Thank you.

(py39venv) C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_git -c pkobn_updi -p avr64dd32 -e

             Vtarget                      : 3.31 V
             PDI/UPDI clock Xmega/megaAVR : 100 kHz
avrdude_git: AVR device initialized and ready to accept instructions
avrdude_git: device signature = 0x1e961a (probably avr64dd32)
erasing chip

avrdude_git done.  Thank you.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Oct 31, 2022

@mcuee I can't test it right now, but it should work on AVR-DDs.
Here's the HV UPDI code:

avrdude/src/jtag3.c

Lines 1200 to 1220 in b569966

// Generate UPDI high-voltage pulse if user asks for it and hardware supports it
LNODEID support;
if (p->prog_modes & PM_UPDI &&
PDATA(pgm)->use_hvupdi == true &&
p->hvupdi_variant != HV_UPDI_VARIANT_1) {
parm[0] = PARM3_UPDI_HV_NONE;
for (support = lfirst(pgm->hvupdi_support); support != NULL; support = lnext(support)) {
if(*(int *) ldata(support) == p->hvupdi_variant) {
pmsg_notice("sending HV pulse to targets %s pin\n",
p->hvupdi_variant == HV_UPDI_VARIANT_0? "UPDI": "RESET");
parm[0] = PARM3_UPDI_HV_SIMPLE_PULSE;
break;
}
if (parm[0] == PARM3_UPDI_HV_NONE) {
pmsg_error("%s does not support sending HV pulse to target %s\n", pgm->desc, p->desc);
return -1;
}
}
if (jtag3_setparm(pgm, SCOPE_AVR, 3, PARM3_OPT_12V_UPDI_ENABLE, parm, 1) < 0)
return -1;
}

Maybe you can try to add a few debug line to see what really happens?
In your Avrdude output I can see that you're getting the following error, so there must be an error somewhere:

avrdude_git jtag3_initialize() error: MPLAB(R) PICkit 4 in UPDI mode does not support sending HV pulse to target AVR64DD32

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

High voltage UPDI
4 participants