tcl/target: use command 'jtag newtap' to add a boundary scan TAP
[openocd.git] / src / jtag / hla / hla_transport.c
1 /***************************************************************************
2 * Copyright (C) 2011 by Mathias Kuester *
3 * Mathias Kuester <kesmtp@freenet.de> *
4 * *
5 * Copyright (C) 2012 by Spencer Oliver *
6 * spen@spen-soft.co.uk *
7 * *
8 * This program is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU General Public License as published by *
10 * the Free Software Foundation; either version 2 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This program is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
20 ***************************************************************************/
21
22 #ifdef HAVE_CONFIG_H
23 #include "config.h"
24 #endif
25
26 /* project specific includes */
27 #include <jtag/interface.h>
28 #include <jtag/tcl.h>
29 #include <transport/transport.h>
30 #include <helper/time_support.h>
31 #include <target/target.h>
32 #include <jtag/hla/hla_tcl.h>
33 #include <jtag/hla/hla_transport.h>
34 #include <jtag/hla/hla_interface.h>
35
36 COMMAND_HANDLER(hl_transport_jtag_command)
37 {
38 LOG_DEBUG("hl_transport_jtag_command");
39
40 return ERROR_OK;
41 }
42
43 COMMAND_HANDLER(hl_transport_reset_command)
44 {
45 return hl_interface_init_reset();
46 }
47
48 static const struct command_registration
49 hl_transport_stlink_subcommand_handlers[] = {
50 {
51 .name = "newtap",
52 .mode = COMMAND_CONFIG,
53 .jim_handler = jim_hl_newtap,
54 .help = "Create a new TAP instance named basename.tap_type, "
55 "and appends it to the scan chain.",
56 .usage = "basename tap_type '-irlen' count "
57 "['-expected_id' number] ",
58 },
59
60 COMMAND_REGISTRATION_DONE
61 };
62
63 static const struct command_registration
64 hl_transport_jtag_subcommand_handlers[] = {
65 {
66 .chain = hl_transport_stlink_subcommand_handlers,
67 },
68 {
69 .name = "init",
70 .mode = COMMAND_ANY,
71 .handler = hl_transport_jtag_command,
72 .usage = ""
73 },
74 {
75 .name = "arp_init",
76 .mode = COMMAND_ANY,
77 .handler = hl_transport_jtag_command,
78 .usage = ""
79 },
80 {
81 .name = "arp_init-reset",
82 .mode = COMMAND_ANY,
83 .handler = hl_transport_reset_command,
84 .usage = ""
85 },
86 {
87 .name = "tapisenabled",
88 .mode = COMMAND_EXEC,
89 .jim_handler = jim_jtag_tap_enabler,
90 },
91 {
92 .name = "tapenable",
93 .mode = COMMAND_EXEC,
94 .jim_handler = jim_jtag_tap_enabler,
95 },
96 {
97 .name = "tapdisable",
98 .mode = COMMAND_EXEC,
99 .handler = hl_transport_jtag_command,
100 .usage = "",
101 },
102 {
103 .name = "configure",
104 .mode = COMMAND_EXEC,
105 .handler = hl_transport_jtag_command,
106 .usage = "",
107 },
108 {
109 .name = "cget",
110 .mode = COMMAND_EXEC,
111 .jim_handler = jim_jtag_configure,
112 },
113 {
114 .name = "names",
115 .mode = COMMAND_ANY,
116 .handler = hl_transport_jtag_command,
117 .usage = "",
118 },
119
120 COMMAND_REGISTRATION_DONE
121 };
122
123 static const struct command_registration stlink_transport_command_handlers[] = {
124
125 {
126 .name = "hla",
127 .mode = COMMAND_ANY,
128 .help = "perform hl adapter actions",
129 .usage = "",
130 .chain = hl_transport_stlink_subcommand_handlers,
131 },
132 {
133 .name = "jtag",
134 .mode = COMMAND_ANY,
135 .usage = "",
136 .chain = hl_transport_jtag_subcommand_handlers,
137 },
138 {
139 .name = "jtag_ntrst_delay",
140 .mode = COMMAND_ANY,
141 .handler = hl_transport_jtag_command,
142 .usage = "",
143 },
144 COMMAND_REGISTRATION_DONE
145 };
146
147 static int hl_transport_register_commands(struct command_context *cmd_ctx)
148 {
149 return register_commands(cmd_ctx, NULL,
150 stlink_transport_command_handlers);
151 }
152
153 static int hl_transport_init(struct command_context *cmd_ctx)
154 {
155 LOG_DEBUG("hl_transport_init");
156 struct target *t = get_current_target(cmd_ctx);
157 struct transport *transport;
158 enum hl_transports tr;
159
160 if (!t) {
161 LOG_ERROR("no current target");
162 return ERROR_FAIL;
163 }
164
165 transport = get_current_transport();
166
167 if (!transport) {
168 LOG_ERROR("no transport selected");
169 return ERROR_FAIL;
170 }
171
172 LOG_DEBUG("current transport %s", transport->name);
173
174 /* get selected transport as enum */
175 tr = HL_TRANSPORT_UNKNOWN;
176
177 if (strcmp(transport->name, "hla_swd") == 0)
178 tr = HL_TRANSPORT_SWD;
179 else if (strcmp(transport->name, "hla_jtag") == 0)
180 tr = HL_TRANSPORT_JTAG;
181
182 int retval = hl_interface_open(tr);
183
184 if (retval != ERROR_OK)
185 return retval;
186
187 return hl_interface_init_target(t);
188 }
189
190 static int hl_transport_select(struct command_context *ctx)
191 {
192 LOG_DEBUG("hl_transport_select");
193
194 int retval;
195
196 /* NOTE: interface init must already have been done.
197 * That works with only C code ... no Tcl glue required.
198 */
199
200 retval = hl_transport_register_commands(ctx);
201
202 if (retval != ERROR_OK)
203 return retval;
204
205 return ERROR_OK;
206 }
207
208 static struct transport hl_swd_transport = {
209 .name = "hla_swd",
210 .select = hl_transport_select,
211 .init = hl_transport_init,
212 .override_target = hl_interface_override_target,
213 };
214
215 static struct transport hl_jtag_transport = {
216 .name = "hla_jtag",
217 .select = hl_transport_select,
218 .init = hl_transport_init,
219 .override_target = hl_interface_override_target,
220 };
221
222 const char *hl_transports[] = { "hla_swd", "hla_jtag", NULL };
223
224 static void hl_constructor(void) __attribute__ ((constructor));
225 static void hl_constructor(void)
226 {
227 transport_register(&hl_swd_transport);
228 transport_register(&hl_jtag_transport);
229 }
230
231 bool transport_is_hla(void)
232 {
233 struct transport *t;
234 t = get_current_transport();
235 return t == &hl_swd_transport || t == &hl_jtag_transport;
236 }

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)