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

avrdude MSVC build problem with USB composite device (avrdude-libusb library issue) -- low priority #968

Open
dioannidis opened this issue May 17, 2022 · 42 comments
Assignees
Labels
bug Something isn't working

Comments

@dioannidis
Copy link

dioannidis commented May 17, 2022

Hi,

I tried to use avrdude v7 ( both x86 and x64 ) on a windows 10 box with a usbasp composite ( hid and winusb ) firmware ( https://github.com/dioannidis/usbasp ) with no success.

The USBasp device loads the microsoft winusb driver ( and hid of course ) during enumeration as you can see here

USBDview_USBASP

and here

RegEdit_USBASP

My custom msys2 avrdude 6.3 and 6.4 builds works fine with that device ( https://github.com/dioannidis/usbasp/tree/master/bin/avrdude-winusb ) .

( I just hack the configure.ac like this :

Index: configure.ac
===================================================================
--- configure.ac	(revision 1524)
+++ configure.ac	(working copy)
@@ -99,7 +99,7 @@
 AC_SEARCH_LIBS([setsockopt], [socket])
 AH_TEMPLATE([HAVE_LIBUSB],
             [Define if USB support is enabled via libusb])
-AC_CHECK_LIB([usb], [usb_get_string_simple], [have_libusb=yes])
+AC_CHECK_HEADERS([lusb0_usb.h usb.h], [have_libusb=yes])
 if test x$have_libusb = xyes; then
    case $target in
        *-*-darwin*)

).

I used both -cusbasp and -cusbasp-clone with no success

C:\Users\thouli\Downloads\avrdude-v7.0-windows-x86>avrdude.exe -cusbasp -patmega328p -v

avrdude.exe: Version 7.0
             Copyright (c) Brian Dean, http://www.bdmicro.com/
             Copyright (c) Joerg Wunsch

             System wide configuration file is "C:/Users/thouli/Downloads/avrdude-v7.0-windows-x86/avrdude.conf"

             Using Port                    : usb
             Using Programmer              : usbasp
avrdude.exe: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
avrdude.exe: opening programmer "usbasp" on port "usb" failed

avrdude.exe done.  Thank you.


C:\Users\thouli\Downloads\avrdude-v7.0-windows-x86>avrdude.exe -cusbasp-clone -patmega328p -v

avrdude.exe: Version 7.0
             Copyright (c) Brian Dean, http://www.bdmicro.com/
             Copyright (c) Joerg Wunsch

             System wide configuration file is "C:/Users/thouli/Downloads/avrdude-v7.0-windows-x86/avrdude.conf"

             Using Port                    : usb
             Using Programmer              : usbasp-clone
avrdude.exe: error: could not find USB device with vid=0x16c0 pid=0x5dc
avrdude.exe: opening programmer "usbasp-clone" on port "usb" failed

avrdude.exe done.  Thank you.

Is there something I'm missing ? Maybe a command line switch or maybe the release windows binaries aren't configured with winusb support ?

PS: Also I tried to build today's main in MSYS2 ( following the instructions from the wiki ) but got a lot of "undefined reference to `progname'" errors ...

( a lot of errors .... )
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: CMakeFiles/libavrdude.dir/objects.a(xbee.c.obj): in function `xbee_close':
G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1709: undefined reference to `progname'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1709: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1712: undefined reference to `progname'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1712: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1715: undefined reference to `progname'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1715: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1718: undefined reference to `progname'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1718: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: CMakeFiles/libavrdude.dir/objects.a(xbee.c.obj): in function `xbeedev_open':
G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1125: undefined reference to `progname'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1189: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1241: undefined reference to `progname'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1241: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1174: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1321: undefined reference to `progname'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1321: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1257: undefined reference to `progname'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1257: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1125: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: G:/Programming/dimitris/tools/avrdude_github/src/xbee.c:1134: undefined reference to `avrdude_message'
G:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/11.3.0/../../../../i686-w64-mingw32/bin/ld.exe: CMakeFiles/libavrdude.dir/objects.a(config_gram.c.obj): in function `yyparse':
G:\Programming\dimitris\tools\avrdude_github\build_mingw32\src/config_gram.y:1313: undefined reference to `avrdude_message'
collect2.exe: error: ld returned 1 exit status
make[2]: *** [src/CMakeFiles/libavrdude.dir/build.make:964: src/libavrdude.dll] Error 1
make[1]: *** [CMakeFiles/Makefile2:100: src/CMakeFiles/libavrdude.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
@mcuee
Copy link
Collaborator

mcuee commented May 18, 2022

I have no issues building avrdude 7.0 under MSYS2 by following the wiki instruction. You can try the binary here.
https://github.com/mcuee/avrdude/releases/tag/v7.0

The official binary is built with MSVC and it should have support for both WinUSB and libusb0.sys.
https://github.com/avrdudes/avrdude/wiki/Building-AVRDUDE-for-Windows-using-Visual-Studio
https://github.com/mariusgreuel/avrdude#support-winusb-devices-via-custom-libusb

@mcuee
Copy link
Collaborator

mcuee commented May 18, 2022

If I look at the FW, Interface 0 is using WinUSB and Interface 1 is HID.
https://github.com/dioannidis/usbasp/blob/master/firmware/usb_descriptors.h

So probably it should work out of the box. You can try the MSYS2 binary I provided. Then if not working, set environment variable LIBUSB_DEBUG=4 to see if why it failed.

As for the official MSVC binary ( https://github.com/avrdudes/avrdude/releases/tag/v7.0 ), there should be a way to print out debug message as well. Maybe @mariusgreuel can help here.
https://github.com/avrdudes/libusb/tree/windows/src

@mcuee
Copy link
Collaborator

mcuee commented May 18, 2022

@dioannidis I just figured out the way to print the debug message of the official binary, it is the same as libusb-win32, you just need to the set environment variable USB_DEBUG=255.

I do not have your programmer but I have no problem to print the debug message.

The following run log is from Windows 10 and PowerShell/Windows Terminal.

You can also try to debug using VS2019/VS2022 if you are familiar with VS (I am not familiar with VS debugging. I usually use MSYS2 and not VS myself).

C:\work\avr\binary\avrdude-v7.0-windows-x64> $Env:USB_DEBUG=255

C:\work\avr\binary\avrdude-v7.0-windows-x64> .\avrdude.exe -cusbasp -patmega328p -vvvv
executable_abspath = C:/work/avr/binary/avrdude-v7.0-windows-x64/avrdude.exe
executable_abspath_len = 55
executable_dirpath = C:/work/avr/binary/avrdude-v7.0-windows-x64
executable_dirpath_len = 43
sys_config = C:/work/avr/binary/avrdude-v7.0-windows-x64/avrdude.conf
sys_config_found = true


avrdude.exe: Version 7.0
             Copyright (c) Brian Dean, http://www.bdmicro.com/
             Copyright (c) Joerg Wunsch

             System wide configuration file is "C:/work/avr/binary/avrdude-v7.0-windows-x64/avrdude.conf"

             Using Port                    : usb
             Using Programmer              : usbasp
avrdude.exe: usbasp_open("usb")
avrdude:[os_find_busses] found bus-0
avrdude:[os_find_devices] found \\?\usb#vid_0424&pid_2740#d&127b8a6a&0&5#{a5dcbf10-6530-11d2-901f-00c04fb951ed}--WINUSB on bus-0
avrdude:[os_find_busses] found bus-0
avrdude:[os_find_devices] found \\?\usb#vid_0424&pid_2740#d&127b8a6a&0&5#{a5dcbf10-6530-11d2-901f-00c04fb951ed}--WINUSB on bus-0
avrdude.exe: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
avrdude.exe: opening programmer "usbasp" on port "usb" failed

avrdude.exe done.  Thank you.

@mariusgreuel
Copy link
Contributor

I tried to use avrdude v7 with a usbasp composite ( hid and winusb ) firmware with no success

That is expected as the release build uses libwinusb, which does not work with composite devices.

As @mcuee said, the MSYS2 build with libusb-1.0 will probably work. If it does not compiler for you, you setup is screwed up, or your repo is dirty. You may want to start over, and try git clean -xdf.

@mariusgreuel
Copy link
Contributor

If I look at the FW, Interface 0 is using WinUSB and Interface 1 is HID

@mcuee Just out of curiosity: How does libusb figure which interface to pick? Heuristics?

On Windows, you typically look for an interface. And since we are not searching for an interface, but for a device with a specific pid:vid (such as USB\VID_xxxx&PID_yyyy), it would fail, because that is the composite device. But the device that implements the WinUSB is USB\VID_xxxx&PID_yyyy&MI_00. Meaning you can't just make USBASP a composite device and expect it to work, unless you change the Windows program, too.

@mcuee
Copy link
Collaborator

mcuee commented May 18, 2022

That is expected as the release build uses libwinusb, which does not work with composite devices.

That is interesting to know. Maybe you need to mention that with the official Windows binary.

@mcuee
Copy link
Collaborator

mcuee commented May 18, 2022

If I look at the FW, Interface 0 is using WinUSB and Interface 1 is HID

@mcuee Just out of curiosity: How does libusb figure which interface to pick? Heuristics?

On Windows, you typically look for an interface. And since we are not searching for an interface, but for a device with a specific pid:vid (such as USB\VID_xxxx&PID_yyyy), it would fail, because that is the composite device. But the device that implements the WinUSB is USB\VID_xxxx&PID_yyyy&MI_00. Meaning you can't just make USBASP a composite device and expect it to work, unless you change the Windows program, too.

In this case, Windows will treat the USB composite device as two devices (one with WinUSB and the other one with HID).

For libusb (libusb-win32, libusb-compat-0.1 and libusb-1.0) to work, you need to know the interface number and claim it. I think by default you will claim Interface 0 and then it should work with this particular ubasp USB composite device as well since WinUSB interface is on Interface 0. I am not so sure why avrdude-libwinusb does not work in this case.

Still if programmers with the same VID/PID can have different FW (by right that should not happen) like this, I think you may need to have extra parameter like interface number or manufacture/product strings to differentiate.

For example some FTDI based programmer (no FW, but different EEPROM configuration) may have same VID/PID but then they may have different manufacture/product strings to differentiate

@dioannidis
Copy link
Author

If I look at the FW, Interface 0 is using WinUSB and Interface 1 is HID. https://github.com/dioannidis/usbasp/blob/master/firmware/usb_descriptors.h

Correct . I choose the winusb to be interface 0 exactly for this.

So probably it should work out of the box. You can try the MSYS2 binary I provided. Then if not working, set environment variable LIBUSB_DEBUG=4 to see if why it failed.

You're right. Your binary works out of the box.

@dioannidis
Copy link
Author

dioannidis commented May 18, 2022

That is expected as the release build uses libwinusb, which does not work with composite devices.

That is interesting to know. Maybe you need to mention that with the official Windows binary.

I agree ! A note regarding that this version is does not support composite devices will be good.

@dioannidis
Copy link
Author

For libusb (libusb-win32, libusb-compat-0.1 and libusb-1.0) to work, you need to know the interface number and claim it. I think by default you will claim Interface 0 and then it should work with this particular ubasp USB composite device as well since WinUSB interface is on Interface 0. I am not so sure why avrdude-libwinusb does not work in this case.

@mcuee The assignment of winusb interface to interface 0 was done deliberately with the defaults in mind. I tested the firmware with libusb in Windows, Linux ( Debian, Ubuntu ) and macOS with success.

@mariusgreuel FYI, in my limited testing it fails at

for(bus=usb_get_busses(); bus; bus=bus->next){
. I don't know if it helps but the usb_find_busses() finds only one bus ( bus-0 ) on my machine .

I'll take a look if I can fix this . If I do will you accept a PR regarding this ?

@dioannidis
Copy link
Author

dioannidis commented May 18, 2022

@mariusgreuel
@mcuee

here is a log using mcuee's msys2 binary ( it's long ... ) :

C:\Users\thouli\Downloads\avrdude-7.0_bin64>avrdude_shared.exe -cusbasp -patmega328p -vvvv
executable_abspath = C:/Users/thouli/Downloads/avrdude-7.0_bin64/avrdude_shared.exe
executable_abspath_len = 62
executable_dirpath = C:/Users/thouli/Downloads/avrdude-7.0_bin64
executable_dirpath_len = 43
sys_config = C:/Users/thouli/Downloads/avrdude-7.0_bin64/avrdude.conf
sys_config_found = true


avrdude_shared.exe: Version 7.0
                    Copyright (c) Brian Dean, http://www.bdmicro.com/
                    Copyright (c) Joerg Wunsch

                    System wide configuration file is "C:/Users/thouli/Downloads/avrdude-7.0_bin64/avrdude.conf"

                    Using Port                    : usb
                    Using Programmer              : usbasp
avrdude_shared.exe: usbasp_open("usb")
[timestamp] [threadID] facility level [function call] <message>
--------------------------------------------------------------------------------
[ 0.001359] [00005348] libusb: debug [libusb_init] libusb v1.0.26.11724
[ 0.001926] [00005348] libusb: debug [usbi_add_event_source] add HANDLE 00000000000000fc events 0
[ 0.002521] [00005348] libusb: debug [usbi_io_init] using timer for timeouts
[ 0.003115] [00005348] libusb: debug [usbi_add_event_source] add HANDLE 0000000000000100 events 0
[ 0.003656] [00005348] libusb: debug [get_windows_version] Windows 10 64-bit
[ 0.004679] [00005348] libusb: debug [htab_create] using 1021 entries hash table
[ 0.006014] [00005348] libusb: info [winusbx_init] WinUSB DLL available (with isoch support)
[ 0.008284] [00005348] libusb: debug [winusbx_init] libusbK DLL found, version: 3.0.7.0
[ 0.010366] [00005348] libusb: info [windows_init] UsbDk backend is not available
[ 0.010474] [00005348] libusb: warning [libusb_init] installing new context as implicit default
[ 0.012569] [00005080] libusb: debug [windows_iocp_thread] I/O completion thread started
[ 0.012572] [00005348] libusb: debug [libusb_get_device_list]
[ 0.020461] [00005348] libusb: debug [winusb_get_device_list] allocating new device for session [5D]
[ 0.020708] [00005348] libusb: debug [winusb_get_device_list] allocating new device for session [5E]
[ 0.021261] [00005348] libusb: debug [winusb_get_device_list] allocating new device for session [5F]
[ 0.022248] [00005348] libusb: debug [get_api_type] driver(s): usbccgp
[ 0.022431] [00005348] libusb: debug [get_api_type] matched driver name against Composite API
[ 0.022946] [00005348] libusb: debug [winusb_get_device_list] allocating new device for session [47]
[ 0.024490] [00005348] libusb: debug [get_api_type] driver(s): usbccgp
[ 0.025012] [00005348] libusb: debug [get_api_type] matched driver name against Composite API
[ 0.028311] [00005348] libusb: debug [winusb_get_device_list] allocating new device for session [48]
[ 0.029040] [00005348] libusb: debug [get_api_type] driver(s): HidUsb
[ 0.029646] [00005348] libusb: debug [get_api_type] matched driver name against HID API
[ 0.030233] [00005348] libusb: debug [winusb_get_device_list] allocating new device for session [49]
[ 0.030943] [00005348] libusb: debug [get_api_type] driver(s): usbccgp
[ 0.031469] [00005348] libusb: debug [get_api_type] matched driver name against Composite API
[ 0.032058] [00005348] libusb: debug [winusb_get_device_list] allocating new device for session [4A]
[ 0.032963] [00005348] libusb: debug [enumerate_hcd_root_hub] assigning HCD 'PCI\VEN_8086&DEV_8CB1&SUBSYS_50071458&REV_00\3&11583659&0&A0' bus number 1
[ 0.034473] [00005348] libusb: debug [init_root_hub] root hub 'USB\ROOT_HUB30\4&1B824007&0&0' reports 21 ports
[ 0.034752] [00005348] libusb: warning [init_root_hub] could not get node connection information (V2) for root hub 'USB\ROOT_HUB30\4&1B824007&0&0' port 15:
[87] The parameter is incorrect.
[ 0.035154] [00005348] libusb: debug [init_device] (bus: 1, addr: 0, depth: 0, port: 0): 'USB\ROOT_HUB30\4&1B824007&0&0'
[ 0.035759] [00005348] libusb: debug [winusb_get_device_list] extra GUID: {AD57D3B9-1166-43F8-8790-EBE14DDC7504}
[ 0.036362] [00005348] libusb: debug [winusb_get_device_list] found existing device for session [49]
[ 0.037130] [00005348] libusb: debug [init_device] found 1 configurations (current config: 1)
[ 0.037601] [00005348] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 34 bytes)
[ 0.038250] [00005348] libusb: debug [init_device] (bus: 1, addr: 26, depth: 2, port: 2): 'USB\VID_0461&PID_4D81\6&26D86E1A&0&2'
[ 0.038876] [00005348] libusb: debug [winusb_get_device_list] found existing device for session [4A]
[ 0.040473] [00005348] libusb: debug [init_device] found 1 configurations (current config: 1)
[ 0.043380] [00005348] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 50 bytes)
[ 0.043911] [00005348] libusb: debug [init_device] (bus: 1, addr: 30, depth: 1, port: 13): 'USB\VID_16C0&PID_05DC\5&E658374&0&13'
[ 0.044638] [00005348] libusb: debug [winusb_get_device_list] found existing device for session [5F]
[ 0.045092] [00005348] libusb: debug [init_device] found 1 configurations (current config: 1)
[ 0.045617] [00005348] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 25 bytes)
[ 0.046134] [00005348] libusb: debug [init_device] (bus: 1, addr: 31, depth: 2, port: 3): 'USB\VID_214B&PID_7250\6&26D86E1A&0&3'
[ 0.046675] [00005348] libusb: debug [winusb_get_device_list] found existing device for session [47]
[ 0.047194] [00005348] libusb: debug [init_device] found 1 configurations (current config: 1)
[ 0.047676] [00005348] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 59 bytes)
[ 0.048199] [00005348] libusb: debug [init_device] (bus: 1, addr: 29, depth: 2, port: 1): 'USB\VID_1A2C&PID_2124\6&26D86E1A&0&1'
[ 0.048770] [00005348] libusb: debug [winusb_get_device_list] extra GUID: {CC4BC031-F61A-4C2B-BBB2-795872B38F66}
[ 0.049287] [00005348] libusb: debug [winusb_get_device_list] found existing device for session [5D]
[ 0.049780] [00005348] libusb: debug [init_device] found 1 configurations (current config: 1)
[ 0.050249] [00005348] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 25 bytes)
[ 0.050769] [00005348] libusb: debug [init_device] (bus: 1, addr: 28, depth: 1, port: 4): 'USB\VID_214B&PID_7250\5&E658374&0&4'
[ 0.051336] [00005348] libusb: debug [winusb_get_device_list] found existing device for session [48]
[ 0.051838] [00005348] libusb: debug [init_device] found 1 configurations (current config: 1)
[ 0.052321] [00005348] libusb: debug [cache_config_descriptors] cached config descriptor 0 (bConfigurationValue=1, 714 bytes)
[ 0.052879] [00005348] libusb: debug [init_device] (bus: 1, addr: 2, depth: 1, port: 10): 'USB\VID_045E&PID_0761\5&E658374&0&10'
[ 0.053746] [00005348] libusb: debug [winusb_get_device_list] setting HID interface for [49]:
[ 0.053960] [00005348] libusb: debug [set_hid_interface] interface[0] = \\?\HID#VID_0461&PID_4D81#7&18B9A3AB&0&0000#{4D1E55B2-F16F-11CF-88CB-001111000030}
[ 0.054995] [00005348] libusb: debug [winusb_get_device_list] setting composite interface for [47]:
[ 0.059485] [00005348] libusb: debug [set_composite_interface] interface[1] = \\?\HID#VID_1A2C&PID_2124&MI_01&COL02#8&999148D&0&0001#{4D1E55B2-F16F-11CF-88C
B-001111000030}
[ 0.059838] [00005348] libusb: debug [winusb_get_device_list] setting composite interface for [47]:
[ 0.060777] [00005348] libusb: debug [set_composite_interface] interface[1] already set - ignoring HID collection: HID\VID_1A2C&PID_2124&MI_01&COL01\8&99914
8D&0&0000
[ 0.061049] [00005348] libusb: debug [winusb_get_device_list] setting composite interface for [47]:
[ 0.062183] [00005348] libusb: debug [set_composite_interface] interface[0] = \\?\HID#VID_1A2C&PID_2124&MI_00#8&2D70524F&0&0000#{4D1E55B2-F16F-11CF-88CB-001
111000030}\KBD
[ 0.063288] [00005348] libusb: debug [winusb_get_device_list] setting composite interface for [4A]:
[ 0.063907] [00005348] libusb: debug [set_composite_interface] interface[1] = \\?\HID#VID_16C0&PID_05DC&MI_01#7&137BAC19&0&0000#{4D1E55B2-F16F-11CF-88CB-001
111000030}
[ 0.065066] [00005348] libusb: debug [get_api_type] driver(s): WINUSB
[ 0.065187] [00005348] libusb: debug [get_api_type] matched driver name against WinUSB
[ 0.065748] [00005348] libusb: debug [winusb_get_device_list] setting composite interface for [4A]:
[ 0.066283] [00005348] libusb: debug [set_composite_interface] interface[0] = \\?\USB#VID_16C0&PID_05DC&MI_00#6&2DF11988&0&0000#{CC4BC031-F61A-4C2B-BBB2-795
872B38F66}
[ 0.067084] [00005348] libusb: debug [libusb_get_device_descriptor]
[ 0.067220] [00005348] libusb: debug [libusb_get_device_descriptor]
[ 0.067680] [00005348] libusb: debug [libusb_get_device_descriptor]
[ 0.068197] [00005348] libusb: debug [libusb_open] open 1.30
[ 0.068853] [00005348] libusb: debug [hid_open] set maximum input buffer size to 512
[ 0.069274] [00005348] libusb: debug [hid_open] 1 HID input report value(s) found
[ 0.069978] [00005348] libusb: debug [hid_open]   Report ID: 0x00
[ 0.070566] [00005348] libusb: debug [hid_open] 1 HID output report value(s) found
[ 0.073230] [00005348] libusb: debug [hid_open]   Report ID: 0x00
[ 0.077466] [00005348] libusb: debug [hid_open] 1 HID feature report value(s) found
[ 0.078071] [00005348] libusb: debug [hid_open]   Report ID: 0x00
[ 0.080768] [00005348] libusb: debug [libusb_submit_transfer] transfer 000001cbe7008f70
[ 0.080854] [00005348] libusb: debug [add_to_flying_list] arm timer for timeout in 1000ms (first in line)
[ 0.081402] [00005348] libusb: debug [composite_submit_control_transfer] using interface 0
[ 0.081947] [00005348] libusb: debug [libusb_claim_interface] interface 0
[ 0.082577] [00005348] libusb: debug [winusbx_claim_interface] claimed interface 0
[ 0.083096] [00005348] libusb: debug [windows_assign_endpoints] no endpoints found for interface 0
[ 0.083644] [00005348] libusb: debug [auto_claim] auto-claimed interface 0 for control request
[ 0.084193] [00005348] libusb: debug [winusbx_submit_control_transfer] will use interface 0
[ 0.084794] [00005348] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.085328] [00005348] libusb: debug [handle_events] event sources modified, reallocating event data
[ 0.085131] [00005080] libusb: debug [windows_iocp_thread] transfer 000001cbe7008f70 completed, length 4
[ 0.085823] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() for 2 HANDLEs with timeout in 60000ms
[ 0.088456] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() returned 0
[ 0.091633] [00005348] libusb: debug [handle_event_trigger] event triggered
[ 0.092228] [00005348] libusb: debug [windows_handle_transfer_completion] handling transfer 000001cbe7008f70 completion with errcode 0, length 4
[ 0.092810] [00005348] libusb: debug [libusb_release_interface] interface 0
[ 0.093335] [00005348] libusb: debug [auto_release] auto-released interface 0
[ 0.093840] [00005348] libusb: debug [arm_timer_for_next_timeout] no timeouts, disarming timer
[ 0.094364] [00005348] libusb: debug [usbi_handle_transfer_completion] transfer 000001cbe7008f70 has callback 00007ff969e58d00
[ 0.094893] [00005348] libusb: debug [sync_transfer_cb] actual_length=4
[ 0.095411] [00005348] libusb: debug [libusb_free_transfer] transfer 000001cbe7008f70
[ 0.095924] [00005348] libusb: debug [libusb_submit_transfer] transfer 000001cbe7008f70
[ 0.096407] [00005348] libusb: debug [add_to_flying_list] arm timer for timeout in 1000ms (first in line)
[ 0.096898] [00005348] libusb: debug [composite_submit_control_transfer] using interface 0
[ 0.097399] [00005348] libusb: debug [libusb_claim_interface] interface 0
[ 0.097940] [00005348] libusb: debug [winusbx_claim_interface] claimed interface 0
[ 0.098393] [00005348] libusb: debug [windows_assign_endpoints] no endpoints found for interface 0
[ 0.098881] [00005348] libusb: debug [auto_claim] auto-claimed interface 0 for control request
[ 0.099384] [00005348] libusb: debug [winusbx_submit_control_transfer] will use interface 0
[ 0.099924] [00005348] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.100422] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() for 2 HANDLEs with timeout in 60000ms
[ 0.100947] [00005080] libusb: debug [windows_iocp_thread] transfer 000001cbe7008f70 completed, length 28
[ 0.101464] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() returned 0
[ 0.105718] [00005348] libusb: debug [handle_event_trigger] event triggered
[ 0.106293] [00005348] libusb: debug [windows_handle_transfer_completion] handling transfer 000001cbe7008f70 completion with errcode 0, length 28
[ 0.107084] [00005348] libusb: debug [libusb_release_interface] interface 0
[ 0.107586] [00005348] libusb: debug [auto_release] auto-released interface 0
[ 0.108118] [00005348] libusb: debug [arm_timer_for_next_timeout] no timeouts, disarming timer
[ 0.108611] [00005348] libusb: debug [usbi_handle_transfer_completion] transfer 000001cbe7008f70 has callback 00007ff969e58d00
[ 0.109113] [00005348] libusb: debug [sync_transfer_cb] actual_length=28
[ 0.109591] [00005348] libusb: debug [libusb_free_transfer] transfer 000001cbe7008f70
avrdude_shared.exe: seen device from vendor ->www.fischl.de<-
[ 0.112895] [00005348] libusb: debug [libusb_submit_transfer] transfer 000001cbe7008f70
[ 0.113389] [00005348] libusb: debug [add_to_flying_list] arm timer for timeout in 1000ms (first in line)
[ 0.113904] [00005348] libusb: debug [composite_submit_control_transfer] using interface 0
[ 0.114431] [00005348] libusb: debug [libusb_claim_interface] interface 0
[ 0.115004] [00005348] libusb: debug [winusbx_claim_interface] claimed interface 0
[ 0.115494] [00005348] libusb: debug [windows_assign_endpoints] no endpoints found for interface 0
[ 0.116024] [00005348] libusb: debug [auto_claim] auto-claimed interface 0 for control request
[ 0.116553] [00005348] libusb: debug [winusbx_submit_control_transfer] will use interface 0
[ 0.117107] [00005348] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.117471] [00005080] libusb: debug [windows_iocp_thread] transfer 000001cbe7008f70 completed, length 4
[ 0.117752] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() for 2 HANDLEs with timeout in 60000ms
[ 0.124206] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() returned 0
[ 0.124747] [00005348] libusb: debug [handle_event_trigger] event triggered
[ 0.125310] [00005348] libusb: debug [windows_handle_transfer_completion] handling transfer 000001cbe7008f70 completion with errcode 0, length 4
[ 0.125841] [00005348] libusb: debug [libusb_release_interface] interface 0
[ 0.126365] [00005348] libusb: debug [auto_release] auto-released interface 0
[ 0.126856] [00005348] libusb: debug [arm_timer_for_next_timeout] no timeouts, disarming timer
[ 0.127396] [00005348] libusb: debug [usbi_handle_transfer_completion] transfer 000001cbe7008f70 has callback 00007ff969e58d00
[ 0.127915] [00005348] libusb: debug [sync_transfer_cb] actual_length=4
[ 0.128457] [00005348] libusb: debug [libusb_free_transfer] transfer 000001cbe7008f70
[ 0.129012] [00005348] libusb: debug [libusb_submit_transfer] transfer 000001cbe7008f70
[ 0.129524] [00005348] libusb: debug [add_to_flying_list] arm timer for timeout in 1000ms (first in line)
[ 0.130082] [00005348] libusb: debug [composite_submit_control_transfer] using interface 0
[ 0.130622] [00005348] libusb: debug [libusb_claim_interface] interface 0
[ 0.131184] [00005348] libusb: debug [winusbx_claim_interface] claimed interface 0
[ 0.131663] [00005348] libusb: debug [windows_assign_endpoints] no endpoints found for interface 0
[ 0.132200] [00005348] libusb: debug [auto_claim] auto-claimed interface 0 for control request
[ 0.132715] [00005348] libusb: debug [winusbx_submit_control_transfer] will use interface 0
[ 0.134474] [00005348] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.138750] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() for 2 HANDLEs with timeout in 60000ms
[ 0.135180] [00005080] libusb: debug [windows_iocp_thread] transfer 000001cbe7008f70 completed, length 14
[ 0.139907] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() returned 0
[ 0.140455] [00005348] libusb: debug [handle_event_trigger] event triggered
[ 0.140959] [00005348] libusb: debug [windows_handle_transfer_completion] handling transfer 000001cbe7008f70 completion with errcode 0, length 14
[ 0.141469] [00005348] libusb: debug [libusb_release_interface] interface 0
[ 0.141974] [00005348] libusb: debug [auto_release] auto-released interface 0
[ 0.142481] [00005348] libusb: debug [arm_timer_for_next_timeout] no timeouts, disarming timer
[ 0.143014] [00005348] libusb: debug [usbi_handle_transfer_completion] transfer 000001cbe7008f70 has callback 00007ff969e58d00
[ 0.143512] [00005348] libusb: debug [sync_transfer_cb] actual_length=14
[ 0.144017] [00005348] libusb: debug [libusb_free_transfer] transfer 000001cbe7008f70
avrdude_shared.exe: seen product ->USBasp<-
[ 0.146621] [00005348] libusb: debug [libusb_unref_device] destroy device 1.26
[ 0.147117] [00005348] libusb: debug [libusb_unref_device] destroy device 1.31
[ 0.147602] [00005348] libusb: debug [libusb_unref_device] destroy device 1.29
[ 0.148171] [00005348] libusb: debug [libusb_unref_device] destroy device 1.28
[ 0.148687] [00005348] libusb: debug [libusb_unref_device] destroy device 1.2
                    AVR Part                      : ATmega328P
                    Chip Erase delay              : 9000 us
                    PAGEL                         : PD7
                    BS2                           : PC2
                    RESET disposition             : dedicated
                    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
                                                      Block Poll               Page                       Polled
                      Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                      ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                      flash                  65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
                                                      Block Poll               Page                       Polled
                      Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                      ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                      lfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                                                      Block Poll               Page                       Polled
                      Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                      ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                      hfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                                                      Block Poll               Page                       Polled
                      Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                      ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                      efuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                                                      Block Poll               Page                       Polled
                      Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                      ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                      lock                    0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
                                                      Block Poll               Page                       Polled
                      Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                      ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                      calibration             0     0     0    0 no          1    1      0     0     0 0x00 0x00
                                                      Block Poll               Page                       Polled
                      Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
                      ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
                      signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00

                    Programmer Type : usbasp
                    Description     : USBasp, http://www.fischl.de/usbasp/

avrdude_shared.exe: usbasp_initialize()
avrdude_shared.exe: usbasp_transmit("USBASP_FUNC_GETCAPABILITIES", 0x00, 0x00, 0x00, 0x00)
[ 0.414719] [00005348] libusb: debug [libusb_submit_transfer] transfer 000001cbe7006880
[ 0.415331] [00005348] libusb: debug [add_to_flying_list] arm timer for timeout in 5000ms (first in line)
[ 0.416761] [00005348] libusb: debug [composite_submit_control_transfer] using interface 0
[ 0.417351] [00005348] libusb: debug [libusb_claim_interface] interface 0
[ 0.422437] [00005348] libusb: debug [winusbx_claim_interface] claimed interface 0
[ 0.423059] [00005348] libusb: debug [windows_assign_endpoints] no endpoints found for interface 0
[ 0.423693] [00005348] libusb: debug [auto_claim] auto-claimed interface 0 for control request
[ 0.424321] [00005348] libusb: debug [winusbx_submit_control_transfer] will use interface 0
[ 0.424959] [00005348] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.425463] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() for 2 HANDLEs with timeout in 60000ms
[ 0.425388] [00005080] libusb: debug [windows_iocp_thread] transfer 000001cbe7006880 completed, length 4
[ 0.426555] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() returned 0
[ 0.427045] [00005348] libusb: debug [handle_event_trigger] event triggered
[ 0.427513] [00005348] libusb: debug [windows_handle_transfer_completion] handling transfer 000001cbe7006880 completion with errcode 0, length 4
[ 0.428117] [00005348] libusb: debug [libusb_release_interface] interface 0
[ 0.428698] [00005348] libusb: debug [auto_release] auto-released interface 0
[ 0.429230] [00005348] libusb: debug [arm_timer_for_next_timeout] no timeouts, disarming timer
[ 0.429773] [00005348] libusb: debug [usbi_handle_transfer_completion] transfer 000001cbe7006880 has callback 00007ff969e58d00
[ 0.430300] [00005348] libusb: debug [sync_transfer_cb] actual_length=4
[ 0.430769] [00005348] libusb: debug [libusb_free_transfer] transfer 000001cbe7006880
                    <= [81] [03] [00] [00]
avrdude_shared.exe: usbasp_spi_set_sck_period(0)
avrdude_shared.exe: auto set sck period (because given equals null)
avrdude_shared.exe: usbasp_transmit("USBASP_FUNC_SETISPSCK", 0x00, 0x00, 0x00, 0x00)
[ 0.448929] [00005348] libusb: debug [libusb_submit_transfer] transfer 000001cbe7006880
[ 0.449421] [00005348] libusb: debug [add_to_flying_list] arm timer for timeout in 5000ms (first in line)
[ 0.452900] [00005348] libusb: debug [composite_submit_control_transfer] using interface 0
[ 0.453017] [00005348] libusb: debug [libusb_claim_interface] interface 0
[ 0.453958] [00005348] libusb: debug [winusbx_claim_interface] claimed interface 0
[ 0.454491] [00005348] libusb: debug [windows_assign_endpoints] no endpoints found for interface 0
[ 0.455077] [00005348] libusb: debug [auto_claim] auto-claimed interface 0 for control request
[ 0.455552] [00005348] libusb: debug [winusbx_submit_control_transfer] will use interface 0
[ 0.456106] [00005348] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.456650] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() for 2 HANDLEs with timeout in 60000ms
[ 0.456441] [00005080] libusb: debug [windows_iocp_thread] transfer 000001cbe7006880 completed, length 1
[ 0.457666] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() returned 0
[ 0.458186] [00005348] libusb: debug [handle_event_trigger] event triggered
[ 0.458708] [00005348] libusb: debug [windows_handle_transfer_completion] handling transfer 000001cbe7006880 completion with errcode 0, length 1
[ 0.459202] [00005348] libusb: debug [libusb_release_interface] interface 0
[ 0.459682] [00005348] libusb: debug [auto_release] auto-released interface 0
[ 0.460228] [00005348] libusb: debug [arm_timer_for_next_timeout] no timeouts, disarming timer
[ 0.460766] [00005348] libusb: debug [usbi_handle_transfer_completion] transfer 000001cbe7006880 has callback 00007ff969e58d00
[ 0.461266] [00005348] libusb: debug [sync_transfer_cb] actual_length=1
[ 0.461780] [00005348] libusb: debug [libusb_free_transfer] transfer 000001cbe7006880
                    <= [00]
avrdude_shared.exe: usbasp_transmit("USBASP_FUNC_CONNECT", 0x00, 0x00, 0x00, 0x00)
[ 0.471116] [00005348] libusb: debug [libusb_submit_transfer] transfer 000001cbe7006880
[ 0.471676] [00005348] libusb: debug [add_to_flying_list] arm timer for timeout in 5000ms (first in line)
[ 0.472162] [00005348] libusb: debug [composite_submit_control_transfer] using interface 0
[ 0.472657] [00005348] libusb: debug [libusb_claim_interface] interface 0
[ 0.473173] [00005348] libusb: debug [winusbx_claim_interface] claimed interface 0
[ 0.473624] [00005348] libusb: debug [windows_assign_endpoints] no endpoints found for interface 0
[ 0.473675] [00005348] libusb: debug [auto_claim] auto-claimed interface 0 for control request
[ 0.473751] [00005348] libusb: debug [winusbx_submit_control_transfer] will use interface 0
[ 0.473824] [00005348] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.473878] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() for 2 HANDLEs with timeout in 60000ms
[ 0.474487] [00005080] libusb: debug [windows_iocp_thread] transfer 000001cbe7006880 completed, length 0
[ 0.474547] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() returned 0
[ 0.474600] [00005348] libusb: debug [handle_event_trigger] event triggered
[ 0.474647] [00005348] libusb: debug [windows_handle_transfer_completion] handling transfer 000001cbe7006880 completion with errcode 0, length 0
[ 0.474701] [00005348] libusb: debug [libusb_release_interface] interface 0
[ 0.474750] [00005348] libusb: debug [auto_release] auto-released interface 0
[ 0.474797] [00005348] libusb: debug [arm_timer_for_next_timeout] no timeouts, disarming timer
[ 0.474847] [00005348] libusb: debug [usbi_handle_transfer_completion] transfer 000001cbe7006880 has callback 00007ff969e58d00
[ 0.474900] [00005348] libusb: debug [sync_transfer_cb] actual_length=0
[ 0.474947] [00005348] libusb: debug [libusb_free_transfer] transfer 000001cbe7006880
avrdude_shared.exe: usbasp_program_enable()
avrdude_shared.exe: usbasp_transmit("USBASP_FUNC_ENABLEPROG", 0x00, 0x00, 0x00, 0x00)
[ 0.595943] [00005348] libusb: debug [libusb_submit_transfer] transfer 000001cbe7006880
[ 0.595995] [00005348] libusb: debug [add_to_flying_list] arm timer for timeout in 5000ms (first in line)
[ 0.596060] [00005348] libusb: debug [composite_submit_control_transfer] using interface 0
[ 0.596136] [00005348] libusb: debug [libusb_claim_interface] interface 0
[ 0.596233] [00005348] libusb: debug [winusbx_claim_interface] claimed interface 0
[ 0.596308] [00005348] libusb: debug [windows_assign_endpoints] no endpoints found for interface 0
[ 0.596385] [00005348] libusb: debug [auto_claim] auto-claimed interface 0 for control request
[ 0.596443] [00005348] libusb: debug [winusbx_submit_control_transfer] will use interface 0
[ 0.596528] [00005348] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 0.596604] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() for 2 HANDLEs with timeout in 60000ms
[ 1.611200] [00005080] libusb: debug [windows_iocp_thread] transfer 000001cbe7006880 completed, length 1
[ 1.611427] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() returned 0
[ 1.612405] [00005348] libusb: debug [handle_event_trigger] event triggered
[ 1.612588] [00005348] libusb: debug [windows_handle_transfer_completion] handling transfer 000001cbe7006880 completion with errcode 0, length 1
[ 1.612804] [00005348] libusb: debug [libusb_release_interface] interface 0
[ 1.613003] [00005348] libusb: debug [auto_release] auto-released interface 0
[ 1.613162] [00005348] libusb: debug [arm_timer_for_next_timeout] no timeouts, disarming timer
[ 1.613298] [00005348] libusb: debug [usbi_handle_transfer_completion] transfer 000001cbe7006880 has callback 00007ff969e58d00
[ 1.613385] [00005348] libusb: debug [sync_transfer_cb] actual_length=1
[ 1.613444] [00005348] libusb: debug [libusb_free_transfer] transfer 000001cbe7006880
                    <= [01]
avrdude_shared.exe: error: program enable: target doesn't answer. 1
avrdude_shared.exe: initialization failed, rc=-1
                    Double check connections and try again, or use -F to override
                    this check.

avrdude_shared.exe: usbasp_close()
avrdude_shared.exe: usbasp_transmit("USBASP_FUNC_DISCONNECT", 0x00, 0x00, 0x00, 0x00)
[ 1.630848] [00005348] libusb: debug [libusb_submit_transfer] transfer 000001cbe7006880
[ 1.630894] [00005348] libusb: debug [add_to_flying_list] arm timer for timeout in 5000ms (first in line)
[ 1.630943] [00005348] libusb: debug [composite_submit_control_transfer] using interface 0
[ 1.630986] [00005348] libusb: debug [libusb_claim_interface] interface 0
[ 1.631072] [00005348] libusb: debug [winusbx_claim_interface] claimed interface 0
[ 1.631120] [00005348] libusb: debug [windows_assign_endpoints] no endpoints found for interface 0
[ 1.631165] [00005348] libusb: debug [auto_claim] auto-claimed interface 0 for control request
[ 1.631208] [00005348] libusb: debug [winusbx_submit_control_transfer] will use interface 0
[ 1.631274] [00005348] libusb: debug [libusb_handle_events_timeout_completed] doing our own event handling
[ 1.631321] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() for 2 HANDLEs with timeout in 60000ms
[ 1.631693] [00005080] libusb: debug [windows_iocp_thread] transfer 000001cbe7006880 completed, length 0
[ 1.631763] [00005348] libusb: debug [usbi_wait_for_events] WaitForMultipleObjects() returned 0
[ 1.631809] [00005348] libusb: debug [handle_event_trigger] event triggered
[ 1.631851] [00005348] libusb: debug [windows_handle_transfer_completion] handling transfer 000001cbe7006880 completion with errcode 0, length 0
[ 1.631900] [00005348] libusb: debug [libusb_release_interface] interface 0
[ 1.631944] [00005348] libusb: debug [auto_release] auto-released interface 0
[ 1.631987] [00005348] libusb: debug [arm_timer_for_next_timeout] no timeouts, disarming timer
[ 1.632032] [00005348] libusb: debug [usbi_handle_transfer_completion] transfer 000001cbe7006880 has callback 00007ff969e58d00
[ 1.632080] [00005348] libusb: debug [sync_transfer_cb] actual_length=0
[ 1.632123] [00005348] libusb: debug [libusb_free_transfer] transfer 000001cbe7006880
[ 1.632167] [00005348] libusb: debug [libusb_close]
[ 1.632251] [00005348] libusb: debug [libusb_unref_device] destroy device 1.30
[ 1.632304] [00005348] libusb: debug [libusb_unref_device] destroy device 1.0
[ 1.632351] [00005348] libusb: debug [libusb_exit]
[ 1.632398] [00005080] libusb: debug [windows_iocp_thread] I/O completion thread exiting
[ 1.632750] [00005348] libusb: debug [usbi_remove_event_source] remove HANDLE 0000000000000100
[ 1.632800] [00005348] libusb: debug [usbi_remove_event_source] remove HANDLE 00000000000000fc

avrdude_shared.exe done.  Thank you.

@dioannidis
Copy link
Author

@mariusgreuel

and here is a log using the official avrdude v7 binary :

C:\Users\thouli\Downloads\avrdude-v7.0-windows-x64>avrdude.exe -cusbasp -patmega328p -vvvv
executable_abspath = C:/Users/thouli/Downloads/avrdude-v7.0-windows-x64/avrdude.exe
executable_abspath_len = 62
executable_dirpath = C:/Users/thouli/Downloads/avrdude-v7.0-windows-x64
executable_dirpath_len = 50
sys_config = C:/Users/thouli/Downloads/avrdude-v7.0-windows-x64/avrdude.conf
sys_config_found = true


avrdude.exe: Version 7.0
             Copyright (c) Brian Dean, http://www.bdmicro.com/
             Copyright (c) Joerg Wunsch

             System wide configuration file is "C:/Users/thouli/Downloads/avrdude-v7.0-windows-x64/avrdude.conf"

             Using Port                    : usb
             Using Programmer              : usbasp
avrdude.exe: usbasp_open("usb")
avrdude:[os_find_busses] found bus-0
avrdude:[os_find_busses] found bus-0
avrdude.exe: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp'
avrdude.exe: opening programmer "usbasp" on port "usb" failed

avrdude.exe done.  Thank you.

@dioannidis
Copy link
Author

@mcuee

this part from the libusb msys2 avrdude log

[ 0.416761] [00005348] libusb: debug [composite_submit_control_transfer] using interface 0
[ 0.417351] [00005348] libusb: debug [libusb_claim_interface] interface 0
[ 0.422437] [00005348] libusb: debug [winusbx_claim_interface] claimed interface 0
[ 0.423059] [00005348] libusb: debug [windows_assign_endpoints] no endpoints found for interface 0
[ 0.423693] [00005348] libusb: debug [auto_claim] auto-claimed interface 0 for control request
[ 0.424321] [00005348] libusb: debug [winusbx_submit_control_transfer] will use interface 0

confirms your writing :

For libusb (libusb-win32, libusb-compat-0.1 and libusb-1.0) to work, you need to know the interface number and claim it. I think by default you will claim Interface 0 and then it should work with this particular ubasp USB composite device as well since WinUSB interface is on Interface 0. I am not so sure why avrdude-libwinusb does not work in this case.

@dioannidis
Copy link
Author

dioannidis commented May 18, 2022

Looking at the libwinusb sources I think that, for avrdude to be able to support composite devices with winusb and/or libusb0,

  1. add to the UsbDeviceEnumerator->EnumerateDevices() the functionality to enumerate the usbccgp parent driver and add the device's info to m_devices list to appear as a "regular" device.
  2. create another UsbDriver class for the usbccgp parent driver wrapping the calls to child winusb and/or libusb0 device . That requires of course some changes to UsbDevice class Open() .
  3. switch to libusb and don't use libwinusb ( If one install the winusb driver for his/her device it'll work, no ? ).

What do you guys think ? ( I don't know how much work is needed for the first 2 or time )

@mcuee
Copy link
Collaborator

mcuee commented May 18, 2022

@dioannidis
Before you attempt any fix, let's hear from @mariusgreuel. libwinusb was developed with the following motivation (to support libusb0.sys and WinUSB without using libusb-win32 library or libusb-1.0). I can understand the motivation as there are issues with libusb-1.0's support of libusb0.sys. We at libusb project have since fixed a few issues of libusb0.sys support but there are still other issues remaining due to the lack of Windows developers now.
https://github.com/mariusgreuel/avrdude#support-winusb-devices-via-custom-libusb

@mcuee
Copy link
Collaborator

mcuee commented May 19, 2022

@dioannidis
The best solution to me (win-win for libusb Windows and avrdude Windows) is to improve the support of libusb0.sys support in libusb-1.0.

libusb0.sys support was a bit problematic in libusb-1.0.23 and complete brokern in libusb-1.0.24, we have since fixed some major issues in the following ticket.

There are still issues open.
https://github.com/libusb/libusb/issues?q=is%3Aopen+is%3Aissue+label%3Alibusbk_libusb0

The main reason is that the complexity of libusb Windows and the lack of new developers now that Pete (original author) and Chris (libusb Windows developer after Pete) are not active.

The complexity comes from many places.

  1. To reconcile the Linux philosophy of treating USB composite device as one device, versus Windows philosophy of treating USB composite devices as multiple devices. The enumeration part of libusb-1.0 Windows backend is very complex.

  2. Many backends:
    a) pure WinUSB backend (without using libusbk.dll)
    b) WinUSB, libusb0.sys and libusbk.sys support through libusbk.dll
    c) USB HID backend
    d) usbdk backend

Your No 1 and No 2 proposal of improveing the avrdude-libwinusb is somewhat similar to 1).
I tend to believe that it will require a lot of work.

@mcuee
Copy link
Collaborator

mcuee commented May 19, 2022

@dioannidis
You can try one experiment, just switch the driver of Interface 0 from WinUSB to libusb0.sys using Zadig, and then use the official Windows binary and the MSYS2 binary, I believe both should work.

libusb-win32 uses a very simple enumeration process as it only supports libusb0.sys based devices (and libusbk.sys as libusbk.sys is supposed to be a near-drop-in of libusb0.sys with quite some improvements).

I believe avrdude-libwinusb has similar simple enumeration like libusb-win32 but add WinUSB support. Maybe there is a simpler way to work around USB composite device support as well.

BTW, the original author of libusb-win32 (Stephan Meyer) tried to add WinUSB support to libusb-win32 in 2007. Pete took some of those codes in his work of porting libusb-1.0 to Windows back in Dec 2009/2010.
https://github.com/mcuee/libusb-win32/tree/4cdc120cecdb7b4b1dd967238806527777aee3da/libusb1
https://code.google.com/archive/p/libusb-winusb-wip/source/default/commits

@mcuee
Copy link
Collaborator

mcuee commented May 19, 2022

@dioannidis I think if you want to proceed with improving avrdude-libwinusb, probably you can take some reference from libusbk device enueration codes which is much simpler than libusb-1.0 Windows. It does support all three device driver (libusb0.sys, libusbk.sys and WinUSB). WinUSB is a first class citizen in libusbk project.
https://github.com/mcuee/libusbk/blob/master/libusbK/src/lusbk_device_list.c

@dioannidis
Copy link
Author

@mcuee ;) I'm not scared easily ...

@dioannidis
Copy link
Author

@mcuee

I'm just waiting some feedback from @mariusgreuel . I don't want to start something that it'll take time ( something I don't have ) and in the end it will not be accepted because there was no clear goals ....

@mariusgreuel
Copy link
Contributor

I think by default you will claim Interface 0 and then it should work with this particular ubasp USB composite device as well

Now where you say it, I seem to remember.

If I do will you accept a PR regarding this?

Sure. I have not tried it, but it does not sound to be too difficult to make composite devices work. WinUSB devices that are children of composite devices behave very similar as non-composite WinUSB devices. Windows even makes an effort to rewrite the descriptors, so I think even calls to WinUsb_GetDescriptor() will succeed. If you are lucky, you do not need to interact with the parent USB driver at all, but just need to enumerate the composite WinUSB drivers.

switch to libusb and don't use libwinusb

That would be the easiest way to do it. Note that our MinGW builds always use the stock libusb-1.0 libraries, so you can just grab the nightly builds from https://nightly.link/avrdudes/avrdude/workflows/build/main. Even better, if you could make libusb0.sys work with libusb.

Maybe you need to mention that with the official Windows binary.

Time will tell if there are any real issues with libwinusb. libwinusb is meant for avrdude only, and it had a bunch of known shortcomings compared to libusb, some of which perhaps are even unknown to me. In the long run, I would rather switch to libusb.

@mcuee
Copy link
Collaborator

mcuee commented May 20, 2022

Even better, if you could make libusb0.sys work with libusb.

Indeed. To improve libusb Windows support for libusb0.sys will be great.

Right now libusb project does not have a real Windows developer since Chris Dickens is busy with other things (his last commit was on 2021-02-09 for Linux backend and 2021-02-02 for Windows backend).

Time will tell if there are any real issues with libwinusb. libwinusb is meant for avrdude only, and it had a bunch of known shortcomings compared to libusb, some of which perhaps are even unknown to me. In the long run, I would rather switch to libusb.

That will be great.

@mcuee
Copy link
Collaborator

mcuee commented Jun 2, 2022

@dioannidis Will you still want to fix the avrdude-libwinusb? I see that you have updated your repo to point to the alternative MSYS2 binary.
Ref: https://github.com/dioannidis/usbasp

Pre-built avrdude 6.3 and 6.4, windows executables, if needed, is in the bin\avrdude-winusb directory. For avrdude v7 the official windows binary from avrdudes/avrdude uses libwinusb instead of libusb, which doesn't support composite devices as this firmware implements. Please use the unofficial build from mcuee repo.

@dioannidis
Copy link
Author

dioannidis commented Jun 2, 2022

@mcuee IMHO, I don't think fixing avrdude-libwinusb is the way to go. I'll try to help fixing the libusb0.sys support on libusb so I'm slowly getting familiar with libusb windows code base.

I see that you have updated your repo to point to the alternative MSYS2 binary.

As the alternative MSYS2 avrdude binary works for composite devices, I thought that it'll be useful for the users if they want to use avrdude v7 to get it from there instead of waiting a official new version . If this is an issue I can remove it ...

@mcuee
Copy link
Collaborator

mcuee commented Jun 2, 2022

No issues at all to use my unofficial binary build. You are more than welcome to link to it.

And it is great that you now spend the time trying to improve libusb0.sys support for libusb Windows.

@mcuee
Copy link
Collaborator

mcuee commented Jun 3, 2022

@mariusgreuel @dioannidis
I guess this issue can be closed as this is a known limitation of the official avrdude 7.0 release Windows binary due to the use of avrdude-libwinusb. And there is an easy work-around to use MSYS2 build (from github action or from my unofficial build).

@mcuee
Copy link
Collaborator

mcuee commented Jun 8, 2022

BTW, it seems to me libusb-1.0.26 and libusb0.sys work with avrdude. I have tested avrftdi. I will carry out test with usbasp later.

@mcuee mcuee changed the title avrdude MSVC build with composite device firmware ( usbasp with winusb and hid ) avrdude MSVC build with composite device Jan 20, 2023
@mcuee
Copy link
Collaborator

mcuee commented Jan 20, 2023

@mariusgreuel

This issue becomes more critical now. I find out that it will have issues with more programmers, like Microchip ATtiny817 Xplained Pro.

Using official WIndows avrdude 7.1 binary.

PS C:\work\avr\avrdude_test\avrdude_bin\bin_misc\avrdude-v7.1-windows-x64> .\avrdude -c xplainedpro_updi -p t817
avrdude warning: USB device with VID: 0x03eb and PID: 0x2111 not found
avrdude error: no device found matching VID 0x03eb and PID list: 0x2111
avrdude error: unable to open programmer xplainedpro_updi on port usb

avrdude done.  Thank you.

It has 4 interfaces, first interface is the one avrdude wants to use (EDBG CMSIS-DAP, with WinUSB driver). The 2nd and 3rd interfaces are for the CDC-ACM USB to Serial port. The 4th interface is the EDBG Data Gateway (with WinUSB driver).

No problem with MinGW build.

PS C:\work\avr\avrdude_test\avrdude_bin\bin_misc\avrdude-v7.1-mingw64> .\avrdude -c xplainedpro_updi -p t817
avrdude warning: USB device with VID: 0x03eb and PID: 0x2111 not found

         Vtarget         : 3.34 V
         PDI/UPDI clk    : 1000 kHz

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

avrdude done.  Thank you.

@mcuee mcuee added this to the AVRDUDE 7.2 milestone Jan 20, 2023
@mcuee mcuee changed the title avrdude MSVC build with composite device avrdude MSVC build problem with USB composite device Jan 20, 2023
@mcuee
Copy link
Collaborator

mcuee commented Jan 20, 2023

Luckily there are no issues with those with the first interface as USB HID interface, like ATmega328PB Xplained Mini, ATtiny416 Xpalined Nano and ATtiny104 Xplained Nano.

PICKit 4 and SNAP are also fine.

PS C:\work\avr\avrdude_test\avrdude_bin\bin_misc\avrdude-v7.1-windows-x64> .\avrdude -c xplainedmini -p m328pb

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

avrdude done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin\bin_misc\avrdude-v7.1-windows-x64> .\avrdude -c xplainedmini_updi -p t416

         Vtarget         : 5.00 V

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

avrdude done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin\bin_misc\avrdude-v7.1-windows-x64> .\avrdude -c xplainedmini_tpi -p t104

         Vtarget         : 5.00 V

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

avrdude done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin\bin_misc\avrdude-v7.1-windows-x64> .\avrdude -c pickit4_isp -p m8a

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

avrdude done.  Thank you.

@mariusgreuel
Copy link
Contributor

@mcuee Wow, you sure have a lot of hardware. Thank you for all your testing!

It has 4 interfaces, first interface is the one avrdude wants to use (EDBG CMSIS-DAP, with WinUSB driver)

I thought all EDBG devices were required to use the HID transport. I just looked up the spec and it appears that CMSIS-DAP v2 switched to WinUSB. Got to get this fixed.

@mcuee
Copy link
Collaborator

mcuee commented Jan 21, 2023

Wow, you sure have a lot of hardware. Thank you for all your testing!

Testing facilities we have among myself, @MCUdude and @dl8dtl. You can see that @MCUdude and @dl8dtl have more official Microchip tools than I have. :-)

@mcuee
Copy link
Collaborator

mcuee commented Mar 27, 2023

@mariusgreuel
I add this as part of the AVRDUDE 7.2 milestone. But you can remove this if you feel that this is of lower priority. Thanks.

@mcuee
Copy link
Collaborator

mcuee commented May 12, 2023

@mariusgreuel

I think I made a mistake here. Xplained Pro 817's first interface is still an HID interface. I was testing for Issue #1221 and switched the default HID driver to WinUSB and forgot to switch back. So this is a false alarm for xPlained Pro 817.

PS C:\work\avr\avrdude_test\avrdude_bin\bin_misc\avrdude-v7.1-windows-x64> .\avrdude -c xplainedpro_updi -p t817

         Vtarget         : 3.34 V
         PDI/UPDI clk    : 1000 kHz

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

avrdude done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented May 12, 2023

In this case, I will remove this issue from 7.2 Milestone. The issue is still there but the impact is less.

@mcuee mcuee removed this from the AVRDUDE 7.2 milestone May 12, 2023
@mcuee mcuee changed the title avrdude MSVC build problem with USB composite device avrdude MSVC build problem with USB composite device (avrdude-libusb library issue) Jun 16, 2023
@mcuee
Copy link
Collaborator

mcuee commented Nov 2, 2023

This is probably low priority as there is a simple work-around -- to use MinGW build binary.

@mcuee
Copy link
Collaborator

mcuee commented Jan 30, 2024

This is probably low priority as there is a simple work-around -- to use MinGW build binary.

Other work-around which can use the MSVC build (including official avrdude 7.0/7.1/7.2 Windows binary)

  1. Use other USBASP FW without the extra HID interface.

Example good FW to use.
https://github.com/nerdralph/usbasp

  1. Use Zadig to replace the USB composite parent driver with WinUSB (but this kind of defeat the purpose of the extra HID interface).

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

3 participants