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

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)