jtag/jlink: switch to command 'adapter serial' 56/6656/4
authorAntonio Borneo <borneo.antonio@gmail.com>
Fri, 8 Oct 2021 09:53:56 +0000 (11:53 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 28 Nov 2021 11:00:55 +0000 (11:00 +0000)
The driver jlink defines the command 'jlink serial' to specify the
serial string of the adapter.

Remove and deprecate the driver command, and use 'adapter serial'.

Note: in former code the commands 'jlink serial' and 'jlink usb'
were mutually exclusive; running one of them would invalidate the
effect of a previous execution of the other. The new code gives
priority to 'adapter serial', even if executed before 'jlink usb'.

Change-Id: I920b0c136716f459b6fd6f7da8a01a7fa1ed389f
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6656
Reviewed-by: zapb <dev@zapb.de>
Tested-by: jenkins
doc/openocd.texi
src/jtag/drivers/jlink.c
src/jtag/startup.tcl
tcl/interface/jlink.cfg

index 78451c71c07fa05e436bd9641fc2d5771c8fad73..58e533f629d3fc14c6b217486263994cedef939d 100644 (file)
@@ -2371,9 +2371,9 @@ This command is only available if your libusb1 is at least version 1.0.16.
 Specifies the @var{serial_string} of the adapter to use.
 If this command is not specified, serial strings are not checked.
 Only the following adapter drivers use the serial string from this command:
-cmsis_dap, ft232r, ftdi, kitprog, presto, vsllink, xds110.
+cmsis_dap, ft232r, ftdi, jlink, kitprog, presto, vsllink, xds110.
 The following adapters have their own command to specify the serial string:
-hla, jlink, st-link.
+hla, st-link.
 @end deffn
 
 @section Interface Drivers
@@ -2848,12 +2848,6 @@ to the host. If not specified, USB addresses are not considered. Device
 selection via USB address is not always unambiguous. It is recommended to use
 the serial number instead, if possible.
 
-As a configuration command, it can be used only before 'init'.
-@end deffn
-@deffn {Config Command} {jlink serial} <serial number>
-Set the serial number of the interface, in case more than one adapter is
-connected to the host. If not specified, serial numbers are not considered.
-
 As a configuration command, it can be used only before 'init'.
 @end deffn
 @end deffn
index 0414ec7103d18574e2f204a6d9c73ba4f0cf9afa..fdf4ae778ddeb7c97ef9bdf0c02236316130066a 100644 (file)
@@ -669,6 +669,23 @@ static int jlink_init(void)
                return ERROR_JTAG_INIT_FAILED;
        }
 
+       const char *serial = adapter_get_required_serial();
+       if (serial) {
+               ret = jaylink_parse_serial_number(serial, &serial_number);
+               if (ret == JAYLINK_ERR) {
+                       LOG_ERROR("Invalid serial number: %s", serial);
+                       jaylink_exit(jayctx);
+                       return ERROR_JTAG_INIT_FAILED;
+               }
+               if (ret != JAYLINK_OK) {
+                       LOG_ERROR("jaylink_parse_serial_number() failed: %s", jaylink_strerror(ret));
+                       jaylink_exit(jayctx);
+                       return ERROR_JTAG_INIT_FAILED;
+               }
+               use_serial_number = true;
+               use_usb_address = false;
+       }
+
        bool found_device;
        ret = jlink_open_device(JAYLINK_HIF_USB, &found_device);
        if (ret != ERROR_OK)
@@ -979,38 +996,11 @@ COMMAND_HANDLER(jlink_usb_command)
 
        usb_address = tmp;
 
-       use_serial_number = false;
        use_usb_address = true;
 
        return ERROR_OK;
 }
 
-COMMAND_HANDLER(jlink_serial_command)
-{
-       int ret;
-
-       if (CMD_ARGC != 1) {
-               command_print(CMD, "Need exactly one argument for jlink serial");
-               return ERROR_COMMAND_SYNTAX_ERROR;
-       }
-
-       ret = jaylink_parse_serial_number(CMD_ARGV[0], &serial_number);
-
-       if (ret == JAYLINK_ERR) {
-               command_print(CMD, "Invalid serial number: %s", CMD_ARGV[0]);
-               return ERROR_FAIL;
-       } else if (ret != JAYLINK_OK) {
-               command_print(CMD, "jaylink_parse_serial_number() failed: %s",
-                       jaylink_strerror(ret));
-               return ERROR_FAIL;
-       }
-
-       use_serial_number = true;
-       use_usb_address = false;
-
-       return ERROR_OK;
-}
-
 COMMAND_HANDLER(jlink_handle_hwstatus_command)
 {
        int ret;
@@ -1932,13 +1922,6 @@ static const struct command_registration jlink_subcommand_handlers[] = {
                .help = "set the USB address of the device that should be used",
                .usage = "<0-3>"
        },
-       {
-               .name = "serial",
-               .handler = &jlink_serial_command,
-               .mode = COMMAND_CONFIG,
-               .help = "set the serial number of the device that should be used",
-               .usage = "<serial number>"
-       },
        {
                .name = "config",
                .handler = &jlink_handle_config_command,
index d6c3b85b42f2f0f5f360e4e7a5a977304fc27bef..199ca04d6164122b7cb65e437b38494b06cec611 100644 (file)
@@ -759,6 +759,12 @@ proc "ftdi serial" {args} {
        eval adapter serial $args
 }
 
+lappend _telnet_autocomplete_skip "jlink serial"
+proc "jlink serial" {args} {
+       echo "DEPRECATED! use 'adapter serial' not 'jlink serial'"
+       eval adapter serial $args
+}
+
 lappend _telnet_autocomplete_skip kitprog_serial
 proc kitprog_serial args {
        echo "DEPRECATED! use 'adapter serial' not 'kitprog_serial'"
index 51f420b7ff6ad74f18c50059f570e27339222877..f9a18b05f4a141c9d2f34b1e7be5f121406464db 100644 (file)
@@ -11,4 +11,4 @@ adapter driver jlink
 #
 # Example: Select J-Link with serial number 123456789
 #
-# jlink serial 123456789
+# adapter serial 123456789

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)