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

Only send write flash cmd to STK500v2 programmers if page not empty #1273

Merged
merged 1 commit into from
Jan 14, 2023

Conversation

stefanrueger
Copy link
Collaborator

... except if it's for a bootloader: they might need to know about 0xff pages if they use an SPM page erase command and therefore memory does not look like NOR-memory.

This is a slight optimisation for all parts (as writing 0xff pages on NOR-memory flash is a NOP), but more importantly, prevents a firmware error to surface for those parts that need to carry out value polling to determine when writing the page has finished on the device.

Fixes #425

Needs testing with affected parts (ATmega8A) and a flash .hex file with an empty page followed by a non-empty page. Also needs testing eeprom and parts that are not affected by Issue #425, eg, ATmega328P.

... except if it's for a bootloader: they might need to know about
0xff pages if they use an SPM page erase command and therefore
memory does not look like NOR-memory.

This is a slight optimisation for all parts (as writing 0xff pages
on NOR-memory flash is a NOP), but more importantly, prevents a
firmware error to surface for those parts that need to carry out
value polling to determine when writing the page has finished on
the device.
@mcuee mcuee added the bug Something isn't working label Jan 10, 2023
@mcuee
Copy link
Collaborator

mcuee commented Jan 10, 2023

First test: it is good to fix #425 for ATmega8A.

C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1273 -c avrisp2 -p m8a -U .\simpletest_issue425_m8a.hex

avrdude_pr1273: AVR device initialized and ready to accept instructions
avrdude_pr1273: device signature = 0x1e9307 (probably m8a)
avrdude_pr1273: Note: flash memory has been specified, an erase cycle will be performed.
                To disable this feature, specify the -D option.
avrdude_pr1273: erasing chip
avrdude_pr1273: reading input file .\simpletest_issue425_m8a.hex for flash
                with 128 bytes in 2 sections within [0, 0xbf]
                using 2 pages and 0 pad bytes
avrdude_pr1273: writing 128 bytes flash ...

Writing | ################################################## | 100% 0.01 s

avrdude_pr1273: 128 bytes of flash written
avrdude_pr1273: verifying flash memory against .\simpletest_issue425_m8a.hex

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

avrdude_pr1273: 128 bytes of flash verified

avrdude_pr1273 done.  Thank you.

C:\work\avr\avrdude_test\avrdude_bin> cat .\simpletest_issue425_m8a.hex
:020000040000FA
:20000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00
:20002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0
:20008000000000000000000000000000000000000000000000000000000000000000000060
:2000A000000000000000000000000000000000000000000000000000000000000000000040
:00000001FF

@mcuee
Copy link
Collaborator

mcuee commented Jan 10, 2023

No regression for ATmega328P as well.

C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1273 -c avrisp2 -p m328p -U .\simpletest_issue425_m8a.hex

avrdude_pr1273: AVR device initialized and ready to accept instructions
avrdude_pr1273: device signature = 0x1e950f (probably m328p)
avrdude_pr1273: Note: flash memory has been specified, an erase cycle will be performed.
                To disable this feature, specify the -D option.
avrdude_pr1273: erasing chip
avrdude_pr1273: reading input file .\simpletest_issue425_m8a.hex for flash
                with 128 bytes in 2 sections within [0, 0xbf]
                using 2 pages and 128 pad bytes
avrdude_pr1273: writing 128 bytes flash ...

Writing | ################################################## | 100% 0.11 s

avrdude_pr1273: 128 bytes of flash written
avrdude_pr1273: verifying flash memory against .\simpletest_issue425_m8a.hex

Reading | ################################################## | 100% 0.08 s

avrdude_pr1273: 128 bytes of flash verified

avrdude_pr1273 done.  Thank you.

C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1273 -c avrisp2 -p m328p -U .\ATTOBASICV234_m32-16MHZ-uart_btldr.hex

avrdude_pr1273: AVR device initialized and ready to accept instructions
avrdude_pr1273: device signature = 0x1e950f (probably m328p)
avrdude_pr1273: Note: flash memory has been specified, an erase cycle will be performed.
                To disable this feature, specify the -D option.
avrdude_pr1273: erasing chip
avrdude_pr1273: reading input file .\ATTOBASICV234_m32-16MHZ-uart_btldr.hex for flash
                with 15206 bytes in 4 sections within [0, 0x7fff]
                using 120 pages and 154 pad bytes
avrdude_pr1273: writing 15206 bytes flash ...

Writing | ################################################## | 100% 5.20 s

avrdude_pr1273: 15206 bytes of flash written
avrdude_pr1273: verifying flash memory against .\ATTOBASICV234_m32-16MHZ-uart_btldr.hex

Reading | ################################################## | 100% 4.96 s

avrdude_pr1273: 15206 bytes of flash verified

avrdude_pr1273 done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Jan 11, 2023

No regression for the wiring (stk500v2 based) bootloader either.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1273 -c wiring -P COM4 -p m2560 -D
 -U .\simpletest_issue425_m8a.hex


avrdude_pr1273: AVR device initialized and ready to accept instructions
avrdude_pr1273: device signature = 0x1e9801 (probably m2560)
avrdude_pr1273: reading input file .\simpletest_issue425_m8a.hex for flash
                with 128 bytes in 2 sections within [0, 0xbf]
                using 1 page and 128 pad bytes
avrdude_pr1273: writing 128 bytes flash ...

Writing | ################################################## | 100% 0.07 s

avrdude_pr1273: 128 bytes of flash written
avrdude_pr1273: verifying flash memory against .\simpletest_issue425_m8a.hex

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

avrdude_pr1273: 128 bytes of flash verified

avrdude_pr1273 done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1273 -c wiring -P COM4 -p m2560 -D
 -U .\hex\blink-mega2560_lext-test.hex

avrdude_pr1273: AVR device initialized and ready to accept instructions
avrdude_pr1273: device signature = 0x1e9801 (probably m2560)
avrdude_pr1273: reading input file .\hex\blink-mega2560_lext-test.hex for flash
                with 1346 bytes in 4 sections within [0, 0x3106d]
                using 7 pages and 446 pad bytes
avrdude_pr1273: writing 1346 bytes flash ...

Writing | ################################################## | 100% 0.31 s

avrdude_pr1273: 1346 bytes of flash written
avrdude_pr1273: verifying flash memory against .\hex\blink-mega2560_lext-test.hex

Reading | ################################################## | 100% 0.15 s

avrdude_pr1273: 1346 bytes of flash verified

avrdude_pr1273 done.  Thank you.


@mcuee
Copy link
Collaborator

mcuee commented Jan 11, 2023

@stefanrueger
This PR seems to be safe to merge.

@stefanrueger stefanrueger merged commit 65686c7 into avrdudes:main Jan 14, 2023
@stefanrueger stefanrueger deleted the stk500_value_polling branch January 14, 2023 14:30
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.

[bug #48261] STK500V2 ISP problem with ATmega8/8515/8535, ATmega16 and ATmega32
2 participants