Skip to content

Commit

Permalink
Merge pull request #883 from petertorelli/master
Browse files Browse the repository at this point in the history
Added more error info to WLOGs during probe.
  • Loading branch information
Nightwalker-87 authored Mar 21, 2020
2 parents c8a2f13 + 60db4e5 commit 6dac7a3
Showing 1 changed file with 10 additions and 6 deletions.
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

0 comments on commit 6dac7a3

Please sign in to comment.