Hi, I hope Nathan (CC'd) can give us additional suggestions here as he is involved in libusb darwin port.
For your convenience, the thread starts at http://article.gmane.org/gmane.comp.debugging.openocd.devel/25696 TIA On Mon, Nov 03, 2014 at 01:33:02PM +0000, Christian Bjørge Thoresen wrote: > On 30/10/14 15:02, "Christian Bjørge Thoresen" <christian.thore...@hbv.no> > wrote: > > > > > >On 30/10/14 14:20, "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. > -- Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software! mailto:fercer...@gmail.com ------------------------------------------------------------------------------ _______________________________________________ OpenOCD-devel mailing list OpenOCD-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openocd-devel