ADAPTER: Fixed transport selection mechanism to support transports other than jtag...
[openocd.git] / src / jtag / adapter.c
index 15b3ddc2c90c7a32ae93e18a3d2540b5a47d03a2..a0cd5e3dabe826617e445dbfcb4840fc95d65c84 100644 (file)
@@ -35,7 +35,7 @@
 #include "minidriver.h"
 #include "interface.h"
 #include "interfaces.h"
-#include "transport.h"
+#include <transport/transport.h>
 
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
@@ -47,8 +47,7 @@
  */
 
 extern struct jtag_interface *jtag_interface;
-
-
+const char *jtag_only[] = { "jtag", NULL };
 
 static int
 jim_adapter_name(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
@@ -101,14 +100,15 @@ COMMAND_HANDLER(interface_transport_command)
        retval = CALL_COMMAND_HANDLER(transport_list_parse, &transports);
        if (retval != ERROR_OK) {
                return retval;
+       }
 
        retval = allow_transports(CMD_CTX, (const char **)transports);
+
        if (retval != ERROR_OK) {
                for (unsigned i = 0; transports[i]; i++)
                        free(transports[i]);
                free(transports);
        }
-       }
        return retval;
 }
 
@@ -129,6 +129,8 @@ COMMAND_HANDLER(handle_interface_list_command)
 
 COMMAND_HANDLER(handle_interface_command)
 {
+       int retval;
+
        /* check whether the interface is already configured */
        if (jtag_interface)
        {
@@ -147,7 +149,7 @@ COMMAND_HANDLER(handle_interface_command)
 
                if (NULL != jtag_interfaces[i]->commands)
                {
-                       int retval = register_commands(CMD_CTX, NULL,
+                       retval = register_commands(CMD_CTX, NULL,
                                        jtag_interfaces[i]->commands);
                        if (ERROR_OK != retval)
                                return retval;
@@ -155,6 +157,19 @@ COMMAND_HANDLER(handle_interface_command)
 
                jtag_interface = jtag_interfaces[i];
 
+       /* LEGACY SUPPORT ... adapter drivers  must declare what
+        * transports they allow.  Until they all do so, assume
+        * the legacy drivers are JTAG-only
+        */
+       if (!jtag_interface->transports)
+               LOG_WARNING("Adapter driver '%s' did not declare "
+                       "which transports it allows; assuming "
+                       "legacy JTAG-only", jtag_interface->name);
+               retval = allow_transports(CMD_CTX, jtag_interface->transports
+                                               ? jtag_interface->transports : jtag_only);
+                       if (ERROR_OK != retval)
+                               return retval;
+
                if (jtag_interface->khz == NULL)
                        jtag_interface->khz = default_khz;
                if (jtag_interface->speed_div == NULL)
@@ -170,7 +185,8 @@ COMMAND_HANDLER(handle_interface_command)
        /* no valid interface was found (i.e. the configuration option,
         * didn't match one of the compiled-in interfaces
         */
-       LOG_ERROR("The specified debug interface was not found (%s)", CMD_ARGV[0]);
+       LOG_ERROR("The specified debug interface was not found (%s)",
+                               CMD_ARGV[0]);
        CALL_COMMAND_HANDLER(handle_interface_list_command);
        return ERROR_JTAG_INVALID_INTERFACE;
 }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)