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
@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.
@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:
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
@end deffn
@section Interface Drivers
-@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:
@deffn {Config Command} {cmsis_dap_backend} [@option{auto}|@option{usb_bulk}|@option{hid}]
Specifies how to communicate with the adapter:
/* 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 };
/* 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;
static int cmsis_dap_backend = -1;
static bool swd_mode;
if (cmsis_dap_backend >= 0) {
/* Use forced backend */
backend = cmsis_dap_backends[cmsis_dap_backend];
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];
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;
break;
else
backend = NULL;
free(cmsis_dap_handle->packet_buffer);
free(cmsis_dap_handle);
cmsis_dap_handle = NULL;
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);
for (int i = 0; i < MAX_PENDING_REQUESTS; i++) {
free(pending_fifo[i].transfers);
-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) {
COMMAND_HANDLER(cmsis_dap_handle_backend_command)
{
if (CMD_ARGC == 1) {
.help = "the vendor ID and product ID of the CMSIS-DAP device",
.usage = "(vid pid)*",
},
.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,
{
.name = "cmsis_dap_backend",
.handler = &cmsis_dap_handle_backend_command,
struct cmsis_dap_backend {
const char *name;
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);
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);
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 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;
{
int err;
struct libusb_context *ctx;
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 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;
{
hid_device *dev = NULL;
int i;
eval adapter 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
+}
+
adapter driver cmsis-dap
# Optionally specify the serial number of CMSIS-DAP usb device.
adapter driver cmsis-dap
# Optionally specify the serial number of CMSIS-DAP usb device.
-#cmsis_dap_serial 02200201E6661E601B98E3B9
+# adapter serial 02200201E6661E601B98E3B9