Following patch reads the endpoint numbers from the usb lib device
structure, and it removes some of the extra testing that breaks older
versions of JLink.
This should improve the situation.
Hopefully the same trick works under win and mac os.
Have a nice day
Magnus
Index: src/jtag/jlink.c
===================================================================
--- src/jtag/jlink.c (revision 1834)
+++ src/jtag/jlink.c (working copy)
@@ -36,9 +36,12 @@
#define JLINK_WRITE_ENDPOINT 0x02
#define JLINK_READ_ENDPOINT 0x81
+unsigned int jlink_write_ep = JLINK_WRITE_ENDPOINT;
+unsigned int jlink_read_ep = JLINK_READ_ENDPOINT;
+
#define JLINK_USB_TIMEOUT 1000
-// See Section 1.3.2 of the Segger JLink USB protocol manual
+/* See Section 1.3.2 of the Segger JLink USB protocol manual */
/* 2048 is the max value we can use here */
//#define JLINK_TAP_BUFFER_SIZE 2048
#define JLINK_TAP_BUFFER_SIZE 256
@@ -543,7 +546,7 @@
{
int result;
int len;
- u32 jlink_caps, jlink_max_size;
+ u32 jlink_caps;
/* query hardware version */
jlink_simple_command(EMU_CMD_VERSION);
@@ -579,21 +582,6 @@
jlink_caps = buf_get_u32(usb_in_buffer, 0, 32);
LOG_INFO("JLink caps 0x%x", jlink_caps);
-
- /* query hardware maximum memory 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;
- }
-
- jlink_max_size = buf_get_u32(usb_in_buffer, 0, 32);
- LOG_INFO("JLink max mem block %i", jlink_max_size);
-
-
return ERROR_OK;
}
@@ -661,7 +649,7 @@
int bit_index = tap_length % 8;
u8 bit = 1 << bit_index;
- // we do not pad TMS, so be sure to initialize all bits
+ /* we do not pad TMS, so be sure to initialize all bits */
if (0 == bit_index)
{
tms_buffer[index] = tdi_buffer[index] = 0;
@@ -814,6 +802,24 @@
*/
usb_set_altinterface(result->usb_handle, 0);
#endif
+ int i;
+ for (i =0 ; i<dev->config[0].interface[0].altsetting[0].bNumEndpoints; i++)
+ {
+ u8 epnum = dev->config[0].interface[0].altsetting[0].endpoint[i].bEndpointAddress;
+ {
+ if (epnum&0x80)
+ {
+ LOG_DEBUG("usb ep in %02x",epnum);
+ jlink_read_ep = epnum;
+ }
+ else
+ {
+ LOG_DEBUG("usb ep out %02x",epnum);
+ jlink_write_ep = epnum;
+ }
+ }
+ }
+
return result;
}
}
@@ -937,7 +943,7 @@
return -1;
}
- result = usb_bulk_write_ex(jlink_jtag->usb_handle, JLINK_WRITE_ENDPOINT,
+ result = usb_bulk_write_ex(jlink_jtag->usb_handle, jlink_write_ep,
(char *)usb_out_buffer, out_length, JLINK_USB_TIMEOUT);
DEBUG_JTAG_IO("jlink_usb_write, out_length = %d, result = %d", out_length, result);
@@ -951,7 +957,7 @@
/* Read data from USB into in_buffer. */
static int jlink_usb_read(jlink_jtag_t *jlink_jtag, int expected_size)
{
- int result = usb_bulk_read_ex(jlink_jtag->usb_handle, JLINK_READ_ENDPOINT,
+ int result = usb_bulk_read_ex(jlink_jtag->usb_handle, jlink_read_ep,
(char *)usb_in_buffer, expected_size, JLINK_USB_TIMEOUT);
DEBUG_JTAG_IO("jlink_usb_read, result = %d", result);
@@ -965,7 +971,7 @@
/* 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,
+ int result = usb_bulk_read_ex(jlink_jtag->usb_handle, jlink_read_ep,
(char *)usb_emu_result_buffer, 1 /* JLINK_EMU_RESULT_BUFFER_SIZE */,
JLINK_USB_TIMEOUT);
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development