From 1d4b252bb16ef823d8e98bd70fc323099033898b Mon Sep 17 00:00:00 2001 From: Marc Schink Date: Wed, 23 Jun 2021 19:39:24 +0200 Subject: drivers/ftdi: Group adapter commands Use a command group 'ftdi' with subcommands instead of individual commands with 'ftdi_' prefix. The old commands are still available for backward compatibility but marked as deprecated. Change-Id: I93a0ae7070226cd2fdea566effeb14a141269de8 Signed-off-by: Marc Schink Reviewed-on: http://openocd.zylin.com/6332 Tested-by: jenkins Reviewed-by: Antonio Borneo --- doc/openocd.texi | 26 ++++++++++++------------ src/jtag/drivers/ftdi.c | 43 ++++++++++++++++++++++++--------------- src/jtag/startup.tcl | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 94 insertions(+), 29 deletions(-) diff --git a/doc/openocd.texi b/doc/openocd.texi index 1eebe14..b495505 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2466,10 +2466,10 @@ configuration files, without the need to patch and rebuild OpenOCD. The driver uses a signal abstraction to enable Tcl configuration files to define outputs for one or several FTDI GPIO. These outputs can then be -controlled using the @command{ftdi_set_signal} command. Special signal names +controlled using the @command{ftdi set_signal} command. Special signal names are reserved for nTRST, nSRST and LED (for blink) so that they, if defined, will be used for their customary purpose. Inputs can be read using the -@command{ftdi_get_signal} command. +@command{ftdi get_signal} command. To support SWD, a signal named SWD_EN must be defined. It is set to 1 when the SWD protocol is selected. When set, the adapter should route the SWDIO pin to @@ -2494,21 +2494,21 @@ signal. The following output buffer configurations are supported: These interfaces have several commands, used to configure the driver before initializing the JTAG scan chain: -@deffn {Config Command} {ftdi_vid_pid} [vid pid]+ +@deffn {Config Command} {ftdi vid_pid} [vid pid]+ The vendor ID and product ID of the adapter. Up to eight [@var{vid}, @var{pid}] pairs may be given, e.g. @example -ftdi_vid_pid 0x0403 0xcff8 0x15ba 0x0003 +ftdi vid_pid 0x0403 0xcff8 0x15ba 0x0003 @end example @end deffn -@deffn {Config Command} {ftdi_device_desc} description +@deffn {Config Command} {ftdi device_desc} description Provides the USB device description (the @emph{iProduct string}) of the adapter. If not specified, the device description is ignored during device selection. @end deffn -@deffn {Config Command} {ftdi_serial} serial-number +@deffn {Config Command} {ftdi serial} serial-number Specifies the @var{serial-number} of the adapter to use, in case the vendor provides unique IDs and more than one adapter is connected to the host. @@ -2517,12 +2517,12 @@ If not specified, serial numbers are not considered. and are not restricted to containing only decimal digits.) @end deffn -@deffn {Config Command} {ftdi_channel} channel +@deffn {Config Command} {ftdi channel} channel Selects the channel of the FTDI device to use for MPSSE operations. Most adapters use the default, channel 0, but there are exceptions. @end deffn -@deffn {Config Command} {ftdi_layout_init} data direction +@deffn {Config Command} {ftdi layout_init} data direction Specifies the initial values of the FTDI GPIO data and direction registers. Each value is a 16-bit number corresponding to the concatenation of the high and low FTDI GPIO registers. The values should be selected based on the @@ -2531,7 +2531,7 @@ minimal impact on the target system. Avoid floating inputs, conflicting outputs and initially asserted reset signals. @end deffn -@deffn {Command} {ftdi_layout_signal} name [@option{-data}|@option{-ndata} data_mask] [@option{-input}|@option{-ninput} input_mask] [@option{-oe}|@option{-noe} oe_mask] [@option{-alias}|@option{-nalias} name] +@deffn {Command} {ftdi layout_signal} name [@option{-data}|@option{-ndata} data_mask] [@option{-input}|@option{-ninput} input_mask] [@option{-oe}|@option{-noe} oe_mask] [@option{-alias}|@option{-nalias} name] Creates a signal with the specified @var{name}, controlled by one or more FTDI GPIO pins via a range of possible buffer connections. The masks are FTDI GPIO register bitmasks to tell the driver the connection and type of the output @@ -2541,7 +2541,7 @@ used with inverting data inputs and @option{-data} with non-inverting inputs. The @option{-oe} (or @option{-noe}) option tells where the output-enable (or not-output-enable) input to the output buffer is connected. The options @option{-input} and @option{-ninput} specify the bitmask for pins to be read -with the method @command{ftdi_get_signal}. +with the method @command{ftdi get_signal}. Both @var{data_mask} and @var{oe_mask} need not be specified. For example, a simple open-collector transistor driver would be specified with @option{-oe} @@ -2562,7 +2562,7 @@ identical (or with data inverted) to an already specified signal @var{name}. @end deffn -@deffn {Command} {ftdi_set_signal} name @option{0}|@option{1}|@option{z} +@deffn {Command} {ftdi set_signal} name @option{0}|@option{1}|@option{z} Set a previously defined signal to the specified level. @itemize @minus @item @option{0}, drive low @@ -2571,11 +2571,11 @@ Set a previously defined signal to the specified level. @end itemize @end deffn -@deffn {Command} {ftdi_get_signal} name +@deffn {Command} {ftdi get_signal} name Get the value of a previously defined signal. @end deffn -@deffn {Command} {ftdi_tdo_sample_edge} @option{rising}|@option{falling} +@deffn {Command} {ftdi tdo_sample_edge} @option{rising}|@option{falling} Configure TCK edge at which the adapter samples the value of the TDO signal Due to signal propagation delays, sampling TDO on rising TCK can become quite diff --git a/src/jtag/drivers/ftdi.c b/src/jtag/drivers/ftdi.c index 1a6ba59..a3d6dac 100644 --- a/src/jtag/drivers/ftdi.c +++ b/src/jtag/drivers/ftdi.c @@ -289,7 +289,7 @@ static int ftdi_speed(int speed) if (!swd_mode && speed >= 10000000 && ftdi_jtag_mode != JTAG_MODE_ALT) LOG_INFO("ftdi: if you experience problems at higher adapter clocks, try " - "the command \"ftdi_tdo_sample_edge falling\""); + "the command \"ftdi tdo_sample_edge falling\""); return ERROR_OK; } @@ -666,7 +666,7 @@ static int ftdi_initialize(void) LOG_DEBUG("ftdi interface using shortest path jtag state transitions"); if (!ftdi_vid[0] && !ftdi_pid[0]) { - LOG_ERROR("Please specify ftdi_vid_pid"); + LOG_ERROR("Please specify ftdi vid_pid"); return ERROR_JTAG_INIT_FAILED; } @@ -730,7 +730,7 @@ COMMAND_HANDLER(ftdi_handle_device_desc_command) free(ftdi_device_desc); ftdi_device_desc = strdup(CMD_ARGV[0]); } else { - LOG_ERROR("expected exactly one argument to ftdi_device_desc "); + LOG_ERROR("expected exactly one argument to ftdi device_desc "); } return ERROR_OK; @@ -897,12 +897,12 @@ COMMAND_HANDLER(ftdi_handle_get_signal_command) COMMAND_HANDLER(ftdi_handle_vid_pid_command) { if (CMD_ARGC > MAX_USB_IDS * 2) { - LOG_WARNING("ignoring extra IDs in ftdi_vid_pid " + LOG_WARNING("ignoring extra IDs in ftdi 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 ftdi_vid_pid configuration directive"); + LOG_WARNING("incomplete ftdi vid_pid configuration directive"); if (CMD_ARGC < 2) return ERROR_COMMAND_SYNTAX_ERROR; /* remove the incomplete trailing id */ @@ -917,7 +917,7 @@ COMMAND_HANDLER(ftdi_handle_vid_pid_command) /* * Explicitly terminate, in case there are multiples instances of - * ftdi_vid_pid. + * ftdi vid_pid. */ ftdi_vid[i >> 1] = ftdi_pid[i >> 1] = 0; @@ -947,30 +947,30 @@ COMMAND_HANDLER(ftdi_handle_tdo_sample_edge_command) return ERROR_OK; } -static const struct command_registration ftdi_command_handlers[] = { +static const struct command_registration ftdi_subcommand_handlers[] = { { - .name = "ftdi_device_desc", + .name = "device_desc", .handler = &ftdi_handle_device_desc_command, .mode = COMMAND_CONFIG, .help = "set the USB device description of the FTDI device", .usage = "description_string", }, { - .name = "ftdi_serial", + .name = "serial", .handler = &ftdi_handle_serial_command, .mode = COMMAND_CONFIG, .help = "set the serial number of the FTDI device", .usage = "serial_string", }, { - .name = "ftdi_channel", + .name = "channel", .handler = &ftdi_handle_channel_command, .mode = COMMAND_CONFIG, .help = "set the channel of the FTDI device that is used as JTAG", .usage = "(0-3)", }, { - .name = "ftdi_layout_init", + .name = "layout_init", .handler = &ftdi_handle_layout_init_command, .mode = COMMAND_CONFIG, .help = "initialize the FTDI GPIO signals used " @@ -978,7 +978,7 @@ static const struct command_registration ftdi_command_handlers[] = { .usage = "data direction", }, { - .name = "ftdi_layout_signal", + .name = "layout_signal", .handler = &ftdi_handle_layout_signal_command, .mode = COMMAND_ANY, .help = "define a signal controlled by one or more FTDI GPIO as data " @@ -986,28 +986,28 @@ static const struct command_registration ftdi_command_handlers[] = { .usage = "name [-data mask|-ndata mask] [-oe mask|-noe mask] [-alias|-nalias name]", }, { - .name = "ftdi_set_signal", + .name = "set_signal", .handler = &ftdi_handle_set_signal_command, .mode = COMMAND_EXEC, .help = "control a layout-specific signal", .usage = "name (1|0|z)", }, { - .name = "ftdi_get_signal", + .name = "get_signal", .handler = &ftdi_handle_get_signal_command, .mode = COMMAND_EXEC, .help = "read the value of a layout-specific signal", .usage = "name", }, { - .name = "ftdi_vid_pid", + .name = "vid_pid", .handler = &ftdi_handle_vid_pid_command, .mode = COMMAND_CONFIG, .help = "the vendor ID and product ID of the FTDI device", .usage = "(vid pid)*", }, { - .name = "ftdi_tdo_sample_edge", + .name = "tdo_sample_edge", .handler = &ftdi_handle_tdo_sample_edge_command, .mode = COMMAND_ANY, .help = "set which TCK clock edge is used for sampling TDO " @@ -1018,6 +1018,17 @@ static const struct command_registration ftdi_command_handlers[] = { COMMAND_REGISTRATION_DONE }; +static const struct command_registration ftdi_command_handlers[] = { + { + .name = "ftdi", + .mode = COMMAND_ANY, + .help = "perform ftdi management", + .chain = ftdi_subcommand_handlers, + .usage = "", + }, + COMMAND_REGISTRATION_DONE +}; + static int create_default_signal(const char *name, uint16_t data_mask) { struct signal *sig = create_signal(name); diff --git a/src/jtag/startup.tcl b/src/jtag/startup.tcl index 3060c5c..472a9f2 100644 --- a/src/jtag/startup.tcl +++ b/src/jtag/startup.tcl @@ -207,4 +207,58 @@ proc "hla newtap" {args} { eval swj_newdap $args } +lappend _telnet_autocomplete_skip ftdi_device_desc +proc ftdi_device_desc args { + echo "DEPRECATED! use 'ftdi device_desc' not 'ftdi_device_desc'" + eval ftdi device_desc $args +} + +lappend _telnet_autocomplete_skip ftdi_serial +proc ftdi_serial args { + echo "DEPRECATED! use 'ftdi serial' not 'ftdi_serial'" + eval ftdi serial $args +} + +lappend _telnet_autocomplete_skip ftdi_channel +proc ftdi_channel args { + echo "DEPRECATED! use 'ftdi channel' not 'ftdi_channel'" + eval ftdi channel $args +} + +lappend _telnet_autocomplete_skip ftdi_layout_init +proc ftdi_layout_init args { + echo "DEPRECATED! use 'ftdi layout_init' not 'ftdi_layout_init'" + eval ftdi layout_init $args +} + +lappend _telnet_autocomplete_skip ftdi_layout_signal +proc ftdi_layout_signal args { + echo "DEPRECATED! use 'ftdi layout_signal' not 'ftdi_layout_signal'" + eval ftdi layout_signal $args +} + +lappend _telnet_autocomplete_skip ftdi_set_signal +proc ftdi_set_signal args { + echo "DEPRECATED! use 'ftdi set_signal' not 'ftdi_set_signal'" + eval ftdi set_signal $args +} + +lappend _telnet_autocomplete_skip ftdi_get_signal +proc ftdi_get_signal args { + echo "DEPRECATED! use 'ftdi get_signal' not 'ftdi_get_signal'" + eval ftdi get_signal $args +} + +lappend _telnet_autocomplete_skip ftdi_vid_pid +proc ftdi_vid_pid args { + echo "DEPRECATED! use 'ftdi vid_pid' not 'ftdi_vid_pid'" + eval ftdi vid_pid $args +} + +lappend _telnet_autocomplete_skip ftdi_tdo_sample_edge +proc ftdi_tdo_sample_edge args { + echo "DEPRECATED! use 'ftdi tdo_sample_edge' not 'ftdi_tdo_sample_edge'" + eval ftdi tdo_sample_edge $args +} + # END MIGRATION AIDS -- cgit v1.1