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

sparkfun Tiny Usb ISP programmer not working after update #253

Closed
smdg49 opened this issue Feb 8, 2023 · 23 comments
Closed

sparkfun Tiny Usb ISP programmer not working after update #253

smdg49 opened this issue Feb 8, 2023 · 23 comments

Comments

@smdg49
Copy link

smdg49 commented Feb 8, 2023

USBtinyISP (minicore) programmer fails to burn bootloaders in minicore versions greater than 2.1.3.

I get the folowing message from avrdude

"C:\Users\**********\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\7.1-arduino.1/bin/avrdude" "-CC:\Users\*************\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1/avrdude.conf" -v -patmega328p -cusbtiny  -e -Ulock:w:0xff:m -Uefuse:w:0b11111101:m -Uhfuse:w:0b11010110:m -Ulfuse:w:0b11110111:m

avrdude: Version 7.1-arduino.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\Users\********\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1\avrdude.conf

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): found USBtinyISP, bus:device: 002:031
avrdude usbtiny_open() warning: cannot open USB device: Permission denied
avrdude usbtiny_open() error: cannot find USBtiny device (0x1781/0xc9f)
avrdude main() error: unable to open programmer usbtiny on port usb

avrdude done.  Thank you.

Failed chip erase: uploading error: exit status 1

@MCUdude
Copy link
Owner

MCUdude commented Feb 8, 2023

This appears to be an Avrdude-related issue. MiniCore was upgraded to use Avrdude 7.1 after the 2.2.0 release.

What kind of machine and which OS are you running?

@smdg49
Copy link
Author

smdg49 commented Feb 8, 2023 via email

@mcuee
Copy link

mcuee commented Feb 9, 2023

Windows 10 Arduino ide 2.03

Which driver are you using for your USBTinyISP? Are you using libusb0.sys or WinUSB driver?

Can you try the official avrdude 7.1 Windows binary here?
https://github.com/avrdudes/avrdude/releases/tag/v7.1

You can use the command line avrdude.exe -c usbtiny -p m328p -v to see if that works.

@smdg49
Copy link
Author

smdg49 commented Feb 9, 2023 via email

@mcuee
Copy link

mcuee commented Feb 10, 2023

No issue with either WinUSB driver or libusb-win32 driver (libusb0.sys) for my generic USBtinyISP (using ATtiny2313). Tested under Windows 10 and Arduino IDE 2.0.3.

avrdude: Version 7.1-arduino.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\Users\xfchen\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1\avrdude.conf

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): found USBtinyISP, bus:device: 003:020
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                 65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash                  65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           hfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           efuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           lock                    0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
           calibration             0     0     0    0 no          1    1      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, https://learn.adafruit.com/usbtinyisp
avrdude pgm_default() error: programmer operation not supported

avrdude: using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: using SCK period of 10 usec
"C:\Users\xfchen\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\7.1-arduino.1/bin/avrdude" "-CC:\Users\xfchen\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1/avrdude.conf" -v -patmega328p -cusbtiny  "-Uflash:w:C:\Users\xfchen\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1/bootloaders/optiboot_flash/bootloaders/atmega328p/16000000L/optiboot_flash_atmega328p_UART0_115200_16000000L_B5.hex:i" -Ulock:w:0xcf:m
avrdude: reading input file 0xff for lock
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lock ...
avrdude: 1 byte of lock written
avrdude: verifying lock memory against 0xff
avrdude: 1 byte of lock verified
avrdude: reading input file 0b11111101 for efuse
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte efuse ...
avrdude: 1 byte of efuse written
avrdude: verifying efuse memory against 0b11111101
avrdude: 1 byte of efuse verified
avrdude: reading input file 0b11010110 for hfuse
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte hfuse ...
avrdude: 1 byte of hfuse written
avrdude: verifying hfuse memory against 0b11010110
avrdude: 1 byte of hfuse verified
avrdude: reading input file 0b11110111 for lfuse
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lfuse ...
avrdude: 1 byte of lfuse written
avrdude: verifying lfuse memory against 0b11110111
avrdude: 1 byte of lfuse verified

avrdude done.  Thank you.


avrdude: Version 7.1-arduino.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\Users\xfchen\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1\avrdude.conf

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): found USBtinyISP, bus:device: 003:020
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                 65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash                  65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           hfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           efuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           lock                    0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
           calibration             0     0     0    0 no          1    1      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, https://learn.adafruit.com/usbtinyisp
avrdude pgm_default() error: programmer operation not supported

avrdude: using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)
avrdude: Note: flash memory has been specified, an erase cycle will be performed.
         To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: using SCK period of 10 usec
avrdude: reading input file C:\Users\xfchen\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1/bootloaders/optiboot_flash/bootloaders/atmega328p/16000000L/optiboot_flash_atmega328p_UART0_115200_16000000L_B5.hex for flash
         with 484 bytes in 2 sections within [0x7e00, 0x7fff]
         using 4 pages and 28 pad bytes
avrdude: writing 484 bytes flash ...

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

avrdude: 484 bytes of flash written
avrdude: verifying flash memory against C:\Users\xfchen\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1/bootloaders/optiboot_flash/bootloaders/atmega328p/16000000L/optiboot_flash_atmega328p_UART0_115200_16000000L_B5.hex

Reading | ################################################## | 100% 0.00s

avrdude: 484 bytes of flash verified
avrdude: reading input file 0xcf for lock
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lock ...
avrdude: 1 byte of lock written
avrdude: verifying lock memory against 0xcf
avrdude: 1 byte of lock verified

avrdude done.  Thank you.

@mcuee
Copy link

mcuee commented Feb 10, 2023

libusb.sys and .dll

@smdg49

You can try the following.

  1. Unplug and plug to see if it works or not. Sometimes USBtinyISP may become not responsive.
  2. Switch to WinUSB driver if 1) does not work. You can use Zadig or the method here.
    https://github.com/avrdudes/avrdude/wiki/Troubleshooting-USB-devices-in-Windows#install-the-winusb-driver-for-a-usb-device

@smdg49
Copy link
Author

smdg49 commented Feb 12, 2023 via email

@mcuee
Copy link

mcuee commented Feb 12, 2023

WinUSB works but only once.
I bricked a few chips like this all were smd atmega328p

That is strange. This should not happen. Are you saying the old avrdude 6.3 works for your setup yet the new avrdude 7.1 does not work?

The symptom looks more like HW problem to me. You may try to check the HW connection and your board layout first.

Arduino as ISP does not work either in the new minicore version.

Again, does the old avrdude 6.3 from Arduino work for you setup?

@smdg49
Copy link
Author

smdg49 commented Feb 12, 2023 via email

@smdg49
Copy link
Author

smdg49 commented Feb 12, 2023 via email

@mcuee
Copy link

mcuee commented Feb 13, 2023

So nano only works with libusb
new minicore only works with winusb driver

It is expected that avrdude 6.3 from Arduino only works with libusb0.sys (libusb-win32 device driver), as it uses dynamic link to to libusb0.dll (libusb-win32 dynamic library) which does not support WinUSB driver. That is why you see the following error when you use avrdude 6.3 with WinUSB driver.

avrdude: Error: Could not find USBtiny device (0x1781/0xc9f)

As for avrdude 7.1 from Arduino, it is recommended to use WinUSB driver, as it is linked to libusb-compat-0.1 library (static link) which is on top of libusb-1.0 library. By right, libusb0.sys should also work but there are problems with libusb0.sys support for libusb-1.0. Therefore libusb project does not recommend the use of libusb0.sys for libusb-1.0 and libusb-compat-0.1 under Windows.
https://github.com/libusb/libusb/wiki/Windows#user-content-Driver_Installation

If you use the official avrdude 7.1 Windows binary from avrdude project, it should work with both libusb0.sys driver or WinUSB driver, as it is using static link to avrdude-libusb.
https://github.com/avrdudes/avrdude/releases/tag/v7.1

Reference:

@mcuee
Copy link

mcuee commented Feb 13, 2023

@smdg49

If you want to further debug the issue (not with avrdude project or MiniCore project, but with libusb project), you can add more info here.

You can run Arduino avrdude 7.1 version without the IDE, and set environment variable LIBUSB_DEBUG=4. Then post the debug log in the above issue.

@smdg49
Copy link
Author

smdg49 commented Feb 13, 2023 via email

@mcuee
Copy link

mcuee commented Feb 13, 2023

@smdg49

What about "Arduino as ISP"? It does not use libusb at all so the issue is different.

@smdg49
Copy link
Author

smdg49 commented Feb 13, 2023 via email

@mcuee
Copy link

mcuee commented Feb 13, 2023

Did not look into that yet. Rarely use it.

No problem.

BTW, did you encounter the issue every time or not with your Sparkfun programmer? Or is it happening only occasionally? When you encounter the issue, does it help if you unplug and plug it back?

"C:\Users\**********\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\7.1-arduino.1/bin/avrdude" 
"-CC:\Users\*************\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1/avrdude.conf" 
-v -patmega328p -cusbtiny  -e -Ulock:w:0xff:m -Uefuse:w:0b11111101:m 
-Uhfuse:w:0b11010110:m -Ulfuse:w:0b11110111:m

avrdude: Version 7.1-arduino.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\Users\********\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1\avrdude.conf

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): found USBtinyISP, bus:device: 002:031
avrdude usbtiny_open() warning: cannot open USB device: Permission denied
avrdude usbtiny_open() error: cannot find USBtiny device (0x1781/0xc9f)
avrdude main() error: unable to open programmer usbtiny on port usb

avrdude done.  Thank you.

Failed chip erase: uploading error: exit status 1

@smdg49
Copy link
Author

smdg49 commented Feb 13, 2023 via email

@mcuee
Copy link

mcuee commented Feb 13, 2023

Every time

Please help to post the verbose debug log from arvdude first by running the following under Windows command line.

"C:\Users\**********\AppData\Local\Arduino15\packages\MiniCore\tools\avrdude\7.1-arduino.1\bin\avrdude" 
"-CC:\Users\*************\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\2.2.1\avrdude.conf" 
-vvvv -patmega328p -cusbtiny 

Then do the same thing but with Environment Variable LIBUSB_DEBUG set to 4.

@smdg49
Copy link
Author

smdg49 commented Feb 13, 2023 via email

@mcuee
Copy link

mcuee commented Feb 13, 2023

Arduino IDE is still using avrdude 6.3.x

Sorry but I do not understand this sentence. Arduino IDE with MiniCore 2.2.1 will use avrdude 7.1 version from Arduino. Arduino IDE with MiniCore 2.1.3 version will use avrdude 6.3 from Arduino. Take note Arduino does not use official avrdude release from avrdude project.

To troubleshoot the issue, you do not need to use Arduino IDE at all. Rather you just use the command line to see what is the problem.

To make it easier to you, maybe you can download the binary here and try it. It is the same as the version shipped with MiniCore 2.2.1.
https://github.com/arduino/avrdude-packing/releases/tag/7.1-arduino.1
https://github.com/arduino/avrdude-packing/releases/download/7.1-arduino.1/avrdude_7.1-arduino.1_Windows_32bit.tar.gz

Then you can run the following command line.

.\bin\avrdude -C .\etc\avrdude.conf -c usbtiny -p m328p -vvvv

I cannot reproduce the issue with my USBtinyISP programmer (clone with ATtiny2313), using libusb0.sys driver.

C:\work\avr\avrdude_test\avrdude_bin\avrdude_7.1-arduino.1_Windows_32bit> .\bin\avrdude.exe -c usbtiny -p m328p

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)

avrdude done.  Thank you.

C:\work\avr\avrdude_test\avrdude_bin\avrdude_7.1-arduino.1_Windows_32bit> .\bin\avrdude.exe -c usbtiny -p m328p -v

avrdude: Version 7.1-arduino.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\work\avr\avrdude_test\avrdude_bin\avrdude_7.1-arduino.1_Windows_32bit\etc\avrdude.conf

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): found USBtinyISP, bus:device: 003:020
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                 65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash                  65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           hfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           efuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           lock                    0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
           calibration             0     0     0    0 no          1    1      0     0     0 0x00 0x00

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, https://learn.adafruit.com/usbtinyisp
avrdude pgm_default() error: programmer operation not supported

avrdude: using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably m328p)

avrdude done.  Thank you.

@mcuee
Copy link

mcuee commented Feb 14, 2023

@smdg49

It is okay if you find it troublesome to troubleshoot the issue as it is not really related to MiniCore or even avrdude 7.1, rather it is related to libusb-1.0 Windows support for libusb0.sys.

As mentioned, you should use WinUSB driver for avrdude 7.0/7.1 under Windows in general and not libusb0.sys.

If you agree, then you can close this issue.

@smdg49
Copy link
Author

smdg49 commented Feb 14, 2023 via email

@mcuee
Copy link

mcuee commented Feb 14, 2023

Thanks.
I also switched out avrdude arduino boards to 7.0.x. everything seems to work fine now with winusb driver.

In that case, is it okay that you can close this issue? Thanks.

@smdg49 smdg49 closed this as completed Feb 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants