cmd: add missing usage vars
[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 .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_EXEC,
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_CTX,
964 " TapName Enabled IdCode Expected IrLen IrCap IrMask");
965 command_print(CMD_CTX,
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_CTX,
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[1]);
995 if (tap->ignore_version)
996 expected_id[2] = '*';
997
998 command_print(CMD_CTX,
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 {
1015 unsigned delay;
1016 COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay);
1017
1018 jtag_set_ntrst_delay(delay);
1019 }
1020 command_print(CMD_CTX, "jtag_ntrst_delay: %u", jtag_get_ntrst_delay());
1021 return ERROR_OK;
1022 }
1023
1024 COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command)
1025 {
1026 if (CMD_ARGC > 1)
1027 return ERROR_COMMAND_SYNTAX_ERROR;
1028 if (CMD_ARGC == 1)
1029 {
1030 unsigned delay;
1031 COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], delay);
1032
1033 jtag_set_ntrst_assert_width(delay);
1034 }
1035 command_print(CMD_CTX, "jtag_ntrst_assert_width: %u", jtag_get_ntrst_assert_width());
1036 return ERROR_OK;
1037 }
1038
1039 COMMAND_HANDLER(handle_jtag_rclk_command)
1040 {
1041 if (CMD_ARGC > 1)
1042 return ERROR_COMMAND_SYNTAX_ERROR;
1043
1044 int retval = ERROR_OK;
1045 if (CMD_ARGC == 1)
1046 {
1047 unsigned khz = 0;
1048 COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], khz);
1049
1050 retval = jtag_config_rclk(khz);
1051 if (ERROR_OK != retval)
1052 return retval;
1053 }
1054
1055 int cur_khz = jtag_get_speed_khz();
1056 retval = jtag_get_speed_readable(&cur_khz);
1057 if (ERROR_OK != retval)
1058 return retval;
1059
1060 if (cur_khz)
1061 command_print(CMD_CTX, "RCLK not supported - fallback to %d kHz", cur_khz);
1062 else
1063 command_print(CMD_CTX, "RCLK - adaptive");
1064
1065 return retval;
1066 }
1067
1068 COMMAND_HANDLER(handle_jtag_reset_command)
1069 {
1070 if (CMD_ARGC != 2)
1071 return ERROR_COMMAND_SYNTAX_ERROR;
1072
1073 int trst = -1;
1074 if (CMD_ARGV[0][0] == '1')
1075 trst = 1;
1076 else if (CMD_ARGV[0][0] == '0')
1077 trst = 0;
1078 else
1079 return ERROR_COMMAND_SYNTAX_ERROR;
1080
1081 int srst = -1;
1082 if (CMD_ARGV[1][0] == '1')
1083 srst = 1;
1084 else if (CMD_ARGV[1][0] == '0')
1085 srst = 0;
1086 else
1087 return ERROR_COMMAND_SYNTAX_ERROR;
1088
1089 if (adapter_init(CMD_CTX) != ERROR_OK)
1090 return ERROR_JTAG_INIT_FAILED;
1091
1092 jtag_add_reset(trst, srst);
1093 return jtag_execute_queue();
1094 }
1095
1096 COMMAND_HANDLER(handle_runtest_command)
1097 {
1098 if (CMD_ARGC != 1)
1099 return ERROR_COMMAND_SYNTAX_ERROR;
1100
1101 unsigned num_clocks;
1102 COMMAND_PARSE_NUMBER(uint, CMD_ARGV[0], num_clocks);
1103
1104 jtag_add_runtest(num_clocks, TAP_IDLE);
1105 return jtag_execute_queue();
1106 }
1107
1108 /*
1109 * For "irscan" or "drscan" commands, the "end" (really, "next") state
1110 * should be stable ... and *NOT* a shift state, otherwise free-running
1111 * jtag clocks could change the values latched by the update state.
1112 * Not surprisingly, this is the same constraint as SVF; the "irscan"
1113 * and "drscan" commands are a write-only subset of what SVF provides.
1114 */
1115
1116 COMMAND_HANDLER(handle_irscan_command)
1117 {
1118 int i;
1119 struct scan_field *fields;
1120 struct jtag_tap *tap = NULL;
1121 tap_state_t endstate;
1122
1123 if ((CMD_ARGC < 2) || (CMD_ARGC % 2))
1124 {
1125 return ERROR_COMMAND_SYNTAX_ERROR;
1126 }
1127
1128 /* optional "-endstate" "statename" at the end of the arguments,
1129 * so that e.g. IRPAUSE can let us load the data register before
1130 * entering RUN/IDLE to execute the instruction we load here.
1131 */
1132 endstate = TAP_IDLE;
1133
1134 if (CMD_ARGC >= 4) {
1135 /* have at least one pair of numbers. */
1136 /* is last pair the magic text? */
1137 if (strcmp("-endstate", CMD_ARGV[CMD_ARGC - 2]) == 0) {
1138 endstate = tap_state_by_name(CMD_ARGV[CMD_ARGC - 1]);
1139 if (endstate == TAP_INVALID)
1140 return ERROR_COMMAND_SYNTAX_ERROR;
1141 if (!scan_is_safe(endstate))
1142 LOG_WARNING("unstable irscan endstate \"%s\"",
1143 CMD_ARGV[CMD_ARGC - 1]);
1144 CMD_ARGC -= 2;
1145 }
1146 }
1147
1148 int num_fields = CMD_ARGC / 2;
1149 if (num_fields > 1)
1150 {
1151 /* we really should be looking at plain_ir_scan if we want
1152 * anything more fancy.
1153 */
1154 LOG_ERROR("Specify a single value for tap");
1155 return ERROR_COMMAND_SYNTAX_ERROR;
1156 }
1157
1158 size_t fields_len = sizeof(struct scan_field) * num_fields;
1159 fields = malloc(fields_len);
1160 memset(fields, 0, fields_len);
1161
1162 int retval;
1163 for (i = 0; i < num_fields; i++)
1164 {
1165 tap = jtag_tap_by_string(CMD_ARGV[i*2]);
1166 if (tap == NULL)
1167 {
1168 int j;
1169 for (j = 0; j < i; j++)
1170 free((void *)fields[j].out_value);
1171 free(fields);
1172 command_print(CMD_CTX, "Tap: %s unknown", CMD_ARGV[i*2]);
1173
1174 return ERROR_FAIL;
1175 }
1176 int field_size = tap->ir_length;
1177 fields[i].num_bits = field_size;
1178 fields[i].out_value = malloc(DIV_ROUND_UP(field_size, 8));
1179
1180 uint32_t value;
1181 retval = parse_u32(CMD_ARGV[i * 2 + 1], &value);
1182 if (ERROR_OK != retval)
1183 goto error_return;
1184 void *v = (void *)fields[i].out_value;
1185 buf_set_u32(v, 0, field_size, value);
1186 fields[i].in_value = NULL;
1187 }
1188
1189 /* did we have an endstate? */
1190 jtag_add_ir_scan(tap, fields, endstate);
1191
1192 retval = jtag_execute_queue();
1193
1194 error_return:
1195 for (i = 0; i < num_fields; i++)
1196 {
1197 if (NULL != fields[i].out_value)
1198 free((void *)fields[i].out_value);
1199 }
1200
1201 free (fields);
1202
1203 return retval;
1204 }
1205
1206
1207 COMMAND_HANDLER(handle_verify_ircapture_command)
1208 {
1209 if (CMD_ARGC > 1)
1210 return ERROR_COMMAND_SYNTAX_ERROR;
1211
1212 if (CMD_ARGC == 1)
1213 {
1214 bool enable;
1215 COMMAND_PARSE_ENABLE(CMD_ARGV[0], enable);
1216 jtag_set_verify_capture_ir(enable);
1217 }
1218
1219 const char *status = jtag_will_verify_capture_ir() ? "enabled": "disabled";
1220 command_print(CMD_CTX, "verify Capture-IR is %s", status);
1221
1222 return ERROR_OK;
1223 }
1224
1225 COMMAND_HANDLER(handle_verify_jtag_command)
1226 {
1227 if (CMD_ARGC > 1)
1228 return ERROR_COMMAND_SYNTAX_ERROR;
1229
1230 if (CMD_ARGC == 1)
1231 {
1232 bool enable;
1233 COMMAND_PARSE_ENABLE(CMD_ARGV[0], enable);
1234 jtag_set_verify(enable);
1235 }
1236
1237 const char *status = jtag_will_verify() ? "enabled": "disabled";
1238 command_print(CMD_CTX, "verify jtag capture is %s", status);
1239
1240 return ERROR_OK;
1241 }
1242
1243 COMMAND_HANDLER(handle_tms_sequence_command)
1244 {
1245 if (CMD_ARGC > 1)
1246 return ERROR_COMMAND_SYNTAX_ERROR;
1247
1248 if (CMD_ARGC == 1)
1249 {
1250 bool use_new_table;
1251 if (strcmp(CMD_ARGV[0], "short") == 0)
1252 use_new_table = true;
1253 else if (strcmp(CMD_ARGV[0], "long") == 0)
1254 use_new_table = false;
1255 else
1256 return ERROR_COMMAND_SYNTAX_ERROR;
1257
1258 tap_use_new_tms_table(use_new_table);
1259 }
1260
1261 command_print(CMD_CTX, "tms sequence is %s",
1262 tap_uses_new_tms_table() ? "short": "long");
1263
1264 return ERROR_OK;
1265 }
1266
1267 COMMAND_HANDLER(handle_jtag_flush_queue_sleep)
1268 {
1269 if (CMD_ARGC != 1)
1270 return ERROR_COMMAND_SYNTAX_ERROR;
1271
1272 int sleep_ms;
1273 COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], sleep_ms);
1274
1275 jtag_set_flush_queue_sleep(sleep_ms);
1276
1277 return ERROR_OK;
1278 }
1279
1280 COMMAND_HANDLER(handle_wait_srst_deassert)
1281 {
1282 if (CMD_ARGC != 1)
1283 return ERROR_COMMAND_SYNTAX_ERROR;
1284
1285 int timeout_ms;
1286 COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], timeout_ms);
1287 if ((timeout_ms <= 0) || (timeout_ms > 100000))
1288 {
1289 LOG_ERROR("Timeout must be an integer between 0 and 100000");
1290 return ERROR_FAIL;
1291 }
1292
1293 LOG_USER("Waiting for srst assert + deassert for at most %dms", timeout_ms);
1294 int asserted_yet;
1295 long long then = timeval_ms();
1296 while (jtag_srst_asserted(&asserted_yet) == ERROR_OK)
1297 {
1298 if ((timeval_ms() - then) > timeout_ms)
1299 {
1300 LOG_ERROR("Timed out");
1301 return ERROR_FAIL;
1302 }
1303 if (asserted_yet)
1304 break;
1305 }
1306 while (jtag_srst_asserted(&asserted_yet) == ERROR_OK)
1307 {
1308 if ((timeval_ms() - then) > timeout_ms)
1309 {
1310 LOG_ERROR("Timed out");
1311 return ERROR_FAIL;
1312 }
1313 if (!asserted_yet)
1314 break;
1315 }
1316
1317 return ERROR_OK;
1318 }
1319
1320
1321
1322 static const struct command_registration jtag_command_handlers[] = {
1323
1324 {
1325 .name = "jtag_flush_queue_sleep",
1326 .handler = handle_jtag_flush_queue_sleep,
1327 .mode = COMMAND_ANY,
1328 .help = "For debug purposes(simulate long delays of interface) "
1329 "to test performance or change in behavior. Default 0ms.",
1330 .usage = "[sleep in ms]",
1331 },
1332 {
1333 .name = "jtag_rclk",
1334 .handler = handle_jtag_rclk_command,
1335 .mode = COMMAND_ANY,
1336 .help = "With an argument, change to to use adaptive clocking "
1337 "if possible; else to use the fallback speed. "
1338 "With or without argument, display current setting.",
1339 .usage = "[fallback_speed_khz]",
1340 },
1341 {
1342 .name = "jtag_ntrst_delay",
1343 .handler = handle_jtag_ntrst_delay_command,
1344 .mode = COMMAND_ANY,
1345 .help = "delay after deasserting trst in ms",
1346 .usage = "[milliseconds]",
1347 },
1348 {
1349 .name = "jtag_ntrst_assert_width",
1350 .handler = handle_jtag_ntrst_assert_width_command,
1351 .mode = COMMAND_ANY,
1352 .help = "delay after asserting trst in ms",
1353 .usage = "[milliseconds]",
1354 },
1355 {
1356 .name = "scan_chain",
1357 .handler = handle_scan_chain_command,
1358 .mode = COMMAND_ANY,
1359 .help = "print current scan chain configuration",
1360 .usage = ""
1361 },
1362 {
1363 .name = "jtag_reset",
1364 .handler = handle_jtag_reset_command,
1365 .mode = COMMAND_EXEC,
1366 .help = "Set reset line values. Value '1' is active, "
1367 "value '0' is inactive.",
1368 .usage = "trst_active srst_active",
1369 },
1370 {
1371 .name = "runtest",
1372 .handler = handle_runtest_command,
1373 .mode = COMMAND_EXEC,
1374 .help = "Move to Run-Test/Idle, and issue TCK for num_cycles.",
1375 .usage = "num_cycles"
1376 },
1377 {
1378 .name = "irscan",
1379 .handler = handle_irscan_command,
1380 .mode = COMMAND_EXEC,
1381 .help = "Execute Instruction Register (DR) scan. The "
1382 "specified opcodes are put into each TAP's IR, "
1383 "and other TAPs are put in BYPASS.",
1384 .usage = "[tap_name instruction]* ['-endstate' state_name]",
1385 },
1386 {
1387 .name = "verify_ircapture",
1388 .handler = handle_verify_ircapture_command,
1389 .mode = COMMAND_ANY,
1390 .help = "Display or assign flag controlling whether to "
1391 "verify values captured during Capture-IR.",
1392 .usage = "['enable'|'disable']",
1393 },
1394 {
1395 .name = "verify_jtag",
1396 .handler = handle_verify_jtag_command,
1397 .mode = COMMAND_ANY,
1398 .help = "Display or assign flag controlling whether to "
1399 "verify values captured during IR and DR scans.",
1400 .usage = "['enable'|'disable']",
1401 },
1402 {
1403 .name = "tms_sequence",
1404 .handler = handle_tms_sequence_command,
1405 .mode = COMMAND_ANY,
1406 .help = "Display or change what style TMS sequences to use "
1407 "for JTAG state transitions: short (default) or "
1408 "long. Only for working around JTAG bugs.",
1409 /* Specifically for working around DRIVER bugs... */
1410 .usage = "['short'|'long']",
1411 },
1412 {
1413 .name = "wait_srst_deassert",
1414 .handler = handle_wait_srst_deassert,
1415 .mode = COMMAND_ANY,
1416 .help = "Wait for an SRST deassert. "
1417 "Useful for cases where you need something to happen within ms "
1418 "of an srst deassert. Timeout in ms ",
1419 .usage = "ms",
1420 },
1421 {
1422 .name = "jtag",
1423 .mode = COMMAND_ANY,
1424 .help = "perform jtag tap actions",
1425 .usage = "",
1426
1427 .chain = jtag_subcommand_handlers,
1428 },
1429 {
1430 .chain = jtag_command_handlers_to_move,
1431 },
1432 COMMAND_REGISTRATION_DONE
1433 };
1434
1435 int jtag_register_commands(struct command_context *cmd_ctx)
1436 {
1437 return register_commands(cmd_ctx, NULL, jtag_command_handlers);
1438 }

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)