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

Added more error info to WLOGs during probe. #883

Merged
merged 1 commit into from
Mar 21, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions src/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1102,9 +1102,9 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) {
/* Count stlink */
while ((dev = devs[i++]) != NULL) {
struct libusb_device_descriptor desc;
int r = libusb_get_device_descriptor(dev, &desc);
if (r < 0) {
WLOG("failed to get libusb device descriptor\n");
ret = libusb_get_device_descriptor(dev, &desc);
if (ret < 0) {
WLOG("failed to get libusb device descriptor (libusb error: %d)\n", ret);
break;
}

Expand Down Expand Up @@ -1133,7 +1133,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) {
struct libusb_device_descriptor desc;
ret = libusb_get_device_descriptor(dev, &desc);
if (ret < 0) {
WLOG("failed to get libusb device descriptor\n");
WLOG("failed to get libusb device descriptor (libusb error: %d)\n", ret);
break;
}

Expand All @@ -1148,7 +1148,11 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) {

ret = libusb_open(dev, &handle);
if (ret < 0) {
WLOG("failed to get libusb device descriptor\n");
if (ret == LIBUSB_ERROR_ACCESS) {
WLOG("failed to open USB device (LIBUSB_ERROR_ACCESS), try running as root?\n");
} else {
WLOG("failed to open USB device (libusb error: %d)\n", ret);
}
break;
}

Expand All @@ -1159,7 +1163,7 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) {
libusb_close(handle);

stlink_t *sl = NULL;
sl = stlink_open_usb(0, 1, serial);
sl = stlink_open_usb(0, 1, serial);
if (!sl)
continue;

Expand Down