jtag: add -ir-bypass option to newtap
[openocd.git] / src / jtag / hla / hla_transport.c
1 // SPDX-License-Identifier: GPL-2.0-or-later
2
3 /***************************************************************************
4 * Copyright (C) 2011 by Mathias Kuester *
5 * Mathias Kuester <kesmtp@freenet.de> *
6 * *
7 * Copyright (C) 2012 by Spencer Oliver *
8 * spen@spen-soft.co.uk *
9 ***************************************************************************/
10
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
14
15 /* project specific includes */
16 #include <jtag/interface.h>
17 #include <jtag/tcl.h>
18 #include <transport/transport.h>
19 #include <helper/time_support.h>
20 #include <target/target.h>
21 #include <jtag/hla/hla_transport.h>
22 #include <jtag/hla/hla_interface.h>
23
24 COMMAND_HANDLER(hl_transport_jtag_command)
25 {
26 LOG_DEBUG("hl_transport_jtag_command");
27
28 return ERROR_OK;
29 }
30
31 COMMAND_HANDLER(hl_transport_reset_command)
32 {
33 return hl_interface_init_reset();
34 }
35
36 static const struct command_registration hl_swd_transport_subcommand_handlers[] = {
37 {
38 .name = "newdap",
39 .mode = COMMAND_CONFIG,
40 .handler = handle_jtag_newtap,
41 .help = "declare a new SWD DAP",
42 .usage = "basename dap_type ['-irlen' count] "
43 "['-enable'|'-disable'] "
44 "['-expected_id' number] "
45 "['-ignore-version'] "
46 "['-ignore-bypass'] "
47 "['-ircapture' number] "
48 "['-ir-bypass' number] "
49 "['-mask' number]",
50 },
51 COMMAND_REGISTRATION_DONE
52 };
53
54 static const struct command_registration hl_swd_transport_command_handlers[] = {
55 {
56 .name = "swd",
57 .mode = COMMAND_ANY,
58 .help = "SWD command group",
59 .usage = "",
60 .chain = hl_swd_transport_subcommand_handlers,
61 },
62 COMMAND_REGISTRATION_DONE
63 };
64
65 static const struct command_registration hl_transport_jtag_subcommand_handlers[] = {
66 {
67 .name = "newtap",
68 .mode = COMMAND_CONFIG,
69 .handler = handle_jtag_newtap,
70 .help = "Create a new TAP instance named basename.tap_type, "
71 "and appends it to the scan chain.",
72 .usage = "basename tap_type '-irlen' count "
73 "['-enable'|'-disable'] "
74 "['-expected_id' number] "
75 "['-ignore-version'] "
76 "['-ignore-bypass'] "
77 "['-ircapture' number] "
78 "['-ir-bypass' number] "
79 "['-mask' number]",
80 },
81 {
82 .name = "init",
83 .mode = COMMAND_ANY,
84 .handler = hl_transport_jtag_command,
85 .usage = ""
86 },
87 {
88 .name = "arp_init",
89 .mode = COMMAND_ANY,
90 .handler = hl_transport_jtag_command,
91 .usage = ""
92 },
93 {
94 .name = "arp_init-reset",
95 .mode = COMMAND_ANY,
96 .handler = hl_transport_reset_command,
97 .usage = ""
98 },
99 {
100 .name = "tapisenabled",
101 .mode = COMMAND_EXEC,
102 .handler = handle_jtag_tap_enabler,
103 .help = "Returns a Tcl boolean (0/1) indicating whether "
104 "the TAP is enabled (1) or not (0).",
105 .usage = "tap_name",
106 },
107 {
108 .name = "tapenable",
109 .mode = COMMAND_EXEC,
110 .handler = handle_jtag_tap_enabler,
111 .help = "Try to enable the specified TAP using the "
112 "'tap-enable' TAP event.",
113 .usage = "tap_name",
114 },
115 {
116 .name = "tapdisable",
117 .mode = COMMAND_EXEC,
118 .handler = hl_transport_jtag_command,
119 .usage = "",
120 },
121 {
122 .name = "configure",
123 .mode = COMMAND_EXEC,
124 .handler = hl_transport_jtag_command,
125 .usage = "",
126 },
127 {
128 .name = "cget",
129 .mode = COMMAND_EXEC,
130 .jim_handler = jim_jtag_configure,
131 },
132 {
133 .name = "names",
134 .mode = COMMAND_ANY,
135 .handler = hl_transport_jtag_command,
136 .usage = "",
137 },
138
139 COMMAND_REGISTRATION_DONE
140 };
141
142 static const struct command_registration hl_jtag_transport_command_handlers[] = {
143 {
144 .name = "jtag",
145 .mode = COMMAND_ANY,
146 .help = "perform jtag tap actions",
147 .usage = "",
148 .chain = hl_transport_jtag_subcommand_handlers,
149 },
150 {
151 .name = "jtag_ntrst_delay",
152 .mode = COMMAND_ANY,
153 .handler = hl_transport_jtag_command,
154 .usage = "",
155 },
156 COMMAND_REGISTRATION_DONE
157 };
158
159
160 static int hl_transport_init(struct command_context *cmd_ctx)
161 {
162 LOG_DEBUG("hl_transport_init");
163 struct target *t = get_current_target(cmd_ctx);
164 struct transport *transport;
165 enum hl_transports tr;
166
167 if (!t) {
168 LOG_ERROR("no current target");
169 return ERROR_FAIL;
170 }
171
172 transport = get_current_transport();
173
174 if (!transport) {
175 LOG_ERROR("no transport selected");
176 return ERROR_FAIL;
177 }
178
179 LOG_DEBUG("current transport %s", transport->name);
180
181 /* get selected transport as enum */
182 tr = HL_TRANSPORT_UNKNOWN;
183
184 if (strcmp(transport->name, "hla_swd") == 0)
185 tr = HL_TRANSPORT_SWD;
186 else if (strcmp(transport->name, "hla_jtag") == 0)
187 tr = HL_TRANSPORT_JTAG;
188
189 int retval = hl_interface_open(tr);
190
191 if (retval != ERROR_OK)
192 return retval;
193
194 return hl_interface_init_target(t);
195 }
196
197 static int hl_jtag_transport_select(struct command_context *cmd_ctx)
198 {
199 LOG_DEBUG("hl_jtag_transport_select");
200
201 /* NOTE: interface init must already have been done.
202 * That works with only C code ... no Tcl glue required.
203 */
204
205 return register_commands(cmd_ctx, NULL, hl_jtag_transport_command_handlers);
206 }
207
208 static int hl_swd_transport_select(struct command_context *cmd_ctx)
209 {
210 LOG_DEBUG("hl_swd_transport_select");
211 return register_commands(cmd_ctx, NULL, hl_swd_transport_command_handlers);
212 }
213
214 static struct transport hl_swd_transport = {
215 .name = "hla_swd",
216 .select = hl_swd_transport_select,
217 .init = hl_transport_init,
218 .override_target = hl_interface_override_target,
219 };
220
221 static struct transport hl_jtag_transport = {
222 .name = "hla_jtag",
223 .select = hl_jtag_transport_select,
224 .init = hl_transport_init,
225 .override_target = hl_interface_override_target,
226 };
227
228 const char *hl_transports[] = { "hla_swd", "hla_jtag", NULL };
229
230 static void hl_constructor(void) __attribute__ ((constructor));
231 static void hl_constructor(void)
232 {
233 transport_register(&hl_swd_transport);
234 transport_register(&hl_jtag_transport);
235 }
236
237 bool transport_is_hla(void)
238 {
239 struct transport *t;
240 t = get_current_transport();
241 return t == &hl_swd_transport || t == &hl_jtag_transport;
242 }

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)