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

Make default EEPROM readback values 0xff for STK500 v1 programmer #1753

Merged
merged 1 commit into from
Apr 25, 2024

Conversation

stefanrueger
Copy link
Collaborator

Fixes #1713

That bug probably affects all classic parts. Rather than changing the config readback values to 0xff 0xff, this PR

  • Keeps the readback values as specified in the .atdf (0x00 0x00)
  • Insert a statement in stk500.c to change 0x00 0x00 values to 0xff 0xff

Please check a few other parts than m328p (basically any classic part) whether they exhibit the EEPROM writing problem without this PR and whether this PR would introduce a regression.

@stefanrueger stefanrueger added the bug Something isn't working label Apr 17, 2024
@mcuee
Copy link
Collaborator

mcuee commented Apr 20, 2024

I will carry out some tests with this PR. The plan is to test with ATmega328P, ATmega8A and ATmega256.

@mcuee
Copy link
Collaborator

mcuee commented Apr 21, 2024

Firstly this PR is good for ATmega328P. Tested under macOS 14.4.1 (Mac Mini M1 2020).

mcuee@mcuees-Mac-mini avrdude_bin % avrdude -c usbasp -p m328p -T "erase eeprom"
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)

avrdude: processing -T erase eeprom
Caching | ################################################## | 100% 0.33 s 
avrdude: synching cache to device ... 
Writing | ################################################## | 100% 10.85 s 

avrdude done.  Thank you.

mcuee@mcuees-Mac-mini avrdude_bin % ./avrdude_pr1753 -C ./avrdude_pr1753.conf -c stk500v1 -P /dev/tty.usbserial-1110 -p m328p -U eeprom:w:holes_pack_my_box_1024B.hex:i
avrdude_pr1753: AVR device initialized and ready to accept instructions
avrdude_pr1753: device signature = 0x1e950f (probably m328p)

avrdude_pr1753: processing -U eeprom:w:holes_pack_my_box_1024B.hex:i
avrdude_pr1753: reading input file holes_pack_my_box_1024B.hex for eeprom
                with 252 bytes in 2 sections within [0x82, 0x37d]
                using 64 pages and 4 pad bytes
avrdude_pr1753: writing 252 bytes eeprom ...
Writing | ################################################## | 100% 1.14 s 
avrdude_pr1753: 252 bytes of eeprom written
avrdude_pr1753: verifying eeprom memory against holes_pack_my_box_1024B.hex
Reading | ################################################## | 100% 0.17 s 
avrdude_pr1753: 252 bytes of eeprom verified

avrdude_pr1753 done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Apr 21, 2024

git main has issues with ATmega2560 as well. This PR is good to fix the issue again.
(Note: I erase the EEPROM using usbasp before the tesing. If not it may appear that the result is okay for git main).

mcuee@mcuees-Mac-mini avrdude_bin % avrdude -c usbasp -p m2560 -T "erase eeprom"
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9801 (probably m2560)

avrdude: processing -T erase eeprom
Caching | ################################################## | 100% 0.82 s 
avrdude: synching cache to device ... 
Writing | ################################################## | 100% 6.55 s 

avrdude done.  Thank you.

mcuee@mcuees-Mac-mini avrdude_bin % ./avrdude -c stk500v1 -P /dev/tty.usbserial-1110 -p m2560 -U eeprom:w:holes_pack_my_box_1024B.hex:i        
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9801 (probably m2560)

avrdude: processing -U eeprom:w:holes_pack_my_box_1024B.hex:i
avrdude: reading input file holes_pack_my_box_1024B.hex for eeprom
         with 252 bytes in 2 sections within [0x82, 0x37d]
         using 32 pages and 4 pad bytes
avrdude: writing 252 bytes eeprom ...
Writing | ################################################## | 100% 0.53 s 
avrdude: 252 bytes of eeprom written
avrdude: verifying eeprom memory against holes_pack_my_box_1024B.hex
Reading | ################################################## | 100% 0.06 s 
avrdude warning: verification mismatch
        device 0xff != input 0x50 at addr 0x0082 (error)
avrdude error: verification mismatch

avrdude done.  Thank you.

mcuee@mcuees-Mac-mini avrdude_bin % ./avrdude_pr1753 -C ./avrdude_pr1753.conf -c stk500v1 -P /dev/tty.usbserial-1110 -p m2560 -U eeprom:w:holes_pack_my_box_1024B.hex:i
avrdude_pr1753: AVR device initialized and ready to accept instructions
avrdude_pr1753: device signature = 0x1e9801 (probably m2560)

avrdude_pr1753: processing -U eeprom:w:holes_pack_my_box_1024B.hex:i
avrdude_pr1753: reading input file holes_pack_my_box_1024B.hex for eeprom
                with 252 bytes in 2 sections within [0x82, 0x37d]
                using 32 pages and 4 pad bytes
avrdude_pr1753: writing 252 bytes eeprom ...
Writing | ################################################## | 100% 1.08 s 
avrdude_pr1753: 252 bytes of eeprom written
avrdude_pr1753: verifying eeprom memory against holes_pack_my_box_1024B.hex
Reading | ################################################## | 100% 0.12 s 
avrdude_pr1753: 252 bytes of eeprom verified

avrdude_pr1753 done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Apr 21, 2024

For ATmega128A, both git main and this PR are okay.

mcuee@mcuees-Mac-mini avrdude_bin % avrdude -c usbasp -p m128 -T "erase eeprom"
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9702 (probably m128)

avrdude: processing -T erase eeprom
Caching | ################################################## | 100% 0.82 s 
avrdude: synching cache to device ... 
Writing | ################################################## | 100% 42.36 s 

avrdude done.  Thank you.

mcuee@mcuees-Mac-mini avrdude_bin % ./avrdude -c stk500v1 -P /dev/tty.usbserial-1110 -p m128 -U eeprom:w:holes_pack_my_box_1024B.hex:i
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9702 (probably m128)

avrdude: processing -U eeprom:w:holes_pack_my_box_1024B.hex:i
avrdude: reading input file holes_pack_my_box_1024B.hex for eeprom
         with 252 bytes in 2 sections within [0x82, 0x37d]
         using 32 pages and 4 pad bytes
avrdude: writing 252 bytes eeprom ...
Writing | ################################################## | 100% 1.22 s 
avrdude: 252 bytes of eeprom written
avrdude: verifying eeprom memory against holes_pack_my_box_1024B.hex
Reading | ################################################## | 100% 0.06 s 
avrdude: 252 bytes of eeprom verified

avrdude done.  Thank you.

mcuee@mcuees-Mac-mini avrdude_bin % ./avrdude -c stk500v1 -P /dev/tty.usbserial-1110 -p m128 -U eeprom:w:the_quick_brown_fox_1024B.hex:i 
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9702 (probably m128)

avrdude: processing -U eeprom:w:the_quick_brown_fox_1024B.hex:i
avrdude: reading input file the_quick_brown_fox_1024B.hex for eeprom
         with 1024 bytes in 1 section within [0, 0x3ff]
         using 128 pages and 0 pad bytes
avrdude: writing 1024 bytes eeprom ...
Writing | ################################################## | 100% 9.60 s 
avrdude: 1024 bytes of eeprom written
avrdude: verifying eeprom memory against the_quick_brown_fox_1024B.hex
Reading | ################################################## | 100% 0.48 s 
avrdude: 1024 bytes of eeprom verified

avrdude done.  Thank you.

mcuee@mcuees-Mac-mini avrdude_bin % avrdude -c usbasp -p m128 -T "erase eeprom"
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9702 (probably m128)

avrdude: processing -T erase eeprom
Caching | ################################################## | 100% 0.82 s 
avrdude: synching cache to device ... 
Writing | ################################################## | 100% 10.54 s 

avrdude done.  Thank you.

mcuee@mcuees-Mac-mini avrdude_bin % ./avrdude_pr1753 -C ./avrdude_pr1753.conf -c stk500v1 -P /dev/tty.usbserial-1110 -p m128 -U eeprom:w:holes_pack_my_box_1024B.hex:i
avrdude_pr1753: AVR device initialized and ready to accept instructions
avrdude_pr1753: device signature = 0x1e9702 (probably m128)

avrdude_pr1753: processing -U eeprom:w:holes_pack_my_box_1024B.hex:i
avrdude_pr1753: reading input file holes_pack_my_box_1024B.hex for eeprom
                with 252 bytes in 2 sections within [0x82, 0x37d]
                using 32 pages and 4 pad bytes
avrdude_pr1753: writing 252 bytes eeprom ...
Writing | ################################################## | 100% 2.44 s 
avrdude_pr1753: 252 bytes of eeprom written
avrdude_pr1753: verifying eeprom memory against holes_pack_my_box_1024B.hex
Reading | ################################################## | 100% 0.12 s 
avrdude_pr1753: 252 bytes of eeprom verified

avrdude_pr1753 done.  Thank you.

mcuee@mcuees-Mac-mini avrdude_bin % ./avrdude_pr1753 -C ./avrdude_pr1753.conf -c stk500v1 -P /dev/tty.usbserial-1110 -p m128 -U eeprom:w:the_quick_brown_fox_1024B.hex:i 
avrdude_pr1753: AVR device initialized and ready to accept instructions
avrdude_pr1753: device signature = 0x1e9702 (probably m128)

avrdude_pr1753: processing -U eeprom:w:the_quick_brown_fox_1024B.hex:i
avrdude_pr1753: reading input file the_quick_brown_fox_1024B.hex for eeprom
                with 1024 bytes in 1 section within [0, 0x3ff]
                using 128 pages and 0 pad bytes
avrdude_pr1753: writing 1024 bytes eeprom ...
Writing | ################################################## | 100% 9.60 s 
avrdude_pr1753: 1024 bytes of eeprom written
avrdude_pr1753: verifying eeprom memory against the_quick_brown_fox_1024B.hex
Reading | ################################################## | 100% 0.48 s 
avrdude_pr1753: 1024 bytes of eeprom verified

avrdude_pr1753 done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Apr 21, 2024

@stefanrueger

I think this PR is now good to be merged.

@mcuee
Copy link
Collaborator

mcuee commented Apr 21, 2024

One more sanity check, it does not cause regression with "Arduino as ISP" as well.

mcuee@mcuees-Mac-mini tools % ./test-avrdude -e ../build_darwin/src/avrdude -p "-c arduino_as_isp -P /dev/tty.usbserial-224570 -p m168p -b 19200"
Testing ../build_darwin/src/avrdude version 7.3-20240417 (4b2c9947)
Prepare "-c arduino_as_isp -P /dev/tty.usbserial-224570 -p m168p -b 19200" and press 'enter' or 'space' to continue. Press any other key to skip
✅   1.355 s: fuse access: clear, set and read eesave fuse bit
✅   1.327 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
✅   1.688 s: chip erase
✅   6.676 s: flash -U write/verify holes_rjmp_loops_16384B.hex
✅   3.100 s: flash -T write/verify holes_rjmp_loops_16384B.hex
✅   1.783 s: eeprom check whether programmer can flip 0s to 1s
✅   8.138 s: eeprom -U write/verify holes_pack_my_box_512B.hex
✅  15.363 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_512B.hex
✅   3.447 s: chip erase and spot check flash is actually erased
✅   1.809 s: spot check eeprom is erased, too

BTW, git main is okay with "Arduino as ISP".

mcuee@mcuees-Mac-mini tools % ./test-avrdude -p "-c arduino_as_isp -P /dev/tty.usbserial-224570 -p m168p -b 19200"
Testing avrdude version 7.3-20240417 (8fe729f0)
Prepare "-c arduino_as_isp -P /dev/tty.usbserial-224570 -p m168p -b 19200" and press 'enter' or 'space' to continue. Press any other key to skip
✅   1.359 s: fuse access: clear, set and read eesave fuse bit
✅   1.326 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
✅   1.694 s: chip erase
✅   6.682 s: flash -U write/verify holes_rjmp_loops_16384B.hex
✅   3.077 s: flash -T write/verify holes_rjmp_loops_16384B.hex
✅   1.776 s: eeprom check whether programmer can flip 0s to 1s
✅   8.123 s: eeprom -U write/verify holes_pack_my_box_512B.hex
✅  15.347 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_512B.hex
✅   3.448 s: chip erase and spot check flash is actually erased
✅   1.814 s: spot check eeprom is erased, too

@mcuee
Copy link
Collaborator

mcuee commented Apr 21, 2024

For ATmega128A, both git main and this PR are okay.

Same for ATmega8A.

This PR is good.

mcuee@mcuees-Mac-mini tools % ./test-avrdude -e ../build_darwin/src/avrdude  -p "-c stk500v1 -P /dev/tty.usbserial-1110 -p m8a"
Testing ../build_darwin/src/avrdude version 7.3-20240417 (4b2c9947)
Prepare "-c stk500v1 -P /dev/tty.usbserial-1110 -p m8a" and press 'enter' or 'space' to continue. Press any other key to skip
✅   0.999 s: fuse access: clear, set and read eesave fuse bit
✅   1.015 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
✅   1.143 s: chip erase
✅   2.027 s: flash -U write/verify holes_rjmp_loops_8192B.hex
✅   1.417 s: flash -T write/verify holes_rjmp_loops_8192B.hex
✅   1.166 s: eeprom check whether programmer can flip 0s to 1s
✅   2.354 s: eeprom -U write/verify holes_pack_my_box_512B.hex
✅   3.744 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_512B.hex
✅   1.538 s: chip erase and spot check flash is actually erased
✅   1.097 s: spot check eeprom is erased, too

git main is also good.

mcuee@mcuees-Mac-mini tools % ./test-avrdude -p "-c stk500v1 -P /dev/tty.usbserial-1110 -p m8a"  
Testing avrdude version 7.3-20240417 (8fe729f0)
Prepare "-c stk500v1 -P /dev/tty.usbserial-1110 -p m8a" and press 'enter' or 'space' to continue. Press any other key to skip
✅   0.993 s: fuse access: clear, set and read eesave fuse bit
✅   1.025 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
✅   1.151 s: chip erase
✅   2.026 s: flash -U write/verify holes_rjmp_loops_8192B.hex
✅   1.425 s: flash -T write/verify holes_rjmp_loops_8192B.hex
✅   1.166 s: eeprom check whether programmer can flip 0s to 1s
✅   2.346 s: eeprom -U write/verify holes_pack_my_box_512B.hex
✅   3.745 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_512B.hex
✅   1.536 s: chip erase and spot check flash is actually erased
✅   1.109 s: spot check eeprom is erased, too

@mcuee
Copy link
Collaborator

mcuee commented Apr 21, 2024

For ATmega168P, situation is the same as ATmega328P. git main is bad but this PR is good.

mcuee@mcuees-Mac-mini tools % ./test-avrdude -p "-c stk500v1 -P /dev/tty.usbserial-1110 -p m168p"
Testing avrdude version 7.3-20240417 (8fe729f0)
Prepare "-c stk500v1 -P /dev/tty.usbserial-1110 -p m168p" and press 'enter' or 'space' to continue. Press any other key to skip
✅   1.005 s: fuse access: clear, set and read eesave fuse bit
✅   1.025 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
✅   1.211 s: chip erase
✅   3.448 s: flash -U write/verify holes_rjmp_loops_16384B.hex
✅   2.068 s: flash -T write/verify holes_rjmp_loops_16384B.hex
✅   1.046 s: eeprom check whether programmer can flip 0s to 1s
❌   1.727 s: eeprom -U write/verify holes_pack_my_box_512B.hex (failed command below)
$ avrdude -qq -c stk500v1 -P /dev/tty.usbserial-1110 -p m168p -Ueeprom:w:./test_files/holes_pack_my_box_512B.hex
✅   3.731 s: eeprom -U write/verify the_quick_brown_fox_512B.hex
✅   2.480 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_512B.hex
✅   2.257 s: chip erase and spot check flash is actually erased
✅   1.117 s: spot check eeprom is erased, too

mcuee@mcuees-Mac-mini tools % ./test-avrdude -e ../build_darwin/src/avrdude -p "-c stk500v1 -P /dev/tty.usbserial-1110 -p m168p"
Testing ../build_darwin/src/avrdude version 7.3-20240417 (4b2c9947)
Prepare "-c stk500v1 -P /dev/tty.usbserial-1110 -p m168p" and press 'enter' or 'space' to continue. Press any other key to skip
✅   0.990 s: fuse access: clear, set and read eesave fuse bit
✅   1.027 s: fuse access: set eesave fusebit to delete EEPROM on chip erase
✅   1.201 s: chip erase
✅   3.446 s: flash -U write/verify holes_rjmp_loops_16384B.hex
✅   2.067 s: flash -T write/verify holes_rjmp_loops_16384B.hex
✅   1.147 s: eeprom check whether programmer can flip 0s to 1s
✅   1.766 s: eeprom -U write/verify holes_pack_my_box_512B.hex
✅   2.577 s: eeprom -T write/verify holes_{the_five_boxing_wizards,pack_my_box}_512B.hex
✅   2.256 s: chip erase and spot check flash is actually erased
✅   1.118 s: spot check eeprom is erased, too

@stefanrueger stefanrueger merged commit 51bea2a into avrdudes:main Apr 25, 2024
12 checks passed
@stefanrueger stefanrueger deleted the stk500-v1-eeprom branch April 25, 2024 16:29
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.

Regression: EEPROM issue with official STK500 V1 FW -- avrdude 7.1 is okay but not 7.2 and 7.3
2 participants