1 /***************************************************************************
2 * Copyright (C) 2011 by Mathias Kuester *
3 * Mathias Kuester <kesmtp@freenet.de> *
5 * Copyright (C) 2012 by Spencer Oliver *
6 * spen@spen-soft.co.uk *
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. *
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. *
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 ***************************************************************************/
26 /* project specific includes */
27 #include <jtag/interface.h>
28 #include <transport/transport.h>
29 #include <helper/time_support.h>
31 #include <jtag/hla/hla_tcl.h>
32 #include <jtag/hla/hla_layout.h>
33 #include <jtag/hla/hla_transport.h>
34 #include <jtag/hla/hla_interface.h>
36 #include <target/target.h>
38 static struct hl_interface_s hl_if
= { {0, 0, 0, 0, 0, HL_TRANSPORT_UNKNOWN
, false, -1}, 0, 0 };
40 int hl_interface_open(enum hl_transports tr
)
42 LOG_DEBUG("hl_interface_open");
44 enum reset_types jtag_reset_config
= jtag_get_reset_config();
46 if (jtag_reset_config
& RESET_CNCT_UNDER_SRST
) {
47 if (jtag_reset_config
& RESET_SRST_NO_GATING
)
48 hl_if
.param
.connect_under_reset
= true;
50 LOG_WARNING("\'srst_nogate\' reset_config option is required");
53 /* set transport mode */
54 hl_if
.param
.transport
= tr
;
56 int result
= hl_if
.layout
->open(&hl_if
);
57 if (result
!= ERROR_OK
)
60 return hl_interface_init_reset();
63 int hl_interface_init_target(struct target
*t
)
67 LOG_DEBUG("hl_interface_init_target");
69 /* this is the interface for the current target and we
70 * can setup the private pointer in the tap structure
71 * if the interface match the tap idcode
73 res
= hl_if
.layout
->api
->idcode(hl_if
.handle
, &t
->tap
->idcode
);
78 unsigned ii
, limit
= t
->tap
->expected_ids_cnt
;
81 for (ii
= 0; ii
< limit
; ii
++) {
82 uint32_t expected
= t
->tap
->expected_ids
[ii
];
84 /* treat "-expected-id 0" as a "don't-warn" wildcard */
85 if (!expected
|| !t
->tap
->idcode
||
86 (t
->tap
->idcode
== expected
)) {
93 LOG_WARNING("UNEXPECTED idcode: 0x%08" PRIx32
, t
->tap
->idcode
);
94 for (ii
= 0; ii
< limit
; ii
++)
95 LOG_ERROR("expected %u of %u: 0x%08" PRIx32
, ii
+ 1, limit
,
96 t
->tap
->expected_ids
[ii
]);
101 t
->tap
->priv
= &hl_if
;
102 t
->tap
->hasidcode
= 1;
107 static int hl_interface_init(void)
109 LOG_DEBUG("hl_interface_init");
111 /* here we can initialize the layout */
112 return hl_layout_init(&hl_if
);
115 static int hl_interface_quit(void)
117 LOG_DEBUG("hl_interface_quit");
119 if (hl_if
.layout
->api
->close
)
120 hl_if
.layout
->api
->close(hl_if
.handle
);
125 static int hl_interface_execute_queue(void)
127 LOG_DEBUG("hl_interface_execute_queue: ignored");
132 int hl_interface_init_reset(void)
134 /* incase the adapter has not already handled asserting srst
135 * we will attempt it again */
136 if (hl_if
.param
.connect_under_reset
) {
137 jtag_add_reset(0, 1);
138 hl_if
.layout
->api
->assert_srst(hl_if
.handle
, 0);
140 jtag_add_reset(0, 0);
146 static int hl_interface_khz(int khz
, int *jtag_speed
)
148 if (hl_if
.layout
->api
->speed
== NULL
)
151 *jtag_speed
= hl_if
.layout
->api
->speed(hl_if
.handle
, khz
, true);
155 static int hl_interface_speed_div(int speed
, int *khz
)
161 static int hl_interface_speed(int speed
)
163 if (hl_if
.layout
->api
->speed
== NULL
)
166 if (hl_if
.handle
== NULL
) {
167 /* pass speed as initial param as interface not open yet */
168 hl_if
.param
.initial_interface_speed
= speed
;
172 hl_if
.layout
->api
->speed(hl_if
.handle
, speed
, false);
177 int hl_interface_override_target(const char **targetname
)
179 if (hl_if
.layout
->api
->override_target
) {
180 if (hl_if
.layout
->api
->override_target(*targetname
)) {
181 *targetname
= "hla_target";
189 int hl_interface_config_trace(bool enabled
, enum tpio_pin_protocol pin_protocol
,
190 uint32_t port_size
, unsigned int *trace_freq
)
192 if (hl_if
.layout
->api
->config_trace
)
193 return hl_if
.layout
->api
->config_trace(hl_if
.handle
, enabled
, pin_protocol
,
194 port_size
, trace_freq
);
196 LOG_ERROR("The selected interface does not support tracing");
203 int hl_interface_poll_trace(uint8_t *buf
, size_t *size
)
205 if (hl_if
.layout
->api
->poll_trace
)
206 return hl_if
.layout
->api
->poll_trace(hl_if
.handle
, buf
, size
);
211 COMMAND_HANDLER(hl_interface_handle_device_desc_command
)
213 LOG_DEBUG("hl_interface_handle_device_desc_command");
216 hl_if
.param
.device_desc
= strdup(CMD_ARGV
[0]);
218 LOG_ERROR("expected exactly one argument to hl_device_desc <description>");
224 COMMAND_HANDLER(hl_interface_handle_serial_command
)
226 LOG_DEBUG("hl_interface_handle_serial_command");
229 hl_if
.param
.serial
= strdup(CMD_ARGV
[0]);
231 LOG_ERROR("expected exactly one argument to hl_serial <serial-number>");
237 COMMAND_HANDLER(hl_interface_handle_layout_command
)
239 LOG_DEBUG("hl_interface_handle_layout_command");
242 LOG_ERROR("Need exactly one argument to stlink_layout");
243 return ERROR_COMMAND_SYNTAX_ERROR
;
247 LOG_ERROR("already specified hl_layout %s",
249 return (strcmp(hl_if
.layout
->name
, CMD_ARGV
[0]) != 0)
250 ? ERROR_FAIL
: ERROR_OK
;
253 for (const struct hl_layout
*l
= hl_layout_get_list(); l
->name
;
255 if (strcmp(l
->name
, CMD_ARGV
[0]) == 0) {
261 LOG_ERROR("No adapter layout '%s' found", CMD_ARGV
[0]);
265 COMMAND_HANDLER(hl_interface_handle_vid_pid_command
)
267 LOG_DEBUG("hl_interface_handle_vid_pid_command");
270 LOG_WARNING("ignoring extra IDs in hl_vid_pid (maximum is 1 pair)");
271 return ERROR_COMMAND_SYNTAX_ERROR
;
274 COMMAND_PARSE_NUMBER(u16
, CMD_ARGV
[0], hl_if
.param
.vid
);
275 COMMAND_PARSE_NUMBER(u16
, CMD_ARGV
[1], hl_if
.param
.pid
);
280 COMMAND_HANDLER(interface_handle_hla_command
)
283 return ERROR_COMMAND_SYNTAX_ERROR
;
285 if (!hl_if
.layout
->api
->custom_command
) {
286 LOG_ERROR("The selected adapter doesn't support custom commands");
290 hl_if
.layout
->api
->custom_command(hl_if
.handle
, CMD_ARGV
[0]);
295 static const struct command_registration hl_interface_command_handlers
[] = {
297 .name
= "hla_device_desc",
298 .handler
= &hl_interface_handle_device_desc_command
,
299 .mode
= COMMAND_CONFIG
,
300 .help
= "set the a device description of the adapter",
301 .usage
= "description_string",
304 .name
= "hla_serial",
305 .handler
= &hl_interface_handle_serial_command
,
306 .mode
= COMMAND_CONFIG
,
307 .help
= "set the serial number of the adapter",
308 .usage
= "serial_string",
311 .name
= "hla_layout",
312 .handler
= &hl_interface_handle_layout_command
,
313 .mode
= COMMAND_CONFIG
,
314 .help
= "set the layout of the adapter",
315 .usage
= "layout_name",
318 .name
= "hla_vid_pid",
319 .handler
= &hl_interface_handle_vid_pid_command
,
320 .mode
= COMMAND_CONFIG
,
321 .help
= "the vendor and product ID of the adapter",
322 .usage
= "(vid pid)* ",
325 .name
= "hla_command",
326 .handler
= &interface_handle_hla_command
,
327 .mode
= COMMAND_EXEC
,
328 .help
= "execute a custom adapter-specific command",
329 .usage
= "hla_command <command>",
331 COMMAND_REGISTRATION_DONE
334 struct jtag_interface hl_interface
= {
337 .commands
= hl_interface_command_handlers
,
338 .transports
= hl_transports
,
339 .init
= hl_interface_init
,
340 .quit
= hl_interface_quit
,
341 .execute_queue
= hl_interface_execute_queue
,
342 .speed
= &hl_interface_speed
,
343 .khz
= &hl_interface_khz
,
344 .speed_div
= &hl_interface_speed_div
,
345 .config_trace
= &hl_interface_config_trace
,
346 .poll_trace
= &hl_interface_poll_trace
,
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)