J-Link serial number config option
[openocd.git] / src / jtag / drivers / jlink.c
index 63580f7f6eca2d92b6352b47b22b61c720a867a1..40665c3e788e3d47c7d6963fafece1a7330dfb38 100644 (file)
@@ -256,6 +256,8 @@ static struct jlink *jlink_handle;
 static uint16_t vids[] = { 0x1366, 0x1366, 0x1366, 0x1366, 0x1366, 0 };
 static uint16_t pids[] = { 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0 };
 
 static uint16_t vids[] = { 0x1366, 0x1366, 0x1366, 0x1366, 0x1366, 0 };
 static uint16_t pids[] = { 0x0101, 0x0102, 0x0103, 0x0104, 0x0105, 0 };
 
+static char *jlink_serial;
+
 static uint32_t jlink_caps;
 static uint32_t jlink_hw_type;
 
 static uint32_t jlink_caps;
 static uint32_t jlink_hw_type;
 
@@ -1019,6 +1021,19 @@ COMMAND_HANDLER(jlink_pid_command)
        return ERROR_OK;
 }
 
        return ERROR_OK;
 }
 
+COMMAND_HANDLER(jlink_serial_command)
+{
+       if (CMD_ARGC != 1) {
+               LOG_ERROR("Need exactly one argument to jlink_serial");
+               return ERROR_FAIL;
+       }
+       if (jlink_serial)
+               free(jlink_serial);
+       jlink_serial = strdup(CMD_ARGV[0]);
+
+       return ERROR_OK;
+}
+
 COMMAND_HANDLER(jlink_handle_jlink_info_command)
 {
        if (jlink_get_version_info() == ERROR_OK) {
 COMMAND_HANDLER(jlink_handle_jlink_info_command)
 {
        if (jlink_get_version_info() == ERROR_OK) {
@@ -1335,6 +1350,12 @@ static const struct command_registration jlink_subcommand_handlers[] = {
                .mode = COMMAND_CONFIG,
                .help = "set the pid of the interface we want to use",
        },
                .mode = COMMAND_CONFIG,
                .help = "set the pid of the interface we want to use",
        },
+       {
+               .name = "serial",
+               .handler = &jlink_serial_command,
+               .mode = COMMAND_CONFIG,
+               .help = "set the serial number of the J-Link adapter we want to use"
+       },
        COMMAND_REGISTRATION_DONE
 };
 
        COMMAND_REGISTRATION_DONE
 };
 
@@ -1744,7 +1765,7 @@ static void jlink_swd_queue_cmd(struct adiv5_dap *dap, uint8_t cmd, uint32_t *ds
 static struct jlink *jlink_usb_open()
 {
        struct jtag_libusb_device_handle *devh;
 static struct jlink *jlink_usb_open()
 {
        struct jtag_libusb_device_handle *devh;
-       if (jtag_libusb_open(vids, pids, NULL, &devh) != ERROR_OK)
+       if (jtag_libusb_open(vids, pids, jlink_serial, &devh) != ERROR_OK)
                return NULL;
 
        /* BE ***VERY CAREFUL*** ABOUT MAKING CHANGES IN THIS
                return NULL;
 
        /* BE ***VERY CAREFUL*** ABOUT MAKING CHANGES IN THIS
@@ -1776,7 +1797,7 @@ static struct jlink *jlink_usb_open()
        /* reopen jlink after usb_reset
         * on win32 this may take a second or two to re-enumerate */
        int retval;
        /* reopen jlink after usb_reset
         * on win32 this may take a second or two to re-enumerate */
        int retval;
-       while ((retval = jtag_libusb_open(vids, pids, NULL, &devh)) != ERROR_OK) {
+       while ((retval = jtag_libusb_open(vids, pids, jlink_serial, &devh)) != ERROR_OK) {
                usleep(1000);
                timeout--;
                if (!timeout)
                usleep(1000);
                timeout--;
                if (!timeout)

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)