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

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)