jtag/kitprog: switch to command 'adapter serial'
authorAntonio Borneo <borneo.antonio@gmail.com>
Thu, 7 Oct 2021 20:31:27 +0000 (22:31 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sun, 28 Nov 2021 10:58:14 +0000 (10:58 +0000)
The driver kitprog defines the command 'kitprog_serial' to specify
the serial string of the adapter.

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

Change-Id: I844cb815af01137392b6d12e1b5972fc77ac092d
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6652
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
doc/openocd.texi
src/jtag/drivers/kitprog.c
src/jtag/startup.tcl
tcl/interface/kitprog.cfg

index 5b9d65047b3ca836c430526e6e76dcc4977dcbd2..c36047f07a2d2234024af78b087ecd4d611332e5 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.
+cmsis_dap, ft232r, ftdi, kitprog.
 The following adapters have their own command to specify the serial string:
-hla, jlink, kitprog, presto, st-link, vsllink, xds110.
+hla, jlink, presto, st-link, vsllink, xds110.
 @end deffn
 
 @section Interface Drivers
@@ -2896,11 +2896,6 @@ Indicate that a PSoC acquisition sequence needs to be run during adapter init.
 Please be aware that the acquisition sequence hard-resets the target.
 @end deffn
 
-@deffn {Config Command} {kitprog_serial} serial
-Select a KitProg device by its @var{serial}. If left unspecified, the first
-device detected by OpenOCD will be used.
-@end deffn
-
 @deffn {Command} {kitprog acquire_psoc}
 Run a PSoC acquisition sequence immediately. Typically, this should not be used
 outside of the target-specific configuration scripts since it hard-resets the
index 327bb572db055f03038c92fabcc3a984c7f4ff6f..0c5ccc6a7ee8fbb0237cbdc37dd2102bacd40523 100644 (file)
@@ -39,6 +39,7 @@
 
 #include <hidapi.h>
 
+#include <jtag/adapter.h>
 #include <jtag/interface.h>
 #include <jtag/swd.h>
 #include <jtag/commands.h>
@@ -114,7 +115,6 @@ struct pending_transfer_result {
        void *buffer;
 };
 
-static char *kitprog_serial;
 static bool kitprog_init_acquire_psoc;
 
 static int pending_transfer_count, pending_queue_len;
@@ -230,7 +230,6 @@ static int kitprog_quit(void)
        free(kitprog_handle->packet_buffer);
        free(kitprog_handle->serial);
        free(kitprog_handle);
-       free(kitprog_serial);
        free(pending_transfers);
 
        return ERROR_OK;
@@ -272,7 +271,7 @@ static int kitprog_usb_open(void)
        const uint16_t vids[] = { VID, 0 };
        const uint16_t pids[] = { PID, 0 };
 
-       if (jtag_libusb_open(vids, pids, kitprog_serial,
+       if (jtag_libusb_open(vids, pids, adapter_get_required_serial(),
                        &kitprog_handle->usb_handle, NULL) != ERROR_OK) {
                LOG_ERROR("Failed to open or find the device");
                return ERROR_FAIL;
@@ -851,22 +850,6 @@ COMMAND_HANDLER(kitprog_handle_acquire_psoc_command)
        return retval;
 }
 
-COMMAND_HANDLER(kitprog_handle_serial_command)
-{
-       if (CMD_ARGC == 1) {
-               kitprog_serial = strdup(CMD_ARGV[0]);
-               if (!kitprog_serial) {
-                       LOG_ERROR("Failed to allocate memory for the serial number");
-                       return ERROR_FAIL;
-               }
-       } else {
-               LOG_ERROR("expected exactly one argument to kitprog_serial <serial-number>");
-               return ERROR_FAIL;
-       }
-
-       return ERROR_OK;
-}
-
 COMMAND_HANDLER(kitprog_handle_init_acquire_psoc_command)
 {
        kitprog_init_acquire_psoc = true;
@@ -900,13 +883,6 @@ static const struct command_registration kitprog_command_handlers[] = {
                .usage = "<cmd>",
                .chain = kitprog_subcommand_handlers,
        },
-       {
-               .name = "kitprog_serial",
-               .handler = &kitprog_handle_serial_command,
-               .mode = COMMAND_CONFIG,
-               .help = "set the serial number of the adapter",
-               .usage = "serial_string",
-       },
        {
                .name = "kitprog_init_acquire_psoc",
                .handler = &kitprog_handle_init_acquire_psoc_command,
index b21ddc646affb9d887fb1b2a2d4671b8d6e1081b..75b1bfbdf91e26da06b585cd8c21544ef6bec736 100644 (file)
@@ -759,4 +759,10 @@ proc "ftdi serial" {args} {
        eval adapter serial $args
 }
 
+lappend _telnet_autocomplete_skip kitprog_serial
+proc kitprog_serial args {
+       echo "DEPRECATED! use 'adapter serial' not 'kitprog_serial'"
+       eval adapter serial $args
+}
+
 # END MIGRATION AIDS
index 29fce489bffd7e546f9bc8113710a2600bfd156e..933a054088dbc62d47914e57a8ff2fe1ac23efee 100644 (file)
@@ -9,4 +9,4 @@
 adapter driver kitprog
 
 # Optionally specify the serial number of the KitProg you want to use.
-#kitprog_serial 1926402735485200
+# adapter serial 1926402735485200