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

Fix for libusb_kernel_driver_active & error handling for st.st_size #1210

Merged
merged 8 commits into from
Jan 23, 2022
3 changes: 3 additions & 0 deletions src/stlink-lib/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,8 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, enum connect_type connect,

libusb_free_device_list(list, 1);

// libusb_kernel_driver_active is not available on Windows.
#if !defined(_WIN32)
Nightwalker-87 marked this conversation as resolved.
Show resolved Hide resolved
if (libusb_kernel_driver_active(slu->usb_handle, 0) == 1) {
ret = libusb_detach_kernel_driver(slu->usb_handle, 0);

Expand All @@ -1229,6 +1231,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, enum connect_type connect,
goto on_libusb_error;
}
}
#endif

if (libusb_get_configuration(slu->usb_handle, &config)) {
// this may fail for a previous configured device
Expand Down