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

Automatic verification is designed to fail for stdin #1044

Closed
stefanrueger opened this issue Jul 23, 2022 · 7 comments
Closed

Automatic verification is designed to fail for stdin #1044

stefanrueger opened this issue Jul 23, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@stefanrueger
Copy link
Collaborator

Problem. Currently, automatic verification is instigated during option parsing of -U through

avrdude/src/main.c

Lines 528 to 532 in affe4cb

if (verify && upd->op == DEVICE_WRITE) {
upd = dup_update(upd);
upd->op = DEVICE_VERIFY;
ladd(updates, upd);
}

So, each -U memory:w:file:... will see a verification request -U memory:v:file:... inserted into the update action list after the write request (unless -V was specified before the -U). This is designed to fail if file is stdin - as the file is read twice.

Proposed solution. I would make verify a global variable, remove above lines and change the code for writing to memory that it checks against the already read file (so that does not need to be read twice).

(Making verify global also helps the micronucleus programmer print a warning that it needs to switch off verify because the micronucleus bootloader cannot read flash.)

@stefanrueger
Copy link
Collaborator Author

The following should give a verification error

yes "The quick brown fox jumps over the lazy dog" | avrdude -c ... -p ... -U eeprom:w:-:r

@MCUdude
Copy link
Collaborator

MCUdude commented Jul 23, 2022

Thanks for reporting! Would be great if a solution to this would be something #1036 could benefit from.

yes "The quick brown fox jumps over the lazy dog" | avrdude -c ... -p ... -U eeprom:w:-:r

Ooh, this could be very useful!

@mcuee
Copy link
Collaborator

mcuee commented Jul 24, 2022

Indeed this is an issue. Verfication after writing will fail even though the writing itself is good.

$ yes "The quick brown fox jumps over the lazy dog" | ./avrdude -c usbasp -qqp m328p 
-U eeprom:w:-:r
avrdude.exe: verification error, first mismatch at byte 0x0000
             0x54 != 0x6f
avrdude.exe: verification error; content mismatch

$ yes "The quick brown fox jumps over the lazy dog" | ./avrdude -c usbasp -qqp m328p 
-U eeprom:v:-:r && echo OK
OK

$ yes "The quick brown fox jumps over the lazy dog" | ./avrdude -c usbasp -qqp m328p 
-V -U eeprom:w:-:r && echo OK
OK

@dl8dtl
Copy link
Contributor

dl8dtl commented Jul 24, 2022

I'm not a big fan of global variables … but we certainly ought to do something, I agree.

@mcuee
Copy link
Collaborator

mcuee commented Jul 31, 2022

The simplest fix is probably documentation fix to mention this limitation of the current implementation -- and then provide the workaround of using -V before -U.

@mcuee
Copy link
Collaborator

mcuee commented Jul 31, 2022

@stefanrueger
Copy link
Collaborator Author

Fixed by PR #1053

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

No branches or pull requests

4 participants