@end quotation
@end deffn
+@anchor{hla_interface}
@deffn {Interface Driver} {hla}
This is a driver that supports multiple High Level Adapters.
This type of adapter does not expose some of the lower level api's
version of OpenOCD.
@end deffn
-@deffn Command {transport select} transport_name
+@deffn Command {transport select} @option{transport_name}
Select which of the supported transports to use in this OpenOCD session.
-The transport must be supported by the debug adapter hardware and by the
-version of OpenOCD you are using (including the adapter's driver).
-No arguments: returns name of session's selected transport.
+
+When invoked with @option{transport_name}, attempts to select the named
+transport. The transport must be supported by the debug adapter
+hardware and by the version of OpenOCD you are using (including the
+adapter's driver).
+
+If no transport has been selected and no @option{transport_name} is
+provided, @command{transport select} auto-selects the first transport
+supported by the debug adapter.
+
+@command{transport select} always returns the name of the session's selected
+transport, if any.
@end deffn
@subsection JTAG Transport
each of which must be explicitly declared.
JTAG supports both debugging and boundary scan testing.
Flash programming support is built on top of debug support.
+
+JTAG transport is selected with the command @command{transport select
+jtag}. Unless your adapter uses @ref{hla_interface,the hla interface
+driver}, in which case the command is @command{transport select
+hla_jtag}.
+
@subsection SWD Transport
@cindex SWD
@cindex Serial Wire Debug
SWD is debug-oriented, and does not support boundary scan testing.
Flash programming support is built on top of debug support.
(Some processors support both JTAG and SWD.)
+
+SWD transport is selected with the command @command{transport select
+swd}. Unless your adapter uses @ref{hla_interface,the hla interface
+driver}, in which case the command is @command{transport select
+hla_swd}.
+
@deffn Command {swd newdap} ...
Declares a single DAP which uses SWD transport.
Parameters are currently the same as "jtag newtap" but this is
No parameters: displays current settings.
@end deffn
-@subsection CMSIS-DAP Transport
-@cindex CMSIS-DAP
-CMSIS-DAP is an ARM-specific transport that is used to connect to
-compilant debuggers.
-
@subsection SPI Transport
@cindex SPI
@cindex Serial Peripheral Interface
*/
static int jim_transport_select(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
{
+ int res;
switch (argc) {
- case 1: /* return/display */
+ case 1: /* autoselect if necessary, then return/display current config */
if (!session) {
- LOG_ERROR("session transport was not selected. Use 'transport select <transport>'");
- return JIM_ERR;
- } else {
- Jim_SetResultString(interp, session->name, -1);
- return JIM_OK;
+ if (!allowed_transports) {
+ LOG_ERROR("Debug adapter does not support any transports? Check config file order.");
+ return JIM_ERR;
+ }
+ LOG_INFO("auto-selecting first available session transport \"%s\". "
+ "To override use 'transport select <transport>'.", allowed_transports[0]);
+ res = transport_select(global_cmd_ctx, allowed_transports[0]);
+ if (res != JIM_OK)
+ return res;
}
+ Jim_SetResultString(interp, session->name, -1);
+ return JIM_OK;
break;
- case 2: /* assign */
+ case 2: /* assign */
if (session) {
if (!strcmp(session->name, argv[1]->bytes)) {
LOG_WARNING("Transport \"%s\" was already selected", session->name);
+ Jim_SetResultString(interp, session->name, -1);
return JIM_OK;
} else {
LOG_ERROR("Can't change session's transport after the initial selection was made");
for (unsigned i = 0; allowed_transports[i]; i++) {
- if (strcmp(allowed_transports[i], argv[1]->bytes) == 0)
- return transport_select(global_cmd_ctx, argv[1]->bytes);
+ if (strcmp(allowed_transports[i], argv[1]->bytes) == 0) {
+ if (transport_select(global_cmd_ctx, argv[1]->bytes) == ERROR_OK) {
+ Jim_SetResultString(interp, session->name, -1);
+ return JIM_OK;
+ }
+ return JIM_ERR;
+ }
}
LOG_ERROR("Debug adapter doesn't support '%s' transport", argv[1]->bytes);