Align loader to 32-bit boundary
[fw/stlink] / src / stlink-usb.c
index 24f9769880fc9f3303fd0350db2b02d6e28b99ba..98654129eccdca57b5a20ebaca2b5d525f48d873 100644 (file)
@@ -743,6 +743,10 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[16
     int devBus =0;
     int devAddr=0;
 
+    /* @TODO: Reading a environment variable in a usb open function is not very nice, this
+      should be refactored and moved into the CLI tools, and instead of giving USB_BUS:USB_ADDR a real stlink
+      serial string should be passed to this function. Probably people are using this but this is very odd because
+      as programmer can change to multiple busses and it is better to detect them based on serial.  */
     char *device = getenv("STLINK_DEVICE");
     if (device) {
         char *c = strchr(device,':');
@@ -832,7 +836,7 @@ stlink_t *stlink_open_usb(enum ugly_loglevel verbose, bool reset, char serial[16
     }
 
     if (libusb_claim_interface(slu->usb_handle, 0)) {
-        WLOG("libusb_claim_interface() failed\n");
+        WLOG("Stlink usb device found, but unable to claim (probably already in use?)\n");
         goto on_libusb_error;
     }
 
@@ -940,8 +944,10 @@ static size_t stlink_probe_usb_devs(libusb_device **devs, stlink_t **sldevs[]) {
             WLOG("failed to get libusb device descriptor\n");
             break;
         }
+
         ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, (unsigned char *)&serial, sizeof(serial));
-       if (ret < 0) *serial = 0;
+        if (ret < 0)
+          *serial = NULL;
 
         libusb_close(handle);