helper/command: make script_debug() static
[openocd.git] / src / jtag / tcl.c
1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
4 * *
5 * Copyright (C) 2007-2010 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
7 * *
8 * Copyright (C) 2009 SoftPLC Corporation *
9 * http://softplc.com *
10 * dick@softplc.com *
11 * *
12 * Copyright (C) 2009 Zachary T Welch *
13 * zw@superlucidity.net *
14 * *
15 * This program is free software; you can redistribute it and/or modify *
16 * it under the terms of the GNU General Public License as published by *
17 * the Free Software Foundation; either version 2 of the License, or *
18 * (at your option) any later version. *
19 * *
20 * This program is distributed in the hope that it will be useful, *
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
23 * GNU General Public License for more details. *
24 * *
25 * You should have received a copy of the GNU General Public License *
26 * along with this program. If not, see <http://www.gnu.org/licenses/>. *
27 ***************************************************************************/
28
29 #ifdef HAVE_CONFIG_H
30 #include "config.h"
31 #endif
32
33 #include "jtag.h"
34 #include "swd.h"
35 #include "minidriver.h"
36 #include "interface.h"
37 #include "interfaces.h"
38 #include "tcl.h"
39
40 #ifdef HAVE_STRINGS_H
41 #include <strings.h>
42 #endif
43
44 #include <helper/time_support.h>
45 #include "transport/transport.h"
46
47 /**
48 * @file
49 * Holds support for accessing JTAG-specific mechanisms from TCl scripts.
50 */
51
52 static const Jim_Nvp nvp_jtag_tap_event[] = {
53 { .value = JTAG_TRST_ASSERTED, .name = "post-reset" },
54 { .value = JTAG_TAP_EVENT_SETUP, .name = "setup" },
55 { .value = JTAG_TAP_EVENT_ENABLE, .name = "tap-enable" },
56 { .value = JTAG_TAP_EVENT_DISABLE, .name = "tap-disable" },
57
58 { .name = NULL, .value = -1 }
59 };
60
61 struct jtag_tap *jtag_tap_by_jim_obj(Jim_Interp *interp, Jim_Obj *o)
62 {
63 const char *cp = Jim_GetString(o, NULL);
64 struct jtag_tap *t = cp ? jtag_tap_by_string(cp) : NULL;
65 if (NULL == cp)
66 cp = "(unknown)";
67 if (NULL == t)
68 Jim_SetResultFormatted(interp, "Tap '%s' could not be found", cp);
69 return t;
70 }
71
72 static bool scan_is_safe(tap_state_t state)
73 {
74 switch (state) {
75 case TAP_RESET:
76 case TAP_IDLE:
77 case TAP_DRPAUSE:
78 case TAP_IRPAUSE:
79 return true;
80 default:
81 return false;
82 }
83 }
84
85 static int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args)
86 {
87 int retval;
88 struct scan_field *fields;
89 int num_fields;
90 int field_count = 0;
91 int i, e;
92 struct jtag_tap *tap;
93 tap_state_t endstate;
94
95 /* args[1] = device
96 * args[2] = num_bits
97 * args[3] = hex string
98 * ... repeat num bits and hex string ...
99 *
100 * .. optionally:
101 * args[N-2] = "-endstate"
102 * args[N-1] = statename
103 */
104 if ((argc < 4) || ((argc % 2) != 0)) {
105 Jim_WrongNumArgs(interp, 1, args, "wrong arguments");
106 return JIM_ERR;
107 }
108
109 endstate = TAP_IDLE;
110
111 /* validate arguments as numbers */
112 e = JIM_OK;
113 for (i = 2; i < argc; i += 2) {
114 long bits;
115 const char *cp;
116
117 e = Jim_GetLong(interp, args[i], &bits);
118 /* If valid - try next arg */
119 if (e == JIM_OK)
120 continue;
121
122 /* Not valid.. are we at the end? */
123 if (((i + 2) != argc)) {
124 /* nope, then error */
125 return e;
126 }
127
128 /* it could be: "-endstate FOO"
129 * e.g. DRPAUSE so we can issue more instructions
130 * before entering RUN/IDLE and executing them.
131 */
132
133 /* get arg as a string. */
134 cp = Jim_GetString(args[i], NULL);
135 /* is it the magic? */
136 if (0 == strcmp("-endstate", cp)) {
137 /* is the statename valid? */
138 cp = Jim_GetString(args[i + 1], NULL);
139
140 /* see if it is a valid state name */
141 endstate = tap_state_by_name(cp);
142 if (endstate < 0) {
143 /* update the error message */
144 Jim_SetResultFormatted(interp, "endstate: %s invalid", cp);
145 } else {
146 if (!scan_is_safe(endstate))
147 LOG_WARNING("drscan with unsafe "
148 "endstate \"%s\"", cp);
149
150 /* valid - so clear the error */
151 e = JIM_OK;
152 /* and remove the last 2 args */
153 argc -= 2;
154 }
155 }
156
157 /* Still an error? */
158 if (e != JIM_OK)
159 return e; /* too bad */
160 } /* validate args */
161
162 assert(e == JIM_OK);
163
164 tap = jtag_tap_by_jim_obj(interp, args[1]);
165 if (tap == NULL)
166 return JIM_ERR;
167
168 num_fields = (argc-2)/2;
169 if (num_fields <= 0) {
170 Jim_SetResultString(interp, "drscan: no scan fields supplied", -1);
171 return JIM_ERR;
172 }
173 fields = malloc(sizeof(struct scan_field) * num_fields);
174 for (i = 2; i < argc; i += 2) {
175 long bits;
176 int len;
177 const char *str;
178
179 Jim_GetLong(interp, args[i], &bits);
180 str = Jim_GetString(args[i + 1], &len);
181
182 fields[field_count].num_bits = bits;
183 void *t = malloc(DIV_ROUND_UP(bits, 8));
184 fields[field_count].out_value = t;
185 str_to_buf(str, len, t, bits, 0);
186 fields[field_count].in_value = t;
187 field_count++;
188 }
189
190 jtag_add_dr_scan(tap, num_fields, fields, endstate);
191
192 retval = jtag_execute_queue();
193 if (retval != ERROR_OK) {
194 Jim_SetResultString(interp, "drscan: jtag execute failed", -1);
195
196 for (i = 0; i < field_count; i++)
197 free(fields[i].in_value);
198 free(fields);
199
200 return JIM_ERR;
201 }
202
203 field_count = 0;
204 Jim_Obj *list = Jim_NewListObj(interp, NULL, 0);
205 for (i = 2; i < argc; i += 2) {
206 long bits;
207 char *str;
208
209 Jim_GetLong(interp, args[i], &bits);
210 str = buf_to_hex_str(fields[field_count].in_value, bits);
211 free(fields[field_count].in_value);
212
213 Jim_ListAppendElement(interp, list, Jim_NewStringObj(interp, str, strlen(str)));
214 free(str);
215 field_count++;
216 }
217
218 Jim_SetResult(interp, list);
219
220 free(fields);
221
222 return JIM_OK;
223 }
224
225
226 static int Jim_Command_pathmove(Jim_Interp *interp, int argc, Jim_Obj *const *args)
227 {
228 tap_state_t states[8];
229
230 if ((argc < 2) || ((size_t)argc > (ARRAY_SIZE(states) + 1))) {
231 Jim_WrongNumArgs(interp, 1, args, "wrong arguments");
232 return JIM_ERR;
233 }
234
235 int i;
236 for (i = 0; i < argc-1; i++) {
237 const char *cp;
238 cp = Jim_GetString(args[i + 1], NULL);
239 states[i] = tap_state_by_name(cp);
240 if (states[i] < 0) {
241 /* update the error message */
242 Jim_SetResultFormatted(interp, "endstate: %s invalid", cp);
243 return JIM_ERR;
244 }
245 }
246
247 if ((jtag_add_statemove(states[0]) != ERROR_OK) || (jtag_execute_queue() != ERROR_OK)) {
248 Jim_SetResultString(interp, "pathmove: jtag execute failed", -1);
249 return JIM_ERR;
250 }
251
252 jtag_add_pathmove(argc - 2, states + 1);
253
254 if (jtag_execute_queue() != ERROR_OK) {
255 Jim_SetResultString(interp, "pathmove: failed", -1);
256 return JIM_ERR;
257 }
258
259 return JIM_OK;
260 }
261
262
263 static int Jim_Command_flush_count(Jim_Interp *interp, int argc, Jim_Obj *const *args)
264 {
265 Jim_SetResult(interp, Jim_NewIntObj(interp, jtag_get_flush_queue_count()));
266
267 return JIM_OK;
268 }
269
270 /* REVISIT Just what about these should "move" ... ?
271 * These registrations, into the main JTAG table?
272 *
273 * There's a minor compatibility issue, these all show up twice;
274 * that's not desirable:
275 * - jtag drscan ... NOT DOCUMENTED!
276 * - drscan ...
277 *
278 * The "irscan" command (for example) doesn't show twice.
279 */
280 static const struct command_registration jtag_command_handlers_to_move[] = {
281 {
282 .name = "drscan",
283 .mode = COMMAND_EXEC,
284 .jim_handler = Jim_Command_drscan,
285 .help = "Execute Data Register (DR) scan for one TAP. "
286 "Other TAPs must be in BYPASS mode.",
287 .usage = "tap_name [num_bits value]* ['-endstate' state_name]",
288 },
289 {
290 .name = "flush_count",
291 .mode = COMMAND_EXEC,
292 .jim_handler = Jim_Command_flush_count,
293 .help = "Returns the number of times the JTAG queue "
294 "has been flushed.",
295 },
296 {
297 .name = "pathmove",
298 .mode = COMMAND_EXEC,
299 .jim_handler = Jim_Command_pathmove,
300 .usage = "start_state state1 [state2 [state3 ...]]",
301 .help = "Move JTAG state machine from current state "
302 "(start_state) to state1, then state2, state3, etc.",
303 },
304 COMMAND_REGISTRATION_DONE
305 };
306
307
308 enum jtag_tap_cfg_param {
309 JCFG_EVENT,
310 JCFG_IDCODE,
311 };
312
313 static Jim_Nvp nvp_config_opts[] = {
314 { .name = "-event", .value = JCFG_EVENT },
315 { .name = "-idcode", .value = JCFG_IDCODE },
316
317 { .name = NULL, .value = -1 }
318 };
319
320 static int jtag_tap_configure_event(Jim_GetOptInfo *goi, struct jtag_tap *tap)
321 {
322 if (goi->argc == 0) {
323 Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event <event-name> ...");
324 return JIM_ERR;
325 }
326
327 Jim_Nvp *n;
328 int e = Jim_GetOpt_Nvp(goi, nvp_jtag_tap_event, &n);
329 if (e != JIM_OK) {
330 Jim_GetOpt_NvpUnknown(goi, nvp_jtag_tap_event, 1);
331 return e;
332 }
333
334 if (goi->isconfigure) {
335 if (goi->argc != 1) {
336 Jim_WrongNumArgs(goi->interp,
337 goi->argc,
338 goi->argv,
339 "-event <event-name> <event-body>");
340 return JIM_ERR;
341 }
342 } else {
343 if (goi->argc != 0) {
344 Jim_WrongNumArgs(goi->interp, goi->argc, goi->argv, "-event <event-name>");
345 return JIM_ERR;
346 }
347 }
348
349 struct jtag_tap_event_action *jteap = tap->event_action;
350 /* replace existing event body */
351 bool found = false;
352 while (jteap) {
353 if (jteap->event == (enum jtag_event)n->value) {
354 found = true;
355 break;
356 }
357 jteap = jteap->next;
358 }
359
360 Jim_SetEmptyResult(goi->interp);
361
362 if (goi->isconfigure) {
363 if (!found)
364 jteap = calloc(1, sizeof(*jteap));
365 else if (NULL != jteap->body)
366 Jim_DecrRefCount(goi->interp, jteap->body);
367
368 jteap->interp = goi->interp;
369 jteap->event = n->value;
370
371 Jim_Obj *o;
372 Jim_GetOpt_Obj(goi, &o);
373 jteap->body = Jim_DuplicateObj(goi->interp, o);
374 Jim_IncrRefCount(jteap->body);
375
376 if (!found) {
377 /* add to head of event list */
378 jteap->next = tap->event_action;
379 tap->event_action = jteap;
380 }
381 } else if (found) {
382 jteap->interp = goi->interp;
383 Jim_SetResult(goi->interp,
384 Jim_DuplicateObj(goi->interp, jteap->body));
385 }
386 return JIM_OK;
387 }
388
389 static int jtag_tap_configure_cmd(Jim_GetOptInfo *goi, struct jtag_tap *tap)
390 {
391 /* parse config or cget options */
392 while (goi->argc > 0) {
393 Jim_SetEmptyResult(goi->interp);
394
395 Jim_Nvp *n;
396 int e = Jim_GetOpt_Nvp(goi, nvp_config_opts, &n);
397 if (e != JIM_OK) {
398 Jim_GetOpt_NvpUnknown(goi, nvp_config_opts, 0);
399 return e;
400 }
401
402 switch (n->value) {
403 case JCFG_EVENT:
404 e = jtag_tap_configure_event(goi, tap);
405 if (e != JIM_OK)
406 return e;
407 break;
408 case JCFG_IDCODE:
409 if (goi->isconfigure) {
410 Jim_SetResultFormatted(goi->interp,
411 "not settable: %s", n->name);
412 return JIM_ERR;
413 } else {
414 if (goi->argc != 0) {
415 Jim_WrongNumArgs(goi->interp,
416 goi->argc, goi->argv,
417 "NO PARAMS");
418 return JIM_ERR;
419 }
420 }
421 Jim_SetResult(goi->interp, Jim_NewIntObj(goi->interp, tap->idcode));
422 break;
423 default:
424 Jim_SetResultFormatted(goi->interp, "unknown value: %s", n->name);
425 return JIM_ERR;
426 }
427 }
428
429 return JIM_OK;
430 }
431
432 static int is_bad_irval(int ir_length, jim_wide w)
433 {
434 jim_wide v = 1;
435
436 v <<= ir_length;
437 v -= 1;
438 v = ~v;
439 return (w & v) != 0;
440 }
441
442 static int jim_newtap_expected_id(Jim_Nvp *n, Jim_GetOptInfo *goi,
443 struct jtag_tap *pTap)
444 {
445 jim_wide w;
446 int e = Jim_GetOpt_Wide(goi, &w);
447 if (e != JIM_OK) {
448 Jim_SetResultFormatted(goi->interp, "option: %s bad parameter", n->name);
449 return e;
450 }
451
452 uint32_t *p = realloc(pTap->expected_ids,
453 (pTap->expected_ids_cnt + 1) * sizeof(uint32_t));
454 if (!p) {
455 Jim_SetResultFormatted(goi->interp, "no memory");
456 return JIM_ERR;
457 }
458
459 pTap->expected_ids = p;
460 pTap->expected_ids[pTap->expected_ids_cnt++] = w;
461
462 return JIM_OK;
463 }
464
465 #define NTAP_OPT_IRLEN 0
466 #define NTAP_OPT_IRMASK 1
467 #define NTAP_OPT_IRCAPTURE 2
468 #define NTAP_OPT_ENABLED 3
469 #define NTAP_OPT_DISABLED 4
470 #define NTAP_OPT_EXPECTED_ID 5
471 #define NTAP_OPT_VERSION 6
472
473 static int jim_newtap_ir_param(Jim_Nvp *n, Jim_GetOptInfo *goi,
474 struct jtag_tap *pTap)
475 {
476 jim_wide w;
477 int e = Jim_GetOpt_Wide(goi, &w);
478 if (e != JIM_OK) {
479 Jim_SetResultFormatted(goi->interp,
480 "option: %s bad parameter", n->name);
481 return e;
482 }
483 switch (n->value) {
484 case NTAP_OPT_IRLEN:
485 if (w > (jim_wide) (8 * sizeof(pTap->ir_capture_value))) {
486 LOG_WARNING("%s: huge IR length %d",
487 pTap->dotted_name, (int) w);
488 }
489 pTap->ir_length = w;
490 break;
491 case NTAP_OPT_IRMASK:
492 if (is_bad_irval(pTap->ir_length, w)) {
493 LOG_ERROR("%s: IR mask %x too big",
494 pTap->dotted_name,
495 (int) w);
496 return JIM_ERR;
497 }
498 if ((w & 3) != 3)
499 LOG_WARNING("%s: nonstandard IR mask", pTap->dotted_name);
500 pTap->ir_capture_mask = w;
501 break;
502 case NTAP_OPT_IRCAPTURE:
503 if (is_bad_irval(pTap->ir_length, w)) {
504 LOG_ERROR("%s: IR capture %x too big",
505 pTap->dotted_name, (int) w);
506 return JIM_ERR;
507 }
508 if ((w & 3) != 1)
509 LOG_WARNING("%s: nonstandard IR value",
510 pTap->dotted_name);
511 pTap->ir_capture_value = w;
512 break;
513 default:
514 return JIM_ERR;
515 }
516 return JIM_OK;
517 }
518
519 static int jim_newtap_cmd(Jim_GetOptInfo *goi)
520 {
521 struct jtag_tap *pTap;
522 int x;
523 int e;
524 Jim_Nvp *n;
525 char *cp;
526 const Jim_Nvp opts[] = {
527 { .name = "-irlen", .value = NTAP_OPT_IRLEN },
528 { .name = "-irmask", .value = NTAP_OPT_IRMASK },
529 { .name = "-ircapture", .value = NTAP_OPT_IRCAPTURE },
530 { .name = "-enable", .value = NTAP_OPT_ENABLED },
531 { .name = "-disable", .value = NTAP_OPT_DISABLED },
532 { .name = "-expected-id", .value = NTAP_OPT_EXPECTED_ID },
533 { .name = "-ignore-version", .value = NTAP_OPT_VERSION },
534 { .name = NULL, .value = -1 },
535 };
536
537 pTap = calloc(1, sizeof(struct jtag_tap));
538 if (!pTap) {
539 Jim_SetResultFormatted(goi->interp, "no memory");
540 return JIM_ERR;
541 }
542
543 /*
544 * we expect CHIP + TAP + OPTIONS
545 * */
546 if (goi->argc < 3) {
547 Jim_SetResultFormatted(goi->interp, "Missing CHIP TAP OPTIONS ....");
548 free(pTap);
549 return JIM_ERR;
550 }
551
552 const char *tmp;
553 Jim_GetOpt_String(goi, &tmp, NULL);
554 pTap->chip = strdup(tmp);
555
556 Jim_GetOpt_String(goi, &tmp, NULL);
557 pTap->tapname = strdup(tmp);
558
559 /* name + dot + name + null */
560 x = strlen(pTap->chip) + 1 + strlen(pTap->tapname) + 1;
561 cp = malloc(x);
562 sprintf(cp, "%s.%s", pTap->chip, pTap->tapname);
563 pTap->dotted_name = cp;
564
565 LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
566 pTap->chip, pTap->tapname, pTap->dotted_name, goi->argc);
567
568 if (!transport_is_jtag()) {
569 /* SWD doesn't require any JTAG tap parameters */
570 pTap->enabled = true;
571 jtag_tap_init(pTap);
572 return JIM_OK;
573 }
574
575 /* IEEE specifies that the two LSBs of an IR scan are 01, so make
576 * that the default. The "-ircapture" and "-irmask" options are only
577 * needed to cope with nonstandard TAPs, or to specify more bits.
578 */
579 pTap->ir_capture_mask = 0x03;
580 pTap->ir_capture_value = 0x01;
581
582 while (goi->argc) {
583 e = Jim_GetOpt_Nvp(goi, opts, &n);
584 if (e != JIM_OK) {
585 Jim_GetOpt_NvpUnknown(goi, opts, 0);
586 free(cp);
587 free(pTap);
588 return e;
589 }
590 LOG_DEBUG("Processing option: %s", n->name);
591 switch (n->value) {
592 case NTAP_OPT_ENABLED:
593 pTap->disabled_after_reset = false;
594 break;
595 case NTAP_OPT_DISABLED:
596 pTap->disabled_after_reset = true;
597 break;
598 case NTAP_OPT_EXPECTED_ID:
599 e = jim_newtap_expected_id(n, goi, pTap);
600 if (JIM_OK != e) {
601 free(cp);
602 free(pTap);
603 return e;
604 }
605 break;
606 case NTAP_OPT_IRLEN:
607 case NTAP_OPT_IRMASK:
608 case NTAP_OPT_IRCAPTURE:
609 e = jim_newtap_ir_param(n, goi, pTap);
610 if (JIM_OK != e) {
611 free(cp);
612 free(pTap);
613 return e;
614 }
615 break;
616 case NTAP_OPT_VERSION:
617 pTap->ignore_version = true;
618 break;
619 } /* switch (n->value) */
620 } /* while (goi->argc) */
621
622 /* default is enabled-after-reset */
623 pTap->enabled = !pTap->disabled_after_reset;
624
625 /* Did all the required option bits get cleared? */
626 if (pTap->ir_length != 0) {
627 jtag_tap_init(pTap);
628 return JIM_OK;
629 }
630
631 Jim_SetResultFormatted(goi->interp,
632 "newtap: %s missing IR length",
633 pTap->dotted_name);
634 jtag_tap_free(pTap);
635 return JIM_ERR;
636 }
637
638 static void jtag_tap_handle_event(struct jtag_tap *tap, enum jtag_event e)
639 {
640 struct jtag_tap_event_action *jteap;
641 int retval;
642
643 for (jteap = tap->event_action; jteap != NULL; jteap = jteap->next) {
644 if (jteap->event != e)
645 continue;
646
647 Jim_Nvp *nvp = Jim_Nvp_value2name_simple(nvp_jtag_tap_event, e);
648 LOG_DEBUG("JTAG tap: %s event: %d (%s)\n\taction: %s",
649 tap->dotted_name, e, nvp->name,
650 Jim_GetString(jteap->body, NULL));
651
652 retval = Jim_EvalObj(jteap->interp, jteap->body);
653 if (retval == JIM_RETURN)
654 retval = jteap->interp->returnCode;
655
656 if (retval != JIM_OK) {
657 Jim_MakeErrorMessage(jteap->interp);
658 LOG_USER("%s", Jim_GetString(Jim_GetResult(jteap->interp), NULL));
659 continue;
660 }
661
662 switch (e) {
663 case JTAG_TAP_EVENT_ENABLE:
664 case JTAG_TAP_EVENT_DISABLE:
665 /* NOTE: we currently assume the handlers
666 * can't fail. Right here is where we should
667 * really be verifying the scan chains ...
668 */
669 tap->enabled = (e == JTAG_TAP_EVENT_ENABLE);
670 LOG_INFO("JTAG tap: %s %s", tap->dotted_name,
671 tap->enabled ? "enabled" : "disabled");
672 break;
673 default:
674 break;
675 }
676 }
677 }
678
679 static int jim_jtag_arp_init(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
680 {
681 Jim_GetOptInfo goi;
682 Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1);
683 if (goi.argc != 0) {
684 Jim_WrongNumArgs(goi.interp, 1, goi.argv-1, "(no params)");
685 return JIM_ERR;
686 }
687 struct command_context *context = current_command_context(interp);
688 int e = jtag_init_inner(context);
689 if (e != ERROR_OK) {
690 Jim_Obj *eObj = Jim_NewIntObj(goi.interp, e);
691 Jim_IncrRefCount(eObj);
692 Jim_SetResultFormatted(goi.interp, "error: %#s", eObj);
693 Jim_DecrRefCount(goi.interp, eObj);
694 return JIM_ERR;
695 }
696 return JIM_OK;
697 }
698
699 static int jim_jtag_arp_init_reset(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
700 {
701 int e = ERROR_OK;
702 Jim_GetOptInfo goi;
703 Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1);
704 if (goi.argc != 0) {
705 Jim_WrongNumArgs(goi.interp, 1, goi.argv-1, "(no params)");
706 return JIM_ERR;
707 }
708 struct command_context *context = current_command_context(interp);
709 if (transport_is_jtag())
710 e = jtag_init_reset(context);
711 else if (transport_is_swd())
712 e = swd_init_reset(context);
713
714 if (e != ERROR_OK) {
715 Jim_Obj *eObj = Jim_NewIntObj(goi.interp, e);
716 Jim_IncrRefCount(eObj);
717 Jim_SetResultFormatted(goi.interp, "error: %#s", eObj);
718 Jim_DecrRefCount(goi.interp, eObj);
719 return JIM_ERR;
720 }
721 return JIM_OK;
722 }
723
724 int jim_jtag_newtap(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
725 {
726 Jim_GetOptInfo goi;
727 Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1);
728 return jim_newtap_cmd(&goi);
729 }
730
731 static bool jtag_tap_enable(struct jtag_tap *t)
732 {
733 if (t->enabled)
734 return false;
735 jtag_tap_handle_event(t, JTAG_TAP_EVENT_ENABLE);
736 if (!t->enabled)
737 return false;
738
739 /* FIXME add JTAG sanity checks, w/o TLR
740 * - scan chain length grew by one (this)
741 * - IDs and IR lengths are as expected
742 */
743 jtag_call_event_callbacks(JTAG_TAP_EVENT_ENABLE);
744 return true;
745 }
746 static bool jtag_tap_disable(struct jtag_tap *t)
747 {
748 if (!t->enabled)
749 return false;
750 jtag_tap_handle_event(t, JTAG_TAP_EVENT_DISABLE);
751 if (t->enabled)
752 return false;
753
754 /* FIXME add JTAG sanity checks, w/o TLR
755 * - scan chain length shrank by one (this)
756 * - IDs and IR lengths are as expected
757 */
758 jtag_call_event_callbacks(JTAG_TAP_EVENT_DISABLE);
759 return true;
760 }
761
762 int jim_jtag_tap_enabler(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
763 {
764 struct command *c = jim_to_command(interp);
765 const char *cmd_name = c->name;
766 Jim_GetOptInfo goi;
767 Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1);
768 if (goi.argc != 1) {
769 Jim_SetResultFormatted(goi.interp, "usage: %s <name>", cmd_name);
770 return JIM_ERR;
771 }
772
773 struct jtag_tap *t;
774
775 t = jtag_tap_by_jim_obj(goi.interp, goi.argv[0]);
776 if (t == NULL)
777 return JIM_ERR;
778
779 if (strcasecmp(cmd_name, "tapisenabled") == 0) {
780 /* do nothing, just return the value */
781 } else if (strcasecmp(cmd_name, "tapenable") == 0) {
782 if (!jtag_tap_enable(t)) {
783 LOG_WARNING("failed to enable tap %s", t->dotted_name);
784 return JIM_ERR;
785 }
786 } else if (strcasecmp(cmd_name, "tapdisable") == 0) {
787 if (!jtag_tap_disable(t)) {
788 LOG_WARNING("failed to disable tap %s", t->dotted_name);
789 return JIM_ERR;
790 }
791 } else {
792 LOG_ERROR("command '%s' unknown", cmd_name);
793 return JIM_ERR;
794 }
795 bool e = t->enabled;
796 Jim_SetResult(goi.interp, Jim_NewIntObj(goi.interp, e));
797 return JIM_OK;
798 }
799
800 int jim_jtag_configure(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
801 {
802 struct command *c = jim_to_command(interp);
803 const char *cmd_name = c->name;
804 Jim_GetOptInfo goi;
805 Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1);
806 goi.isconfigure = !strcmp(cmd_name, "configure");
807 if (goi.argc < 2 + goi.isconfigure) {
808 Jim_WrongNumArgs(goi.interp, 0, NULL,
809 "<tap_name> <attribute> ...");
810 return JIM_ERR;
811 }
812
813 struct jtag_tap *t;
814
815 Jim_Obj *o;
816 Jim_GetOpt_Obj(&goi, &o);
817 t = jtag_tap_by_jim_obj(goi.interp, o);
818 if (t == NULL)
819 return JIM_ERR;
820
821 return jtag_tap_configure_cmd(&goi, t);
822 }
823
824 static int jim_jtag_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
825 {
826 Jim_GetOptInfo goi;
827 Jim_GetOpt_Setup(&goi, interp, argc-1, argv + 1);
828 if (goi.argc != 0) {
829 Jim_WrongNumArgs(goi.interp, 1, goi.argv, "Too many parameters");
830 return JIM_ERR;
831 }
832 Jim_SetResult(goi.interp, Jim_NewListObj(goi.interp, NULL, 0));
833 struct jtag_tap *tap;
834
835 for (tap = jtag_all_taps(); tap; tap = tap->next_tap) {
836 Jim_ListAppendElement(goi.interp,
837 Jim_GetResult(goi.interp),
838 Jim_NewStringObj(goi.interp,
839 tap->dotted_name, -1));
840 }
841 return JIM_OK;
842 }
843
844 COMMAND_HANDLER(handle_jtag_init_command)
845 {
846 if (CMD_ARGC != 0)
847 return ERROR_COMMAND_SYNTAX_ERROR;
848
849 static bool jtag_initialized;
850 if (jtag_initialized) {
851 LOG_INFO("'jtag init' has already been called");
852 return ERROR_OK;
853 }
854 jtag_initialized = true;
855
856 LOG_DEBUG("Initializing jtag devices...");
857 return jtag_init(CMD_CTX);
858 }
859
860 static const struct command_registration jtag_subcommand_handlers[] = {
861 {
862 .name = "init",
863 .mode = COMMAND_ANY,
864 .handler = handle_jtag_init_command,
865 .help = "initialize jtag scan chain",
866 .usage = ""
867 },
868 {
869 .name = "arp_init",
870 .mode = COMMAND_ANY,
871 .jim_handler = jim_jtag_arp_init,
872 .help = "Validates JTAG scan chain against the list of "
873 "declared TAPs using just the four standard JTAG "
874 "signals.",
875 },
876 {
877 .name = "arp_init-reset",
878 .mode = COMMAND_ANY,
879 .jim_handler = jim_jtag_arp_init_reset,
880 .help = "Uses TRST and SRST to try resetting everything on "
881 "the JTAG scan chain, then performs 'jtag arp_init'."
882 },
883 {
884 .name = "newtap",
885 .mode = COMMAND_CONFIG,
886 .jim_handler = jim_jtag_newtap,
887 .help = "Create a new TAP instance named basename.tap_type, "
888 "and appends it to the scan chain.",
889 .usage = "basename tap_type '-irlen' count "
890 "['-enable'|'-disable'] "
891 "['-expected_id' number] "
892 "['-ignore-version'] "
893 "['-ircapture' number] "
894 "['-mask' number] ",
895 },
896 {
897 .name = "tapisenabled",
898 .mode = COMMAND_EXEC,
899 .jim_handler = jim_jtag_tap_enabler,
900 .help = "Returns a Tcl boolean (0/1) indicating whether "
901 "the TAP is enabled (1) or not (0).",
902 .usage = "tap_name",
903 },
904 {
905 .name = "tapenable",
906 .mode = COMMAND_EXEC,
907 .jim_handler = jim_jtag_tap_enabler,
908 .help = "Try to enable the specified TAP using the "
909 "'tap-enable' TAP event.",
910 .usage = "tap_name",
911 },
912 {
913 .name = "tapdisable",
914 .mode = COMMAND_EXEC,
915 .jim_handler = jim_jtag_tap_enabler,
916 .help = "Try to disable the specified TAP using the "
917 "'tap-disable' TAP event.",
918 .usage = "tap_name",
919 },
920 {
921 .name = "configure",
922 .mode = COMMAND_ANY,
923 .jim_handler = jim_jtag_configure,
924 .help = "Provide a Tcl handler for the specified "
925 "TAP event.",
926 .usage = "tap_name '-event' event_name handler",
927 },
928 {
929 .name = "cget",
930 .mode = COMMAND_EXEC,
931 .jim_handler = jim_jtag_configure,
932 .help = "Return any Tcl handler for the specified "
933 "TAP event.",
934 .usage = "tap_name '-event' event_name",
935 },
936 {
937 .name = "names",
938 .mode = COMMAND_ANY,
939 .jim_handler = jim_jtag_names,
940 .help = "Returns list of all JTAG tap names.",
941 },
942 {
943 .chain = jtag_command_handlers_to_move,
944 },
945 COMMAND_REGISTRATION_DONE
946 };
947
948 void jtag_notify_event(enum jtag_event event)
949 {
950 struct jtag_tap *tap;
951
952 for (tap = jtag_all_taps(); tap; tap = tap->next_tap)
953 jtag_tap_handle_event(tap, event);
954 }
955
956
957 COMMAND_HANDLER(handle_scan_chain_command)
958 {
959 struct jtag_tap *tap;
960 char expected_id[12];
961
962 tap = jtag_all_taps();
963 command_print(CMD,
964 " TapName Enabled IdCode Expected IrLen IrCap IrMask");
965 command_print(CMD,
966 "-- ------------------- -------- ---------- ---------- ----- ----- ------");
967
968 while (tap) {
969 uint32_t expected, expected_mask, ii;
970
971 snprintf(expected_id, sizeof(expected_id), "0x%08x",
972 (unsigned)((tap->expected_ids_cnt > 0)
973 ? tap->expected_ids[0]
974 : 0));
975 if (tap->ignore_version)
976 expected_id[2] = '*';
977
978 expected = buf_get_u32(tap->expected, 0, tap->ir_length);
979 expected_mask = buf_get_u32(tap->expected_mask, 0, tap->ir_length);
980
981 command_print(CMD,
982 "%2d %-18s %c 0x%08x %s %5d 0x%02x 0x%02x",
983 tap->abs_chain_position,
984 tap->dotted_name,
985 tap->enabled ? 'Y' : 'n',
986 (unsigned int)(tap->idcode),
987 expected_id,
988 (unsigned int)(tap->ir_length),
989 (unsigned int)(expected),
990 (unsigned int)(expected_mask));
991
992 for (ii = 1; ii < tap->expected_ids_cnt; ii++) {
993 snprintf(expected_id, sizeof(expected_id), "0x%08x",
994 (unsigned) tap->expected_ids[ii]);
995 if (tap->ignore_version)
996 expected_id[2] = '*';
997
998 command_print(CMD,
999 " %s",
1000 expected_id);
1001 }
1002
1003 tap = tap->next_tap;
1004 }
1005
1006 return ERROR_OK;
1007 }
1008
1009 COMMAND_HANDLER(handle_jtag_ntrst_delay_command)
1010 {
1011 if (CMD_ARGC > 1)
1012 return ERROR_COMMAND_SYNTAX_ERROR;
1013 if (CMD_ARGC == 1) {
1014 unsigned delay;
1015 COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay);
1016
1017 jtag_set_ntrst_delay(delay);
1018 }
1019 command_print(CMD, "jtag_ntrst_delay: %u", jtag_get_ntrst_delay());
1020 return ERROR_OK;
1021 }
1022
1023 COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command)
1024 {
1025 if (CMD_ARGC > 1)
1026 return ERROR_COMMAND_SYNTAX_ERROR;
1027 if (CMD_ARGC == 1) {
1028 unsigned delay;
1029 COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay);
1030
1031 jtag_set_ntrst_assert_width(delay);
1032 }
1033 command_print(CMD, "jtag_ntrst_assert_width: %u", jtag_get_ntrst_assert_width());
1034 return ERROR_OK;
1035 }
1036
1037 COMMAND_HANDLER(handle_jtag_rclk_command)
1038 {
1039 if (CMD_ARGC > 1)
1040 return ERROR_COMMAND_SYNTAX_ERROR;
1041
1042 int retval = ERROR_OK;
1043 if (CMD_ARGC == 1) {
1044 unsigned khz = 0;
1045 COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], khz);
1046
1047 retval = jtag_config_rclk(khz);
1048 if (ERROR_OK != retval)
1049 return retval;
1050 }
1051
1052 int cur_khz = jtag_get_speed_khz();
1053 retval = jtag_get_speed_readable(&cur_khz);
1054 if (ERROR_OK != retval)
1055 return retval;
1056
1057 if (cur_khz)
1058 command_print(CMD, "RCLK not supported - fallback to %d kHz", cur_khz);
1059 else
1060 command_print(CMD, "RCLK - adaptive");
1061
1062 return retval;
1063 }
1064
1065 COMMAND_HANDLER(handle_runtest_command)
1066 {
1067 if (CMD_ARGC != 1)
1068 return ERROR_COMMAND_SYNTAX_ERROR;
1069
1070 unsigned num_clocks;
1071 COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num_clocks);
1072
1073 jtag_add_runtest(num_clocks, TAP_IDLE);
1074 return jtag_execute_queue();
1075 }
1076
1077 /*
1078 * For "irscan" or "drscan" commands, the "end" (really, "next") state
1079 * should be stable ... and *NOT* a shift state, otherwise free-running
1080 * jtag clocks could change the values latched by the update state.
1081 * Not surprisingly, this is the same constraint as SVF; the "irscan"
1082 * and "drscan" commands are a write-only subset of what SVF provides.
1083 */
1084
1085 COMMAND_HANDLER(handle_irscan_command)
1086 {
1087 int i;
1088 struct scan_field *fields;
1089 struct jtag_tap *tap = NULL;
1090 tap_state_t endstate;
1091
1092 if ((CMD_ARGC < 2) || (CMD_ARGC % 2))
1093 return ERROR_COMMAND_SYNTAX_ERROR;
1094
1095 /* optional "-endstate" "statename" at the end of the arguments,
1096 * so that e.g. IRPAUSE can let us load the data register before
1097 * entering RUN/IDLE to execute the instruction we load here.
1098 */
1099 endstate = TAP_IDLE;
1100
1101 if (CMD_ARGC >= 4) {
1102 /* have at least one pair of numbers.
1103 * is last pair the magic text? */
1104 if (strcmp("-endstate", CMD_ARGV[CMD_ARGC - 2]) == 0) {
1105 endstate = tap_state_by_name(CMD_ARGV[CMD_ARGC - 1]);
1106 if (endstate == TAP_INVALID)
1107 return ERROR_COMMAND_SYNTAX_ERROR;
1108 if (!scan_is_safe(endstate))
1109 LOG_WARNING("unstable irscan endstate \"%s\"",
1110 CMD_ARGV[CMD_ARGC - 1]);
1111 CMD_ARGC -= 2;
1112 }
1113 }
1114
1115 int num_fields = CMD_ARGC / 2;
1116 if (num_fields > 1) {
1117 /* we really should be looking at plain_ir_scan if we want
1118 * anything more fancy.
1119 */
1120 LOG_ERROR("Specify a single value for tap");
1121 return ERROR_COMMAND_SYNTAX_ERROR;
1122 }
1123
1124 fields = calloc(num_fields, sizeof(*fields));
1125
1126 int retval;
1127 for (i = 0; i < num_fields; i++) {
1128 tap = jtag_tap_by_string(CMD_ARGV[i*2]);
1129 if (tap == NULL) {
1130 free(fields);
1131 command_print(CMD, "Tap: %s unknown", CMD_ARGV[i*2]);
1132
1133 return ERROR_FAIL;
1134 }
1135 uint64_t value;
1136 retval = parse_u64(CMD_ARGV[i * 2 + 1], &value);
1137 if (ERROR_OK != retval)
1138 goto error_return;
1139
1140 int field_size = tap->ir_length;
1141 fields[i].num_bits = field_size;
1142 uint8_t *v = calloc(1, DIV_ROUND_UP(field_size, 8));
1143 if (!v) {
1144 LOG_ERROR("Out of memory");
1145 goto error_return;
1146 }
1147
1148 buf_set_u64(v, 0, field_size, value);
1149 fields[i].out_value = v;
1150 fields[i].in_value = NULL;
1151 }
1152
1153 /* did we have an endstate? */
1154 jtag_add_ir_scan(tap, fields, endstate);
1155
1156 retval = jtag_execute_queue();
1157
1158 error_return:
1159 for (i = 0; i < num_fields; i++)
1160 free((void *)fields[i].out_value);
1161
1162 free(fields);
1163
1164 return retval;
1165 }
1166
1167 COMMAND_HANDLER(handle_verify_ircapture_command)
1168 {
1169 if (CMD_ARGC > 1)
1170 return ERROR_COMMAND_SYNTAX_ERROR;
1171
1172 if (CMD_ARGC == 1) {
1173 bool enable;
1174 COMMAND_PARSE_ENABLE(CMD_ARGV[0], enable);
1175 jtag_set_verify_capture_ir(enable);
1176 }
1177
1178 const char *status = jtag_will_verify_capture_ir() ? "enabled" : "disabled";
1179 command_print(CMD, "verify Capture-IR is %s", status);
1180
1181 return ERROR_OK;
1182 }
1183
1184 COMMAND_HANDLER(handle_verify_jtag_command)
1185 {
1186 if (CMD_ARGC > 1)
1187 return ERROR_COMMAND_SYNTAX_ERROR;
1188
1189 if (CMD_ARGC == 1) {
1190 bool enable;
1191 COMMAND_PARSE_ENABLE(CMD_ARGV[0], enable);
1192 jtag_set_verify(enable);
1193 }
1194
1195 const char *status = jtag_will_verify() ? "enabled" : "disabled";
1196 command_print(CMD, "verify jtag capture is %s", status);
1197
1198 return ERROR_OK;
1199 }
1200
1201 COMMAND_HANDLER(handle_tms_sequence_command)
1202 {
1203 if (CMD_ARGC > 1)
1204 return ERROR_COMMAND_SYNTAX_ERROR;
1205
1206 if (CMD_ARGC == 1) {
1207 bool use_new_table;
1208 if (strcmp(CMD_ARGV[0], "short") == 0)
1209 use_new_table = true;
1210 else if (strcmp(CMD_ARGV[0], "long") == 0)
1211 use_new_table = false;
1212 else
1213 return ERROR_COMMAND_SYNTAX_ERROR;
1214
1215 tap_use_new_tms_table(use_new_table);
1216 }
1217
1218 command_print(CMD, "tms sequence is %s",
1219 tap_uses_new_tms_table() ? "short" : "long");
1220
1221 return ERROR_OK;
1222 }
1223
1224 COMMAND_HANDLER(handle_jtag_flush_queue_sleep)
1225 {
1226 if (CMD_ARGC != 1)
1227 return ERROR_COMMAND_SYNTAX_ERROR;
1228
1229 int sleep_ms;
1230 COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], sleep_ms);
1231
1232 jtag_set_flush_queue_sleep(sleep_ms);
1233
1234 return ERROR_OK;
1235 }
1236
1237 COMMAND_HANDLER(handle_wait_srst_deassert)
1238 {
1239 if (CMD_ARGC != 1)
1240 return ERROR_COMMAND_SYNTAX_ERROR;
1241
1242 int timeout_ms;
1243 COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], timeout_ms);
1244 if ((timeout_ms <= 0) || (timeout_ms > 100000)) {
1245 LOG_ERROR("Timeout must be an integer between 0 and 100000");
1246 return ERROR_FAIL;
1247 }
1248
1249 LOG_USER("Waiting for srst assert + deassert for at most %dms", timeout_ms);
1250 int asserted_yet;
1251 int64_t then = timeval_ms();
1252 while (jtag_srst_asserted(&asserted_yet) == ERROR_OK) {
1253 if ((timeval_ms() - then) > timeout_ms) {
1254 LOG_ERROR("Timed out");
1255 return ERROR_FAIL;
1256 }
1257 if (asserted_yet)
1258 break;
1259 }
1260 while (jtag_srst_asserted(&asserted_yet) == ERROR_OK) {
1261 if ((timeval_ms() - then) > timeout_ms) {
1262 LOG_ERROR("Timed out");
1263 return ERROR_FAIL;
1264 }
1265 if (!asserted_yet)
1266 break;
1267 }
1268
1269 return ERROR_OK;
1270 }
1271
1272 static const struct command_registration jtag_command_handlers[] = {
1273
1274 {
1275 .name = "jtag_flush_queue_sleep",
1276 .handler = handle_jtag_flush_queue_sleep,
1277 .mode = COMMAND_ANY,
1278 .help = "For debug purposes(simulate long delays of interface) "
1279 "to test performance or change in behavior. Default 0ms.",
1280 .usage = "[sleep in ms]",
1281 },
1282 {
1283 .name = "jtag_rclk",
1284 .handler = handle_jtag_rclk_command,
1285 .mode = COMMAND_ANY,
1286 .help = "With an argument, change to to use adaptive clocking "
1287 "if possible; else to use the fallback speed. "
1288 "With or without argument, display current setting.",
1289 .usage = "[fallback_speed_khz]",
1290 },
1291 {
1292 .name = "jtag_ntrst_delay",
1293 .handler = handle_jtag_ntrst_delay_command,
1294 .mode = COMMAND_ANY,
1295 .help = "delay after deasserting trst in ms",
1296 .usage = "[milliseconds]",
1297 },
1298 {
1299 .name = "jtag_ntrst_assert_width",
1300 .handler = handle_jtag_ntrst_assert_width_command,
1301 .mode = COMMAND_ANY,
1302 .help = "delay after asserting trst in ms",
1303 .usage = "[milliseconds]",
1304 },
1305 {
1306 .name = "scan_chain",
1307 .handler = handle_scan_chain_command,
1308 .mode = COMMAND_ANY,
1309 .help = "print current scan chain configuration",
1310 .usage = ""
1311 },
1312 {
1313 .name = "runtest",
1314 .handler = handle_runtest_command,
1315 .mode = COMMAND_EXEC,
1316 .help = "Move to Run-Test/Idle, and issue TCK for num_cycles.",
1317 .usage = "num_cycles"
1318 },
1319 {
1320 .name = "irscan",
1321 .handler = handle_irscan_command,
1322 .mode = COMMAND_EXEC,
1323 .help = "Execute Instruction Register (IR) scan. The "
1324 "specified opcodes are put into each TAP's IR, "
1325 "and other TAPs are put in BYPASS.",
1326 .usage = "[tap_name instruction]* ['-endstate' state_name]",
1327 },
1328 {
1329 .name = "verify_ircapture",
1330 .handler = handle_verify_ircapture_command,
1331 .mode = COMMAND_ANY,
1332 .help = "Display or assign flag controlling whether to "
1333 "verify values captured during Capture-IR.",
1334 .usage = "['enable'|'disable']",
1335 },
1336 {
1337 .name = "verify_jtag",
1338 .handler = handle_verify_jtag_command,
1339 .mode = COMMAND_ANY,
1340 .help = "Display or assign flag controlling whether to "
1341 "verify values captured during IR and DR scans.",
1342 .usage = "['enable'|'disable']",
1343 },
1344 {
1345 .name = "tms_sequence",
1346 .handler = handle_tms_sequence_command,
1347 .mode = COMMAND_ANY,
1348 .help = "Display or change what style TMS sequences to use "
1349 "for JTAG state transitions: short (default) or "
1350 "long. Only for working around JTAG bugs.",
1351 /* Specifically for working around DRIVER bugs... */
1352 .usage = "['short'|'long']",
1353 },
1354 {
1355 .name = "wait_srst_deassert",
1356 .handler = handle_wait_srst_deassert,
1357 .mode = COMMAND_ANY,
1358 .help = "Wait for an SRST deassert. "
1359 "Useful for cases where you need something to happen within ms "
1360 "of an srst deassert. Timeout in ms ",
1361 .usage = "ms",
1362 },
1363 {
1364 .name = "jtag",
1365 .mode = COMMAND_ANY,
1366 .help = "perform jtag tap actions",
1367 .usage = "",
1368
1369 .chain = jtag_subcommand_handlers,
1370 },
1371 {
1372 .chain = jtag_command_handlers_to_move,
1373 },
1374 COMMAND_REGISTRATION_DONE
1375 };
1376
1377 int jtag_register_commands(struct command_context *cmd_ctx)
1378 {
1379 return register_commands(cmd_ctx, NULL, jtag_command_handlers);
1380 }

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)