Hello, I posted a similar patch several month ago. I have a JLink version v3.0
To get it to work you have to change several little things. This is just a very ugly hack that somewhat disables support for >=V5 JLinks I'd just be interested if any of you can also get it to work this way... I would like to build a clean version of this patch that doesen't break the rest of the system, but I'd need some more help as I'm not experienced in any openocd/jtag code If you're interested I can explaine all the things that I needed to change... Benjamin Schmidt On Monday 18 May 2009 05:09:06 pm Gene Smith wrote: > Xiaofan Chen wrote: > > On Mon, May 18, 2009 at 9:37 PM, Gene Smith <g...@chartertn.net> wrote: > >> I can't answer your questions but can only add another jlink question. I > >> know very little about the jlink. I have a yellow jlink that says "jlink > >> ks, IAR Systems" on the front (ks = kickstart?). On the back it says > >> J-Link-ARM-KS Serial Number 10001576. No idea of the rev level or > >> processor it contains (it is borrowed). > > > > http://www.segger.com/download_jlink.html > > You can download the beta software for Linux. Here is what I get > > for the V6 Jlink. > > Yes, found it too. > > > mc...@ubuntu904:~/Desktop/build/openocd/jlink$ ./start > > SEGGER J-Link Commander V4.03a ('?' for help) > > Compiled Feb 2 2009 11:34:21 > > Updating firmware: J-Link ARM V6 compiled Jan 15 2009 11:58:34 > > Mine says: Updating firmware: J-Link compiled Feb 20 2006 18:20:20 -- > Update -- > > > Replacing firmware: J-Link ARM V6 compiled Dec 03 2007 17:34:18 > > Mine says: Replacing firmware J-Link compiled Dec 2 2004 09:13:33 > > > Waiting for new firmware to boot > > New firmware booted successfully > > > > ****** Error: Communication timed out after firmware update > > DLL version V4.03a, compiled Feb 2 2009 11:34:13 > > Unable to retrieve firmware info ! > > S/N : 156007287 > > Mine says: S/N : -3 > > WARNING: No matching core found. Selecting default core (ARM7) > > *** Error: could not read hardware status! > JTAG speed: 5 Hhz > J-Link> > > Green LED goes off then *don't* see exactly what you see: > > OEM : IAR > > VTarget = 3.248V > > Info: TotalIRLen = 4, IRPrint = 0x01 > > > > WARNING: Identified core does not match configuration. (Found: ARM7, > > Configured: None) > > Found 1 JTAG device, Total IRLen = 4: > > Id of device #0: 0x4F1F0F0F > > Found ARM with core Id 0x4F1F0F0F (ARM7) > > ETM V1.2: 1 pairs addr.comp, 0 data comp, 4 MM decs, 1 counters > > RTCK reaction time is approx. 126ns > > Using adaptive clocking instead of fixed JTAG speed. > > > >> The evaluation board I am > >> connecting it to is IAR (made by Olimex) STR712 (ARM7TDMI). Should this > >> work with openocd? If so, what is the correct linux/bash command line? > >> It works OK with IAR Embedded Workbench Kickstart for ARM 4.30A on > >> windows. Right now whether the board is powered on or off or even if the > >> jtag cable is connected or not all I see is: > >> > >> sudo ./openocd -f target/interface/jlink -f target/target/str710.cfg > >> > >> Error: J-Link Command 0x01 failed (-2) > >> Error: J-Link command EMU_CMD_VERSION failed (-110) > >> <repeated 3 times> > >> > >> Info : J-Link initial read failed, don't worry <-- actually, need to > >> worry! Info : J-Link JTAG Interface ready > >> Error: J-Link command 0xdd failed (-2) > >> Error: J-Link command 0xdf failed (-2) > >> Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive > >> packet not sent! (9190). Workaround: increase "set remotetimeout" in GDB > >> Error: J-Link setting speed failed (-2) > >> Error: There are no enabled taps? > >> Error: J-Link command 0xdd failed (-2) > >> Error: J-Link command 0xdf failed (-2) > >> Error: usb_bulk_write failed (requested=6, result=-2) > >> Error: jlink_tap_execute, wrong result -107 (expected 1) > >> Error: usb_bulk_write failed (requested=6, result=-2) > >> Error: jlink_tap_execute, wrong result -107 (expected 1) > >> Error: J-Link command 0xdd failed (-2) > >> Error: J-Link command 0xdf failed (-2) > >> Error: usb_bulk_write failed (requested=6, result=-2) > >> Error: jlink_tap_execute, wrong result -107 (expected 1) > >> Error: There are no enabled taps? > >> Warn : no telnet port specified, using default port 4444 > >> Warn : no gdb ports allocated as no target has been specified > >> Warn : no tcl port specified, using default port 6666 > >> Info : accepting 'telnet' connection from 0 > >> Error: J-Link command 0x01 failed (-2) > >> > >> (Then I can telnet but can do nothing useful.) > > > > Similar error message here with latest svn version but it seems to work. > > > > mc...@ubuntu904:~/Desktop/build/openocd/jlinknew$ openocd -f > > openocd_lpc2148.cfg Open On-Chip Debugger 0.2.0-in-development > > (2009-05-18-19:51) svn:1809 > > > > > > BUGS? Read http://svn.berlios.de/svnroot/repos/openocd/trunk/BUGS > > > > > > $URL: svn://svn.berlios.de/openocd/trunk/src/openocd.c $ > > jtag_speed: 15 > > force hard breakpoints > > Error: J-Link command EMU_CMD_VERSION failed (-110) > > But I see three re-tries on this at all fail. Yours seems to only fail > > once. Then yours seems to do useful stuff: > > Info : J-Link ARM V6 compiled Dec 03 2007 17:34:18 > > Info : JLink caps 0xf7fbf > > Info : JLink max mem block 9992 > > Info : Vref = 3.248 TCK = 1 TDI = 0 TDO = 0 TMS = 0 SRST = 1 TRST = 1 > > > > Info : J-Link JTAG Interface ready > > Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive > > packet not sent! (3104). Workaround: increase "set remotetimeout" in > > GDB > > Error: usb_bulk_read failed (requested=1, result=-110) > > Error: jlink_tap_execute, wrong result -107 (expected 1) > > Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive > > packet not sent! (3012). Workaround: increase "set remotetimeout" in > > GDB > > Error: usb_bulk_read failed (requested=1, result=-110) > > Error: jlink_tap_execute, wrong result -107 (expected 1) > > Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive > > packet not sent! (3237). Workaround: increase "set remotetimeout" in > > GDB > > Error: usb_bulk_read failed (requested=1, result=-110) > > Error: jlink_tap_execute, wrong result -107 (expected 1) > > Warn : no tcl port specified, using default port 6666 > > Info : accepting 'telnet' connection from 0 > > TapName | Enabled | IdCode Expected IrLen > > IrCap IrMask Instr > > ---|--------------------|---------|------------|------------|------|----- > >-|------|--------- 0 | lpc2148.cpu | Y | 0x00000000 | > > 0x4f1f0f0f | 0x04 | 0x01 | 0x0f | 0x0f > > > > mc...@ubuntu904:~/Desktop/build/openocd/jlinknew$ telnet localhost 4444 > > Trying ::1... > > Trying 127.0.0.1... > > Connected to localhost. > > Escape character is '^]'. > > Open On-Chip Debugger > > > >> scan_chain > > > > TapName | Enabled | IdCode Expected IrLen > > IrCap IrMask Instr > > ---|--------------------|---------|------------|------------|------|----- > >-|------|--------- 0 | lpc2148.cpu | Y | 0x00000000 | > > 0x4f1f0f0f | 0x04 | 0x01 | 0x0f | 0x0f > > My libusb on my fedora 8 is libusb-0.1.12-10.fc8. Do you think I might > need a newer libusb? That is the last version it updated to. > > _______________________________________________ > Openocd-development mailing list > Openocd-development@lists.berlios.de > https://lists.berlios.de/mailman/listinfo/openocd-development
Index: src/jtag/jlink.c =================================================================== --- src/jtag/jlink.c (revision 1833) +++ src/jtag/jlink.c (working copy) @@ -33,7 +33,7 @@ #define VID 0x1366 #define PID 0x0101 -#define JLINK_WRITE_ENDPOINT 0x02 +#define JLINK_WRITE_ENDPOINT 0x01 #define JLINK_READ_ENDPOINT 0x81 #define JLINK_USB_TIMEOUT 1000 @@ -60,7 +60,7 @@ #define EMU_CMD_HW_CLOCK 0xc8 #define EMU_CMD_HW_TMS0 0xc9 #define EMU_CMD_HW_TMS1 0xca -#define EMU_CMD_HW_JTAG3 0xcf +#define EMU_CMD_HW_JTAG3 0xce #define EMU_CMD_GET_MAX_MEM_BLOCK 0xd4 #define EMU_CMD_HW_RESET0 0xdc #define EMU_CMD_HW_RESET1 0xdd @@ -69,7 +69,7 @@ #define EMU_CMD_GET_CAPS 0xe8 /* max speed 12MHz v5.0 jlink */ -#define JLINK_MAX_SPEED 12000 +#define JLINK_MAX_SPEED 4000 /* External interface functions */ static int jlink_execute_queue(void); @@ -111,15 +111,15 @@ static int jlink_usb_message(jlink_jtag_t *jlink_jtag, int out_length, int in_length); static int jlink_usb_write(jlink_jtag_t *jlink_jtag, int out_length); static int jlink_usb_read(jlink_jtag_t *jlink_jtag, int expected_size); -static int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag); +//static int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag); /* helper functions */ static int jlink_get_version_info(void); -#ifdef _DEBUG_USB_COMMS_ + static void jlink_debug_buffer(u8 *buffer, int length); -#endif + static enum tap_state jlink_last_state = TAP_RESET; static jlink_jtag_t* jlink_jtag_handle; @@ -581,16 +581,17 @@ /* query hardware maximum memory block */ - jlink_simple_command(EMU_CMD_GET_MAX_MEM_BLOCK); + //jlink_simple_command(EMU_CMD_GET_MAX_MEM_BLOCK); - result = jlink_usb_read(jlink_jtag_handle, 4); - if (4 != result) - { - LOG_ERROR("J-Link command EMU_CMD_GET_MAX_MEM_BLOCK failed (%d)\n", result); - return ERROR_JTAG_DEVICE_ERROR; - } + //result = jlink_usb_read(jlink_jtag_handle, 4); + //if (4 != result) + //{ + //LOG_ERROR("J-Link command EMU_CMD_GET_MAX_MEM_BLOCK failed (%d)\n", result); + //return ERROR_JTAG_DEVICE_ERROR; + //} - jlink_max_size = buf_get_u32(usb_in_buffer, 0, 32); + //jlink_max_size = buf_get_u32(usb_in_buffer, 0, 32); + jlink_max_size=32; LOG_INFO("JLink max mem block %i", jlink_max_size); @@ -713,10 +714,10 @@ /* JLink returns an extra NULL in packet when size of in message is a multiple of 64, creates problems with usb comms */ /* WARNING This will interfere with tap state counting */ - while ((TAP_SCAN_BYTES(tap_length)%64)==0) - { - jlink_tap_append_step((tap_get_state() == TAP_RESET)?1:0, 0); - } + //while ((TAP_SCAN_BYTES(tap_length)%64)==0) + //{ + // jlink_tap_append_step((tap_get_state() == TAP_RESET)?1:0, 0); + //} // number of full bytes (plus one if some would be left over) byte_length = TAP_SCAN_BYTES(tap_length); @@ -734,7 +735,7 @@ result = jlink_usb_message(jlink_jtag_handle, 4 + 2 * byte_length, byte_length); if (result != byte_length) { - LOG_ERROR("jlink_tap_execute, wrong result %d (expected %d)", result, byte_length); + DEBUG_JTAG_IO("jlink_tap_execute, wrong result %d (expected %d)", result, byte_length); jlink_tap_init(); return ERROR_JTAG_QUEUE_FAILED; } @@ -754,10 +755,10 @@ DEBUG_JTAG_IO("pending scan result, length = %d", length); -#ifdef _DEBUG_USB_COMMS_ + jlink_debug_buffer(buffer, byte_length); -#endif + if (jtag_read_buffer(buffer, command) != ERROR_OK) { jlink_tap_init(); @@ -854,22 +855,23 @@ if (result == in_length) { /* Must read the result from the EMU too */ - result2 = jlink_usb_read_emu_result(jlink_jtag); - if (1 != result2) - { - LOG_ERROR("jlink_usb_read_emu_result retried requested=1, result=%d, in_length=%i", result2,in_length); - /* Try again once, should only happen if (in_length%64==0) */ - result2 = jlink_usb_read_emu_result(jlink_jtag); - if (1 != result2) - { - LOG_ERROR("jlink_usb_read_emu_result failed " - "(requested=1, result=%d)", result2); - return ERROR_JTAG_DEVICE_ERROR; - } - } + //result2 = jlink_usb_read_emu_result(jlink_jtag); + //if (1 != result2) + //{ + // LOG_ERROR("jlink_usb_read_emu_result retried requested=1, result=%d, in_length=%i", result2,in_length); + // /* Try again once, should only happen if (in_length%64==0) */ + //result2 = jlink_usb_read_emu_result(jlink_jtag); + // if (1 != result2) + // { + // LOG_ERROR("jlink_usb_read_emu_result failed " + // "(requested=1, result=%d)", result2); + // return ERROR_JTAG_DEVICE_ERROR; + // } + //} /* Check the result itself */ - result2 = usb_emu_result_buffer[0]; + //result2 = usb_emu_result_buffer[0]; + result2=0; } else { @@ -962,22 +964,24 @@ return result; } -/* Read the result from the previous EMU cmd into result_buffer. */ -static int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag) -{ - int result = usb_bulk_read_ex(jlink_jtag->usb_handle, JLINK_READ_ENDPOINT, - (char *)usb_emu_result_buffer, 1 /* JLINK_EMU_RESULT_BUFFER_SIZE */, - JLINK_USB_TIMEOUT); - DEBUG_JTAG_IO("jlink_usb_read_result, result = %d", result); -#ifdef _DEBUG_USB_COMMS_ - jlink_debug_buffer(usb_emu_result_buffer, result); -#endif - return result; -} +///* Read the result from the previous EMU cmd into result_buffer. */ +//static int jlink_usb_read_emu_result(jlink_jtag_t *jlink_jtag) +//{ + //int result = usb_bulk_read_ex(jlink_jtag->usb_handle, JLINK_READ_ENDPOINT, +// //(char *)usb_emu_result_buffer, 1 /* JLINK_EMU_RESULT_BUFFER_SIZE */, +// JLINK_USB_TIMEOUT); +// +// DEBUG_JTAG_IO("jlink_usb_read_result, result = %d", result); +// +//#ifdef _DEBUG_USB_COMMS_ +// jlink_debug_buffer(usb_emu_result_buffer, result); +//#endif +// return result; +//} -#ifdef _DEBUG_USB_COMMS_ + #define BYTES_PER_LINE 16 static void jlink_debug_buffer(u8 *buffer, int length) @@ -998,5 +1002,5 @@ LOG_DEBUG("%s", line); } } -#endif +
_______________________________________________ Openocd-development mailing list Openocd-development@lists.berlios.de https://lists.berlios.de/mailman/listinfo/openocd-development