Merge pull request #61 from UweBonnes/master
authortexane <texane@gmail.com>
Wed, 8 Feb 2012 17:00:42 +0000 (09:00 -0800)
committertexane <texane@gmail.com>
Wed, 8 Feb 2012 17:00:42 +0000 (09:00 -0800)
Use stlink-usb also for STLINKV1, Rename flash to st-flash

flash/Makefile
src/stlink-usb.c

index 4914587179b287eb3d4560c06f770313cd955912..5345dcbfdb913a483964c55e6f81e3f2ad4c5910 100644 (file)
@@ -13,7 +13,7 @@ CFLAGS+=`pkg-config --cflags libusb-1.0`
 SRCS=main.c
 OBJS=$(SRCS:.c=.o)
 
-NAME=flash
+NAME=st-flash
 
 all: $(NAME)
 
index 2a82b8837230d6f27df12436ecf633cf47bf0ee4..8f5c6c410c46420166f817bab8e781db8bc64d62 100644 (file)
@@ -127,8 +127,6 @@ ssize_t send_recv(struct stlink_libusb* handle, int terminate,
     }
     
     if ((handle->protocoll == 1) && terminate) {
-        fprintf(stderr, "This is never used....\n");
-        exit(EXIT_FAILURE);
         /* Read the SG reply */
         unsigned char sg_buf[13];
         libusb_fill_bulk_transfer
@@ -157,7 +155,6 @@ static int fill_command
     int i = 0;
     memset(cmd, 0, sizeof (sl->c_buf));
     if(slu->protocoll == 1) {
-        fprintf(stderr, "This is never used....\n");
         cmd[i++] = 'U';
         cmd[i++] = 'S';
         cmd[i++] = 'B';
@@ -636,11 +633,14 @@ stlink_t* stlink_open_usb(const int verbose) {
     
     slu->usb_handle = libusb_open_device_with_vid_pid(slu->libusb_ctx, USB_ST_VID, USB_STLINK_32L_PID);
     if (slu->usb_handle == NULL) {
-               // TODO - free usb context too...
-               WLOG("Couldn't find any ST-Link/V2 devices");
-        goto on_error;
+       slu->usb_handle = libusb_open_device_with_vid_pid(slu->libusb_ctx, USB_ST_VID, USB_STLINK_PID);
+       if (slu->usb_handle == NULL) {
+           WLOG("Couldn't find any ST-Link/V2 devices");
+           goto on_error;
+       }
+       slu->protocoll = 1;
     }
-    
+
     if (libusb_kernel_driver_active(slu->usb_handle, 0) == 1) {
         int r;