-
Notifications
You must be signed in to change notification settings - Fork 139
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
Comments
I have no issues building avrdude 7.0 under MSYS2 by following the wiki instruction. You can try the binary here. The official binary is built with MSVC and it should have support for both WinUSB and libusb0.sys. |
If I look at the FW, Interface 0 is using WinUSB and Interface 1 is HID. 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. |
@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).
|
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 |
@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. |
That is interesting to know. Maybe you need to mention that with the official Windows binary. |
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 |
Correct . I choose the winusb to be interface 0 exactly for this.
You're right. Your binary works out of the box. |
I agree ! A note regarding that this version |
@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 Line 429 in 4601bee
I'll take a look if I can fix this . If I do will you accept a PR regarding this ? |
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. |
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. |
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 :
|
Looking at the libwinusb sources I think that, for avrdude to be able to support composite devices with winusb and/or libusb0,
What do you guys think ? ( I don't know how much work is needed for the first 2 or time ) |
@dioannidis |
@dioannidis 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. 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.
Your No 1 and No 2 proposal of improveing the avrdude-libwinusb is somewhat similar to 1). |
@dioannidis 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. |
@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. |
@mcuee ;) I'm not scared easily ... |
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 .... |
Now where you say it, I seem to remember.
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
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.
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. |
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).
That will be great. |
@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.
|
@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.
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 ... |
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. |
@mariusgreuel @dioannidis |
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. |
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.
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.
|
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.
|
@mcuee Wow, you sure have a lot of hardware. Thank you for all your testing!
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. |
@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.
|
In this case, I will remove this issue from 7.2 Milestone. The issue is still there but the impact is less. |
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)
Example good FW to use.
|
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
and here
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 :
).
I used both -cusbasp and -cusbasp-clone with no success
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 ...
The text was updated successfully, but these errors were encountered: