On Thu, Jul 9, 2009 at 8:05 AM, Xiaofan Chen<xiaof...@gmail.com> wrote: > What I am thinking now is that this patch is still strange. Typically > the usb_set_configuration() will solve some problems for some USB > device (say USB toggle bit problems) since it is also a light weight > reset. > > But in case usb_reset() is necessary, it is typically called during the > closing stage. > > An example I wrote before. > http://www.microchip.com/forums/tm.aspx?m=340892 > > That is to say, typically you call these three instruction > when closing the usb_handle (after you finish the operation and > prepare for exit). > > usb_release_interface(devh, 0); > usb_rese(devh); //adding this line makes the program happy > usb_close(devh); > > > Which means in this case: > > static void jlink_usb_close(jlink_jtag_t *jlink_jtag) > { > usb_close(jlink_jtag->usb_handle); > free(jlink_jtag); > } > > becomes > > static void jlink_usb_close(jlink_jtag_t *jlink_jtag) > { > usb_release_interface((jlink_jtag->usb_handle,0); > usb_reset(jlink_jtag->usb_handle); > usb_close(jlink_jtag->usb_handle); > free(jlink_jtag); > } > > Could you try this? > > Personally I observed that normally first launch of OpenOCD is okay > and the subsequent launch of OpenOCD might cause startup problems. > So this indicates that the exit may not be so clean and this leads to > Jlink's initial status in a undesired state which even usb_set_configuration > can not help. > > But if you see the problems even during the first launch, then the above > may not help. >
So I tried this way and generated the following patch. Index: src/jtag/jlink.c =================================================================== --- src/jtag/jlink.c (revision 2503) +++ src/jtag/jlink.c (working copy) @@ -864,15 +864,6 @@ { result->usb_handle = usb_open(dev); - /* - * Some j-link dongles experience intermittent communication issues at startup to varying degrees - * depending on the host operating system. Troubleshooting this problem all the way back to libusb - * revealed that without a usb reset, the hardware can start in an uncertain state causing a litany - * of annoying problems. The next step was added to the original code to address this problem. - */ - - usb_reset(result->usb_handle); - /* usb_set_configuration required under win32 */ usb_set_configuration(result->usb_handle, dev->config[0].bConfigurationValue); usb_claim_interface(result->usb_handle, 0); @@ -908,6 +899,8 @@ static void jlink_usb_close(jlink_jtag_t *jlink_jtag) { + usb_release_interface(jlink_jtag->usb_handle,0); + usb_reset(jlink_jtag->usb_handle); usb_close(jlink_jtag->usb_handle); free(jlink_jtag); } It does help to reduce the initialization error under Ubuntu 9.04, but not completely. So it does not work unfortunately. -- Xiaofan http://mcuee.blogspot.com _______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development