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

Support jtag2updi -U EEPROM write #1318

Merged
merged 2 commits into from
Mar 21, 2023
Merged

Conversation

stefanrueger
Copy link
Collaborator

Supposed to fix #1128

@llinjupt @mcuee Could you give this a try?

@mcuee mcuee added the bug Something isn't working label Mar 15, 2023
@mcuee
Copy link
Collaborator

mcuee commented Mar 15, 2023

Yes I will try this over the weekend.

@mcuee
Copy link
Collaborator

mcuee commented Mar 15, 2023

@MCUdude
You may want to give it a try as well.

@mcuee
Copy link
Collaborator

mcuee commented Mar 18, 2023

The following simple test shows this PR is good.

MINGW64 /c/work/avr/avrdude_test/avrdude_sr/build_mingw64_nt-10.0-22621/src
$ git branch --show-current
updi-eeprom

$ echo "Hello World" | ./avrdude -cjtag2updi -PCOM12 -pavr128db48 -Ueeprom:w:-:r

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e970c (probably avr128db48)
avrdude: reading input file <stdin> for eeprom
         with 12 bytes in 1 section within [0, 11]
avrdude: writing 12 bytes eeprom ...

Writing | ################################################## | 100% 0.14 s

avrdude: 12 bytes of eeprom written
avrdude: verifying eeprom memory against <stdin>

Reading | ################################################## | 100% 0.34 s

avrdude: 12 bytes of eeprom verified

avrdude done.  Thank you.

$ echo "dump eeprom 0 0x40" | ./avrdude -cjtag2updi -PCOM12 -pavr128db48 -qqt
avrdude> dump eeprom 0 0x40
0000  48 65 6c 6c 6f 20 57 6f  72 6c 64 0a 6d 70 6c 65  |Hello World mple|
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|

avrdude>

Another test

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1318 -c jtag2updi -P COM12 -p avr128db48
 -U eeprom:w:.\hex\entest.eep:i

avrdude_pr1318: AVR device initialized and ready to accept instructions
avrdude_pr1318: device signature = 0x1e970c (probably avr128db48)
avrdude_pr1318: reading input file .\hex\entest.eep for eeprom
                with 512 bytes in 1 section within [0, 0x1ff]
avrdude_pr1318: writing 512 bytes eeprom ...

Writing | ################################################## | 100% 6.36 s

avrdude_pr1318: 512 bytes of eeprom written
avrdude_pr1318: verifying eeprom memory against .\hex\entest.eep

Reading | ################################################## | 100% 4.19 s

avrdude_pr1318: 512 bytes of eeprom verified

avrdude_pr1318 done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> echo "dump eeprom 0 0x100" | .\avrdude_pr1318
 -c jtag2updi -P COM12 -p avr128db48 -t

avrdude_pr1318: AVR device initialized and ready to accept instructions
avrdude_pr1318: device signature = 0x1e970c (probably avr128db48)
avrdude> dump eeprom 0 0x100

Reading | ################################################## | 100% 2.00 s

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|

avrdude>

avrdude_pr1318 done.  Thank you.

@stefanrueger
Copy link
Collaborator Author

following simple test shows this PR is good

Thanks @mcuee! Amazing that such a simple change has now made jtag2updi work for EEPROM write. Thanks @llinjupt for finding that. Could you and/or @MCUdude do independent checks? I'll earmark this for the next mergefest.

@llinjupt
Copy link
Contributor

llinjupt commented Mar 18, 2023

Thanks @mcuee! Amazing that such a simple change has now made jtag2updi work for EEPROM write. Thanks @llinjupt for
finding that. Could you and/or @MCUdude do independent checks? I'll earmark this for the next mergefest.

@stefanrueger , the patch's good to me. BTW, you also can set page_size = 2/4/8/16 for Dx series to speed up EEPROM writing.

@stefanrueger
Copy link
Collaborator Author

set page_size = 2/4/8/16 for Dx series

avrdude.conf tends to describe a part as in the data sheet

to speed up EEPROM writing

Is that a thing? How big is EEPROM and how big is the time saving? If there is a case for speeding up EEPROM write, perhaps best to change the code base and issue a PR?

@llinjupt
Copy link
Contributor

Is that a thing? How big is EEPROM and how big is the time saving? If there is a case for speeding up EEPROM write, perhaps best to change the code base and issue a PR?

It's not in the spec/datasheet, but it does work, I mention it for others to save time.

@stefanrueger
Copy link
Collaborator Author

| to save time

Do you have numbers? Would be interesting to see if the effect is substantial and/or worthwhile

@llinjupt
Copy link
Contributor

Do you have numbers? Would be interesting to see if the effect is substantial and/or worthwhile

@stefanrueger

Default:

$ ./avrdude.exe -c jtag2updi -P COM177 -p avr128da48 -U eeprom:w:eeprom.bin:r

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9708 (probably avr128da48)
avrdude: reading input file eeprom.bin for eeprom
         with 512 bytes in 1 section within [0, 0x1ff]
avrdude: writing 512 bytes eeprom ...

Writing | ################################################## | 100% 8.17s

avrdude: 512 bytes of eeprom written
avrdude: verifying eeprom memory against eeprom.bin

Reading | ################################################## | 100% 1.66s

avrdude: 512 bytes of eeprom verified

avrdude done.  Thank you.

With page_size=16:

Red@DESKTOP-GI4UT7C MINGW64 /f/avrdude.git.main/build_mingw64_nt-10.0-17134/src
$ ./avrdude.exe -c jtag2updi -P COM177 -p avr128da48 -U eeprom:w:eeprom.bin:r

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9708 (probably avr128da48)
avrdude: reading input file eeprom.bin for eeprom
         with 512 bytes in 1 section within [0, 0x1ff]
         using 32 pages and 0 pad bytes
avrdude: writing 512 bytes eeprom ...

Writing | ################################################## | 100% 5.42s

avrdude: 512 bytes of eeprom written
avrdude: verifying eeprom memory against eeprom.bin

Reading | ################################################## | 100% 0.48s

avrdude: 512 bytes of eeprom verified

avrdude done.  Thank you.

@stefanrueger
Copy link
Collaborator Author

@llinjupt OK, if you want to pursue this here is what needed doing. Test all updi programmers whether they cope with paged EEPROM read/write for DX-parts:

$ avrdude -c*/At | grep prog_modes.PM_UPDI
.prog	serialupdi	prog_modes	PM_UPDI
.prog	jtag3updi	prog_modes	PM_UPDI
.prog	xplainedpro_updi	prog_modes	PM_UPDI
.prog	xplainedmini_updi	prog_modes	PM_UPDI
.prog	atmelice_updi	prog_modes	PM_UPDI
.prog	powerdebugger_updi	prog_modes	PM_UPDI
.prog	pickit4_updi	prog_modes	PM_UPDI
.prog	snap_updi	prog_modes	PM_UPDI
.prog	pkobn_updi	prog_modes	PM_UPDI
.prog	jtag2updi	prog_modes	PM_UPDI

If so, then identify all the places in the code base where the decision for calling paged vs byte access is made and modify the page_size > 1 test to part_is_dx() || page_size > 1 or something to that effect.

I have no doubt that setting page_size for DX-part EEPROM memories works in your case but we need to guard against unwanted side effects for other programmers.

@mcuee
Copy link
Collaborator

mcuee commented Mar 20, 2023

@stefanrueger
I think this PR is good to go.

Further improvements for EEPROM can be dealt with another PR.

@stefanrueger stefanrueger merged commit cb2c2e2 into avrdudes:main Mar 21, 2023
@stefanrueger stefanrueger deleted the updi-eeprom branch April 9, 2023 17:11
@MCUdude MCUdude changed the title Support UPDI EEPROM write Support jtag2updi UPDI EEPROM write Jun 14, 2023
@MCUdude MCUdude changed the title Support jtag2updi UPDI EEPROM write Support jtag2updi -U EEPROM write Jun 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

jtag2updi EEPROM write issue for AVR Dx parts in CLI mode
3 participants