avrdudes / avrdude

AVRDUDE is a utility to program AVR microcontrollers
GNU General Public License v2.0
705 stars 136 forks source link

JTAG3 based programmers can only write 0's to EEPROM #1009

Closed MCUdude closed 2 years ago

MCUdude commented 2 years ago

I'm not sure if this is a bug in the Xplainedmini_updi firmware, or has something to do with Avrdude. EDIT: It appears that all JTAG3 based UPDI programmers are affected.

Unlike other UPDI programmers, I can only write 0's to EEPROM, and not 1's.

Here's some terminal output to illustrate what I mean:

$ ./avrdude -cxplainedmini_updi -t -patmega4808 -v

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

         System wide configuration file is "/Users/hans/Downloads/avrdude-joerg/src/avrdude.conf"
         User configuration file is "/Users/hans/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : xplainedmini_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
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           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
           tempsense               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
           fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
           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
           lock                    0     0     0    0 no          1    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
           flash                   0     0     0    0 no      49152  128      0     0     0 0x00 0x00
           eeprom                  0     0     0    0 no        256   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.19 (rel. 57)
         Serial number   : MICROUPDIPROGRAMMERX
         Vtarget         : 5.00 V
avrdude: Partial Family_ID returned: "mega"
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.03s

avrdude: Device signature = 0x1e9650 (probably m4808)

avrdude> read eeprom 0 0x40
>>> read eeprom 0 0x40 

Reading | ################################################## | 100% 0.02s

0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> write eeprom 0 0x10 0xff ...
>>> write eeprom 0 0x10 0xff ... 

Info: Writing 16 bytes starting from address 0x00. Remaining space filled with 0xff

Writing |                                                    | 0% 0.00savrdude (write): error writing 0xff at 0x00000 cell=0x00
avrdude (write): error writing 0xff at 0x00001 cell=0x00
Writing | ###                                                | 6% 0.16savrdude (write): error writing 0xff at 0x00002 cell=0x00
Writing | ######                                             | 12% 0.24savrdude (write): error writing 0xff at 0x00003 cell=0x00
Writing | #########                                          | 18% 0.32savrdude (write): error writing 0xff at 0x00004 cell=0x00
Writing | #############                                      | 25% 0.40savrdude (write): error writing 0xff at 0x00005 cell=0x00
Writing | ################                                   | 31% 0.48savrdude (write): error writing 0xff at 0x00006 cell=0x00
Writing | ###################                                | 37% 0.56savrdude (write): error writing 0xff at 0x00007 cell=0x00
Writing | ######################                             | 43% 0.64savrdude (write): error writing 0xff at 0x00008 cell=0x00
Writing | #########################                          | 50% 0.72savrdude (write): error writing 0xff at 0x00009 cell=0x00
Writing | ############################                       | 56% 0.80savrdude (write): error writing 0xff at 0x0000a cell=0x00
Writing | ###############################                    | 62% 0.88savrdude (write): error writing 0xff at 0x0000b cell=0x00
Writing | ##################################                 | 68% 0.96savrdude (write): error writing 0xff at 0x0000c cell=0x00
Writing | ######################################             | 75% 1.04savrdude (write): error writing 0xff at 0x0000d cell=0x00
Writing | #########################################          | 81% 1.12savrdude (write): error writing 0xff at 0x0000e cell=0x00
Writing | ############################################       | 87% 1.20savrdude (write): error writing 0xff at 0x0000f cell=0x00
Writing | ################################################## | 100% 1.28s

avrdude> write eeprom 0x10 0x10 0xAA ...
>>> write eeprom 0x10 0x10 0xAA ... 

Info: Writing 16 bytes starting from address 0x10. Remaining space filled with 0xAA

Writing | ################################################## | 100% 1.28s

avrdude> read eeprom 0 0x40
>>> read eeprom 0 0x40 

Reading | ################################################## | 100% 0.00s

0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0010  aa aa aa aa aa aa aa aa  aa aa aa aa aa aa aa aa  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> write eeprom 0x20 0x10 0x55 ...
>>> write eeprom 0x20 0x10 0x55 ... 

Info: Writing 16 bytes starting from address 0x20. Remaining space filled with 0x55

Writing | ################################################## | 100% 1.28s

avrdude> read eeprom 0 0x40
>>> read eeprom 0 0x40 

Reading | ################################################## | 100% 0.00s

0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0010  aa aa aa aa aa aa aa aa  aa aa aa aa aa aa aa aa  |................|
0020  55 55 55 55 55 55 55 55  55 55 55 55 55 55 55 55  |UUUUUUUUUUUUUUUU|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> write eeprom 0x20 0x10 0xAA ...
>>> write eeprom 0x20 0x10 0xAA ... 

Info: Writing 16 bytes starting from address 0x20. Remaining space filled with 0xAA

Writing |                                                    | 0% 0.00savrdude (write): error writing 0xaa at 0x00020 cell=0x00
avrdude (write): error writing 0xaa at 0x00021 cell=0x00
Writing | ###                                                | 6% 0.16savrdude (write): error writing 0xaa at 0x00022 cell=0x00
Writing | ######                                             | 12% 0.24savrdude (write): error writing 0xaa at 0x00023 cell=0x00
Writing | #########                                          | 18% 0.32savrdude (write): error writing 0xaa at 0x00024 cell=0x00
Writing | #############                                      | 25% 0.40savrdude (write): error writing 0xaa at 0x00025 cell=0x00
Writing | ################                                   | 31% 0.48savrdude (write): error writing 0xaa at 0x00026 cell=0x00
Writing | ###################                                | 37% 0.56savrdude (write): error writing 0xaa at 0x00027 cell=0x00
Writing | ######################                             | 43% 0.64savrdude (write): error writing 0xaa at 0x00028 cell=0x00
Writing | #########################                          | 50% 0.72savrdude (write): error writing 0xaa at 0x00029 cell=0x00
Writing | ############################                       | 56% 0.80savrdude (write): error writing 0xaa at 0x0002a cell=0x00
Writing | ###############################                    | 62% 0.88savrdude (write): error writing 0xaa at 0x0002b cell=0x00
Writing | ##################################                 | 68% 0.96savrdude (write): error writing 0xaa at 0x0002c cell=0x00
Writing | ######################################             | 75% 1.04savrdude (write): error writing 0xaa at 0x0002d cell=0x00
Writing | #########################################          | 81% 1.12savrdude (write): error writing 0xaa at 0x0002e cell=0x00
Writing | ############################################       | 87% 1.20savrdude (write): error writing 0xaa at 0x0002f cell=0x00
Writing | ################################################## | 100% 1.28s

avrdude> read eeprom 0 0x40
>>> read eeprom 0 0x40 

Reading | ################################################## | 100% 0.00s

0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0010  aa aa aa aa aa aa aa aa  aa aa aa aa aa aa aa aa  |................|
0020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
MCUdude commented 2 years ago

When using a serialupdi programmer, everything works perfectly.

mcuee commented 2 years ago

Interesting.

Just FYI, no issue with xplainedmini programmer with ATmega328PB.

PS C:\work\avr\avrdude_test\avrdude-v7.0-windows-x64> .\avrdude.exe -qqp m328pb 
-c xplainedmini -U eeprom:w:.\hex\en.eep:i && echo OK
OK

PS C:\work\avr\avrdude_test\avrdude-v7.0-windows-x64> echo "read eeprom 0 512" | .\avrdude.exe 
-c xplainedmini -p m328pb -t

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude.exe: Device signature = 0x1e9516 (probably m328pb)
avrdude> >>> read eeprom 0 512

Reading | ################################################## | 100% 4.09s

0000  54 68 65 20 71 75 69 63  6b 20 62 72 6f 77 6e 20  |The quick brown |
0010  66 6f 78 20 6a 75 6d 70  73 20 6f 76 65 72 20 74  |fox jumps over t|
0020  68 65 20 6c 61 7a 79 20  64 6f 67 0a 54 68 65 20  |he lazy dog The |
0030  71 75 69 63 6b 20 62 72  6f 77 6e 20 66 6f 78 20  |quick brown fox |
0040  6a 75 6d 70 73 20 6f 76  65 72 20 74 68 65 20 6c  |jumps over the l|
0050  61 7a 79 20 64 6f 67 0a  54 68 65 20 71 75 69 63  |azy dog The quic|
0060  6b 20 62 72 6f 77 6e 20  66 6f 78 20 6a 75 6d 70  |k brown fox jump|
0070  73 20 6f 76 65 72 20 74  68 65 20 6c 61 7a 79 20  |s over the lazy |
0080  64 6f 67 0a 54 68 65 20  71 75 69 63 6b 20 62 72  |dog The quick br|
0090  6f 77 6e 20 66 6f 78 20  6a 75 6d 70 73 20 6f 76  |own fox jumps ov|
00a0  65 72 20 74 68 65 20 6c  61 7a 79 20 64 6f 67 0a  |er the lazy dog |
00b0  54 68 65 20 71 75 69 63  6b 20 62 72 6f 77 6e 20  |The quick brown |
00c0  66 6f 78 20 6a 75 6d 70  73 20 6f 76 65 72 20 74  |fox jumps over t|
00d0  68 65 20 6c 61 7a 79 20  64 6f 67 0a 54 68 65 20  |he lazy dog The |
00e0  71 75 69 63 6b 20 62 72  6f 77 6e 20 66 6f 78 20  |quick brown fox |
00f0  6a 75 6d 70 73 20 6f 76  65 72 20 74 68 65 20 6c  |jumps over the l|
0100  61 7a 79 20 64 6f 67 0a  54 68 65 20 71 75 69 63  |azy dog The quic|
0110  6b 20 62 72 6f 77 6e 20  66 6f 78 20 6a 75 6d 70  |k brown fox jump|
0120  73 20 6f 76 65 72 20 74  68 65 20 6c 61 7a 79 20  |s over the lazy |
0130  64 6f 67 0a 54 68 65 20  71 75 69 63 6b 20 62 72  |dog The quick br|
0140  6f 77 6e 20 66 6f 78 20  6a 75 6d 70 73 20 6f 76  |own fox jumps ov|
0150  65 72 20 74 68 65 20 6c  61 7a 79 20 64 6f 67 0a  |er the lazy dog |
0160  54 68 65 20 71 75 69 63  6b 20 62 72 6f 77 6e 20  |The quick brown |
0170  66 6f 78 20 6a 75 6d 70  73 20 6f 76 65 72 20 74  |fox jumps over t|
0180  68 65 20 6c 61 7a 79 20  64 6f 67 0a 54 68 65 20  |he lazy dog The |
0190  71 75 69 63 6b 20 62 72  6f 77 6e 20 66 6f 78 20  |quick brown fox |
01a0  6a 75 6d 70 73 20 6f 76  65 72 20 74 68 65 20 6c  |jumps over the l|
01b0  61 7a 79 20 64 6f 67 0a  54 68 65 20 71 75 69 63  |azy dog The quic|
01c0  6b 20 62 72 6f 77 6e 20  66 6f 78 20 6a 75 6d 70  |k brown fox jump|
01d0  73 20 6f 76 65 72 20 74  68 65 20 6c 61 7a 79 20  |s over the lazy |
01e0  64 6f 67 0a 54 68 65 20  71 75 69 63 6b 20 62 72  |dog The quick br|
01f0  6f 77 6e 20 66 6f 78 20  6a 75 6d 70 73 20 6f 76  |own fox jumps ov|

avrdude>
avrdude.exe done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude-v7.0-windows-x64> .\avrdude.exe -qqp m328pb -c xplainedmini
 -U eeprom:w:.\hex\de.eep:i && echo OK
OK

PS C:\work\avr\avrdude_test\avrdude-v7.0-windows-x64> echo "read eeprom 0 512" | .\avrdude.exe 
-c xplainedmini -p m328pb -t

avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude.exe: Device signature = 0x1e9516 (probably m328pb)
avrdude> >>> read eeprom 0 512

Reading | ################################################## | 100% 4.09s

0000  5a 20 6a 61 67 74 20 69  6d 20 6b 6f 6d 70 6c 65  |Z jagt im komple|
0010  74 74 20 76 65 72 77 61  68 72 6c 6f 73 74 65 6e  |tt verwahrlosten|
0020  20 54 61 78 69 20 71 75  65 72 20 64 75 72 63 68  | Taxi quer durch|
0030  20 42 61 79 65 72 6e 0a  5a 20 6a 61 67 74 20 69  | Bayern Z jagt i|
0040  6d 20 6b 6f 6d 70 6c 65  74 74 20 76 65 72 77 61  |m komplett verwa|
0050  68 72 6c 6f 73 74 65 6e  20 54 61 78 69 20 71 75  |hrlosten Taxi qu|
0060  65 72 20 64 75 72 63 68  20 42 61 79 65 72 6e 0a  |er durch Bayern |
0070  5a 20 6a 61 67 74 20 69  6d 20 6b 6f 6d 70 6c 65  |Z jagt im komple|
0080  74 74 20 76 65 72 77 61  68 72 6c 6f 73 74 65 6e  |tt verwahrlosten|
0090  20 54 61 78 69 20 71 75  65 72 20 64 75 72 63 68  | Taxi quer durch|
00a0  20 42 61 79 65 72 6e 0a  5a 20 6a 61 67 74 20 69  | Bayern Z jagt i|
00b0  6d 20 6b 6f 6d 70 6c 65  74 74 20 76 65 72 77 61  |m komplett verwa|
00c0  68 72 6c 6f 73 74 65 6e  20 54 61 78 69 20 71 75  |hrlosten Taxi qu|
00d0  65 72 20 64 75 72 63 68  20 42 61 79 65 72 6e 0a  |er durch Bayern |
00e0  5a 20 6a 61 67 74 20 69  6d 20 6b 6f 6d 70 6c 65  |Z jagt im komple|
00f0  74 74 20 76 65 72 77 61  68 72 6c 6f 73 74 65 6e  |tt verwahrlosten|
0100  20 54 61 78 69 20 71 75  65 72 20 64 75 72 63 68  | Taxi quer durch|
0110  20 42 61 79 65 72 6e 0a  5a 20 6a 61 67 74 20 69  | Bayern Z jagt i|
0120  6d 20 6b 6f 6d 70 6c 65  74 74 20 76 65 72 77 61  |m komplett verwa|
0130  68 72 6c 6f 73 74 65 6e  20 54 61 78 69 20 71 75  |hrlosten Taxi qu|
0140  65 72 20 64 75 72 63 68  20 42 61 79 65 72 6e 0a  |er durch Bayern |
0150  5a 20 6a 61 67 74 20 69  6d 20 6b 6f 6d 70 6c 65  |Z jagt im komple|
0160  74 74 20 76 65 72 77 61  68 72 6c 6f 73 74 65 6e  |tt verwahrlosten|
0170  20 54 61 78 69 20 71 75  65 72 20 64 75 72 63 68  | Taxi quer durch|
0180  20 42 61 79 65 72 6e 0a  5a 20 6a 61 67 74 20 69  | Bayern Z jagt i|
0190  6d 20 6b 6f 6d 70 6c 65  74 74 20 76 65 72 77 61  |m komplett verwa|
01a0  68 72 6c 6f 73 74 65 6e  20 54 61 78 69 20 71 75  |hrlosten Taxi qu|
01b0  65 72 20 64 75 72 63 68  20 42 61 79 65 72 6e 0a  |er durch Bayern |
01c0  5a 20 6a 61 67 74 20 69  6d 20 6b 6f 6d 70 6c 65  |Z jagt im komple|
01d0  74 74 20 76 65 72 77 61  68 72 6c 6f 73 74 65 6e  |tt verwahrlosten|
01e0  20 54 61 78 69 20 71 75  65 72 20 64 75 72 63 68  | Taxi quer durch|
01f0  20 42 61 79 65 72 6e 0a  5a 20 6a 61 67 74 20 69  | Bayern Z jagt i|

avrdude>
avrdude.exe done.  Thank you.
mcuee commented 2 years ago

pkobn_updi seems to have the same problem, tested with AVR128DB48 Curiosity Nano board.

First character of EEPROM 54 -->0101 0100 (initial eeprom write from empty state -- 1111 1111, so no issues) 5a -->0101 1010 (expected second eeprom write rwsult) 50 -->0101 0000 (what was really written because only 0 can not be changed to 1.

PS C:\work\avr\avrdude_test\avrdude-v7.0-windows-x64> .\avrdude.exe -c pkobn_updi -qqp avr128db48 -e 
&& echo OK
             Vtarget                      : 3.31 V
             PDI/UPDI clock Xmega/megaAVR : 100 kHz

OK

PS C:\work\avr\avrdude_test\avrdude-v7.0-windows-x64> .\avrdude.exe -c pkobn_updi -qqp avr128db48 
-U eeprom:w:.\hex\en.eep:i && echo OK
             Vtarget                      : 3.31 V
             PDI/UPDI clock Xmega/megaAVR : 100 kHz

OK

PS C:\work\avr\avrdude_test\avrdude-v7.0-windows-x64> .\avrdude.exe -c pkobn_updi -qqp avr128db48
 -U eeprom:w:.\hex\de.eep:i && echo OK
             Vtarget                      : 3.31 V
             PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude.exe: verification error, first mismatch at byte 0x0000
             0x50 != 0x5a
avrdude.exe: verification error; content mismatch

PS C:\work\avr\avrdude_test\avrdude-v7.0-windows-x64> echo "read eeprom 0 512" | .\avrdude.exe -c pkobn_updi 
-p avr128db48 -t

             Vtarget                      : 3.31 V
             PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude.exe: AVR device initialized and ready to accept instructions

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

avrdude.exe: Device signature = 0x1e970c (probably avr128db48)
avrdude> >>> read eeprom 0 512

Reading | ################################################## | 100% 2.14s

0000  50 20 60 20 61 74 20 61  69 20 62 62 6d 70 6c 20  |P ` at ai bbmpl |
0010  64 64 20 20 60 70 65 60  60 20 6c 66 61 70 20 64  |dd  `pe`` lfap d|
0020  20 44 20 68 61 20 71 20  64 62 20 00 54 60 61 20  | D ha q db .T`a |
0030  20 40 61 61 61 20 62 02  4a 20 6a 20 66 64 20 20  | @aaa b.J j fd  |
0040  68 20 69 60 61 20 6c 64  64 70 20 74 60 60 20 60  |h i`a lddp t`` `|
0050  60 72 68 20 60 64 65 0a  00 40 61 20 61 20 61 61  |`rh `de .@a a aa|
0060  61 20 20 60 65 72 62 20  20 42 60 20 60 70 6c 00  |a  `erb  B` `pl.|
0070  52 20 6a 60 65 70 20 60  68 20 20 6c 61 70 68 20  |R j`ep `h  laph |
0080  64 64 20 02 44 60 65 20  60 70 68 63 63 20 60 62  |dd .D`e `phcc `b|
0090  20 54 60 20 60 20 70 20  60 70 20 60 71 20 63 60  | T` ` p `p `q c`|
00a0  20 42 20 70 60 60 20 08  40 20 68 20 64 64 20 08  | B p`` .@ h dd .|
00b0  44 20 61 20 61 70 68 61  60 20 20 72 65 72 66 20  |D a apha`  rerf |
00c0  60 62 68 20 62 74 65 60  20 00 61 70 61 20 20 74  |`bh bte` .apa  t|
00d0  60 60 20 64 61 72 61 20  20 42 61 08 44 60 64 00  |`` dara  Ba.D`d.|
00e0  50 20 68 61 63 20 20 60  6d 20 6a 20 64 60 68 20  |P hac  `m j d`h |
00f0  60 74 20 70 61 20 67 60  60 72 20 64 60 64 20 6c  |`t pa g``r d`d l|
0100  20 50 61 20 60 20 61 00  44 60 20 20 71 70 61 60  | Pa ` a.D`  qpa`|
0110  20 00 60 70 65 72 6e 00  42 20 68 20 62 74 20 60  | .`pern.B h bt `|
0120  61 20 6b 66 65 70 20 64  60 64 20 64 61 72 71 20  |a kfep d`d darq |
0130  60 62 64 0a 50 60 65 20  20 54 61 60 69 20 60 70  |`bd P`e  Ta`i `p|
0140  65 72 20 20 64 62 60 20  20 40 61 70 61 20 6e 02  |er  db`  @apa n.|
0150  40 20 20 60 60 64 20 68  61 20 69 20 64 60 64 00  |@  ``d ha i d`d.|
0160  54 60 20 20 61 70 61 61  68 20 60 62 63 74 64 20  |T`  apaah `bctd |
0170  20 44 60 20 68 20 61 70  61 20 20 64 65 72 20 60  | D` h apa  der `|
0180  20 40 20 68 61 72 68 00  40 20 62 00 44 60 20 20  | @ harh.@ b.D`  |
0190  61 20 69 63 69 20 60 60  64 74 20 20 64 62 70 20  |a ici ``dt  dbp |
01a0  68 70 6c 60 73 20 65 66  20 50 20 70 68 20 20 64  |hpl`s ef P ph  d|
01b0  61 72 20 20 64 62 63 08  00 40 61 20 61 70 68 02  |ar  dbc..@a aph.|
01c0  4a 20 62 60 67 74 20 20  64 20 68 20 68 70 6c 60  |J b`gt  d h hpl`|
01d0  70 20 20 76 65 72 20 60  68 60 20 6c 61 70 61 20  |p  ver `h` lapa |
01e0  20 44 61 08 40 20 61 20  61 70 20 60 61 20 62 60  | Da.@ a ap `a b`|
01f0  20 42 60 20 64 62 68 00  4a 20 68 60 63 20 20 60  | B` dbh.J h`c  `|

avrdude>
avrdude.exe done.  Thank you.
dl8dtl commented 2 years ago

pkobn_updi seems to have the same problem

Which is not quite surprising, as it's the same code.

JTAG also used to have issues with EEPROM auto-erase, so it's nothing really new.

MCUdude commented 2 years ago

For reference, this appears to be an issue with the Pickit4 and MPLAB SNAP as well. I'll assume the Atmel ICE has the same issue.

Pickit4:

$ ./avrdude -cpickit4_updi -t -patmega4808 -v

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

         System wide configuration file is "/Users/hans/Downloads/avrdude-joerg/src/avrdude.conf"
         User configuration file is "/Users/hans/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         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
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           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
           tempsense               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
           fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
           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
           lock                    0     0     0    0 no          1    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
           flash                   0     0     0    0 no      49152  128      0     0     0 0x00 0x00
           eeprom                  0     0     0    0 no        256   64      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         : 5.06 V
         JTAG clock megaAVR/program   : 1000 kHz
         JTAG clock megaAVR/debug     : 100 kHz
         PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude: Partial Family_ID returned: "mega"
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.05s

avrdude: Device signature = 0x1e9650 (probably m4808)
avrdude> read eeprom 0 0x20
>>> read eeprom 0 0x20 

Reading | ################################################## | 100% 0.02s

0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> write eeprom 0 0x10 0x55 ...
>>> write eeprom 0 0x10 0x55 ... 

Info: Writing 16 bytes starting from address 0x00. Remaining space filled with 0x55

Writing | ################################################## | 100% 1.22s

avrdude> write eeprom 0 0x10 0xAA ...
>>> write eeprom 0 0x10 0xAA ... 

Info: Writing 16 bytes starting from address 0x00. Remaining space filled with 0xAA

Writing |                                                    | 0% 0.00savrdude (write): error writing 0xaa at 0x00000 cell=0x00
avrdude (write): error writing 0xaa at 0x00001 cell=0x00
Writing | ###                                                | 6% 0.15savrdude (write): error writing 0xaa at 0x00002 cell=0x00
Writing | ######                                             | 12% 0.23savrdude (write): error writing 0xaa at 0x00003 cell=0x00
Writing | #########                                          | 18% 0.30savrdude (write): error writing 0xaa at 0x00004 cell=0x00
Writing | #############                                      | 25% 0.38savrdude (write): error writing 0xaa at 0x00005 cell=0x00
Writing | ################                                   | 31% 0.46savrdude (write): error writing 0xaa at 0x00006 cell=0x00
Writing | ###################                                | 37% 0.53savrdude (write): error writing 0xaa at 0x00007 cell=0x00
Writing | ######################                             | 43% 0.61savrdude (write): error writing 0xaa at 0x00008 cell=0x00
Writing | #########################                          | 50% 0.68savrdude (write): error writing 0xaa at 0x00009 cell=0x00
Writing | ############################                       | 56% 0.76savrdude (write): error writing 0xaa at 0x0000a cell=0x00
Writing | ###############################                    | 62% 0.84savrdude (write): error writing 0xaa at 0x0000b cell=0x00
Writing | ##################################                 | 68% 0.91savrdude (write): error writing 0xaa at 0x0000c cell=0x00
Writing | ######################################             | 75% 0.99savrdude (write): error writing 0xaa at 0x0000d cell=0x00
Writing | #########################################          | 81% 1.06savrdude (write): error writing 0xaa at 0x0000e cell=0x00
Writing | ############################################       | 87% 1.14savrdude (write): error writing 0xaa at 0x0000f cell=0x00
Writing | ################################################## | 100% 1.22s

avrdude> read eeprom 0 0x20
>>> read eeprom 0 0x20 

Reading | ################################################## | 100% 0.00s

0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> q
>>> q 

avrdude done.  Thank you.

MPLAB SNAP:

$ ./avrdude -csnap_updi -t -patmega4808 -v

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

         System wide configuration file is "/Users/hans/Downloads/avrdude-joerg/src/avrdude.conf"
         User configuration file is "/Users/hans/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : usb
         Using Programmer              : snap_updi
avrdude: usbhid_open(): No device found
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
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           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
           tempsense               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
           fuses                   0     0     0    0 no          9   10      0     0     0 0x00 0x00
           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
           lock                    0     0     0    0 no          1    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
           flash                   0     0     0    0 no      49152  128      0     0     0 0x00 0x00
           eeprom                  0     0     0    0 no        256   64      0     0     0 0x00 0x00

         Programmer Type : JTAGICE3_UPDI
         Description     : MPLAB(R) SNAP in UPDI mode
         ICE HW version  : 1
         ICE FW version  : 1.09 (rel. 223)
         Serial number   : 
         Vtarget         : 5.06 V
         JTAG clock megaAVR/program   : 1000 kHz
         JTAG clock megaAVR/debug     : 100 kHz
         PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude: Partial Family_ID returned: "mega"
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.04s

avrdude: Device signature = 0x1e9650 (probably m4808)

avrdude> read eeprom 0x20 0x20
>>> read eeprom 0x20 0x20 

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

0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> write eeprom 0x20 0x10 0x55 ...
>>> write eeprom 0x20 0x10 0x55 ... 

Info: Writing 16 bytes starting from address 0x20. Remaining space filled with 0x55

Writing | ################################################## | 100% 0.99s

avrdude> read eeprom 0x20 0x20
>>> read eeprom 0x20 0x20 

Reading | ################################################## | 100% 0.00s

0020  55 55 55 55 55 55 55 55  55 55 55 55 55 55 55 55  |UUUUUUUUUUUUUUUU|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> write eeprom 0x20 0x10 0xAA ...
>>> write eeprom 0x20 0x10 0xAA ... 

Info: Writing 16 bytes starting from address 0x20. Remaining space filled with 0xAA

Writing |                                                    | 0% 0.00savrdude (write): error writing 0xaa at 0x00020 cell=0x00
avrdude (write): error writing 0xaa at 0x00021 cell=0x00
Writing | ###                                                | 6% 0.12savrdude (write): error writing 0xaa at 0x00022 cell=0x00
Writing | ######                                             | 12% 0.19savrdude (write): error writing 0xaa at 0x00023 cell=0x00
Writing | #########                                          | 18% 0.25savrdude (write): error writing 0xaa at 0x00024 cell=0x00
Writing | #############                                      | 25% 0.31savrdude (write): error writing 0xaa at 0x00025 cell=0x00
Writing | ################                                   | 31% 0.37savrdude (write): error writing 0xaa at 0x00026 cell=0x00
Writing | ###################                                | 37% 0.43savrdude (write): error writing 0xaa at 0x00027 cell=0x00
Writing | ######################                             | 43% 0.50savrdude (write): error writing 0xaa at 0x00028 cell=0x00
Writing | #########################                          | 50% 0.56savrdude (write): error writing 0xaa at 0x00029 cell=0x00
Writing | ############################                       | 56% 0.62savrdude (write): error writing 0xaa at 0x0002a cell=0x00
Writing | ###############################                    | 62% 0.68savrdude (write): error writing 0xaa at 0x0002b cell=0x00
Writing | ##################################                 | 68% 0.74savrdude (write): error writing 0xaa at 0x0002c cell=0x00
Writing | ######################################             | 75% 0.80savrdude (write): error writing 0xaa at 0x0002d cell=0x00
Writing | #########################################          | 81% 0.87savrdude (write): error writing 0xaa at 0x0002e cell=0x00
Writing | ############################################       | 87% 0.93savrdude (write): error writing 0xaa at 0x0002f cell=0x00
Writing | ################################################## | 100% 0.99s

avrdude> read eeprom 0x20 0x20
>>> read eeprom 0x20 0x20 

Reading | ################################################## | 100% 0.00s

0020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> q
>>> q 

avrdude done.  Thank you.
MCUdude commented 2 years ago

Writing hex files that wants to flip 0's to 1's doesn't work either:

$ echo "read eeprom 0 0x100" | ./avrdude -cpickit4_updi -patmega4808 -t -qq
         Vtarget                      : 5.07 V
         JTAG clock megaAVR/program   : 1000 kHz
         JTAG clock megaAVR/debug     : 100 kHz
         PDI/UPDI clock Xmega/megaAVR : 100 kHz

>>> read eeprom 0 0x100 
0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0090  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

$ cat ff_dump.hex 
:20000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
:20002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0
:20004000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC0
:20006000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFA0
:20008000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF80
:2000A000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF60
:2000C000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF40
:2000E000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF20
:00000001FF

$ ./avrdude -cpickit4_updi -patmega4808 -Ueeprom:w:ff_dump.hex:i

         Vtarget                      : 5.07 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.05s

avrdude: Device signature = 0x1e9650 (probably m4808)
avrdude: reading input file "ff_dump.hex"
avrdude: writing eeprom (256 bytes):

Writing | ################################################## | 100% 0.17s

avrdude: 256 bytes of eeprom written
avrdude: verifying eeprom memory against ff_dump.hex:

Reading | ################################################## | 100% 0.07s

avrdude: verification error, first mismatch at byte 0x0000
         0x00 != 0xff
avrdude: verification error; content mismatch

avrdude done.  Thank you.

$ echo "read eeprom 0 0x100" | ./avrdude -cpickit4_updi -patmega4808 -t -qq
         Vtarget                      : 5.07 V
         JTAG clock megaAVR/program   : 1000 kHz
         JTAG clock megaAVR/debug     : 100 kHz
         PDI/UPDI clock Xmega/megaAVR : 100 kHz

>>> read eeprom 0 0x100 
0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0090  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
dl8dtl commented 2 years ago

Writing hex files that wants to flip 0's to 1's doesn't work either:

Sure, NOR flash: you can only write 0 bits, and have to erase to get a bit to 1.

As I wrote, I knew this behaviour from JTAG programmers for many years. For whatever reason, the programming interface doesn't perform (byte or page) auto erases there. The most interesting part is that UPDI itself obviously can do it while the Atmel/Microchip tools don't.

MCUdude commented 2 years ago

As I wrote, I knew this behavior from JTAG programmers for many years. For whatever reason, the programming interface doesn't perform (byte or page) auto erases there. The most interesting part is that UPDI itself obviously can do it while the Atmel/Microchip tools don't.

So does this means that it's not Avrdude, but the programmers themselves that don't handle EEPROM correctly? I was hoping that this was simply a bug in the Avrdude JTAG3 implementation. So when using Atmel Studio, how can one clear the EEPROM without de-selecting the "EEPROM preserve" fuse bit and performing a chip erase afterward?

dl8dtl commented 2 years ago

So does this means that it's not Avrdude, but the programmers themselves that don't handle EEPROM correctly?

That's at least my first guess, yes.

MCUdude commented 2 years ago

So does this means that it's not Avrdude, but the programmers themselves that don't handle EEPROM correctly?

That's at least my first guess, yes.

I can confirm that Atmel/Microchip studio can write 1's to the EEPROM without performing a chip erase (test with a Pickit4 programmer). I guess this is Avrdude related then.

$ ./avrdude -cpickit4_updi -patmega4808 -t

         Vtarget                      : 5.05 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.05s

avrdude: Device signature = 0x1e9650 (probably m4808)
avrdude> write eeprom 0 0x100 0x00 ...
>>> write eeprom 0 0x100 0x00 ... 

Writing | ################################################## | 100% 19.46s

avrdude> read eeprom 0 0x100
>>> read eeprom 0 0x100 

Reading | ################################################## | 100% 0.07s

0000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0090  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

avrdude> 
^C

# Used Microchip studio to write all 0xff's to all 250 bytes of EEPROM:

$ ./avrdude -cpickit4_updi -patmega4808 -t

         Vtarget                      : 5.05 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.05s

avrdude: Device signature = 0x1e9650 (probably m4808)
avrdude> read eeprom
>>> read eeprom 

Reading | ################################################## | 100% 0.07s

0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude>

^C
dl8dtl commented 2 years ago

I can confirm that Atmel/Microchip studio can write 1's to the EEPROM without performing a chip erase

In that case, an USB trace would be interesting …

MCUdude commented 2 years ago

In that case, an USB trace would be interesting …

I have no experience with USB tracing really. Could be interesting to try someday, but I just found out that pymcuprog supports writing 1's to EEPROM. I've only tested their "terminal mode".

# pymcuprog command (write 0x01 followed by 0x02 starting from EEPROM address 0x00)

$ pymcuprog write -m eeprom -d atmega4808 -o 0x00 -l 0x01 0x02
Connecting to anything possible
Connected to MPLAB PICkit 4 CMSIS-DAP from Microchip Technology Incorporated (serial number BUR204071896)
Debugger firmware version 1.13.236
Debugger hardware revision 4
Pinging device...
Ping response: 1E9650
Writing literal values...
Done.

Avrdude output:

$ echo "read eeprom 0 0x100" | ./avrdude -cpickit4_updi -patmega4808 -t

         Vtarget                      : 5.05 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.05s

avrdude: Device signature = 0x1e9650 (probably m4808)
>>> read eeprom 0 0x100 

Reading | ################################################## | 100% 0.07s

0000  01 02 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0010  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
0090  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

avrdude done.  Thank you.

This means that the source code we need is in there somewhere!

dl8dtl commented 2 years ago

but I just found out that pymcuprog supports writing 1's to EEPROM.

cool!

MCUdude commented 2 years ago

IMO it's a pain to browse the pymcuprog source code since everything is scattered around in different files and the backbone, pyedbglib, is a separate library, so I gave USB tracing a go just for kicks.

I don't know how to read such a trace, but to my surprise, the data 0x40 0x41 0x42 0x43 was sent as single bytes (@ABC) with pymcuprog, but avrdude sent them as a string (see avrdude packet 174). Not sure if this is relevant or not.

Xplainedmini_USB_trace.zip

MCUdude commented 2 years ago

Oh, I forgot to add the commands!

pymcuprog: pymcuprog write -m eeprom -datmega4808 -o 0x00 -l 0x40 0x41 0x42 0x43

avrdude: echo "write eeprom 0 0x40 0x41 0x42 0x43" | ./avrdude -cxplainedmini_updi -patmega4808 -t

MCUdude commented 2 years ago

Huh, the in pymcuprog's nvm.py, the write_eeprom function is defined like so. It looks like it explicitly performs an erase before (or after?) writing.

    def write_eeprom(self, address, data):
        """
        Write data to EEPROM (v0)
        :param address: address to write to
        :param data: data to write
        """
        return self.write_nvm(address, data, use_word_access=False,
                              nvmcommand=constants.UPDI_V0_NVMCTRL_CTRLA_ERASE_WRITE_PAGE)
MCUdude commented 2 years ago

I couldn't stop thinking about this issue, and how it might be an easy fix. After diving into the EDBG documentation and the pymcuprog source code, I've found a solution that seems to work well for jtag3-based UPDI programmers.

I have not tested this on Xmega's, but it might be that the Xmegas have similar issues and need the fix I've provided. Please give it a try if you have compatible hardware!

https://github.com/MCUdude/avrdude/tree/jtag3-eeprom-fix

mcuee commented 2 years ago

I couldn't stop thinking about this issue, and how it might be an easy fix. After diving into the EDBG documentation and the pymcuprog source code, I've found a solution that seems to work well for jtag3-based UPDI programmers.

I have not tested this on Xmega's, but it might be that the Xmegas have similar issues and need the fix I've provided. Please give it a try if you have compatible hardware!

https://github.com/MCUdude/avrdude/tree/jtag3-eeprom-fix

Have you tested it on your ATmega4809? Someho the above branch does not work for me. It is able to erase the EEPROM but not write EEPROM.

PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> .\avrdude_issue1009.exe -c pkobn_updi -qqp avr128db48 -e
                       Vtarget                      : 3.31 V
                       PDI/UPDI clock Xmega/megaAVR : 100 kHz

PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> .\avrdude_issue1009.exe -c pkobn_updi -qqp avr128db48 
-U eeprom:w:.\hex\en.eep:i && echo OK
                       Vtarget                      : 3.31 V
                       PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude_issue1009.exe: verification error, first mismatch at byte 0x0000
                       0xff != 0x54
avrdude_issue1009.exe: verification error; content mismatch

PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> echo "read eeprom 0 512" | .\avrdude.exe -c pkobn_updi 
-p avr128db48 -t -qq
             Vtarget                      : 3.31 V
             PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude> >>> read eeprom 0 512
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0100  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0110  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0120  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0130  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0140  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0150  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0160  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0170  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0180  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0190  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff 76  |...............v|

PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> .\avrdude.exe -c pkobn_updi -qqp avr128db48 
-U eeprom:w:.\hex\en.eep:i && echo OK
             Vtarget                      : 3.31 V
             PDI/UPDI clock Xmega/megaAVR : 100 kHz

OK
PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> echo "read eeprom 0 512" | .\avrdude.exe -c pkobn_updi 
-p avr128db48 -t -qq
             Vtarget                      : 3.31 V
             PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude> >>> read eeprom 0 512
0000  54 68 65 20 71 75 69 63  6b 20 62 72 6f 77 6e 20  |The quick brown |
0010  66 6f 78 20 6a 75 6d 70  73 20 6f 76 65 72 20 74  |fox jumps over t|
0020  68 65 20 6c 61 7a 79 20  64 6f 67 0a 54 68 65 20  |he lazy dog The |
0030  71 75 69 63 6b 20 62 72  6f 77 6e 20 66 6f 78 20  |quick brown fox |
0040  6a 75 6d 70 73 20 6f 76  65 72 20 74 68 65 20 6c  |jumps over the l|
0050  61 7a 79 20 64 6f 67 0a  54 68 65 20 71 75 69 63  |azy dog The quic|
0060  6b 20 62 72 6f 77 6e 20  66 6f 78 20 6a 75 6d 70  |k brown fox jump|
0070  73 20 6f 76 65 72 20 74  68 65 20 6c 61 7a 79 20  |s over the lazy |
0080  64 6f 67 0a 54 68 65 20  71 75 69 63 6b 20 62 72  |dog The quick br|
0090  6f 77 6e 20 66 6f 78 20  6a 75 6d 70 73 20 6f 76  |own fox jumps ov|
00a0  65 72 20 74 68 65 20 6c  61 7a 79 20 64 6f 67 0a  |er the lazy dog |
00b0  54 68 65 20 71 75 69 63  6b 20 62 72 6f 77 6e 20  |The quick brown |
00c0  66 6f 78 20 6a 75 6d 70  73 20 6f 76 65 72 20 74  |fox jumps over t|
00d0  68 65 20 6c 61 7a 79 20  64 6f 67 0a 54 68 65 20  |he lazy dog The |
00e0  71 75 69 63 6b 20 62 72  6f 77 6e 20 66 6f 78 20  |quick brown fox |
00f0  6a 75 6d 70 73 20 6f 76  65 72 20 74 68 65 20 6c  |jumps over the l|
0100  61 7a 79 20 64 6f 67 0a  54 68 65 20 71 75 69 63  |azy dog The quic|
0110  6b 20 62 72 6f 77 6e 20  66 6f 78 20 6a 75 6d 70  |k brown fox jump|
0120  73 20 6f 76 65 72 20 74  68 65 20 6c 61 7a 79 20  |s over the lazy |
0130  64 6f 67 0a 54 68 65 20  71 75 69 63 6b 20 62 72  |dog The quick br|
0140  6f 77 6e 20 66 6f 78 20  6a 75 6d 70 73 20 6f 76  |own fox jumps ov|
0150  65 72 20 74 68 65 20 6c  61 7a 79 20 64 6f 67 0a  |er the lazy dog |
0160  54 68 65 20 71 75 69 63  6b 20 62 72 6f 77 6e 20  |The quick brown |
0170  66 6f 78 20 6a 75 6d 70  73 20 6f 76 65 72 20 74  |fox jumps over t|
0180  68 65 20 6c 61 7a 79 20  64 6f 67 0a 54 68 65 20  |he lazy dog The |
0190  71 75 69 63 6b 20 62 72  6f 77 6e 20 66 6f 78 20  |quick brown fox |
01a0  6a 75 6d 70 73 20 6f 76  65 72 20 74 68 65 20 6c  |jumps over the l|
01b0  61 7a 79 20 64 6f 67 0a  54 68 65 20 71 75 69 63  |azy dog The quic|
01c0  6b 20 62 72 6f 77 6e 20  66 6f 78 20 6a 75 6d 70  |k brown fox jump|
01d0  73 20 6f 76 65 72 20 74  68 65 20 6c 61 7a 79 20  |s over the lazy |
01e0  64 6f 67 0a 54 68 65 20  71 75 69 63 6b 20 62 72  |dog The quick br|
01f0  6f 77 6e 20 66 6f 78 20  6a 75 6d 70 73 20 6f 76  |own fox jumps ov|

avrdude>
PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> .\avrdude_issue1009.exe -c pkobn_updi -qqp avr128db48 
-U eeprom:w:.\hex\de.eep:i && echo OK
                       Vtarget                      : 3.31 V
                       PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude_issue1009.exe: verification error, first mismatch at byte 0x0000
                       0xff != 0x5a
avrdude_issue1009.exe: verification error; content mismatch
PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> echo "read eeprom 0 512" | .\avrdude.exe -c pkobn_updi 
-p avr128db48 -t -qq
             Vtarget                      : 3.31 V
             PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude> >>> read eeprom 0 512
0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0100  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0110  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0120  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0130  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0140  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0150  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0160  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0170  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0180  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0190  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
01f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff 69  |...............i|

avrdude>
MCUdude commented 2 years ago

It does work with the ATmega4809, but it has issues. I'm not able to write the entire memory to 0x00 anymore. I'll have to investigate more when I have more time. But I'm sure I'm onto something!

avrdude> write eeprom 0 "Hello World!"
>>> write eeprom 0 "Hello World!" 

Writing | ################################################## | 100% 1.24s

avrdude> read eeprom
>>> read eeprom 

Reading | ################################################## | 100% 0.07s

0000  48 65 6c 6c 6f 20 57 6f  72 6c 64 21 00 ff ff ff  |Hello World!....|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> write eeprom 0 0x100 0x00 ...
>>> write eeprom 0 0x100 0x00 ... 

Writing | ################################################## | 100% 24.58s

avrdude> read eeprom
>>> read eeprom 

Reading | ################################################## | 100% 0.09s

0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|

avrdude> write eeprom 0 0x100 0xff ...
>>> write eeprom 0 0x100 0xff ... 

Writing | ################################################## | 100% 24.58s

avrdude> read eeprom
>>> read eeprom 

Reading | ################################################## | 100% 0.09s

0000  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0010  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0020  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0040  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0050  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0060  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0070  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0080  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
0090  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
00f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|

avrdude> 
MCUdude commented 2 years ago

It appeared that the issue was a much simpler fix than I initially thought. I've rebased my fork, so please try again 🙂

https://github.com/MCUdude/avrdude/tree/jtag3-eeprom-fix

mcuee commented 2 years ago

@MCUdude

Yes I can confirm that your branch now fixed the issues for me. I think now you can create a pull request.

PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> .\avrdude_issue1009v1.exe -c pkobn_updi
 -qqp avr128db48 -U eeprom:w:.\hex
\en.eep:i && echo OK
                         Vtarget                      : 3.31 V
                         PDI/UPDI clock Xmega/megaAVR : 100 kHz

OK
PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> .\avrdude_issue1009v1.exe -c pkobn_updi 
-qqp avr128db48 -U eeprom:w:.\hex\de.eep:i && echo OK
                         Vtarget                      : 3.31 V
                         PDI/UPDI clock Xmega/megaAVR : 100 kHz

OK
PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> .\avrdude_issue1009v1.exe -c pkobn_updi 
-qqp avr128db48 -U eeprom:w:.\hex\en.eep:i && echo OK
                         Vtarget                      : 3.31 V
                         PDI/UPDI clock Xmega/megaAVR : 100 kHz

OK
PS C:\work\avr\avrdude_test\avrdude-7.0_bin64> echo "read eeprom 0 512" | .\avrdude_issue1009v1.exe
 -c pkobn_updi -p avr128db48 -t -qq
                         Vtarget                      : 3.31 V
                         PDI/UPDI clock Xmega/megaAVR : 100 kHz

avrdude> >>> read eeprom 0 512
0000  54 68 65 20 71 75 69 63  6b 20 62 72 6f 77 6e 20  |The quick brown |
0010  66 6f 78 20 6a 75 6d 70  73 20 6f 76 65 72 20 74  |fox jumps over t|
0020  68 65 20 6c 61 7a 79 20  64 6f 67 0a 54 68 65 20  |he lazy dog The |
0030  71 75 69 63 6b 20 62 72  6f 77 6e 20 66 6f 78 20  |quick brown fox |
0040  6a 75 6d 70 73 20 6f 76  65 72 20 74 68 65 20 6c  |jumps over the l|
0050  61 7a 79 20 64 6f 67 0a  54 68 65 20 71 75 69 63  |azy dog The quic|
0060  6b 20 62 72 6f 77 6e 20  66 6f 78 20 6a 75 6d 70  |k brown fox jump|
0070  73 20 6f 76 65 72 20 74  68 65 20 6c 61 7a 79 20  |s over the lazy |
0080  64 6f 67 0a 54 68 65 20  71 75 69 63 6b 20 62 72  |dog The quick br|
0090  6f 77 6e 20 66 6f 78 20  6a 75 6d 70 73 20 6f 76  |own fox jumps ov|
00a0  65 72 20 74 68 65 20 6c  61 7a 79 20 64 6f 67 0a  |er the lazy dog |
00b0  54 68 65 20 71 75 69 63  6b 20 62 72 6f 77 6e 20  |The quick brown |
00c0  66 6f 78 20 6a 75 6d 70  73 20 6f 76 65 72 20 74  |fox jumps over t|
00d0  68 65 20 6c 61 7a 79 20  64 6f 67 0a 54 68 65 20  |he lazy dog The |
00e0  71 75 69 63 6b 20 62 72  6f 77 6e 20 66 6f 78 20  |quick brown fox |
00f0  6a 75 6d 70 73 20 6f 76  65 72 20 74 68 65 20 6c  |jumps over the l|
0100  61 7a 79 20 64 6f 67 0a  54 68 65 20 71 75 69 63  |azy dog The quic|
0110  6b 20 62 72 6f 77 6e 20  66 6f 78 20 6a 75 6d 70  |k brown fox jump|
0120  73 20 6f 76 65 72 20 74  68 65 20 6c 61 7a 79 20  |s over the lazy |
0130  64 6f 67 0a 54 68 65 20  71 75 69 63 6b 20 62 72  |dog The quick br|
0140  6f 77 6e 20 66 6f 78 20  6a 75 6d 70 73 20 6f 76  |own fox jumps ov|
0150  65 72 20 74 68 65 20 6c  61 7a 79 20 64 6f 67 0a  |er the lazy dog |
0160  54 68 65 20 71 75 69 63  6b 20 62 72 6f 77 6e 20  |The quick brown |
0170  66 6f 78 20 6a 75 6d 70  73 20 6f 76 65 72 20 74  |fox jumps over t|
0180  68 65 20 6c 61 7a 79 20  64 6f 67 0a 54 68 65 20  |he lazy dog The |
0190  71 75 69 63 6b 20 62 72  6f 77 6e 20 66 6f 78 20  |quick brown fox |
01a0  6a 75 6d 70 73 20 6f 76  65 72 20 74 68 65 20 6c  |jumps over the l|
01b0  61 7a 79 20 64 6f 67 0a  54 68 65 20 71 75 69 63  |azy dog The quic|
01c0  6b 20 62 72 6f 77 6e 20  66 6f 78 20 6a 75 6d 70  |k brown fox jump|
01d0  73 20 6f 76 65 72 20 74  68 65 20 6c 61 7a 79 20  |s over the lazy |
01e0  64 6f 67 0a 54 68 65 20  71 75 69 63 6b 20 62 72  |dog The quick br|
01f0  6f 77 6e 20 66 6f 78 20  6a 75 6d 70 73 20 6f 76  |own fox jumps ov|

avrdude>
MCUdude commented 2 years ago

Thanks for testing, I'll create a PR right away!