On Tue, Sep 9, 2014 at 12:00 PM, Anders Oleson <[email protected]> wrote: > I have been working with an LPC Link-2 configured with JLink firmware (as > distributed by Segger and LPC). This firmware basically turns the very nice > $20 LPC Link-2 board into a JLink adapter. It is clear to me that Segger had > a hand in this firmware and you can find references to it on their pages as > well as on LPC's pages. > > This adapter has two other firmwares choices - either the proprietary > RedLink firmware which works only with LPC Xpresso or also the CMSIS-DAP > firmware. Since I had even less luck with the CMSIS-DAP firmware and I am > much more familiar with JTAG than SWD, I decided to try to use JLink > firmware because that should be supported with OpenOCD. > > Well, it didn't work. I have found a couple references to OpenOCD not > working with "newer" JLink firmware on this forum, but nothing clear. > > At first I thought it was a hardware problem, but I tested the Segger JLink > proprietary executable on the same system and USB port and cable and it > worked fine. Moreover, after OpenOCD attempted to access the LPC Link-2 > JLink, the Segger software stopped working. > > After a long while with a USB sniffer, I was able to discern the critical > difference between the USB initialization of Segger JLink software vs. > OpenOCD. The problem appears to be that the LPC Link-2 JLink firmware > crashes if the USB "set_configuration" is called more than once. > > On my Ubuntu Linux with libusb 1.0, plugging the device into the system > causes the default configurations to be set. Either the kernel or some user > level service like udev is doing this, not the application. The Segger > software does not call "set_configuration", but OpenOCD tries to reset the > device and then explicitly calls "set_configuration" again, which actually > causes it to happen two more times. This crashes the probe. Clearly what > OpenOCD is doing is "right", but the probe firmware is just stupid. > > I was able to comment out the USB reset and set_configuration from jlink.c > and everything worked beautifully. > > Unfortunately, the firmware is closed-source and is the latest and only > version available. > > So here is the problem: I suspect a few people might be interested in > getting the LPC Link-2 working with OpenOCD because it is such a nice and > yet very cheap JTAG probe. CMSIS-DAP is broken (I may work on that next), > and JLink support is broken too but I know the fix. However, I don't suspect > that the fixes I made will apply to *all* types of JLink, and strongly > suspect they won't. > > So, what I''d like to do is either: > 1. Based on USB ID detect the LPC Link-2 and apply this workaround > or > 2. Add some parameter or command to the jlink adapter so that the TCL config > can control this workaround. > or > 3. Something almost entirely different that 1 or 2 that I haven't thought of > > The problem with this is that I don't know how to do them, and I don't know > what the most acceptable approach would be. I'm leaning toward option 2, > but I am less confident in what would be involved in doing it that way. > > So, I could get a few pointers (especially on how to do option 2) and > suggestions on what people might want to see, I could make a proper patch > for this. > > Until then, I have my own private build that "works", and you all have a > "hint"... >
Actually easy, Option 3 is the best. You can remove the libusb_set_configuration under all OS (using libusb-1.0 API). The only time usb_set_configuration is required is when using libusb-win32 under Windows (libusb-0.1 API). -- Xiaofan ------------------------------------------------------------------------------ Want excitement? Manually upgrade your production database. When you want reliability, choose Perforce Perforce version control. Predictably reliable. http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
