On Mon, Nov 3, 2014 at 9:33 PM, Christian Bjørge Thoresen
<christian.thore...@hbv.no> wrote:
>>>Also so far I¹ve never seen the problem after reconnecting the USB cable
>>>to the interface board. My best guess would therefore be that depending
>>>on
>>>the termination of OpenOCD, there may still be a read transfer in the
>>>system which will steal the first data received.
>>
>>Confirmed by terminating OpenOCD properly using the shutdown command
>>instead of just killing the process by Ctrl+C when running from terminal
>>or Terminate when run through debug plugin for eclipse. No problem on next
>>execution experienced when issuing the shutdown command. I see openOCD get
>>exit value -1 when terminated from eclipse.
>
> Would you consider this normal behavior, and rather a bug/missing feature
> of the GNU ARM Eclipse plugin? For robustness I would prefer my debug
> tools to work even after I previously killed its process, or for that
> matter the process of a similar tool making use of the same interface
> board. Thus I looked further into finding a fix for the problem:
> By including a call to libusb_reset_device() in the device initialization
> procedure, I no longer have any problem after terminating by killing
> process. My solution (mpsse.c):
>
>   if (!found) {
>     LOG_ERROR("no device found");
>     return false;
>   }
>
> +
> +   err = libusb_reset_device(ctx->usb_dev);
> +   if (err != LIBUSB_SUCCESS) {
> +     LOG_ERROR("libusb_reset_device() failed with %d", err);
> +     libusb_close(ctx->usb_dev);
> +     return false;
> +   }
>
>   err = libusb_get_config_descriptor(libusb_get_device(ctx->usb_dev), 0,
> &config0);
>
> However I don’t know if calling libusb_reset_device might fail on other
> platforms or systems, where device initialization would otherwise work
> without. If so, a failed reset invalidates the device handle, thus
> open_matching_device() needs to be called again with the usb reset call
> disabled.
>

libusb_reset_device most likely will not work under Windows since
WinUSB driver does not support it.

-- 
Xiaofan

------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://pubads.g.doubleclick.net/gampad/clk?id=154624111&iu=/4140/ostg.clktrk
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to