swd: Convert API to asynchronous
[openocd.git] / src / jtag / drivers / jlink.c
index ae80eb89b069c721ddab68fc03e0fcc3e9504e0b..632dcee4f072650dbafaf9a7e22b55fa98d03eb1 100644 (file)
  * pid = ( usb_address > 0x4) ? 0x0101 : (0x101 + usb_address)
  */
 
-#define VID 0x1366, 0x1366, 0x1366, 0x1366
-#define PID 0x0101, 0x0102, 0x0103, 0x0104
+#define JLINK_OB_PID  0x0105
 
 #define JLINK_WRITE_ENDPOINT   0x02
 #define JLINK_READ_ENDPOINT            0x81
 
+#define JLINK_OB_WRITE_ENDPOINT        0x06
+#define JLINK_OB_READ_ENDPOINT 0x85
+
 static unsigned int jlink_write_ep = JLINK_WRITE_ENDPOINT;
 static unsigned int jlink_read_ep = JLINK_READ_ENDPOINT;
 static unsigned int jlink_hw_jtag_version = 2;
@@ -246,8 +248,8 @@ static enum tap_state jlink_last_state = TAP_RESET;
 static struct jlink *jlink_handle;
 
 /* pid could be specified at runtime */
-static uint16_t vids[] = { VID, 0 };
-static uint16_t pids[] = { PID, 0 };
+static uint16_t vids[] = { 0x1366, 0x1366, 0x1366, 0x1366, 0x1366, 0 };
+static uint16_t pids[] = { 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0 };
 
 static uint32_t jlink_caps;
 static uint32_t jlink_hw_type;
@@ -464,7 +466,7 @@ static int jlink_select_interface(int iface)
        uint32_t iface_mask = buf_get_u32(usb_in_buffer, 0, 32);
 
        if (!(iface_mask & (1<<iface))) {
-               LOG_ERROR("J-Link requesting to select unsupported interface (%x)", iface_mask);
+               LOG_ERROR("J-Link requesting to select unsupported interface (%" PRIx32 ")", iface_mask);
                return ERROR_JTAG_DEVICE_ERROR;
        }
 
@@ -746,7 +748,7 @@ static void jlink_config_kickstart_dump(struct command_context *ctx, struct jlin
        if (!cfg)
                return;
 
-       jlink_dump_printf(ctx, "Kickstart power on JTAG-pin 19: 0x%x",
+       jlink_dump_printf(ctx, "Kickstart power on JTAG-pin 19: 0x%" PRIx32,
                cfg->kickstart_power_on_jtag_pin_19);
 }
 
@@ -920,7 +922,7 @@ static int jlink_get_version_info(void)
                LOG_INFO("J-Link hw version %i", (int)jlink_hw_version);
 
                if (jlink_hw_type >= JLINK_HW_TYPE_MAX)
-                       LOG_INFO("J-Link hw type uknown 0x%x", jlink_hw_type);
+                       LOG_INFO("J-Link hw type uknown 0x%" PRIx32, jlink_hw_type);
                else
                        LOG_INFO("J-Link hw type %s", jlink_hw_type_str[jlink_hw_type]);
        }
@@ -1428,7 +1430,8 @@ static int jlink_tap_execute(void)
 
        result = use_jtag3 ? usb_in_buffer[byte_length] : 0;
        if (result != 0) {
-               LOG_ERROR("jlink_tap_execute failed, result %d", result);
+               LOG_ERROR("jlink_tap_execute failed, result %d (%s)", result,
+                         result == 1 ? "adaptive clocking timeout" : "unknown");
                jlink_tap_init();
                return ERROR_JTAG_QUEUE_FAILED;
        }
@@ -1517,6 +1520,15 @@ static struct jlink *jlink_usb_open()
        usb_set_altinterface(result->usb_handle, 0);
 #endif
 
+       /* Use the OB endpoints if the JLink we matched is a Jlink-OB adapter */
+       uint16_t matched_pid;
+       if (jtag_libusb_get_pid(udev, &matched_pid) == ERROR_OK) {
+               if (matched_pid == JLINK_OB_PID) {
+                       jlink_read_ep = JLINK_OB_WRITE_ENDPOINT;
+                       jlink_write_ep = JLINK_OB_READ_ENDPOINT;
+               }
+       }
+
        jtag_libusb_get_endpoints(udev, &jlink_read_ep, &jlink_write_ep);
 
        struct jlink *result = malloc(sizeof(struct jlink));

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)