arduino / ArduinoCore-avr

The Official Arduino AVR core
https://www.arduino.cc
1.25k stars 1.06k forks source link

Arduino Uno or Mega2560 ATmega16U2 DFU FW issue #490

Open mcuee opened 2 years ago

mcuee commented 2 years ago

Ref: https://github.com/avrdudes/avrdude/issues/1043 Ref: https://support.arduino.cc/hc/en-us/articles/4408887452434-Flash-USB-to-serial-firmware-in-DFU-mode

There is a FW issue with the ATmega16U2 DFU firmware (or the combined DFU+USB serial FW) here. The issue is that it is not able to read the device signature properly. https://github.com/arduino/ArduinoCore-avr/tree/master/firmwares/atmegaxxu2

Symptom -- using avrdude flip1 programmer.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_git.exe -c usbasp -qqp m16u2 
-U flash:r:read_16u2_usbasp.hex:i && echo OK
OK

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_git.exe -c flip1 -qqp m16u2 
-U flash:v:read_16u2_usbasp.hex:i && echo OK
avrdude_git.exe: Warning: Failed to read USB device string 1: Input/output error
avrdude_git.exe: Warning: USB bDeviceClass = 0 (expected 254)
avrdude_git.exe: Warning: USB bDeviceSubClass = 0 (expected 1)
avrdude_git.exe: Expected signature for ATmega16U2 is 1E 94 89
                 Double check chip, or use -F to override this check.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_git.exe -c flip1 -qqp m16u2 
-F -U flash:v:read_16u2_usbasp.hex:i && echo OK
avrdude_git.exe: Warning: Failed to read USB device string 1: Input/output error
avrdude_git.exe: Warning: USB bDeviceClass = 0 (expected 254)
avrdude_git.exe: Warning: USB bDeviceSubClass = 0 (expected 1)
avrdude_git.exe: Expected signature for ATmega16U2 is 1E 94 89
OK

BTW, dfu-progammer works ok. I guess it does not really read the device signature.

mcuee commented 2 years ago

The fix is also present in the above avrdude issue -- to rebuild the DFU firmware using the repo here. https://tewarid.github.io/2016/08/09/arduino-usb-dfu-firmware-from-scratch.html https://github.com/tewarid/arduino-usb-dfu

You can refer to more test results here (including the updated hex files)