Closed surfblink closed 11 months ago
Can you post the entire Avrdude output, so we can see what kind of programmer you're using and other Avrdude-related information?
HEX FILE one.eep.hex
:02000200AABB97
:00000001FF
OUTPUT FROM 7.2
/usr/local/bin/avrdude -c usbtiny -p m328p -e -U eeprom:w:one.eep.hex:i
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: processing -U eeprom:w:one.eep.hex:i
avrdude: reading input file one.eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03s
avrdude: 2 bytes of eeprom written
avrdude: verifying eeprom memory against one.eep.hex
Reading | ################################################## | 100% 0.00s
avrdude warning: verification mismatch
device 0xff != input 0xaa at addr 0x0002 (error)
avrdude error: verification mismatch
avrdude done. Thank you.
make: *** [one] Error 1
OUTPUT FROM 7.1
/Users/tw/Downloads/avrdude-7.1/build_darwin/src/avrdude -c usbtiny -p m328p -e -U eeprom:w:one.eep.hex:i
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: reading input file one.eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.04s
avrdude: 2 bytes of eeprom written
avrdude: verifying eeprom memory against one.eep.hex
Reading | ################################################## | 100% 0.00s
avrdude: 2 bytes of eeprom verified
avrdude done. Thank you.
Hello,
this reminds me off a problem with older versions that results from EEPROM written in pages (4 Bytes). (Atmega328P) Writing a singe byte did not work. The neighbors of the page always been written.
I do not know if this relates. I have not investigated further
Martin
Am 09.10.2023 um 10:35 schrieb surfblink:
Overview
An eeprom file, which is correctly written to an atmega328p by avrdude 6.3 7.0 and 7.1, generates a verification error when written with avrdude 7.2. Looking at the eeprom in -t mode shows that the eeprom has not been correctly written.
Example error
The original eeprom file is relatively large but a similar error can be reproduced with this small hex file.
With 7.2 this hex file is incorrectly written, but with 7.1 no error
:02000200AABB97 :00000001FF
I tried a few more examples
Add a line and it is correctly written with 7.2 and 7.1
:02000000DDCC55 :02000200AABB97 :00000001FF
But this file is also correctly written with 7.2 and 7.1
:02000400AABB95 :00000001FF
And finally this is the line from the original file which caused the error with 7.2 but not 7.1 7.0 and 6.3
:10003400FFFFF00AC4019000F1095C00B008EB0A6C :00000001FF
Is is possible to confirm this behaviour (outside of my setup)?
Kind regards and thanks, Tristan
— Reply to this email directly, view it on GitHub https://github.com/avrdudes/avrdude/issues/1508, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADTXTRQWQFNA6FUWP4QLTITX6OZONAVCNFSM6AAAAAA5YNWKF6VHI2DSMVQWIX3LMV43ASLTON2WKOZRHEZTENJWGI3TENI. You are receiving this because you are subscribed to this thread.Message ID: @.***>
No issues with the hex file using usbasp programmer, using both avrdude 7.2 release and git main. Need to dig out my USBtinyISP to carry out the test.
PS C:\work\avr\avrdude_test\avrdude_bin> cat eep.hex
:02000200AABB97
:00000001FF
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude72.exe -C .\avrdude72.conf -c usbasp -p m328p -U eeprom:w:eep.hex:i
avrdude72: AVR device initialized and ready to accept instructions
avrdude72: device signature = 0x1e950f (probably m328p)
avrdude72: processing -U eeprom:w:eep.hex:i
avrdude72: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude72: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.05 s
avrdude72: 2 bytes of eeprom written
avrdude72: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.00 s
avrdude72: 2 bytes of eeprom verified
avrdude72 done. Thank you.
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_git -c usbasp -p m328p -U eeprom:w:eep.hex:i
avrdude_git: AVR device initialized and ready to accept instructions
avrdude_git: device signature = 0x1e950f (probably m328p)
avrdude_git: processing -U eeprom:w:eep.hex:i
avrdude_git: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude_git: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.05 s
avrdude_git: 2 bytes of eeprom written
avrdude_git: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.00 s
avrdude_git: 2 bytes of eeprom verified
avrdude_git done. Thank you.
No issues with my ATtiny2313 based USBtinyISP either, with either avrdude 7.2 release or avrdude git main.
Edit -- ignore this. I can reproduce the issue once I erase the EEPROM contents first.
PS C:\work\avr\avrdude_test\avrdude_bin> cat eep.hex
:02000200AABB97
:00000001FF
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_git -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude_git: AVR device initialized and ready to accept instructions
avrdude_git: device signature = 0x1e950f (probably m328p)
avrdude_git: processing -U eeprom:w:eep.hex:i
avrdude_git: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude_git: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.02 s
avrdude_git: 2 bytes of eeprom written
avrdude_git: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude_git: 2 bytes of eeprom verified
avrdude_git done. Thank you.
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude72 -C .\avrdude72.conf -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude72: AVR device initialized and ready to accept instructions
avrdude72: device signature = 0x1e950f (probably m328p)
avrdude72: processing -U eeprom:w:eep.hex:i
avrdude72: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude72: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.02 s
avrdude72: 2 bytes of eeprom written
avrdude72: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude72: 2 bytes of eeprom verified
avrdude72 done. Thank you.
@surfblink
Just wondering which version of USBtinyISP programmer you are using. Is it based on ATTiny2313 or using ATtiny44/84/etc? Thanks.
Edit -- ignore this. I can reproduce the issue.
Hmm, I can reprodcue the issue after erasing the EEPROM contents using usbasp and then test again.
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude72 -C .\avrdude72.conf -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude72: AVR device initialized and ready to accept instructions
avrdude72: device signature = 0x1e950f (probably m328p)
avrdude72: processing -U eeprom:w:eep.hex:i
avrdude72: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude72: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03 s
avrdude72: 2 bytes of eeprom written
avrdude72: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude72 warning: verification mismatch
device 0xff != input 0xaa at addr 0x0002 (error)
avrdude72 error: verification mismatch
avrdude72 done. Thank you.
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_git -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude_git: AVR device initialized and ready to accept instructions
avrdude_git: device signature = 0x1e950f (probably m328p)
avrdude_git: processing -U eeprom:w:eep.hex:i
avrdude_git: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude_git: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03 s
avrdude_git: 2 bytes of eeprom written
avrdude_git: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude_git warning: verification mismatch
device 0xff != input 0xaa at addr 0x0002 (error)
avrdude_git error: verification mismatch
avrdude_git done. Thank you.
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_git -c usbasp -p m328p -qqt
avrdude> dump eeprom 0 0x20
0000 ff ff ff bb 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> quit
It is easier to use terminal mode to demonstrate the problem.
Looks like we have a regression in avrdude 7.2 for USBtinyISP from avrdude 7.1.
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude71 -C .\avrdude71.conf -c usbtiny -p m328p -qqt
avrdude> dump eeprom 0 0x20
0000 ff ff aa bb 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 0xff 0xff 0xbb 0xaa
avrdude> flush
avrdude> dump eeprom 0 0x20
0000 ff ff bb aa 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> quit
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude72 -C .\avrdude72.conf -c usbtiny -p m328p -qqt
avrdude> dump eeprom 0 0x20
0000 ff ff bb aa 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 0xff 0xff 0xaa 0xbb
avrdude> flush
avrdude72 error: verification mismatch at eeprom page addr 0x0000
avrdude> dump eeprom 0 0x20
0000 ff ff aa bb 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> quit
avrdude72 error: verification mismatch at eeprom page addr 0x0000
avrdude72 error: verification mismatch at eeprom page addr 0x0000
PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude71 -C .\avrdude71.conf -c usbtiny -p m328p -qqt
avrdude> dump eeprom 0 0x20
0000 ff ff ff bb 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> quit
Good this is reproducible. This seems to be specific to -c usbtiny
. Other progammers such as usbasp
work? -c urclock
works OK for that flle. usbtiny.c
itself only exhibits minor changes between 7.1 and 7.2. So few changes that I predict using the 7.1 usbtiny.c
in git main will not remove the problem. So, wondering which commit introduces the observed failure?
Good this is reproducible. This seems to be specific to
-c usbtiny
. Other progammers such asusbasp
work?-c urclock
works OK for that flle.usbtiny.c
itself only exhibits minor changes between 7.1 and 7.2. So few changes that I predict using the 7.1usbtiny.c
in git main will not remove the problem. So, wondering which commit introduces the observed failure?
Looks like it is an isue unique to -c usbtiny
. Need to check which git commit causes the issue.
Note to myself: use -c urclock
to erase the eeprom before testing.
I have some old binary files kept in my computer. Now I zoomed the issue to be between PR#1273 (good, 14-Jan-2023) and PR #1286 (bad, 5-Mar-2023).
I will further zoom down the commit tomorrow using the method similar to git bisect
but my method is a bit coarse.
PS C:\work\avr\avrdude_test\avrdude_bin\old_bin> .\avrdude_pr1343v1.exe -C .\avrdude_pr1343v1.conf -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude_pr1343v1: AVR device initialized and ready to accept instructions
avrdude_pr1343v1: device signature = 0x1e950f (probably m328p)
avrdude_pr1343v1: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude_pr1343v1: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03 s
avrdude_pr1343v1: 2 bytes of eeprom written
avrdude_pr1343v1: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude_pr1343v1 warning: verification mismatch
device 0xff != input 0xaa at addr 0x0002 (error)
avrdude_pr1343v1 error: verification mismatch
avrdude_pr1343v1 done. Thank you.
PS C:\work\avr\avrdude_test\avrdude_bin\old_bin> .\avrdude_pr1273.exe -C .\avrdude_pr1273.conf -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude_pr1273: AVR device initialized and ready to accept instructions
avrdude_pr1273: device signature = 0x1e950f (probably m328p)
avrdude_pr1273: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude_pr1273: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.04 s
avrdude_pr1273: 2 bytes of eeprom written
avrdude_pr1273: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude_pr1273: 2 bytes of eeprom verified
avrdude_pr1273 done. Thank you.
PR $1320 is also bad.
PS C:\work\avr\avrdude_test\avrdude_bin\old_bin> .\avrdude_pr1320v2.exe -C .\avrdude_pr1320v2.conf -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude_pr1320v2: AVR device initialized and ready to accept instructions avrdude_pr1320v2: device signature = 0x1e950f (probably m328p) avrdude_pr1320v2: reading input file eep.hex for eeprom with 2 bytes in 1 section within [2, 3] using 1 page and 2 pad bytes avrdude_pr1320v2: writing 2 bytes eeprom ... Writing | ################################################## | 100% 0.03 s avrdude_pr1320v2: 2 bytes of eeprom written avrdude_pr1320v2: verifying eeprom memory against eep.hex Reading | ################################################## | 100% 0.01 s avrdude_pr1320v2 warning: verification mismatch device 0xff != input 0xaa at addr 0x0002 (error) avrdude_pr1320v2 error: verification mismatch
avrdude_pr1320v2 done. Thank you.
PR #1309 is also bad.
* #1309 commit [31bc1d3](https://github.com/avrdudes/avrdude/commit/31bc1d3da38315f97d036f4729e571c4d52cc02f) on Mar 22 2023
PS C:\work\avr\avrdude_test\avrdude_bin\old_bin> .\avrdude_pr1309.exe -C .\avrdude_pr1309.conf -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude_pr1309: AVR device initialized and ready to accept instructions avrdude_pr1309: device signature = 0x1e950f (probably m328p) avrdude_pr1309: reading input file eep.hex for eeprom with 2 bytes in 1 section within [2, 3] using 1 page and 2 pad bytes avrdude_pr1309: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03 s
avrdude_pr1309: 2 bytes of eeprom written avrdude_pr1309: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude_pr1309 warning: verification mismatch device 0xff != input 0xaa at addr 0x0002 (error) avrdude_pr1309 error: verification mismatch
avrdude_pr1309 done. Thank you.
PR #1286 is already bad.
* #1286 commit [1995ca6](https://github.com/avrdudes/avrdude/commit/1995ca68687eb004ec75f7fb3bb4a89f7496ecfd) on Mar 5
PS C:\work\avr\avrdude_test\avrdude_bin\old_bin> .\avrdude_pr1286.exe -C .\avrdude_pr1286.conf -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude_pr1286: AVR device initialized and ready to accept instructions avrdude_pr1286: device signature = 0x1e950f (probably m328p) avrdude_pr1286: reading input file eep.hex for eeprom with 2 bytes in 1 section within [2, 3] using 1 page and 2 pad bytes avrdude_pr1286: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03 s
avrdude_pr1286: 2 bytes of eeprom written avrdude_pr1286: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude_pr1286 warning: verification mismatch device 0xff != input 0xaa at addr 0x0002 (error) avrdude_pr1286 error: verification mismatch
avrdude_pr1286 done. Thank you.
Other info.
PS C:\work\avr\avrdude_test\avrdude_bin\old_bin> .\avrdude_pr1282.exe -C .\avrdude_pr1282.conf -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude_pr1282: AVR device initialized and ready to accept instructions
avrdude_pr1282: device signature = 0x1e950f (probably m328p)
avrdude_pr1282: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude_pr1282: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.04 s
avrdude_pr1282: 2 bytes of eeprom written
avrdude_pr1282: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude_pr1282: 2 bytes of eeprom verified
avrdude_pr1282 done. Thank you.
PS C:\work\avr\avrdude_test\avrdude_bin\old_bin> .\avrdude_pr1309.exe -C .\avrdude_pr1309.conf -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude_pr1309: AVR device initialized and ready to accept instructions
avrdude_pr1309: device signature = 0x1e950f (probably m328p)
avrdude_pr1309: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude_pr1309: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03 s
avrdude_pr1309: 2 bytes of eeprom written
avrdude_pr1309: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude_pr1309 warning: verification mismatch
device 0xff != input 0xaa at addr 0x0002 (error)
avrdude_pr1309 error: verification mismatch
avrdude_pr1309 done. Thank you.
PS C:\work\avr\avrdude_test\avrdude_bin\old_bin> .\avrdude_pr1318.exe -C .\avrdude_pr1318.conf -c usbtiny -p m328p -U eeprom:w:eep.hex:i
avrdude_pr1318: AVR device initialized and ready to accept instructions
avrdude_pr1318: device signature = 0x1e950f (probably m328p)
avrdude_pr1318: reading input file eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude_pr1318: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03 s
avrdude_pr1318: 2 bytes of eeprom written
avrdude_pr1318: verifying eeprom memory against eep.hex
Reading | ################################################## | 100% 0.01 s
avrdude_pr1318 warning: verification mismatch
device 0xff != input 0xaa at addr 0x0002 (error)
avrdude_pr1318 error: verification mismatch
avrdude_pr1318 done. Thank you.
I've traced the issue down to this commit: https://github.com/avrdudes/avrdude/commit/a3b7072b7de553a2029bd8a22135483dbec4d559
Does not work:
$ git log --oneline | head
a3b7072b (HEAD) Merge pull request #1272 from stefanrueger/mode_memdelay
9cf4f55b Merge pull request #1280 from mcuee/configure_ac_readline
b3a29917 Merge pull request #1279 from mcuee/configure_ac_update
6595f534 Update configure.ac to reflect HAVE_READLINE statue
a22d379c Update configure.ac for MinGW build
6b95f9d1 Update README.md to point to GitHub Releases
a8931a4e Post-release 7.1 changes
2e0be1e1 (tag: v7.1) This is AVRDUDE release 7.1
beeb14ee Correct memory mode, delay and readback parameters
dcb8165a Show memory mode as hex number in avrdude.conf
e226add0 Merge pull request #1268 from mariusgreuel/pr-update-actions
1b8a4d48 Update NEWS
$ ./avrdude -cusbtiny -patmega328p -e -Ueeprom:w:ee_test_1508.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: reading input file ee_test_1508.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03 s
avrdude: 2 bytes of eeprom written
avrdude: verifying eeprom memory against ee_test_1508.hex
Reading | ################################################## | 100% 0.00 s
avrdude warning: verification mismatch
device 0xff != input 0xaa at addr 0x0002 (error)
avrdude error: verification mismatch
avrdude done. Thank you.
Works:
$ git log --oneline | head
9cf4f55b Merge pull request #1280 from mcuee/configure_ac_readline
b3a29917 Merge pull request #1279 from mcuee/configure_ac_update
6595f534 Update configure.ac to reflect HAVE_READLINE statue
a22d379c Update configure.ac for MinGW build
6b95f9d1 Update README.md to point to GitHub Releases
a8931a4e Post-release 7.1 changes
2e0be1e1 This is AVRDUDE release 7.1
e226add0 Merge pull request #1268 from mariusgreuel/pr-update-actions
1b8a4d48 Update NEWS
5642cecb Merge pull request #1269 from mariusgreuel/pr-update-windows-hidapi
$ ./avrdude -cusbtiny -patmega328p -e -Ueeprom:w:ee_test_1508.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: reading input file ee_test_1508.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.04 s
avrdude: 2 bytes of eeprom written
avrdude: verifying eeprom memory against ee_test_1508.hex
Reading | ################################################## | 100% 0.00 s
avrdude: 2 bytes of eeprom verified
avrdude done. Thank you.
It seems like adding readback = 0xff 0xff;
to the ATmega328 eeprom section in avrdude.conf resolved the issue.
diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in
index 68bf49db..436b7965 100644
--- a/src/avrdude.conf.in
+++ b/src/avrdude.conf.in
@@ -8206,6 +8206,7 @@ part
min_write_delay = 3600;
max_write_delay = 3600;
mode = 0x41;
+ readback = 0xff 0xff;
delay = 20;
blocksize = 4;
readsize = 256;
EDIT:
And readback
are being used by usbtiny.c:
$ grep -n readback usbtiny.c
724: poll_value = (m->readback[1] << 8) | m->readback[0];
I just tried with an AVRISPmkII as well (stk500v2.c also utilizes readback
for paged writes), but this seems unaffected.
Well traced!
Atmel's ATmega328P.atdf file says about the part's eeprom readback
values
<property name="IspProgramEeprom_pollVal1" value="0x00"/>
<property name="IspProgramEeprom_pollVal2" value="0x00"/>
So, wondering whether the .atdf has it wrong or usbtiny.c
.
IIRC the memory mode
(0x41 for the ATmega328P) encodes its programming capabilities and properties. However, usbtiny.c
does not use mem->mode
at all. Unfortunately, I cannot remember where I saw mode
and readback
documented... This is the crucial bit!
I suspect values 0x00 0x00
for readback mean this is not needed. So would predict, if we kept
avrdude.confclose to the .atdf files then the following change in
usbtiny.c` would also do the trick:
diff --git a/src/usbtiny.c b/src/usbtiny.c
index 2efaaec8..0a2c0861 100644
--- a/src/usbtiny.c
+++ b/src/usbtiny.c
@@ -723,9 +723,9 @@ static int usbtiny_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
if (! m->paged) {
unsigned int poll_value;
// Does this chip not support paged writes?
- poll_value = (m->readback[1] << 8) | m->readback[0];
- if (usb_control(pgm, USBTINY_POLL_BYTES, poll_value, 0 ) < 0)
- return -1;
+ if((poll_value = (m->readback[1] << 8) | m->readback[0]))
+ if(usb_control(pgm, USBTINY_POLL_BYTES, poll_value, 0 ) < 0)
+ return -1;
delay = m->max_write_delay;
}
Sorry, but that doesn't work reliably:
$ git diff
diff --git a/src/usbtiny.c b/src/usbtiny.c
index 2efaaec8..930218e7 100644
--- a/src/usbtiny.c
+++ b/src/usbtiny.c
@@ -723,9 +723,9 @@ static int usbtiny_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
if (! m->paged) {
unsigned int poll_value;
// Does this chip not support paged writes?
- poll_value = (m->readback[1] << 8) | m->readback[0];
- if (usb_control(pgm, USBTINY_POLL_BYTES, poll_value, 0 ) < 0)
- return -1;
+ if((poll_value = (m->readback[1] << 8) | m->readback[0]))
+ if (usb_control(pgm, USBTINY_POLL_BYTES, poll_value, 0 ) < 0)
+ return -1;
delay = m->max_write_delay;
}
$ ./avrdude -cusbtiny -patmega328p -e -Ueeprom:w:eep_test_1508.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: processing -U eeprom:w:eep_test_1508.hex:i
avrdude: reading input file eep_test_1508.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03 s
avrdude: 2 bytes of eeprom written
avrdude: verifying eeprom memory against eep_test_1508.hex
Reading | ################################################## | 100% 0.00 s
avrdude warning: verification mismatch
device 0xff != input 0xaa at addr 0x0002 (error)
avrdude error: verification mismatch
avrdude done. Thank you.
However, I power cycled the USBtiny programmer, and I was able to properly program and verify on the second attempt. However, with readback = 0xff 0xff
or works every time.
$ ./avrdude -cusbtiny -patmega328p -Ueeprom:w:eep_test_1508.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: processing -U eeprom:w:eep_test_1508.hex:i
avrdude: reading input file eep_test_1508.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03 s
avrdude: 2 bytes of eeprom written
avrdude: verifying eeprom memory against eep_test_1508.hex
Reading | ################################################## | 100% 0.00 s
avrdude warning: verification mismatch
device 0xff != input 0xaa at addr 0x0002 (error)
avrdude error: verification mismatch
avrdude done. Thank you.
$ ./avrdude -cusbtiny -patmega328p -Ueeprom:w:eep_test_1508.hex
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: processing -U eeprom:w:eep_test_1508.hex:i
avrdude: reading input file eep_test_1508.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.02 s
avrdude: 2 bytes of eeprom written
avrdude: verifying eeprom memory against eep_test_1508.hex
Reading | ################################################## | 100% 0.00 s
avrdude: 2 bytes of eeprom verified
avrdude done. Thank you.
OK, we need to figure out what should happen. Best to find documentation about eeprom/flash readback
and mode
.
readback
is used by stk500.c
, stk500v2.c
and usbtiny.c
. If the .atdf readback
values are wrong, then it might show with stk500
and stk500v2
programmers trying to write the one.hex
file that exposes the problem. There are 155 parts in git main that have eeprom readback 0x00 0x00 and eeprom mode 0x41, which need potentially testing/considering:
avrdude -p*/At | grep eeprom.mode >/tmp/m
avrdude -p*/At | grep eeprom.readback >/tmp/r
paste /tmp/[mr] | cut -f2,5,10 >/tmp/j
cut -f2- /tmp/j | sort | uniq -c
147 0x00 0x00 0x00
8 0x04 0x00 0xff
4 0x04 0x80 0x7f
16 0x04 0xff 0xff
155 0x41 0x00 0x00
3 0x41 0xff 0xff
That is a lot of parts. The three parts with eeprom mode 0x41 and readback 0xff 0xff don't actually have an .atdf file:
grep 0x41.0xff.0xff /tmp/j
ATmega163 0x41 0xff 0xff
ATmega169 0x41 0xff 0xff
AT90PWM2 0x41 0xff 0xff
Given all this, and assuming STK500 and STK500v2 programmers work with the difficult file in git main, I'd suggest
diff --git a/src/usbtiny.c b/src/usbtiny.c
index 2efaaec8..1adb2577 100644
--- a/src/usbtiny.c
+++ b/src/usbtiny.c
@@ -721,9 +721,9 @@ static int usbtiny_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
delay = 0;
if (! m->paged) {
- unsigned int poll_value;
- // Does this chip not support paged writes?
- poll_value = (m->readback[1] << 8) | m->readback[0];
+ unsigned int poll_value = (m->readback[1] << 8) | m->readback[0];
+ if(!poll_value)
+ poll_value = 0xffff;
if (usb_control(pgm, USBTINY_POLL_BYTES, poll_value, 0 ) < 0)
return -1;
delay = m->max_write_delay;
That should do the trick.
@surfblink
PR #1511 works for me. Please check as well. Thanks.
Thank you for addressing this issue. I believe I have built PR #1511 I have included the default help output so I would grateful if you could check that I am running the required version.
Sadly, it does not work for my (a generic 2313A based) usbtiny. Both the example hex file and the actual hex (that highlighted the issue to me give) verification errors.
Usage: avrdude [options]
Options:
-p <partno> Specify AVR device; -p ? lists all known parts
-p <wildcard>/<flags> Run developer options for matched AVR devices,
e.g., -p ATmega328P/s or /S for part definition
-b <baudrate> Override RS-232 baud rate
-B <bitclock> Specify bit clock period (us)
-C <config-file> Specify location of configuration file
-c <programmer> Specify programmer; -c ? and -c ?type list all
-c <wildcard>/<flags> Run developer options for matched programmers,
e.g., -c 'ur*'/s for programmer info/definition
-A Disable trailing-0xff removal for file/AVR read
-D Disable auto erase for flash memory; implies -A
-i <delay> ISP Clock Delay [in microseconds]
-P <port> Connection; -P ?s or -P ?sa lists serial ones
-F Override invalid signature or initial checks
-e Perform a chip erase
-O Perform RC oscillator calibration (see AVR053)
-t Run an interactive terminal when it is its turn
-T <terminal cmd line> Run terminal line when it is its turn
-U <memtype>:r|w|v:<filename>[:format]
Carry out memory operation when it is its turn
Multiple -t, -T and -U options can be specified
-n Do not write to the device whilst processing -U
-V Do not automatically verify during -U
-E <exitsp>[,<exitsp>] List programmer exit specifications
-x <extended_param> Pass <extended_param> to programmer, see -xhelp
-v Verbose output; -v -v for more
-q Quell progress output; -q -q for less
-l logfile Use logfile rather than stderr for diagnostics
-? Display this usage
avrdude version 7.2-20231006 (c8b4e915), https://github.com/avrdudes/avrdude
:02000200AABB97
:00000001FF
debuging...
/Users/tw/avrdude/build_darwin/src/avrdude -c usbtiny -p m328p -e -U eeprom:w:one.eep.hex:i
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: processing -U eeprom:w:one.eep.hex:i
avrdude: reading input file one.eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.03s
avrdude: 2 bytes of eeprom written
avrdude: verifying eeprom memory against one.eep.hex
Reading | ################################################## | 100% 0.00s
avrdude warning: verification mismatch
device 0xff != input 0xaa at addr 0x0002 (error)
avrdude error: verification mismatch
avrdude done. Thank you.
make: *** [one] Error 1
:10003400FFFFF00AC4019000F1095C00B008EB0A6C
:0A00440006034800BB3F010048001E
:06005C000200840670069C
:10006600733B680000000000FF08AF08AF080000FF
:100076000A00A300B100780093007E0200006B0224
:0A008600A93CC83CB83CE33C19005B
:00000001FF
Uploading Hexfiles to Arduino uno
/Users/tw/avrdude/build_darwin/src/avrdude -c usbtiny -p m328p -e -U flash:w:uno.hex:i -U eeprom:w:u\
no.eep.hex:i
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: processing -U flash:w:uno.hex:i
avrdude: reading input file uno.hex for flash
with 9522 bytes in 26 sections within [0, 0x7f81]
using 76 pages and 206 pad bytes
avrdude: writing 9522 bytes flash ...
Writing | ################################################## | 100% 7.36s
avrdude: 9522 bytes of flash written
avrdude: verifying flash memory against uno.hex
Reading | ################################################## | 100% 5.42s
avrdude: 9522 bytes of flash verified
avrdude: processing -U eeprom:w:uno.eep.hex:i
avrdude: reading input file uno.eep.hex for eeprom
with 74 bytes in 3 sections within [0x34, 0x8f]
using 20 pages and 6 pad bytes
avrdude: writing 74 bytes eeprom ...
Writing | ################################################## | 100% 0.21s
avrdude: 74 bytes of eeprom written
avrdude: verifying eeprom memory against uno.eep.hex
Reading | ################################################## | 100% 0.03s
avrdude warning: verification mismatch
device 0xff != input 0xf0 at addr 0x0036 (error)
avrdude error: verification mismatch
avrdude done. Thank you.
make: *** [uno] Error 1
@surfblink You need to checkout the PR's branch usbtiny-readback before building and installing:
git clone git@github.com:stefanrueger/avrdude pr1511
cd pr1511
git checkout usbtiny-readback
# build and install for your OS
@surfblink
Hmm, you are using git main and not PR #1511.
git main --> avrdude version 7.2-20231006 (c8b4e915) PR #1511 --> avrdude version 7.2-20231010 (64f4646b)
Thank you for you help with building the correct version.
avrdude version 7.2-20231010 (64f4646b), https://github.com/avrdudes/avrdude
Success
Both the example file and the original hex file are written without verification errors. Thank you fixing this so efficiently. Much appreciated. Outputs below.
:02000200AABB97
:00000001FF
debuging...
/Users/tw/pr1511/build_darwin/src/avrdude -c usbtiny -p m328p -e -U eepro\
m:w:one.eep.hex:i
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: processing -U eeprom:w:one.eep.hex:i
avrdude: reading input file one.eep.hex for eeprom
with 2 bytes in 1 section within [2, 3]
using 1 page and 2 pad bytes
avrdude: writing 2 bytes eeprom ...
Writing | ################################################## | 100% 0.04s
avrdude: 2 bytes of eeprom written
avrdude: verifying eeprom memory against one.eep.hex
Reading | ################################################## | 100% 0.00s
avrdude: 2 bytes of eeprom verified
avrdude done. Thank you.
:10003400FFFFF00AC4019000F1095C00B008EB0A6C
:0A00440006034800BB3F010048001E
:06005C000200840670069C
:10006600733B680000000000FF08AF08AF080000FF
:100076000A00A300B100780093007E0200006B0224
:0A008600A93CC83CB83CE33C19005B
:00000001FF
Uploading Hexfiles to Arduino uno
/Users/tw/pr1511/build_darwin/src/avrdude -c usbtiny -p m328p -e -U flash:w:uno.hex:i -U eeprom:w:uno.eep.hex:i
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: processing -U flash:w:uno.hex:i
avrdude: reading input file uno.hex for flash
with 9522 bytes in 26 sections within [0, 0x7f81]
using 76 pages and 206 pad bytes
avrdude: writing 9522 bytes flash ...
Writing | ################################################## | 100% 7.36s
avrdude: 9522 bytes of flash written
avrdude: verifying flash memory against uno.hex
Reading | ################################################## | 100% 5.10s
avrdude: 9522 bytes of flash verified
avrdude: processing -U eeprom:w:uno.eep.hex:i
avrdude: reading input file uno.eep.hex for eeprom
with 74 bytes in 3 sections within [0x34, 0x8f]
using 20 pages and 6 pad bytes
avrdude: writing 74 bytes eeprom ...
Writing | ################################################## | 100% 0.21s
avrdude: 74 bytes of eeprom written
avrdude: verifying eeprom memory against uno.eep.hex
Reading | ################################################## | 100% 0.03s
avrdude: 74 bytes of eeprom verified
avrdude done. Thank you.
@surfblink Thank you for reporting. for going to the trouble of identifying a minimum eeprom file that exposes the problem and for confirming the PR works. This issue will close automatically when the PR is merged (may take a few days).
Overview
An eeprom file, which is correctly written to an atmega328p by avrdude 6.3 7.0 and 7.1, generates a verification error when written with avrdude 7.2. Looking at the eeprom in -t mode shows that the eeprom has not been correctly written.
Example error
The original eeprom file is relatively large but a similar error
can be reproduced with this small hex file.
With 7.2 this hex file is incorrectly written, but with 7.1 no error
I tried a few more examples
Add a line and it is correctly written with 7.2 and 7.1
But this file is also correctly written with 7.2 and 7.1
And finally this is the line from the original file which caused the
error with 7.2 but not 7.1 7.0 and 6.3
Is is possible to confirm this behaviour (outside of my setup)?
Kind regards and thanks, Tristan