jtag/drivers/cmsis-dap: Restructure commands

Use a command group 'cmsis-dap' with subcommands instead of individual
commands with 'cmsis_dap_' prefix.

The old commands are still available to ensure backwards compatibility,
but are marked as deprecated.

Change-Id: I75facb7572a86354c2ce6144aa7fadf3b5a6db4e
Signed-off-by: Marc Schink <dev@zapb.de>
Reviewed-on: https://review.openocd.org/c/openocd/+/7963
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
Tested-by: jenkins
Reviewed-by: Bohdan Tymkiv <bohdan200@gmail.com>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Marc Schink 2023-11-06 15:50:40 +01:00 committed by Antonio Borneo
parent bb27677219
commit b25e5322ee
3 changed files with 50 additions and 32 deletions

View File

@ -2543,27 +2543,27 @@ and a specific set of GPIOs is used.
ARM CMSIS-DAP compliant based adapter v1 (USB HID based)
or v2 (USB bulk).
@deffn {Config Command} {cmsis_dap_vid_pid} [vid pid]+
@deffn {Config Command} {cmsis-dap vid_pid} [vid pid]+
The vendor ID and product ID of the CMSIS-DAP device. If not specified
the driver will attempt to auto detect the CMSIS-DAP device.
Currently, up to eight [@var{vid}, @var{pid}] pairs may be given, e.g.
@example
cmsis_dap_vid_pid 0xc251 0xf001 0x0d28 0x0204
cmsis-dap vid_pid 0xc251 0xf001 0x0d28 0x0204
@end example
@end deffn
@deffn {Config Command} {cmsis_dap_backend} [@option{auto}|@option{usb_bulk}|@option{hid}]
@deffn {Config Command} {cmsis-dap backend} [@option{auto}|@option{usb_bulk}|@option{hid}]
Specifies how to communicate with the adapter:
@itemize @minus
@item @option{hid} Use HID generic reports - CMSIS-DAP v1
@item @option{usb_bulk} Use USB bulk - CMSIS-DAP v2
@item @option{auto} First try USB bulk CMSIS-DAP v2, if not found try HID CMSIS-DAP v1.
This is the default if @command{cmsis_dap_backend} is not specified.
This is the default if @command{cmsis-dap backend} is not specified.
@end itemize
@end deffn
@deffn {Config Command} {cmsis_dap_usb interface} [number]
@deffn {Config Command} {cmsis-dap usb interface} [number]
Specifies the @var{number} of the USB interface to use in v2 mode (USB bulk).
In most cases need not to be specified and interfaces are searched by
interface string or for user class interface.

View File

@ -2108,12 +2108,12 @@ COMMAND_HANDLER(cmsis_dap_handle_cmd_command)
COMMAND_HANDLER(cmsis_dap_handle_vid_pid_command)
{
if (CMD_ARGC > MAX_USB_IDS * 2) {
LOG_WARNING("ignoring extra IDs in cmsis_dap_vid_pid "
LOG_WARNING("ignoring extra IDs in cmsis-dap vid_pid "
"(maximum is %d pairs)", MAX_USB_IDS);
CMD_ARGC = MAX_USB_IDS * 2;
}
if (CMD_ARGC < 2 || (CMD_ARGC & 1)) {
LOG_WARNING("incomplete cmsis_dap_vid_pid configuration directive");
LOG_WARNING("incomplete cmsis-dap vid_pid configuration directive");
if (CMD_ARGC < 2)
return ERROR_COMMAND_SYNTAX_ERROR;
/* remove the incomplete trailing id */
@ -2148,10 +2148,10 @@ COMMAND_HANDLER(cmsis_dap_handle_backend_command)
}
}
LOG_ERROR("invalid backend argument to cmsis_dap_backend <backend>");
LOG_ERROR("invalid backend argument to cmsis-dap backend <backend>");
}
} else {
LOG_ERROR("expected exactly one argument to cmsis_dap_backend <backend>");
LOG_ERROR("expected exactly one argument to cmsis-dap backend <backend>");
}
return ERROR_OK;
@ -2172,6 +2172,29 @@ static const struct command_registration cmsis_dap_subcommand_handlers[] = {
.usage = "",
.help = "issue cmsis-dap command",
},
{
.name = "vid_pid",
.handler = &cmsis_dap_handle_vid_pid_command,
.mode = COMMAND_CONFIG,
.help = "the vendor ID and product ID of the CMSIS-DAP device",
.usage = "(vid pid)*",
},
{
.name = "backend",
.handler = &cmsis_dap_handle_backend_command,
.mode = COMMAND_CONFIG,
.help = "set the communication backend to use (USB bulk or HID).",
.usage = "(auto | usb_bulk | hid)",
},
#if BUILD_CMSIS_DAP_USB
{
.name = "usb",
.chain = cmsis_dap_usb_subcommand_handlers,
.mode = COMMAND_ANY,
.help = "USB bulk backend-specific commands",
.usage = "<cmd>",
},
#endif
COMMAND_REGISTRATION_DONE
};
@ -2184,29 +2207,6 @@ static const struct command_registration cmsis_dap_command_handlers[] = {
.usage = "<cmd>",
.chain = cmsis_dap_subcommand_handlers,
},
{
.name = "cmsis_dap_vid_pid",
.handler = &cmsis_dap_handle_vid_pid_command,
.mode = COMMAND_CONFIG,
.help = "the vendor ID and product ID of the CMSIS-DAP device",
.usage = "(vid pid)*",
},
{
.name = "cmsis_dap_backend",
.handler = &cmsis_dap_handle_backend_command,
.mode = COMMAND_CONFIG,
.help = "set the communication backend to use (USB bulk or HID).",
.usage = "(auto | usb_bulk | hid)",
},
#if BUILD_CMSIS_DAP_USB
{
.name = "cmsis_dap_usb",
.chain = cmsis_dap_usb_subcommand_handlers,
.mode = COMMAND_ANY,
.help = "USB bulk backend-specific commands",
.usage = "<cmd>",
},
#endif
COMMAND_REGISTRATION_DONE
};

View File

@ -1108,6 +1108,24 @@ proc "am335xgpio led_on_state" {state} {
}
}
lappend _telnet_autocomplete_skip "cmsis_dap_backend"
proc "cmsis_dap_backend" {backend} {
echo "DEPRECATED! use 'cmsis-dap backend', not 'cmsis_dap_backend'"
eval cmsis-dap backend $backend
}
lappend _telnet_autocomplete_skip "cmsis_dap_vid_pid"
proc "cmsis_dap_vid_pid" {args} {
echo "DEPRECATED! use 'cmsis-dap vid_pid', not 'cmsis_dap_vid_pid'"
eval cmsis-dap vid_pid $args
}
lappend _telnet_autocomplete_skip "cmsis_dap_usb"
proc "cmsis_dap_usb" {args} {
echo "DEPRECATED! use 'cmsis-dap usb', not 'cmsis_dap_usb'"
eval cmsis-dap usb $args
}
lappend _telnet_autocomplete_skip "pld device"
proc "pld device" {driver tap_name {opt 0}} {
echo "DEPRECATED! use 'pld create ...', not 'pld device ...'"