jtag/cmsis_dap: switch to command 'adapter serial' 49/6649/3
authorAntonio Borneo <borneo.antonio@gmail.com>
Thu, 7 Oct 2021 17:42:54 +0000 (19:42 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 28 Nov 2021 10:55:49 +0000 (10:55 +0000)
The driver cmsis_dap defines the command 'cmsis_dap_serial' to
specify the serial string of the adapter.

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

Change-Id: I88e2d4de360a6c6f23529bb18494962a267250df
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6649
Tested-by: jenkins
doc/openocd.texi
src/jtag/drivers/cmsis_dap.c
src/jtag/drivers/cmsis_dap.h
src/jtag/drivers/cmsis_dap_usb_bulk.c
src/jtag/drivers/cmsis_dap_usb_hid.c
src/jtag/startup.tcl
tcl/interface/cmsis-dap.cfg

index 286943643798e9a8017a0d9e7476be39ac851dea..4ce6e0426265c4470c5dcff9cd8641af154039b8 100644 (file)
@@ -2370,9 +2370,10 @@ This command is only available if your libusb1 is at least version 1.0.16.
 @deffn {Config Command} {adapter serial} serial_string
 Specifies the @var{serial_string} of the adapter to use.
 If this command is not specified, serial strings are not checked.
-No adapter uses this command, so far.
+Only the following adapter drivers use the serial string from this command:
+cmsis_dap.
 The following adapters have their own command to specify the serial string:
-cmsis_dap, ft232r, ftdi, hla, jlink, kitprog, presto, st-link, vsllink, xds110.
+ft232r, ftdi, hla, jlink, kitprog, presto, st-link, vsllink, xds110.
 @end deffn
 
 @section Interface Drivers
@@ -2427,11 +2428,6 @@ cmsis_dap_vid_pid 0xc251 0xf001 0x0d28 0x0204
 @end example
 @end deffn
 
-@deffn {Config Command} {cmsis_dap_serial} [serial]
-Specifies the @var{serial} of the CMSIS-DAP device to use.
-If not specified, serial numbers are not considered.
-@end deffn
-
 @deffn {Config Command} {cmsis_dap_backend} [@option{auto}|@option{usb_bulk}|@option{hid}]
 Specifies how to communicate with the adapter:
 
index c0898fc30c50c2f07006870a4dafca195743bd88..e7562d0877c924b34774a2ca4e07cd87614bb93a 100644 (file)
@@ -76,7 +76,6 @@ static const struct cmsis_dap_backend *const cmsis_dap_backends[] = {
 /* vid = pid = 0 marks the end of the list */
 static uint16_t cmsis_dap_vid[MAX_USB_IDS + 1] = { 0 };
 static uint16_t cmsis_dap_pid[MAX_USB_IDS + 1] = { 0 };
-static char *cmsis_dap_serial;
 static int cmsis_dap_backend = -1;
 static bool swd_mode;
 
@@ -289,13 +288,13 @@ static int cmsis_dap_open(void)
        if (cmsis_dap_backend >= 0) {
                /* Use forced backend */
                backend = cmsis_dap_backends[cmsis_dap_backend];
-               if (backend->open(dap, cmsis_dap_vid, cmsis_dap_pid, cmsis_dap_serial) != ERROR_OK)
+               if (backend->open(dap, cmsis_dap_vid, cmsis_dap_pid, adapter_get_required_serial()) != ERROR_OK)
                        backend = NULL;
        } else {
                /* Try all backends */
                for (unsigned int i = 0; i < ARRAY_SIZE(cmsis_dap_backends); i++) {
                        backend = cmsis_dap_backends[i];
-                       if (backend->open(dap, cmsis_dap_vid, cmsis_dap_pid, cmsis_dap_serial) == ERROR_OK)
+                       if (backend->open(dap, cmsis_dap_vid, cmsis_dap_pid, adapter_get_required_serial()) == ERROR_OK)
                                break;
                        else
                                backend = NULL;
@@ -325,8 +324,6 @@ static void cmsis_dap_close(struct cmsis_dap *dap)
        free(cmsis_dap_handle->packet_buffer);
        free(cmsis_dap_handle);
        cmsis_dap_handle = NULL;
-       free(cmsis_dap_serial);
-       cmsis_dap_serial = NULL;
 
        for (int i = 0; i < MAX_PENDING_REQUESTS; i++) {
                free(pending_fifo[i].transfers);
@@ -2056,16 +2053,6 @@ COMMAND_HANDLER(cmsis_dap_handle_vid_pid_command)
        return ERROR_OK;
 }
 
-COMMAND_HANDLER(cmsis_dap_handle_serial_command)
-{
-       if (CMD_ARGC == 1)
-               cmsis_dap_serial = strdup(CMD_ARGV[0]);
-       else
-               LOG_ERROR("expected exactly one argument to cmsis_dap_serial <serial-number>");
-
-       return ERROR_OK;
-}
-
 COMMAND_HANDLER(cmsis_dap_handle_backend_command)
 {
        if (CMD_ARGC == 1) {
@@ -2122,13 +2109,6 @@ static const struct command_registration cmsis_dap_command_handlers[] = {
                .help = "the vendor ID and product ID of the CMSIS-DAP device",
                .usage = "(vid pid)*",
        },
-       {
-               .name = "cmsis_dap_serial",
-               .handler = &cmsis_dap_handle_serial_command,
-               .mode = COMMAND_CONFIG,
-               .help = "set the serial number of the adapter",
-               .usage = "serial_string",
-       },
        {
                .name = "cmsis_dap_backend",
                .handler = &cmsis_dap_handle_backend_command,
index f6d9df21b377f7a7ed0e6baeb3c923fda93d727a..7c64d492c8bd0f53616b9e5bd332bb211f7ff784 100644 (file)
@@ -24,7 +24,7 @@ struct cmsis_dap {
 
 struct cmsis_dap_backend {
        const char *name;
-       int (*open)(struct cmsis_dap *dap, uint16_t vids[], uint16_t pids[], char *serial);
+       int (*open)(struct cmsis_dap *dap, uint16_t vids[], uint16_t pids[], const char *serial);
        void (*close)(struct cmsis_dap *dap);
        int (*read)(struct cmsis_dap *dap, int timeout_ms);
        int (*write)(struct cmsis_dap *dap, int len, int timeout_ms);
index 26c6784f962c7e1451281b4e81c8d6fee4cc6f30..819596b21598793b1a16a4af882a5791629f9c41 100644 (file)
@@ -55,7 +55,7 @@ static int cmsis_dap_usb_interface = -1;
 static void cmsis_dap_usb_close(struct cmsis_dap *dap);
 static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz);
 
-static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t pids[], char *serial)
+static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t pids[], const char *serial)
 {
        int err;
        struct libusb_context *ctx;
index 5bb8ee8b1c3e90476cbfb43525f3ba4754197b3a..912ba3972fa9cf4117403450bee3df2c89b48f22 100644 (file)
@@ -48,7 +48,7 @@ struct cmsis_dap_backend_data {
 static void cmsis_dap_hid_close(struct cmsis_dap *dap);
 static int cmsis_dap_hid_alloc(struct cmsis_dap *dap, unsigned int pkt_sz);
 
-static int cmsis_dap_hid_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t pids[], char *serial)
+static int cmsis_dap_hid_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t pids[], const char *serial)
 {
        hid_device *dev = NULL;
        int i;
index b6c185ef247f2695f6add06a7ab7f7e5722dddf4..94030dbc5742d9f04bbcc708cacb5f884d0a056b 100644 (file)
@@ -741,4 +741,10 @@ proc "aice serial" {args} {
        eval adapter serial $args
 }
 
+lappend _telnet_autocomplete_skip cmsis_dap_serial
+proc cmsis_dap_serial args {
+       echo "DEPRECATED! use 'adapter serial' not 'cmsis_dap_serial'"
+       eval adapter serial $args
+}
+
 # END MIGRATION AIDS
index 887d2d713417707c1819d0dc1828db109f557567..1bc91a52705fc3b564c9118c28ab7b0462605cf2 100644 (file)
@@ -7,4 +7,4 @@
 adapter driver cmsis-dap
 
 # Optionally specify the serial number of CMSIS-DAP usb device.
-#cmsis_dap_serial 02200201E6661E601B98E3B9
+# adapter serial 02200201E6661E601B98E3B9

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)