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

Read programmer serial number from libusb or hidusb #1223

Merged
merged 21 commits into from
Dec 21, 2022

Conversation

MCUdude
Copy link
Collaborator

@MCUdude MCUdude commented Dec 16, 2022

This PR makes it possible to read the serial number from JTAG3-compatible programmers using libusb or hidusb.
Without this PR, Avrdude is not able to read the serial number from the AVRISPmkII, PICkit4, or SNAP.

@mcuee
Copy link
Collaborator

mcuee commented Dec 16, 2022

This PR is good to go from my side. Tested under Linux, Windows and macOS in #1038.

Take note #1212 and #1221 are seperate issues to be addressed eleswhere.

@mcuee mcuee added the enhancement New feature or request label Dec 16, 2022
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.

Review of usb_hidapi.c

  • Not sure whether the serial number access function should have a 14 character limit (plus nul); I generally prefer allocated mem:
    static const char *usbsn = "";
    
    const char *usbhid_get_serno() {
      return usbsn;
    }
    
  • The return value of hid_get_serial_number_string() should be checked for error and only on success the wide character string converted, else usbsn should remain ""
  • wcstombs((char *) usbsn, sn, 15); has no error checking either; all sorts of unterminated strings could ensue; better replace the code with sth like untested(!) and [edited(!)]
    wchar_t sn[1234];
    if(hid_get_serial_number_string(dev, sn, sizeof sn/sizeof*sn) == 0) {
      size_t n = wcstombs(NULL, sn, 0) + 1;
      if(n) {
        char *cn = cfg_malloc(__func__, n);
        if(wcstombs(cn, sn, n) != (size_t) -1)
          usbsn = cache_string(cn);
        free(cn);
      }
    }
    

I'd suggest similar changes for usb_libusb.c. In particular, the line is problematic, as it could lead to an unterminated string. I suggest replacing it with

		  usbsn = cache_string(string);

Other than that:

  • The comment might read Reference or Get not Store; the same in stk500v2.c
  • This condition might be if(pgm->usbsn && *pgm->usbsn); the same in stk500v2.c
  • Unrelated to this PR but potentially still a problem: What makes us sure status in this line is 3 or more? If it isn't the memmove() blows up, so I'd recommend a sanity check with error if(status<3) the line before

@MCUdude
Copy link
Collaborator Author

MCUdude commented Dec 16, 2022

Thank you very much @stefanrueger for the feedback and review!

Unrelated to this PR but potentially still a problem: What makes us sure status in this line is 3 or more?

I have no idea where the number 3 comes from, but I'll add a sanity check just to be safe.

Not sure whether the serial number access function should have a 14 character limit (plus nul); I generally prefer allocated mem:

static const char *usbsn = "";

const char *usbhid_get_serno() {
  return usbsn;
}

Out of curiosity, isn't it problematic to not allocate a fixed amount of memory that usbsn can point to? Isn't there a theoretical chance that writing a "long" string starting from address usbsn points to may cause memory corruption?
I agree that a serial number string of 15 characters may be too little. But 15 was previously used somewhere, so I stuck with this value.

wchar_t sn[1234];
if(hid_get_serial_number_string(dev, sn, sizeof sn/sizeof*sn) == 0) {
  size_t n = wcstombs(NULL, sn, 0) + 1;
  if(n) {
    char *cn = cfg_malloc(__func__, n);
    if(wcstombs(cn, sn, n) != (size_t) -1)
      usbsn = cache_string(cn);
    free(cn);
  }
}

Thanks for suggesting this! I've tested it, and it works great. However, a USB serial number is limited to 126 bytes by the USB spec, so there shouldn't be any need to create an array with room for 1234 wide characters. wchar_t sn[128] wchar_t sn[256] should be enough.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Dec 16, 2022

I just pushed a fix for issue #1212, since this is loosely related to this PR.

However, the formatting has been and still is a bit "off". The colons don't line up, and it also prints out clock settings that's not relevant to the target:

PICkit4 (should really just print the ISP clock):

$ ./avrdude -cpickit4_isp -patmega16 -v

[...]

         Programmer Type : JTAG3_ISP
         Description     : MPLAB(R) PICkit 4 in ISP mode
         ICE HW version  : 4
         ICE FW version  : 1.14 (rel. 268)
         Serial number   : BUR204071896
         Vtarget         : 0.05 V
         JTAG clock megaAVR/program   : 1000 kHz
         JTAG clock megaAVR/debug     : 100 kHz
         PDI/UPDI clock Xmega/megaAVR : 100 kHz
         SCK period                   : 8.00 us

Xplained Mini ATmega328PB:

$ ./avrdude -cxplainedmini -patmega328pb -v

[...]

         Programmer Type : JTAG3_ISP
         Description     : Atmel AVR XplainedMini in ISP mode
         ICE HW version  : 0
         ICE FW version  : 1.22 (rel. 134)
         Serial number   : ATML2523052700005389
         Vtarget         : 5.00 V
         SCK period                   : 8.00 us

@mcuee
Copy link
Collaborator

mcuee commented Dec 16, 2022

Yes the ISP mode works now.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v1 -c pickit4_isp -p m8a -v

avrdude_pr1223v1: Version 7.0-20221216 (93d7e41)
                  Copyright the AVRDUDE authors;
                  see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

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

                  Using Port                    : usb
                  Using Programmer              : pickit4_isp
avrdude_pr1223v1: found CMSIS-DAP compliant device, using EDBG protocol
                  AVR Part                      : ATmega8A
                  ...

                  Programmer Type : JTAG3_ISP
                  Description     : MPLAB(R) PICkit 4 in ISP mode
                  ICE HW version  : 4
                  ICE FW version  : 1.14 (rel. 268)
                  Serial number   : BUR2009xxxxx
                  Vtarget         : 4.93 V
                  JTAG clock megaAVR/program   : 1000 kHz
                  JTAG clock megaAVR/debug     : 100 kHz
                  PDI/UPDI clock Xmega/megaAVR : 100 kHz
                  SCK period                   : 500.00 us

avrdude_pr1223v1: AVR device initialized and ready to accept instructions
avrdude_pr1223v1: device signature = 0x1e9307 (probably m8a)

avrdude_pr1223v1 done.  Thank you.

@stefanrueger
Copy link
Collaborator

| no idea where the number 3 comes from

Nor do I, but memmove(.., ..., status-3) needs to avoid status<3! I suspect status >= 3 is guaranteed by jtag3_command() and the firmware of the programmer that interacts with it but if not that would be vvv hard to debug without the sanity check. There is no harm in sanity checks. BTW, the error message should say it's an unexpected response from the CMD3_GET_INFO command (not the one the error message mentions) and it would be better if it had a terminating \n. I also suspect, if you read closely what jtag3_command() does that it (or a function it calls) allocates memory that ought to be released using free(resp) just before every return. So should have two more free(resp) in jtag3_display(), one just before the return in the sanity check and one at the very end of jtag3_display().

| isn't it problematic to not allocate a fixed amount of memory that usbsn can point to?

Only if the code doesn't allocate the correct amount of memory needed at runtime; cache_string() takes care of that.

@stefanrueger
Copy link
Collaborator

| a USB serial number is limited to 126 bytes by the USB spec

Then wchar_t sn[127]; should be enough, indeed. There is no harm in a (moderately) larger dimension, as the sn array is allocated temporaily on the stack, so will be freed a few microseconds after use (and it's not inside a recursive function).

@MCUdude
Copy link
Collaborator Author

MCUdude commented Dec 17, 2022

I also suspect, if you read closely what jtag3_command() does that it (or a function it calls) allocates memory that ought to be released using free(resp) just before every return

But this means that there are several other places where free(resp) is missing after a failed jtag3_command(). Do you want me to fix this in this PR as well?

@stefanrueger
Copy link
Collaborator

| several other places where free(resp) is missing

... or wrong, indeed. I almost wish I hadn't looked that closely, but there you go. Here my trawl through jtag3.c:

  • This free() is too early as sn = resp is used afterwards; it needs to be moved to be the last command
  • This return should be preceded by a free(resp);
  • Sanity check with error msg recommended before this line to the effect of
    if(status < 4) {
      pmsg_error("unexpected response from read memory jtag3_command()\n");
      free(resp);
      return -1;
    }
    
  • Similarly here and here just with rv < 0 or status < 0
  • Similarly here and here only with a slightly different check
  • Here the function name in the error message is incorrect, also in the pmsg_trace() before
  • Before this return there should be a conditional free() as memory was only allocated when status >= 0
        if(status == 0)
          free(*resp);
    
    And, yes, it really is free(*resp) in this case, not free(resp)
  • This if(status > 0) is "not wrong", but it reads better if it were if(status >= 0) (long story)
  • BTW, well spotted re the pgm_free() in stk500.c. I missed that!

Those pesky sanity checks might not be needed but I could not find the piece of code that would guarantee rv > 3 or status > 3 or similarly - I think that's implied only when you have a cooperating, working programmer that is bug-free and if the comms works without hiccoughs, too.

Anyway, if you could cross-check my thinking and carefully see how to mend the problems above that would be great, even though it's nothing to do with your PR (I normally fix stuff en passant when I go about other goals in my PR's lest I forget later on).

@MCUdude
Copy link
Collaborator Author

MCUdude commented Dec 17, 2022

Thanks for looking through the code! I've just pushed a commit with your suggestions. They all sound very reasonable and shouldn't break anything. The code in stk500v2.c and jtag3.c isn't all that nice to look at, with "magic numbers" everywhere and little to no comments on what's going on. The formatting in these files is also all over the place, with a messy mix of tabs and spaces.

Similarly here and here only with a slightly different check

The last link doesn't point to anything obvious. Could you clarify?

This free() is too early as sn = resp is used afterwards; it needs to be moved to be the last command

It's true that this is at the wrong place, but I can't figure out how to get it right. The problem is the typical

ld: warning: directory not found for option '-FCoreFoundation'
  CC       libavrdude_la-jtag3.lo
jtag3.c:2340:7: warning: variable 'resp' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
  if (pgm->usbsn && *pgm->usbsn)
      ^~~~~~~~~~~~~~~~~~~~~~~~~
jtag3.c:2376:7: note: uninitialized use occurs here
  if (resp)
      ^~~~
jtag3.c:2340:3: note: remove the 'if' if its condition is always false
  if (pgm->usbsn && *pgm->usbsn)
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
jtag3.c:2326:32: note: initialize the variable 'resp' to silence this warning
  unsigned char parms[5], *resp;
                               ^
                                = NULL

warning, where resp may be initialized. if you have a suggestion on how it can be done properly, I'm all ears!

@stefanrueger
Copy link
Collaborator

Excellent, we are converging!

  • This is wrong: Either move status -= 3 past the if() or change the if() to if(status < 0)
  • I probably meant this for sanity checking; I looked for memcpy() and memmove() ...
  • Yes, I can see the uninitialised resp problem now; it needs to be declared first thing and initialised resp = NULL as suggested by the compiler; that would do the trick, b/c free(NULL) is a NOP
diff --git a/src/jtag3.c b/src/jtag3.c
index 105bec7..1622303 100644
--- a/src/jtag3.c
+++ b/src/jtag3.c
@@ -2323,7 +2323,7 @@ int jtag3_set_vtarget(const PROGRAMMER *pgm, double v) {
 }
 
 void jtag3_display(const PROGRAMMER *pgm, const char *p) {
-  unsigned char parms[5];
+  unsigned char parms[5], *resp = NULL;
   const char *sn;
 
   /*
@@ -2340,7 +2340,7 @@ void jtag3_display(const PROGRAMMER *pgm, const char *p) {
   if (pgm->usbsn && *pgm->usbsn)
     sn = pgm->usbsn;
   else {
-    unsigned char cmd[4], *resp, c;
+    unsigned char cmd[4], c;
     int status;
     cmd[0] = SCOPE_INFO;
     cmd[1] = CMD3_GET_INFO;
@@ -2372,6 +2372,7 @@ void jtag3_display(const PROGRAMMER *pgm, const char *p) {
   msg_info("%sICE FW version  : %d.%02d (rel. %d)\n", p, parms[1], parms[2],
            (parms[3] | (parms[4] << 8)));
   msg_info("%sSerial number   : %s", p, sn);
+  free(resp);
 }

@stefanrueger
Copy link
Collaborator

| messy mix of tabs and spaces

I agree; there is a school of thought that these things should be handled as separate PRs so they don't obfuscate the PR at hand. So maybe a good idea to remove the tabs and trainling white space after v7.1 has been released and doing so in a separate PR. @MCUdude You are particularly disadvantaged as your favourite tab expansion is 4 spaces whilst it's almost always 8 spaces everywhere else incl avrdude source.

BTW, I found a great trick to review PRs that change white space; you can tick hide whitespace for web reviews (and you can use git diff -w on the command line.

git-diff-white-space

@mcuee
Copy link
Collaborator

mcuee commented Dec 18, 2022

You are particularly disadvantaged as your favourite tab expansion is 4 spaces whilst it's almost always 8 spaces everywhere else incl avrdude source.

@stefanrueger and @MCUdude

I think we can standardized on 4 space after the 7.1 release which seems to be the norm nowadays.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Dec 18, 2022

I think we can standardized on 4 space after the 7.1 release which seems to be the norm nowadays.

Well, ~95% of the codebase are already indented with two spaces. Why change to 4?
I was thinking about replacing the remaining tabs with two space indents, not reformat the entire codebase.

@mcuee
Copy link
Collaborator

mcuee commented Dec 18, 2022

I think we can standardized on 4 space after the 7.1 release which seems to be the norm nowadays.

Well, ~95% of the codebase are already indented with two spaces. Why change to 4? I was thinking about replacing the remaining tabs with two space indents, not reformat the entire codebase.

I see. Yes that is the way to go then.

@stefanrueger
Copy link
Collaborator

Whilst it might look good to generate a uniform formatting, there are multiple disadvantages:

  • Diffs between two versions over a long time that had, amongst other changes, a formatting change in between become obfuscated; I am not only talking about white space (that diff tools can ignore) but also about formatting changes such as
     if ( xc > 0 )
     {
        return ( 1 );
     }
        else
     {
       return ( 0 );
     }
    
    to the equivalent return xc > 0; Yes, there are about 10 things not right with the first code (one of which to else a return branch) , but unless the code needs to change what is returned, I normally leave this alone (even though the code mildly disturbs me).
  • It might put contributors off who just don't agree with a prescribed formatting
  • It disguises what I call handwriting which for me, as a reviewer, can give subtle clues as to intention of the author
  • As an author strict formatting rules distract me from the real problem at hand; I prefer freedom (within reason)
  • The overly zealous policing of formatting rules distracts from the goal of the project: I don't wish to spend time on that

| I was thinking about replacing the remaining tabs with two space indents

That won't work. Sometimes, the program is 4-spaces indented and the spacing consists of a mixture of 8-space tabs with the remainder being spaces. expand -i is your friend as this should avoid expanding tabs in strings. The remaining tabs would need to be looked at on a case-by-case basis.

@stefanrueger
Copy link
Collaborator

@MCUdude Thanks for all the commits. There is one thing left

@stefanrueger
Copy link
Collaborator

To cut a long short: The messy mix of tabs and spaces hinders readability of the code; I support expanding tabs to spaces, eg, using expand -i in a separate PR. Other than this, I'd caution against overzealous policing, enforcing and changing formatting (unless some gratuitous formatting can be changed at the same time the code needs to change anyway).

@stefanrueger
Copy link
Collaborator

I have taken to check compiler warnings as last step of PRs that I carry out. In this case there are rather a lot (not caused by you, @MCUdude). OK if I push them on to your PR, or do you prefer I do these at another time, perhaps after v7.1. These pesky signed/unsigned warnings require a detailed look in each case.

signed-unsigned

@MCUdude
Copy link
Collaborator Author

MCUdude commented Dec 18, 2022

OK if I push them on to your PR, or do you prefer I do these at another time, perhaps after v7.1. These pesky signed/unsigned warnings require a detailed look in each case.

Is the list of warnings much longer than what's shown in your PR? I'm fine with you pushing a fix for all these working to my branch.

@stefanrueger
Copy link
Collaborator

Done.

@MCUdude please review. @mcuee please test jtag3 in general (and retest this PR).

If Ok, then this should be ready to merge

@MCUdude
Copy link
Collaborator Author

MCUdude commented Dec 19, 2022

@MCUdude please review

Thanks for the commit @stefanrueger! The commit(s) appear very straightforward, and just for kicks, I tested it using an Atmel ICE in ISP mode. Everything seems to work as it should, so I think this PR is ready to be merged unless @mcuee finds any irregularities.

@mcuee
Copy link
Collaborator

mcuee commented Dec 20, 2022

The formating of Vtarget is a bif off in xplainedmini_tpi . Or we should just say the formating is not consistent. This may or may not be related to this PR though. But it is nice to fix it.

Test results for xplainedmini_tpi (ATtiny104 Xplained Nano) and xplainedmini_updi (ATtiny416 Xplained Nano).

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v3 -c xplainedmini_tpi -p t104 -v

avrdude_pr1223v3: Version 7.0-20221219 (99e0822)
                  Copyright the AVRDUDE authors;
                  see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

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

                  Using Port                    : usb
                  Using Programmer              : xplainedmini_tpi
avrdude_pr1223v3: found CMSIS-DAP compliant device, using EDBG protocol
                  AVR Part                      : ATtiny104
                  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
                    ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                    fuse                    0     0     4    0 no          1   16      0     0     0 0x00 0x00
                    lockbits                0     0     0    0 no          1   16      0     0     0 0x00 0x00
                    signature               0     0     0    0 no          3   16      0     0     0 0x00 0x00
                    calibration             0     0     0    0 no          1   16      0     0     0 0x00 0x00
                    flash                   0     0   128    0 no       1024   16      0     0     0 0x00 0x00
                    sigrow                  0     0     0    0 no         16   16      0     0     0 0x00 0x00

                  Programmer Type : JTAGICE3_TPI
                  Description     : Atmel AVR XplainedMini in TPI mode
                  ICE HW version  : 0
                  ICE FW version  : 1.07 (rel. 10)
                  Serial number   : ATMLxxxxxxxxxxxxxxxx
Vtarget         : 5.00 V
avrdude_pr1223v3: AVR device initialized and ready to accept instructions
avrdude_pr1223v3: device signature = 0x1e900b (probably t104)

avrdude_pr1223v3 done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v3 -c xplainedmini_tpi -p t104

Vtarget                      : 5.00 V
avrdude_pr1223v3: AVR device initialized and ready to accept instructions
avrdude_pr1223v3: device signature = 0x1e900b (probably t104)

avrdude_pr1223v3 done.  Thank you.

-c xplainedmini_updi is consistent with others.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v3 -c xplainedmini_updi -p t416 -v

avrdude_pr1223v3: Version 7.0-20221219 (99e0822)
                  Copyright the AVRDUDE authors;
                  see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

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

                  Using Port                    : usb
                  Using Programmer              : xplainedmini_updi
avrdude_pr1223v3: found CMSIS-DAP compliant device, using EDBG protocol
                  AVR Part                      : ATtiny416
                  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       append      0     0     0    0 no          1    1      0     0     0 0x00 0x00
                    fuse8       bootend     0     0     0    0 no          1    1      0     0     0 0x00 0x00
                    fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
                    lock                    0     0     0    0 no          1    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         61   61      0     0     0 0x00 0x00
                    sernum                  0     0     0    0 no         10    1      0     0     0 0x00 0x00
                    osccal16                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    osccal20                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    osc16err                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    osc20err                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    data                    0     0     0    0 no          0    1      0     0     0 0x00 0x00
                    userrow     usersig     0     0     0    0 no         32   32      0     0     0 0x00 0x00
                    eeprom                  0     0     0    0 no        128   32      0     0     0 0x00 0x00
                    flash                   0     0     0    0 no       4096   64      0     0     0 0x00 0x00

                  Programmer Type : JTAGICE3_UPDI
                  Description     : Atmel AVR XplainedMini in UPDI mode
                  ICE HW version  : 0
                  ICE FW version  : 1.13 (rel. 43)
                  Serial number   : ATMLxxxxxxxxxxxxxxxx
                  Vtarget         : 5.00 V
avrdude_pr1223v3: partial Family_ID returned: "tiny"
avrdude_pr1223v3: AVR device initialized and ready to accept instructions
avrdude_pr1223v3: device signature = 0x1e9221 (probably t416)

avrdude_pr1223v3 done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v3 -c xplainedmini_updi -p t416

                  Vtarget                      : 5.00 V
avrdude_pr1223v3: AVR device initialized and ready to accept instructions
avrdude_pr1223v3: device signature = 0x1e9221 (probably t416)

avrdude_pr1223v3 done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Dec 20, 2022

More test results: pkobn_updi (AVR128DB48 Curiosity Nano) and xplainedmini ISP mode (ATmega328PB Xplained MINI)

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v3 -c pkobn_updi -p avr128db48 -v

avrdude_pr1223v3: Version 7.0-20221219 (99e0822)
                  Copyright the AVRDUDE authors;
                  see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

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

                  Using Port                    : usb
                  Using Programmer              : pkobn_updi
avrdude_pr1223v3: found CMSIS-DAP compliant device, using EDBG protocol
                  AVR Part                      : AVR128DB48
                  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        512    1      0     0     0 0x00 0x00
                    flash                   0     0     0    0 no     131072  512      0     0     0 0x00 0x00

                  Programmer Type : JTAGICE3_UPDI
                  Description     : Curiosity nano (nEDBG) in UPDI mode
                  ICE HW version  : 0
                  ICE FW version  : 1.21 (rel. 37)
                  Serial number   : MCHPxxxxxxxxxxxxxxxx
                  Vtarget         : 3.31 V
                  PDI/UPDI clock Xmega/megaAVR : 100 kHz
avrdude_pr1223v3: partial Family_ID returned: "AVR "
avrdude_pr1223v3: AVR device initialized and ready to accept instructions
avrdude_pr1223v3: device signature = 0x1e970c (probably avr128db48)

avrdude_pr1223v3 done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v3 -c xplainedmini -p m328pb -v

avrdude_pr1223v3: Version 7.0-20221219 (99e0822)
                  Copyright the AVRDUDE authors;
                  see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

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

                  Using Port                    : usb
                  Using Programmer              : xplainedmini
avrdude_pr1223v3: found CMSIS-DAP compliant device, using EDBG protocol
                  AVR Part                      : ATmega328PB
                  Chip Erase delay              : 10500 us
                  PAGEL                         : PD7
                  BS2                           : PC2
                  RESET disposition             : possible i/o
                  RETRY pulse                   : SCK
                  Serial program mode           : yes
                  Parallel program mode         : yes
                  Timeout                       : 200
                  StabDelay                     : 100
                  CmdexeDelay                   : 25
                  SyncLoops                     : 32
                  PollIndex                     : 3
                  PollValue                     : 0x53
                  Memory Detail                 :

                                                    Block Poll               Page                       Polled
                    Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                    ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                    eeprom                 65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
                    flash                  65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                    lfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                    hfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                    efuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                    lock                    0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                    signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
                    calibration             0     0     0    0 no          1    1      0     0     0 0x00 0x00

                  Programmer Type : JTAG3_ISP
                  Description     : Atmel AVR XplainedMini in ISP mode
                  ICE HW version  : 0
                  ICE FW version  : 1.22 (rel. 134)
                  Serial number   : ATMLxxxxxxxxxxxxxxxx
                  Vtarget         : 5.00 V
                  SCK period                   : 8.00 us

avrdude_pr1223v3: AVR device initialized and ready to accept instructions
avrdude_pr1223v3: device signature = 0x1e9516 (probably m328pb)

avrdude_pr1223v3 done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Dec 20, 2022

More test results for PICKit 4 (UPDI and ISP) and SNAP.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v3 -c pickit4_updi -p m4808 -v

avrdude_pr1223v3: Version 7.0-20221219 (99e0822)
                  Copyright the AVRDUDE authors;
                  see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

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

                  Using Port                    : usb
                  Using Programmer              : pickit4_updi
avrdude_pr1223v3: found CMSIS-DAP compliant device, using EDBG protocol
                  AVR Part                      : ATmega4808
                  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       append      0     0     0    0 no          1    1      0     0     0 0x00 0x00
                    fuse8       bootend     0     0     0    0 no          1    1      0     0     0 0x00 0x00
                    fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
                    lock                    0     0     0    0 no          1    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         61   61      0     0     0 0x00 0x00
                    sernum                  0     0     0    0 no         10    1      0     0     0 0x00 0x00
                    osccal16                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    osccal20                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    osc16err                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    osc20err                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    data                    0     0     0    0 no          0    1      0     0     0 0x00 0x00
                    userrow     usersig     0     0     0    0 no         64   64      0     0     0 0x00 0x00
                    eeprom                  0     0     0    0 no        256   64      0     0     0 0x00 0x00
                    flash                   0     0     0    0 no      49152  128      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   : BURxxxxxxxx
                  Vtarget         : 4.77 V
                  JTAG clock megaAVR/program   : 1000 kHz
                  JTAG clock megaAVR/debug     : 100 kHz
                  PDI/UPDI clock Xmega/megaAVR : 100 kHz
avrdude_pr1223v3: partial Family_ID returned: "mega"
avrdude_pr1223v3: AVR device initialized and ready to accept instructions
avrdude_pr1223v3: device signature = 0x1e9650 (probably m4808)

avrdude_pr1223v3 done.  Thank you.


PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v3 -c pickit4_isp -p m8a -v

avrdude_pr1223v3: Version 7.0-20221219 (99e0822)
                  Copyright the AVRDUDE authors;
                  see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

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

                  Using Port                    : usb
                  Using Programmer              : pickit4_isp
avrdude_pr1223v3: found CMSIS-DAP compliant device, using EDBG protocol
                  AVR Part                      : ATmega8A
                  Chip Erase delay              : 10000 us
                  PAGEL                         : PD7
                  BS2                           : PC2
                  RESET disposition             : possible i/o
                  RETRY pulse                   : SCK
                  Serial program mode           : yes
                  Parallel program mode         : yes
                  Timeout                       : 200
                  StabDelay                     : 100
                  CmdexeDelay                   : 25
                  SyncLoops                     : 32
                  PollIndex                     : 3
                  PollValue                     : 0x53
                  Memory Detail                 :

                                                    Block Poll               Page                       Polled
                    Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                    ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                    eeprom                  4    20   128    0 no        512    4      0  9000  9000 0xff 0xff
                    flash                  33    10    64    0 yes      8192   64    128  4500  4500 0xff 0x00
                    lfuse                   0     0     0    0 no          1    1      0  2000  2000 0x00 0x00
                    hfuse                   0     0     0    0 no          1    1      0  2000  2000 0x00 0x00
                    lock                    0     0     0    0 no          1    1      0  2000  2000 0x00 0x00
                    signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
                    calibration             0     0     0    0 no          4    1      0     0     0 0x00 0x00

                  Programmer Type : JTAG3_ISP
                  Description     : MPLAB(R) PICkit 4 in ISP mode
                  ICE HW version  : 4
                  ICE FW version  : 1.14 (rel. 268)
                  Serial number   : BURxxxxxxxxx
                  Vtarget         : 4.93 V
                  JTAG clock megaAVR/program   : 1000 kHz
                  JTAG clock megaAVR/debug     : 100 kHz
                  PDI/UPDI clock Xmega/megaAVR : 100 kHz
                  SCK period                   : 8.00 us

avrdude_pr1223v3: AVR device initialized and ready to accept instructions
avrdude_pr1223v3: device signature = 0x1e9307 (probably m8a)

avrdude_pr1223v3 done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v3 -c snap_isp -p m8a -v

avrdude_pr1223v3: Version 7.0-20221219 (99e0822)
                  Copyright the AVRDUDE authors;
                  see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

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

                  Using Port                    : usb
                  Using Programmer              : snap_isp
avrdude_pr1223v3: found CMSIS-DAP compliant device, using EDBG protocol
                  AVR Part                      : ATmega8A
                  Chip Erase delay              : 10000 us
                  PAGEL                         : PD7
                  BS2                           : PC2
                  RESET disposition             : possible i/o
                  RETRY pulse                   : SCK
                  Serial program mode           : yes
                  Parallel program mode         : yes
                  Timeout                       : 200
                  StabDelay                     : 100
                  CmdexeDelay                   : 25
                  SyncLoops                     : 32
                  PollIndex                     : 3
                  PollValue                     : 0x53
                  Memory Detail                 :

                                                    Block Poll               Page                       Polled
                    Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                    ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                    eeprom                  4    20   128    0 no        512    4      0  9000  9000 0xff 0xff
                    flash                  33    10    64    0 yes      8192   64    128  4500  4500 0xff 0x00
                    lfuse                   0     0     0    0 no          1    1      0  2000  2000 0x00 0x00
                    hfuse                   0     0     0    0 no          1    1      0  2000  2000 0x00 0x00
                    lock                    0     0     0    0 no          1    1      0  2000  2000 0x00 0x00
                    signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
                    calibration             0     0     0    0 no          4    1      0     0     0 0x00 0x00

                  Programmer Type : JTAG3_ISP
                  Description     : MPLAB(R) SNAP in ISP mode
                  ICE HW version  : 1
                  ICE FW version  : 1.10 (rel. 249)
                  Serial number   : BURxxxxxxxx
                  Vtarget         : 4.92 V
                  JTAG clock megaAVR/program   : 1000 kHz
                  JTAG clock megaAVR/debug     : 100 kHz
                  PDI/UPDI clock Xmega/megaAVR : 100 kHz
                  SCK period                   : 8.00 us

avrdude_pr1223v3: AVR device initialized and ready to accept instructions
avrdude_pr1223v3: device signature = 0x1e9307 (probably m8a)

avrdude_pr1223v3 done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Dec 20, 2022

More test results: Xplained Pro UPDI mode (ATTiny817 Xplained Pro)

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1223v3 -c xplainedpro_updi -p t817 -v

avrdude_pr1223v3: Version 7.0-20221219 (99e0822)
                  Copyright the AVRDUDE authors;
                  see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

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

                  Using Port                    : usb
                  Using Programmer              : xplainedpro_updi
avrdude_pr1223v3: found CMSIS-DAP compliant device, using EDBG protocol
                  AVR Part                      : ATtiny817
                  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       append      0     0     0    0 no          1    1      0     0     0 0x00 0x00
                    fuse8       bootend     0     0     0    0 no          1    1      0     0     0 0x00 0x00
                    fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
                    lock                    0     0     0    0 no          1    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         61   61      0     0     0 0x00 0x00
                    sernum                  0     0     0    0 no         10    1      0     0     0 0x00 0x00
                    osccal16                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    osccal20                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    osc16err                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    osc20err                0     0     0    0 no          2    1      0     0     0 0x00 0x00
                    data                    0     0     0    0 no          0    1      0     0     0 0x00 0x00
                    userrow     usersig     0     0     0    0 no         32   32      0     0     0 0x00 0x00
                    eeprom                  0     0     0    0 no        128   32      0     0     0 0x00 0x00
                    flash                   0     0     0    0 no       8192   64      0     0     0 0x00 0x00

                  Programmer Type : JTAGICE3_UPDI
                  Description     : Atmel AVR XplainedPro in UPDI mode
                  ICE HW version  : 240
                  ICE FW version  : 3.34 (rel. 435)
                  Serial number   : ATMLxxxxxxxxxxxxxxxx
                  Vtarget         : 3.34 V
                  JTAG clock megaAVR/program   : 1000 kHz
                  JTAG clock megaAVR/debug     : 1000 kHz
                  JTAG clock Xmega             : 1000 kHz
                  PDI/UPDI clock Xmega/megaAVR : 1000 kHz
avrdude_pr1223v3: partial Family_ID returned: "tiny"
avrdude_pr1223v3: AVR device initialized and ready to accept instructions
avrdude_pr1223v3: device signature = 0x1e9320 (probably t817)

avrdude_pr1223v3 done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Dec 20, 2022

@MCUdude and @stefanrueger

Other than the minor issue of Vtarget formating in -c xplainedmini_tpi, this PR is good to go.

You can see I purchased quite some Microchip tools this year and they cost a bit of fortune. :-) I still have a few other Curiosity Nano board but they use the same pkobn_updi programmer so I do not need to test them.

The PICKit 4 and ATtiny817 Xplained Pro are on loan from Microchip Singapore. I will probably return them in Jan 2023.

Now the target voltage is printed out along with the HW version, FW version and serial number, and they all allign nicely. When in ISP mode, the "SCK period" value is printed _after_ the target voltage readout, and _before_ the additional clocks the programmer holds, such as JTAG, PDI and UPDI clocks.
Now everything (finally) lines up nicely, and only relevant clock info are printed for the connected target
@MCUdude
Copy link
Collaborator Author

MCUdude commented Dec 20, 2022

@mcuee and @stefanrueger I've reformatted the programmer info part, so now everything should line up nicely, even in terminal mode. This is what it looks like on a Power Debugger, a PICkit4 and an Xplained Nano TPI:

Power debugger (JTAG and ISP)
$ ./avrdude -cpowerdebugger_isp -patmega16 -v

avrdude: Version 7.0-20220508
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is /Users/hans/Downloads/avrdude/src/avrdude.conf
         User configuration file is /Users/hans/.avrduderc

         Using Port                    : usb
         Using Programmer              : powerdebugger_isp
avrdude: found CMSIS-DAP compliant device, using EDBG protocol
         AVR Part                      : ATmega16
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                  4    10   128    0 no        512    4      0  9000  9000 0xff 0xff
           flash                  33     6   128    0 yes     16384  128    128  4500  4500 0xff 0xff
           lfuse                   0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
           hfuse                   0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
           lock                    0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
           calibration             0     0     0    0 no          4    1      0     0     0 0x00 0x00

         Programmer Type : JTAG3_ISP
         Description     : Atmel PowerDebugger (ARM/AVR) in ISP mode
         ICE HW version  : 1
         ICE FW version  : 1.61 (rel. 184)
         Serial number   : J518000xxxxx
         SCK period      : 125.00 us
         Vtarget         : 5.08 V
         Vout set        : 0.00 V
         Vout measured   : 1.49 V
         Ch A voltage    : 1.480 V
         Ch A current    : -1.038 mA
         Ch B voltage    : 1.525 V
         Ch B current    : 0.000 mA


avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9403 (probably m16)

avrdude done.  Thank you.



$ ./avrdude -cpowerdebugger -patmega16 -v

avrdude: Version 7.0-20220508
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is /Users/hans/Downloads/avrdude/src/avrdude.conf
         User configuration file is /Users/hans/.avrduderc

         Using Port                    : usb
         Using Programmer              : powerdebugger
avrdude: found CMSIS-DAP compliant device, using EDBG protocol
         AVR Part                      : ATmega16
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                  4    10   128    0 no        512    4      0  9000  9000 0xff 0xff
           flash                  33     6   128    0 yes     16384  128    128  4500  4500 0xff 0xff
           lfuse                   0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
           hfuse                   0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
           lock                    0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
           calibration             0     0     0    0 no          4    1      0     0     0 0x00 0x00

         Programmer Type : JTAGICE3
         Description     : Atmel PowerDebugger (ARM/AVR) in JTAG mode
         ICE HW version  : 1
         ICE FW version  : 1.61 (rel. 184)
         Serial number   : J518000xxxxx
         Vtarget         : 5.08 V
         Vout set        : 0.00 V
         Vout measured   : 1.49 V
         Ch A voltage    : 1.475 V
         Ch A current    : -1.045 mA
         Ch B voltage    : 1.520 V
         Ch B current    : 0.000 mA
         JTAG clk prog.  : 250 kHz
         JTAG clk debug  : 1000 kHz

avrdude: JTAG ID returned: 0x3f 0x30 0x40 0x09
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9403 (probably m16)

avrdude done.  Thank you.


$ ./avrdude -cpowerdebugger -patmega16 -t

         Vtarget         : 5.08 V
         Vout set        : 0.00 V
         Vout measured   : 1.49 V
         Ch A voltage    : 1.475 V
         Ch A current    : -1.045 mA
         Ch B voltage    : 1.520 V
         Ch B current    : 0.000 mA
         JTAG clk prog.  : 250 kHz
         JTAG clk debug  : 1000 kHz

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9403 (probably m16)
avrdude> parms
Vtarget         : 5.11 V
Vout set        : 0.00 V
Vout measured   : 1.48 V
Ch A voltage    : 1.475 V
Ch A current    : -1.049 mA
Ch B voltage    : 1.525 V
Ch B current    : 0.000 mA
JTAG clk prog.  : 250 kHz
JTAG clk debug  : 1000 kHz


avrdude> quit
avrdude> 
avrdude done.  Thank you.
PICkit4 (ISP, PDI and UPDI)
$ ./avrdude -cpickit4_isp -patmega16 -v

avrdude: Version 7.0-20220508
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is /Users/hans/Downloads/avrdude/src/avrdude.conf
         User configuration file is /Users/hans/.avrduderc

         Using Port                    : usb
         Using Programmer              : pickit4_isp
avrdude: found CMSIS-DAP compliant device, using EDBG protocol
         AVR Part                      : ATmega16
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                  4    10   128    0 no        512    4      0  9000  9000 0xff 0xff
           flash                  33     6   128    0 yes     16384  128    128  4500  4500 0xff 0xff
           lfuse                   0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
           hfuse                   0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
           lock                    0     0     0    0 no          1    1      0  9000  9000 0x00 0x00
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
           calibration             0     0     0    0 no          4    1      0     0     0 0x00 0x00

         Programmer Type : JTAG3_ISP
         Description     : MPLAB(R) PICkit 4 in ISP mode
         ICE HW version  : 4
         ICE FW version  : 1.14 (rel. 268)
         Serial number   : BUR2040xxxxx
         SCK period      : 8.00 us
         Vtarget         : 5.07 V


avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9403 (probably m16)

avrdude done.  Thank you.


$ ./avrdude -cpickit4_pdi -patxmega128a3u -v

avrdude: Version 7.0-20220508
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is /Users/hans/Downloads/avrdude/src/avrdude.conf
         User configuration file is /Users/hans/.avrduderc

         Using Port                    : usb
         Using Programmer              : pickit4_pdi
avrdude: found CMSIS-DAP compliant device, using EDBG protocol
         AVR Part                      : ATxmega128A3U
         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
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           fuse1                   0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse2                   0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse4                   0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse5                   0     0     0    0 no          1    1      0     0     0 0x00 0x00
           lock                    0     0     0    0 no          1    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         50   50      0     0     0 0x00 0x00
           data                    0     0     0    0 no          0    1      0     0     0 0x00 0x00
           eeprom                  0     0     0    0 no       2048   32      0     0     0 0x00 0x00
           flash                   0     0     0    0 no     139264  512      0     0     0 0x00 0x00
           application             0     0     0    0 no     131072  512      0     0     0 0x00 0x00
           apptable                0     0     0    0 no       8192  512      0     0     0 0x00 0x00
           boot                    0     0     0    0 no       8192  512      0     0     0 0x00 0x00
           usersig                 0     0     0    0 no        512  512      0     0     0 0x00 0x00
           fuse0                   0     0     0    0 no          1    1      0     0     0 0x00 0x00

         Programmer Type : JTAGICE3_PDI
         Description     : MPLAB(R) PICkit 4 in PDI mode
         ICE HW version  : 4
         ICE FW version  : 1.14 (rel. 268)
         Serial number   : BUR2040xxxxx
         Vtarget         : 3.31 V
         PDI/UPDI clk    : 100 kHz

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9742 (probably x128a3u)

avrdude done.  Thank you.


$ ./avrdude -cpickit4_updi -patmega4808 -v

avrdude: Version 7.0-20220508
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is /Users/hans/Downloads/avrdude/src/avrdude.conf
         User configuration file is /Users/hans/.avrduderc

         Using Port                    : usb
         Using Programmer              : pickit4_updi
avrdude: found CMSIS-DAP compliant device, using EDBG protocol
         AVR Part                      : ATmega4808
         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       append      0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuse8       bootend     0     0     0    0 no          1    1      0     0     0 0x00 0x00
           fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
           lock                    0     0     0    0 no          1    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         61   61      0     0     0 0x00 0x00
           sernum                  0     0     0    0 no         10    1      0     0     0 0x00 0x00
           osccal16                0     0     0    0 no          2    1      0     0     0 0x00 0x00
           osccal20                0     0     0    0 no          2    1      0     0     0 0x00 0x00
           osc16err                0     0     0    0 no          2    1      0     0     0 0x00 0x00
           osc20err                0     0     0    0 no          2    1      0     0     0 0x00 0x00
           data                    0     0     0    0 no          0    1      0     0     0 0x00 0x00
           userrow     usersig     0     0     0    0 no         64   64      0     0     0 0x00 0x00
           eeprom                  0     0     0    0 no        256   64      0     0     0 0x00 0x00
           flash                   0     0     0    0 no      49152  128      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   : BUR2040xxxxx
         Vtarget         : 5.05 V
         PDI/UPDI clk    : 100 kHz

avrdude: partial Family_ID returned: "mega"
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9650 (probably m4808)

avrdude done.  Thank you.
Xplained Nano ATtiny104 (TPI)
$ ./avrdude -cxplainedmini_tpi -pattiny104 -v

avrdude: Version 7.0-20220508
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is /Users/hans/Downloads/avrdude/src/avrdude.conf
         User configuration file is /Users/hans/.avrduderc

         Using Port                    : usb
         Using Programmer              : xplainedmini_tpi
avrdude: found CMSIS-DAP compliant device, using EDBG protocol
         AVR Part                      : ATtiny104
         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
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           fuse                    0     0     4    0 no          1   16      0     0     0 0x00 0x00
           lockbits                0     0     0    0 no          1   16      0     0     0 0x00 0x00
           signature               0     0     0    0 no          3   16      0     0     0 0x00 0x00
           calibration             0     0     0    0 no          1   16      0     0     0 0x00 0x00
           flash                   0     0   128    0 no       1024   16      0     0     0 0x00 0x00
           sigrow                  0     0     0    0 no         16   16      0     0     0 0x00 0x00

         Programmer Type : JTAGICE3_TPI
         Description     : Atmel AVR XplainedMini in TPI mode
         ICE HW version  : 0
         ICE FW version  : 1.07 (rel. 10)
         Serial number   : ATML26780202000xxxxx
         Vtarget         : 5.00 V

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e900b (probably t104)

avrdude done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Dec 21, 2022

Yes this PR is good to go now.

@stefanrueger stefanrueger merged commit c991ae9 into avrdudes:main Dec 21, 2022
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.

JTAG3 programmer info not available in ISP mode PICkit4 and SNAP serial numbers not read by Avrdude
3 participants