jtag/ft232r: switch to command 'adapter serial' 50/6650/3
authorAntonio Borneo <borneo.antonio@gmail.com>
Thu, 7 Oct 2021 20:25:27 +0000 (22:25 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 28 Nov 2021 10:56:16 +0000 (10:56 +0000)
The driver ft232r defines the command 'ft232r serial_desc' to
specify the serial string of the adapter.

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

Change-Id: I0bd909923a668420604fed3c9f6a260716b044c7
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6650
Tested-by: jenkins
doc/openocd.texi
src/jtag/drivers/ft232r.c
src/jtag/startup.tcl

index 4ce6e0426265c4470c5dcff9cd8641af154039b8..2891f3519c99a62c19cadc9d643e3490cd4a9c2b 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.
+cmsis_dap, ft232r.
 The following adapters have their own command to specify the serial string:
-ft232r, ftdi, hla, jlink, kitprog, presto, st-link, vsllink, xds110.
+ftdi, hla, jlink, kitprog, presto, st-link, vsllink, xds110.
 @end deffn
 
 @section Interface Drivers
@@ -2641,12 +2641,6 @@ The vendor ID and product ID of the adapter. If not specified, default
 0x0403:0x6001 is used.
 @end deffn
 
-@deffn {Config Command} {ft232r serial_desc} @var{serial}
-Specifies the @var{serial} of the adapter to use, in case the
-vendor provides unique IDs and more than one adapter is connected to
-the host. If not specified, serial numbers are not considered.
-@end deffn
-
 @deffn {Config Command} {ft232r jtag_nums} @var{tck} @var{tms} @var{tdi} @var{tdo}
 Set four JTAG GPIO numbers at once.
 If not specified, default 0 3 1 2 or TXD CTS RXD RTS is used.
index 22c0fe5dddf48c3860e4b7c738cfd39361d62a50..fc3cdbae29918798403ab59c42b2fe96b26986e9 100644 (file)
@@ -26,6 +26,7 @@
 #endif
 
 /* project specific includes */
+#include <jtag/adapter.h>
 #include <jtag/interface.h>
 #include <jtag/commands.h>
 #include <helper/time_support.h>
@@ -68,7 +69,6 @@
 
 #define FT232R_BUF_SIZE_EXTRA  4096
 
-static char *ft232r_serial_desc;
 static uint16_t ft232r_vid = 0x0403; /* FTDI */
 static uint16_t ft232r_pid = 0x6001; /* FT232R */
 static struct libusb_device_handle *adapter;
@@ -257,6 +257,7 @@ static int ft232r_init(void)
 {
        uint16_t avids[] = {ft232r_vid, 0};
        uint16_t apids[] = {ft232r_pid, 0};
+       const char *ft232r_serial_desc = adapter_get_required_serial();
        if (jtag_libusb_open(avids, apids, ft232r_serial_desc, &adapter, NULL)) {
                LOG_ERROR("ft232r not found: vid=%04x, pid=%04x, serial=%s\n",
                        ft232r_vid, ft232r_pid, (!ft232r_serial_desc) ? "[any]" : ft232r_serial_desc);
@@ -395,16 +396,6 @@ static int ft232r_bit_name_to_number(const char *name)
        return -1;
 }
 
-COMMAND_HANDLER(ft232r_handle_serial_desc_command)
-{
-       if (CMD_ARGC == 1)
-               ft232r_serial_desc = strdup(CMD_ARGV[0]);
-       else
-               LOG_ERROR("require exactly one argument to "
-                                 "ft232r_serial_desc <serial>");
-       return ERROR_OK;
-}
-
 COMMAND_HANDLER(ft232r_handle_vid_pid_command)
 {
        if (CMD_ARGC > 2) {
@@ -561,13 +552,6 @@ COMMAND_HANDLER(ft232r_handle_restore_serial_command)
 }
 
 static const struct command_registration ft232r_subcommand_handlers[] = {
-       {
-               .name = "serial_desc",
-               .handler = ft232r_handle_serial_desc_command,
-               .mode = COMMAND_CONFIG,
-               .help = "USB serial descriptor of the adapter",
-               .usage = "serial string",
-       },
        {
                .name = "vid_pid",
                .handler = ft232r_handle_vid_pid_command,
index 94030dbc5742d9f04bbcc708cacb5f884d0a056b..b5f4a0298005ba6eea289b27563511bc78328148 100644 (file)
@@ -677,8 +677,8 @@ proc usb_blaster_firmware args {
 
 lappend _telnet_autocomplete_skip ft232r_serial_desc
 proc ft232r_serial_desc args {
-       echo "DEPRECATED! use 'ft232r serial_desc' not 'ft232r_serial_desc'"
-       eval ft232r serial_desc $args
+       echo "DEPRECATED! use 'adapter serial_desc' not 'ft232r_serial_desc'"
+       eval adapter serial_desc $args
 }
 
 lappend _telnet_autocomplete_skip ft232r_vid_pid
@@ -747,4 +747,10 @@ proc cmsis_dap_serial args {
        eval adapter serial $args
 }
 
+lappend _telnet_autocomplete_skip "ft232r serial_desc"
+proc "ft232r serial_desc" {args} {
+       echo "DEPRECATED! use 'adapter serial' not 'ft232r serial_desc'"
+       eval adapter serial $args
+}
+
 # END MIGRATION AIDS

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)