1 /***************************************************************************
2 * Copyright (C) 2005 by Dominic Rath *
3 * Dominic.Rath@gmx.de *
5 * Copyright (C) 2007,2008 Øyvind Harboe *
6 * oyvind.harboe@zylin.com *
8 * Copyright (C) 2009 SoftPLC Corporation
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License, or *
15 * (at your option) any later version. *
17 * This program is distributed in the hope that it will be useful, *
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20 * GNU General Public License for more details. *
22 * You should have received a copy of the GNU General Public License *
23 * along with this program; if not, write to the *
24 * Free Software Foundation, Inc., *
25 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
26 ***************************************************************************/
31 #include "replacements.h"
42 /* note that this is not marked as static as it must be available from outside jtag.c for those
43 that implement the jtag_xxx() minidriver layer
45 int jtag_error
=ERROR_OK
;
48 typedef struct cmd_queue_page_s
52 struct cmd_queue_page_s
*next
;
55 #define CMD_QUEUE_PAGE_SIZE (1024 * 1024)
56 static cmd_queue_page_t
*cmd_queue_pages
= NULL
;
58 char* jtag_event_strings
[] =
60 "JTAG controller reset (RESET or TRST)"
63 const Jim_Nvp nvp_jtag_tap_event
[] = {
64 { .value
= JTAG_TAP_EVENT_ENABLE
, .name
= "tap-enable" },
65 { .value
= JTAG_TAP_EVENT_DISABLE
, .name
= "tap-disable" },
67 { .name
= NULL
, .value
= -1 }
73 jtag_command_t
*jtag_command_queue
= NULL
;
74 jtag_command_t
**last_comand_pointer
= &jtag_command_queue
;
75 static jtag_tap_t
*jtag_all_taps
= NULL
;
77 enum reset_types jtag_reset_config
= RESET_NONE
;
78 tap_state_t cmd_queue_end_state
= TAP_RESET
;
79 tap_state_t cmd_queue_cur_state
= TAP_RESET
;
81 int jtag_verify_capture_ir
= 1;
83 /* how long the OpenOCD should wait before attempting JTAG communication after reset lines deasserted (in ms) */
84 int jtag_nsrst_delay
= 0; /* default to no nSRST delay */
85 int jtag_ntrst_delay
= 0; /* default to no nTRST delay */
87 /* maximum number of JTAG devices expected in the chain
89 #define JTAG_MAX_CHAIN_SIZE 20
91 /* callbacks to inform high-level handlers about JTAG state changes */
92 jtag_event_callback_t
*jtag_event_callbacks
;
95 static int speed_khz
= 0;
96 /* flag if the kHz speed was defined */
97 static int hasKHz
= 0;
99 /* jtag interfaces (parport, FTDI-USB, TI-USB, ...)
102 #if BUILD_ECOSBOARD == 1
103 extern jtag_interface_t zy1000_interface
;
106 #if BUILD_PARPORT == 1
107 extern jtag_interface_t parport_interface
;
111 extern jtag_interface_t dummy_interface
;
114 #if BUILD_FT2232_FTD2XX == 1
115 extern jtag_interface_t ft2232_interface
;
118 #if BUILD_FT2232_LIBFTDI == 1
119 extern jtag_interface_t ft2232_interface
;
122 #if BUILD_AMTJTAGACCEL == 1
123 extern jtag_interface_t amt_jtagaccel_interface
;
126 #if BUILD_EP93XX == 1
127 extern jtag_interface_t ep93xx_interface
;
130 #if BUILD_AT91RM9200 == 1
131 extern jtag_interface_t at91rm9200_interface
;
134 #if BUILD_GW16012 == 1
135 extern jtag_interface_t gw16012_interface
;
138 #if BUILD_PRESTO_LIBFTDI == 1 || BUILD_PRESTO_FTD2XX == 1
139 extern jtag_interface_t presto_interface
;
142 #if BUILD_USBPROG == 1
143 extern jtag_interface_t usbprog_interface
;
147 extern jtag_interface_t jlink_interface
;
150 #if BUILD_VSLLINK == 1
151 extern jtag_interface_t vsllink_interface
;
155 extern jtag_interface_t rlink_interface
;
158 jtag_interface_t
*jtag_interfaces
[] = {
159 #if BUILD_ECOSBOARD == 1
162 #if BUILD_PARPORT == 1
168 #if BUILD_FT2232_FTD2XX == 1
171 #if BUILD_FT2232_LIBFTDI == 1
174 #if BUILD_AMTJTAGACCEL == 1
175 &amt_jtagaccel_interface
,
177 #if BUILD_EP93XX == 1
180 #if BUILD_AT91RM9200 == 1
181 &at91rm9200_interface
,
183 #if BUILD_GW16012 == 1
186 #if BUILD_PRESTO_LIBFTDI == 1 || BUILD_PRESTO_FTD2XX == 1
189 #if BUILD_USBPROG == 1
195 #if BUILD_VSLLINK == 1
204 jtag_interface_t
*jtag
= NULL
;
207 jtag_interface_t
*jtag_interface
= NULL
;
210 /* forward declarations */
211 void jtag_add_pathmove(int num_states
, tap_state_t
*path
);
212 void jtag_add_runtest(int num_cycles
, tap_state_t endstate
);
213 void jtag_add_end_state(tap_state_t endstate
);
214 void jtag_add_sleep(u32 us
);
215 int jtag_execute_queue(void);
219 int handle_interface_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
220 int handle_jtag_speed_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
221 int handle_jtag_khz_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
222 int handle_jtag_device_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
223 int handle_reset_config_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
224 int handle_jtag_nsrst_delay_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
225 int handle_jtag_ntrst_delay_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
227 int handle_scan_chain_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
229 int handle_endstate_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
230 int handle_jtag_reset_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
231 int handle_runtest_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
232 int handle_irscan_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
233 int Jim_Command_drscan(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
);
235 int handle_verify_ircapture_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
);
237 jtag_tap_t
*jtag_AllTaps(void)
239 return jtag_all_taps
;
242 int jtag_NumTotalTaps(void)
256 int jtag_NumEnabledTaps(void)
273 jtag_tap_t
*jtag_TapByString( const char *s
)
281 if( 0 == strcmp( t
->dotted_name
, s
) ){
287 // backup plan is by number
289 /* ok - is "s" a number? */
291 n
= strtol( s
, &cp
, 0 );
292 if( (s
!= cp
) && (*cp
== 0) ){
294 t
= jtag_TapByAbsPosition(n
);
300 jtag_tap_t
* jtag_TapByJimObj( Jim_Interp
*interp
, Jim_Obj
*o
)
305 cp
= Jim_GetString( o
, NULL
);
310 t
= jtag_TapByString( cp
);
313 Jim_SetResult_sprintf(interp
,"Tap: %s is unknown", cp
);
318 /* returns a pointer to the n-th device in the scan chain */
319 jtag_tap_t
* jtag_TapByAbsPosition( int n
)
327 while( t
&& (n
> 0)) {
334 int jtag_register_event_callback(int (*callback
)(enum jtag_event event
, void *priv
), void *priv
)
336 jtag_event_callback_t
**callbacks_p
= &jtag_event_callbacks
;
338 if (callback
== NULL
)
340 return ERROR_INVALID_ARGUMENTS
;
345 while ((*callbacks_p
)->next
)
346 callbacks_p
= &((*callbacks_p
)->next
);
347 callbacks_p
= &((*callbacks_p
)->next
);
350 (*callbacks_p
) = malloc(sizeof(jtag_event_callback_t
));
351 (*callbacks_p
)->callback
= callback
;
352 (*callbacks_p
)->priv
= priv
;
353 (*callbacks_p
)->next
= NULL
;
358 int jtag_unregister_event_callback(int (*callback
)(enum jtag_event event
, void *priv
))
360 jtag_event_callback_t
**callbacks_p
= &jtag_event_callbacks
;
362 if (callback
== NULL
)
364 return ERROR_INVALID_ARGUMENTS
;
369 jtag_event_callback_t
**next
= &((*callbacks_p
)->next
);
370 if ((*callbacks_p
)->callback
== callback
)
373 *callbacks_p
= *next
;
381 int jtag_call_event_callbacks(enum jtag_event event
)
383 jtag_event_callback_t
*callback
= jtag_event_callbacks
;
385 LOG_DEBUG("jtag event: %s", jtag_event_strings
[event
]);
389 callback
->callback(event
, callback
->priv
);
390 callback
= callback
->next
;
396 /* returns a pointer to the pointer of the last command in queue
397 * this may be a pointer to the root pointer (jtag_command_queue)
398 * or to the next member of the last but one command
400 jtag_command_t
** jtag_get_last_command_p(void)
402 /* jtag_command_t *cmd = jtag_command_queue;
408 return &jtag_command_queue;
412 return last_comand_pointer
;
415 void* cmd_queue_alloc(size_t size
)
417 cmd_queue_page_t
**p_page
= &cmd_queue_pages
;
423 * We align/round the *SIZE* per below
424 * so that all pointers returned by
425 * this function are reasonably well
428 * If we did not, then an "odd-length" request would cause the
429 * *next* allocation to be at an *odd* address, and because
430 * this function has the same type of api as malloc() - we
431 * must also return pointers that have the same type of
434 * What I do not/have is a reasonable portable means
437 * The solution here, is based on these suggestions.
438 * http://gcc.gnu.org/ml/gcc-help/2008-12/msg00041.html
441 union worse_case_align
{
447 #define ALIGN_SIZE (sizeof(union worse_case_align))
449 /* The alignment process. */
450 size
= (size
+ ALIGN_SIZE
-1) & (~(ALIGN_SIZE
-1));
455 while ((*p_page
)->next
)
456 p_page
= &((*p_page
)->next
);
457 if (CMD_QUEUE_PAGE_SIZE
- (*p_page
)->used
< size
)
458 p_page
= &((*p_page
)->next
);
463 *p_page
= malloc(sizeof(cmd_queue_page_t
));
465 (*p_page
)->address
= malloc(CMD_QUEUE_PAGE_SIZE
);
466 (*p_page
)->next
= NULL
;
469 offset
= (*p_page
)->used
;
470 (*p_page
)->used
+= size
;
472 t
=(u8
*)((*p_page
)->address
);
476 void cmd_queue_free(void)
478 cmd_queue_page_t
*page
= cmd_queue_pages
;
482 cmd_queue_page_t
*last
= page
;
488 cmd_queue_pages
= NULL
;
491 static void jtag_prelude1(void)
495 LOG_WARNING("JTAG command queued, while TRST is low (TAP in reset)");
496 jtag_error
=ERROR_JTAG_TRST_ASSERTED
;
500 if (cmd_queue_end_state
== TAP_RESET
)
501 jtag_call_event_callbacks(JTAG_TRST_ASSERTED
);
504 static void jtag_prelude(tap_state_t state
)
509 jtag_add_end_state(state
);
511 cmd_queue_cur_state
= cmd_queue_end_state
;
514 void jtag_add_ir_scan(int num_fields
, scan_field_t
*fields
, tap_state_t state
)
520 retval
=interface_jtag_add_ir_scan(num_fields
, fields
, cmd_queue_end_state
);
521 if (retval
!=ERROR_OK
)
525 int MINIDRIVER(interface_jtag_add_ir_scan
)(int num_fields
, scan_field_t
*fields
, tap_state_t state
)
527 jtag_command_t
**last_cmd
;
535 last_cmd
= jtag_get_last_command_p();
537 /* allocate memory for a new list member */
538 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
539 (*last_cmd
)->next
= NULL
;
540 last_comand_pointer
= &((*last_cmd
)->next
);
541 (*last_cmd
)->type
= JTAG_SCAN
;
543 /* allocate memory for ir scan command */
544 (*last_cmd
)->cmd
.scan
= cmd_queue_alloc(sizeof(scan_command_t
));
545 (*last_cmd
)->cmd
.scan
->ir_scan
= 1;
546 x
= jtag_NumEnabledTaps();
547 (*last_cmd
)->cmd
.scan
->num_fields
= x
; /* one field per device */
548 (*last_cmd
)->cmd
.scan
->fields
= cmd_queue_alloc(x
* sizeof(scan_field_t
));
549 (*last_cmd
)->cmd
.scan
->end_state
= state
;
556 // do this here so it is not forgotten
557 tap
= jtag_NextEnabledTap(tap
);
562 scan_size
= tap
->ir_length
;
563 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].tap
= tap
;
564 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].num_bits
= scan_size
;
565 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].in_value
= NULL
;
566 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].in_handler
= NULL
; /* disable verification by default */
568 /* search the list */
569 for (j
= 0; j
< num_fields
; j
++)
571 if (tap
== fields
[j
].tap
)
574 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].out_value
= buf_cpy(fields
[j
].out_value
, cmd_queue_alloc(CEIL(scan_size
, 8)), scan_size
);
575 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].out_mask
= buf_cpy(fields
[j
].out_mask
, cmd_queue_alloc(CEIL(scan_size
, 8)), scan_size
);
577 if (jtag_verify_capture_ir
)
579 if (fields
[j
].in_handler
==NULL
)
581 jtag_set_check_value((*last_cmd
)->cmd
.scan
->fields
+nth_tap
, tap
->expected
, tap
->expected_mask
, NULL
);
584 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].in_handler
= fields
[j
].in_handler
;
585 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].in_handler_priv
= fields
[j
].in_handler_priv
;
586 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].in_check_value
= tap
->expected
;
587 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].in_check_mask
= tap
->expected_mask
;
598 /* if a tap isn't listed, set it to BYPASS */
599 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].out_value
= buf_set_ones(cmd_queue_alloc(CEIL(scan_size
, 8)), scan_size
);
600 (*last_cmd
)->cmd
.scan
->fields
[nth_tap
].out_mask
= NULL
;
604 /* update device information */
605 buf_cpy((*last_cmd
)->cmd
.scan
->fields
[nth_tap
].out_value
, tap
->cur_instr
, scan_size
);
611 void jtag_add_plain_ir_scan(int num_fields
, scan_field_t
*fields
, tap_state_t state
)
617 retval
=interface_jtag_add_plain_ir_scan(num_fields
, fields
, cmd_queue_end_state
);
618 if (retval
!=ERROR_OK
)
622 int MINIDRIVER(interface_jtag_add_plain_ir_scan
)(int num_fields
, scan_field_t
*fields
, tap_state_t state
)
625 jtag_command_t
**last_cmd
;
627 last_cmd
= jtag_get_last_command_p();
629 /* allocate memory for a new list member */
630 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
631 (*last_cmd
)->next
= NULL
;
632 last_comand_pointer
= &((*last_cmd
)->next
);
633 (*last_cmd
)->type
= JTAG_SCAN
;
635 /* allocate memory for ir scan command */
636 (*last_cmd
)->cmd
.scan
= cmd_queue_alloc(sizeof(scan_command_t
));
637 (*last_cmd
)->cmd
.scan
->ir_scan
= 1;
638 (*last_cmd
)->cmd
.scan
->num_fields
= num_fields
;
639 (*last_cmd
)->cmd
.scan
->fields
= cmd_queue_alloc(num_fields
* sizeof(scan_field_t
));
640 (*last_cmd
)->cmd
.scan
->end_state
= state
;
642 for( i
= 0 ; i
< num_fields
; i
++ ){
643 int num_bits
= fields
[i
].num_bits
;
644 int num_bytes
= CEIL(fields
[i
].num_bits
, 8);
645 (*last_cmd
)->cmd
.scan
->fields
[i
].tap
= fields
[i
].tap
;
646 (*last_cmd
)->cmd
.scan
->fields
[i
].num_bits
= num_bits
;
647 (*last_cmd
)->cmd
.scan
->fields
[i
].out_value
= buf_cpy(fields
[i
].out_value
, cmd_queue_alloc(num_bytes
), num_bits
);
648 (*last_cmd
)->cmd
.scan
->fields
[i
].out_mask
= buf_cpy(fields
[i
].out_mask
, cmd_queue_alloc(num_bytes
), num_bits
);
649 (*last_cmd
)->cmd
.scan
->fields
[i
].in_value
= fields
[i
].in_value
;
650 (*last_cmd
)->cmd
.scan
->fields
[i
].in_check_value
= fields
[i
].in_check_value
;
651 (*last_cmd
)->cmd
.scan
->fields
[i
].in_check_mask
= fields
[i
].in_check_mask
;
652 (*last_cmd
)->cmd
.scan
->fields
[i
].in_handler
= NULL
;
653 (*last_cmd
)->cmd
.scan
->fields
[i
].in_handler_priv
= NULL
;
658 void jtag_add_dr_scan(int num_fields
, scan_field_t
*fields
, tap_state_t state
)
664 retval
=interface_jtag_add_dr_scan(num_fields
, fields
, cmd_queue_end_state
);
665 if (retval
!=ERROR_OK
)
669 int MINIDRIVER(interface_jtag_add_dr_scan
)(int num_fields
, scan_field_t
*fields
, tap_state_t state
)
673 int bypass_devices
= 0;
677 jtag_command_t
**last_cmd
= jtag_get_last_command_p();
680 /* count devices in bypass */
684 tap
= jtag_NextEnabledTap(tap
);
693 /* allocate memory for a new list member */
694 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
695 last_comand_pointer
= &((*last_cmd
)->next
);
696 (*last_cmd
)->next
= NULL
;
697 (*last_cmd
)->type
= JTAG_SCAN
;
699 /* allocate memory for dr scan command */
700 (*last_cmd
)->cmd
.scan
= cmd_queue_alloc(sizeof(scan_command_t
));
701 (*last_cmd
)->cmd
.scan
->ir_scan
= 0;
702 (*last_cmd
)->cmd
.scan
->num_fields
= num_fields
+ bypass_devices
;
703 (*last_cmd
)->cmd
.scan
->fields
= cmd_queue_alloc((num_fields
+ bypass_devices
) * sizeof(scan_field_t
));
704 (*last_cmd
)->cmd
.scan
->end_state
= state
;
710 tap
= jtag_NextEnabledTap(tap
);
715 (*last_cmd
)->cmd
.scan
->fields
[field_count
].tap
= tap
;
717 for (j
= 0; j
< num_fields
; j
++)
719 if (tap
== fields
[j
].tap
)
722 scan_size
= fields
[j
].num_bits
;
723 (*last_cmd
)->cmd
.scan
->fields
[field_count
].num_bits
= scan_size
;
724 (*last_cmd
)->cmd
.scan
->fields
[field_count
].out_value
= buf_cpy(fields
[j
].out_value
, cmd_queue_alloc(CEIL(scan_size
, 8)), scan_size
);
725 (*last_cmd
)->cmd
.scan
->fields
[field_count
].out_mask
= buf_cpy(fields
[j
].out_mask
, cmd_queue_alloc(CEIL(scan_size
, 8)), scan_size
);
726 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_value
= fields
[j
].in_value
;
727 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_check_value
= fields
[j
].in_check_value
;
728 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_check_mask
= fields
[j
].in_check_mask
;
729 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_handler
= fields
[j
].in_handler
;
730 (*last_cmd
)->cmd
.scan
->fields
[field_count
++].in_handler_priv
= fields
[j
].in_handler_priv
;
735 #ifdef _DEBUG_JTAG_IO_
736 /* if a device isn't listed, the BYPASS register should be selected */
739 LOG_ERROR("BUG: no scan data for a device not in BYPASS");
743 /* program the scan field to 1 bit length, and ignore it's value */
744 (*last_cmd
)->cmd
.scan
->fields
[field_count
].num_bits
= 1;
745 (*last_cmd
)->cmd
.scan
->fields
[field_count
].out_value
= NULL
;
746 (*last_cmd
)->cmd
.scan
->fields
[field_count
].out_mask
= NULL
;
747 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_value
= NULL
;
748 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_check_value
= NULL
;
749 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_check_mask
= NULL
;
750 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_handler
= NULL
;
751 (*last_cmd
)->cmd
.scan
->fields
[field_count
++].in_handler_priv
= NULL
;
755 #ifdef _DEBUG_JTAG_IO_
756 /* if a device is listed, the BYPASS register must not be selected */
759 LOG_ERROR("BUG: scan data for a device in BYPASS");
768 void MINIDRIVER(interface_jtag_add_dr_out
)(jtag_tap_t
*target_tap
,
772 tap_state_t end_state
)
777 int bypass_devices
= 0;
779 jtag_command_t
**last_cmd
= jtag_get_last_command_p();
782 /* count devices in bypass */
786 tap
= jtag_NextEnabledTap(tap
);
795 /* allocate memory for a new list member */
796 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
797 last_comand_pointer
= &((*last_cmd
)->next
);
798 (*last_cmd
)->next
= NULL
;
799 (*last_cmd
)->type
= JTAG_SCAN
;
801 /* allocate memory for dr scan command */
802 (*last_cmd
)->cmd
.scan
= cmd_queue_alloc(sizeof(scan_command_t
));
803 (*last_cmd
)->cmd
.scan
->ir_scan
= 0;
804 (*last_cmd
)->cmd
.scan
->num_fields
= num_fields
+ bypass_devices
;
805 (*last_cmd
)->cmd
.scan
->fields
= cmd_queue_alloc((num_fields
+ bypass_devices
) * sizeof(scan_field_t
));
806 (*last_cmd
)->cmd
.scan
->end_state
= end_state
;
811 tap
= jtag_NextEnabledTap(tap
);
816 (*last_cmd
)->cmd
.scan
->fields
[field_count
].tap
= tap
;
818 if (tap
== target_tap
)
821 #ifdef _DEBUG_JTAG_IO_
822 /* if a device is listed, the BYPASS register must not be selected */
825 LOG_ERROR("BUG: scan data for a device in BYPASS");
829 for (j
= 0; j
< num_fields
; j
++)
832 scan_size
= num_bits
[j
];
833 buf_set_u32(out_value
, 0, scan_size
, value
[j
]);
834 (*last_cmd
)->cmd
.scan
->fields
[field_count
].num_bits
= scan_size
;
835 (*last_cmd
)->cmd
.scan
->fields
[field_count
].out_value
= buf_cpy(out_value
, cmd_queue_alloc(CEIL(scan_size
, 8)), scan_size
);
836 (*last_cmd
)->cmd
.scan
->fields
[field_count
].out_mask
= NULL
;
837 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_value
= NULL
;
838 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_check_value
= NULL
;
839 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_check_mask
= NULL
;
840 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_handler
= NULL
;
841 (*last_cmd
)->cmd
.scan
->fields
[field_count
++].in_handler_priv
= NULL
;
845 #ifdef _DEBUG_JTAG_IO_
846 /* if a device isn't listed, the BYPASS register should be selected */
849 LOG_ERROR("BUG: no scan data for a device not in BYPASS");
853 /* program the scan field to 1 bit length, and ignore it's value */
854 (*last_cmd
)->cmd
.scan
->fields
[field_count
].num_bits
= 1;
855 (*last_cmd
)->cmd
.scan
->fields
[field_count
].out_value
= NULL
;
856 (*last_cmd
)->cmd
.scan
->fields
[field_count
].out_mask
= NULL
;
857 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_value
= NULL
;
858 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_check_value
= NULL
;
859 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_check_mask
= NULL
;
860 (*last_cmd
)->cmd
.scan
->fields
[field_count
].in_handler
= NULL
;
861 (*last_cmd
)->cmd
.scan
->fields
[field_count
++].in_handler_priv
= NULL
;
866 void jtag_add_plain_dr_scan(int num_fields
, scan_field_t
*fields
, tap_state_t state
)
872 retval
=interface_jtag_add_plain_dr_scan(num_fields
, fields
, cmd_queue_end_state
);
873 if (retval
!=ERROR_OK
)
877 int MINIDRIVER(interface_jtag_add_plain_dr_scan
)(int num_fields
, scan_field_t
*fields
, tap_state_t state
)
880 jtag_command_t
**last_cmd
= jtag_get_last_command_p();
882 /* allocate memory for a new list member */
883 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
884 last_comand_pointer
= &((*last_cmd
)->next
);
885 (*last_cmd
)->next
= NULL
;
886 (*last_cmd
)->type
= JTAG_SCAN
;
888 /* allocate memory for scan command */
889 (*last_cmd
)->cmd
.scan
= cmd_queue_alloc(sizeof(scan_command_t
));
890 (*last_cmd
)->cmd
.scan
->ir_scan
= 0;
891 (*last_cmd
)->cmd
.scan
->num_fields
= num_fields
;
892 (*last_cmd
)->cmd
.scan
->fields
= cmd_queue_alloc(num_fields
* sizeof(scan_field_t
));
893 (*last_cmd
)->cmd
.scan
->end_state
= state
;
895 for (i
= 0; i
< num_fields
; i
++)
897 int num_bits
= fields
[i
].num_bits
;
898 int num_bytes
= CEIL(fields
[i
].num_bits
, 8);
899 (*last_cmd
)->cmd
.scan
->fields
[i
].tap
= fields
[i
].tap
;
900 (*last_cmd
)->cmd
.scan
->fields
[i
].num_bits
= num_bits
;
901 (*last_cmd
)->cmd
.scan
->fields
[i
].out_value
= buf_cpy(fields
[i
].out_value
, cmd_queue_alloc(num_bytes
), num_bits
);
902 (*last_cmd
)->cmd
.scan
->fields
[i
].out_mask
= buf_cpy(fields
[i
].out_mask
, cmd_queue_alloc(num_bytes
), num_bits
);
903 (*last_cmd
)->cmd
.scan
->fields
[i
].in_value
= fields
[i
].in_value
;
904 (*last_cmd
)->cmd
.scan
->fields
[i
].in_check_value
= fields
[i
].in_check_value
;
905 (*last_cmd
)->cmd
.scan
->fields
[i
].in_check_mask
= fields
[i
].in_check_mask
;
906 (*last_cmd
)->cmd
.scan
->fields
[i
].in_handler
= fields
[i
].in_handler
;
907 (*last_cmd
)->cmd
.scan
->fields
[i
].in_handler_priv
= fields
[i
].in_handler_priv
;
913 void jtag_add_tlr(void)
915 jtag_prelude(TAP_RESET
);
918 retval
=interface_jtag_add_tlr();
919 if (retval
!=ERROR_OK
)
923 int MINIDRIVER(interface_jtag_add_tlr
)(void)
925 tap_state_t state
= TAP_RESET
;
926 jtag_command_t
**last_cmd
= jtag_get_last_command_p();
928 /* allocate memory for a new list member */
929 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
930 last_comand_pointer
= &((*last_cmd
)->next
);
931 (*last_cmd
)->next
= NULL
;
932 (*last_cmd
)->type
= JTAG_STATEMOVE
;
934 (*last_cmd
)->cmd
.statemove
= cmd_queue_alloc(sizeof(statemove_command_t
));
935 (*last_cmd
)->cmd
.statemove
->end_state
= state
;
940 void jtag_add_pathmove(int num_states
, tap_state_t
*path
)
942 tap_state_t cur_state
=cmd_queue_cur_state
;
946 /* the last state has to be a stable state */
947 if (!tap_is_state_stable(path
[num_states
- 1]))
949 LOG_ERROR("BUG: TAP path doesn't finish in a stable state");
953 for (i
=0; i
<num_states
; i
++)
955 if (path
[i
] == TAP_RESET
)
957 LOG_ERROR("BUG: TAP_RESET is not a valid state for pathmove sequences");
960 if ( tap_state_transition(cur_state
, 1) != path
[i
]
961 && tap_state_transition(cur_state
, 0) != path
[i
])
963 LOG_ERROR("BUG: %s -> %s isn't a valid TAP transition", tap_state_name(cur_state
), tap_state_name(path
[i
]));
971 retval
=interface_jtag_add_pathmove(num_states
, path
);
972 cmd_queue_cur_state
= path
[num_states
- 1];
973 if (retval
!=ERROR_OK
)
977 int MINIDRIVER(interface_jtag_add_pathmove
)(int num_states
, tap_state_t
*path
)
979 jtag_command_t
**last_cmd
= jtag_get_last_command_p();
982 /* allocate memory for a new list member */
983 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
984 last_comand_pointer
= &((*last_cmd
)->next
);
985 (*last_cmd
)->next
= NULL
;
986 (*last_cmd
)->type
= JTAG_PATHMOVE
;
988 (*last_cmd
)->cmd
.pathmove
= cmd_queue_alloc(sizeof(pathmove_command_t
));
989 (*last_cmd
)->cmd
.pathmove
->num_states
= num_states
;
990 (*last_cmd
)->cmd
.pathmove
->path
= cmd_queue_alloc(sizeof(tap_state_t
) * num_states
);
992 for (i
= 0; i
< num_states
; i
++)
993 (*last_cmd
)->cmd
.pathmove
->path
[i
] = path
[i
];
998 int MINIDRIVER(interface_jtag_add_runtest
)(int num_cycles
, tap_state_t state
)
1000 jtag_command_t
**last_cmd
= jtag_get_last_command_p();
1002 /* allocate memory for a new list member */
1003 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
1004 (*last_cmd
)->next
= NULL
;
1005 last_comand_pointer
= &((*last_cmd
)->next
);
1006 (*last_cmd
)->type
= JTAG_RUNTEST
;
1008 (*last_cmd
)->cmd
.runtest
= cmd_queue_alloc(sizeof(runtest_command_t
));
1009 (*last_cmd
)->cmd
.runtest
->num_cycles
= num_cycles
;
1010 (*last_cmd
)->cmd
.runtest
->end_state
= state
;
1015 void jtag_add_runtest(int num_cycles
, tap_state_t state
)
1019 jtag_prelude(state
);
1021 /* executed by sw or hw fifo */
1022 retval
=interface_jtag_add_runtest(num_cycles
, cmd_queue_end_state
);
1023 if (retval
!=ERROR_OK
)
1028 int MINIDRIVER(interface_jtag_add_clocks
)( int num_cycles
)
1030 jtag_command_t
**last_cmd
= jtag_get_last_command_p();
1032 /* allocate memory for a new list member */
1033 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
1034 (*last_cmd
)->next
= NULL
;
1035 last_comand_pointer
= &((*last_cmd
)->next
);
1036 (*last_cmd
)->type
= JTAG_STABLECLOCKS
;
1038 (*last_cmd
)->cmd
.stableclocks
= cmd_queue_alloc(sizeof(stableclocks_command_t
));
1039 (*last_cmd
)->cmd
.stableclocks
->num_cycles
= num_cycles
;
1043 void jtag_add_clocks( int num_cycles
)
1047 if( !tap_is_state_stable(cmd_queue_cur_state
) )
1049 LOG_ERROR( "jtag_add_clocks() was called with TAP in non-stable state \"%s\"",
1050 tap_state_name(cmd_queue_cur_state
) );
1051 jtag_error
= ERROR_JTAG_NOT_STABLE_STATE
;
1055 if( num_cycles
> 0 )
1059 retval
= interface_jtag_add_clocks(num_cycles
);
1060 if (retval
!= ERROR_OK
)
1065 void jtag_add_reset(int req_tlr_or_trst
, int req_srst
)
1067 int trst_with_tlr
= 0;
1070 /* FIX!!! there are *many* different cases here. A better
1071 * approach is needed for legal combinations of transitions...
1073 if ((jtag_reset_config
& RESET_HAS_SRST
)&&
1074 (jtag_reset_config
& RESET_HAS_TRST
)&&
1075 ((jtag_reset_config
& RESET_SRST_PULLS_TRST
)==0))
1077 if (((req_tlr_or_trst
&&!jtag_trst
)||
1078 (!req_tlr_or_trst
&&jtag_trst
))&&
1079 ((req_srst
&&!jtag_srst
)||
1080 (!req_srst
&&jtag_srst
)))
1082 /* FIX!!! srst_pulls_trst allows 1,1 => 0,0 transition.... */
1083 //LOG_ERROR("BUG: transition of req_tlr_or_trst and req_srst in the same jtag_add_reset() call is undefined");
1087 /* Make sure that jtag_reset_config allows the requested reset */
1088 /* if SRST pulls TRST, we can't fulfill srst == 1 with trst == 0 */
1089 if (((jtag_reset_config
& RESET_SRST_PULLS_TRST
) && (req_srst
== 1)) && (!req_tlr_or_trst
))
1091 LOG_ERROR("BUG: requested reset would assert trst");
1092 jtag_error
=ERROR_FAIL
;
1096 /* if TRST pulls SRST, we reset with TAP T-L-R */
1097 if (((jtag_reset_config
& RESET_TRST_PULLS_SRST
) && (req_tlr_or_trst
)) && (req_srst
== 0))
1102 if (req_srst
&& !(jtag_reset_config
& RESET_HAS_SRST
))
1104 LOG_ERROR("BUG: requested SRST assertion, but the current configuration doesn't support this");
1105 jtag_error
=ERROR_FAIL
;
1109 if (req_tlr_or_trst
)
1111 if (!trst_with_tlr
&& (jtag_reset_config
& RESET_HAS_TRST
))
1123 jtag_srst
= req_srst
;
1125 retval
= interface_jtag_add_reset(jtag_trst
, jtag_srst
);
1126 if (retval
!=ERROR_OK
)
1134 LOG_DEBUG("SRST line asserted");
1138 LOG_DEBUG("SRST line released");
1139 if (jtag_nsrst_delay
)
1140 jtag_add_sleep(jtag_nsrst_delay
* 1000);
1145 LOG_DEBUG("JTAG reset with RESET instead of TRST");
1146 jtag_add_end_state(TAP_RESET
);
1148 jtag_call_event_callbacks(JTAG_TRST_ASSERTED
);
1154 /* we just asserted nTRST, so we're now in Test-Logic-Reset,
1155 * and inform possible listeners about this
1157 LOG_DEBUG("TRST line asserted");
1158 cmd_queue_cur_state
= TAP_RESET
;
1159 jtag_call_event_callbacks(JTAG_TRST_ASSERTED
);
1163 if (jtag_ntrst_delay
)
1164 jtag_add_sleep(jtag_ntrst_delay
* 1000);
1168 int MINIDRIVER(interface_jtag_add_reset
)(int req_trst
, int req_srst
)
1170 jtag_command_t
**last_cmd
= jtag_get_last_command_p();
1172 /* allocate memory for a new list member */
1173 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
1174 (*last_cmd
)->next
= NULL
;
1175 last_comand_pointer
= &((*last_cmd
)->next
);
1176 (*last_cmd
)->type
= JTAG_RESET
;
1178 (*last_cmd
)->cmd
.reset
= cmd_queue_alloc(sizeof(reset_command_t
));
1179 (*last_cmd
)->cmd
.reset
->trst
= req_trst
;
1180 (*last_cmd
)->cmd
.reset
->srst
= req_srst
;
1185 void jtag_add_end_state(tap_state_t state
)
1187 cmd_queue_end_state
= state
;
1188 if ((cmd_queue_end_state
== TAP_DRSHIFT
)||(cmd_queue_end_state
== TAP_IRSHIFT
))
1190 LOG_ERROR("BUG: TAP_DRSHIFT/IRSHIFT can't be end state. Calling code should use a larger scan field");
1194 int MINIDRIVER(interface_jtag_add_sleep
)(u32 us
)
1196 jtag_command_t
**last_cmd
= jtag_get_last_command_p();
1198 /* allocate memory for a new list member */
1199 *last_cmd
= cmd_queue_alloc(sizeof(jtag_command_t
));
1200 (*last_cmd
)->next
= NULL
;
1201 last_comand_pointer
= &((*last_cmd
)->next
);
1202 (*last_cmd
)->type
= JTAG_SLEEP
;
1204 (*last_cmd
)->cmd
.sleep
= cmd_queue_alloc(sizeof(sleep_command_t
));
1205 (*last_cmd
)->cmd
.sleep
->us
= us
;
1210 void jtag_add_sleep(u32 us
)
1212 keep_alive(); /* we might be running on a very slow JTAG clk */
1213 int retval
=interface_jtag_add_sleep(us
);
1214 if (retval
!=ERROR_OK
)
1219 int jtag_scan_size(scan_command_t
*cmd
)
1224 /* count bits in scan command */
1225 for (i
= 0; i
< cmd
->num_fields
; i
++)
1227 bit_count
+= cmd
->fields
[i
].num_bits
;
1233 int jtag_build_buffer(scan_command_t
*cmd
, u8
**buffer
)
1238 bit_count
= jtag_scan_size(cmd
);
1239 *buffer
= malloc(CEIL(bit_count
, 8));
1243 #ifdef _DEBUG_JTAG_IO_
1244 LOG_DEBUG("num_fields: %i",cmd
->num_fields
);
1247 for (i
= 0; i
< cmd
->num_fields
; i
++)
1249 if (cmd
->fields
[i
].out_value
)
1251 #ifdef _DEBUG_JTAG_IO_
1252 char* char_buf
= buf_to_str(cmd
->fields
[i
].out_value
, (cmd
->fields
[i
].num_bits
> DEBUG_JTAG_IOZ
) ? DEBUG_JTAG_IOZ
: cmd
->fields
[i
].num_bits
, 16);
1254 buf_set_buf(cmd
->fields
[i
].out_value
, 0, *buffer
, bit_count
, cmd
->fields
[i
].num_bits
);
1255 #ifdef _DEBUG_JTAG_IO_
1256 LOG_DEBUG("fields[%i].out_value[%i]: 0x%s", i
, cmd
->fields
[i
].num_bits
, char_buf
);
1261 bit_count
+= cmd
->fields
[i
].num_bits
;
1267 int jtag_read_buffer(u8
*buffer
, scan_command_t
*cmd
)
1273 /* we return ERROR_OK, unless a check fails, or a handler reports a problem */
1276 for (i
= 0; i
< cmd
->num_fields
; i
++)
1278 /* if neither in_value nor in_handler
1279 * are specified we don't have to examine this field
1281 if (cmd
->fields
[i
].in_value
|| cmd
->fields
[i
].in_handler
)
1283 int num_bits
= cmd
->fields
[i
].num_bits
;
1284 u8
*captured
= buf_set_buf(buffer
, bit_count
, malloc(CEIL(num_bits
, 8)), 0, num_bits
);
1286 #ifdef _DEBUG_JTAG_IO_
1287 char *char_buf
= buf_to_str(captured
, (num_bits
> DEBUG_JTAG_IOZ
) ? DEBUG_JTAG_IOZ
: num_bits
, 16);
1288 LOG_DEBUG("fields[%i].in_value[%i]: 0x%s", i
, num_bits
, char_buf
);
1292 if (cmd
->fields
[i
].in_value
)
1294 buf_cpy(captured
, cmd
->fields
[i
].in_value
, num_bits
);
1296 if (cmd
->fields
[i
].in_handler
)
1298 if (cmd
->fields
[i
].in_handler(cmd
->fields
[i
].in_value
, cmd
->fields
[i
].in_handler_priv
, cmd
->fields
+i
) != ERROR_OK
)
1300 LOG_WARNING("in_handler: with \"in_value\", mismatch in %s", cmd
->ir_scan
? "SIR" : "SDR" );
1301 retval
= ERROR_JTAG_QUEUE_FAILED
;
1306 /* no in_value specified, but a handler takes care of the scanned data */
1307 if (cmd
->fields
[i
].in_handler
&& (!cmd
->fields
[i
].in_value
))
1309 if (cmd
->fields
[i
].in_handler(captured
, cmd
->fields
[i
].in_handler_priv
, cmd
->fields
+i
) != ERROR_OK
)
1311 /* We're going to call the error:handler later, but if the in_handler
1312 * reported an error we report this failure upstream
1314 LOG_WARNING("in_handler: w/o \"in_value\", mismatch in %s", cmd
->ir_scan
? "SIR" : "SDR" );
1315 retval
= ERROR_JTAG_QUEUE_FAILED
;
1321 bit_count
+= cmd
->fields
[i
].num_bits
;
1327 static const char *jtag_tap_name(jtag_tap_t
*tap
)
1329 return (tap
== NULL
) ? "(unknown)" : tap
->dotted_name
;
1332 int jtag_check_value(u8
*captured
, void *priv
, scan_field_t
*field
)
1334 int retval
= ERROR_OK
;
1335 int num_bits
= field
->num_bits
;
1337 int compare_failed
= 0;
1339 if (field
->in_check_mask
)
1340 compare_failed
= buf_cmp_mask(captured
, field
->in_check_value
, field
->in_check_mask
, num_bits
);
1342 compare_failed
= buf_cmp(captured
, field
->in_check_value
, num_bits
);
1344 if (compare_failed
){
1345 /* An error handler could have caught the failing check
1346 * only report a problem when there wasn't a handler, or if the handler
1347 * acknowledged the error
1349 LOG_WARNING("TAP %s:",
1350 jtag_tap_name(field
->tap
));
1353 char *captured_char
= buf_to_str(captured
, (num_bits
> DEBUG_JTAG_IOZ
) ? DEBUG_JTAG_IOZ
: num_bits
, 16);
1354 char *in_check_value_char
= buf_to_str(field
->in_check_value
, (num_bits
> DEBUG_JTAG_IOZ
) ? DEBUG_JTAG_IOZ
: num_bits
, 16);
1356 if (field
->in_check_mask
)
1358 char *in_check_mask_char
;
1359 in_check_mask_char
= buf_to_str(field
->in_check_mask
, (num_bits
> DEBUG_JTAG_IOZ
) ? DEBUG_JTAG_IOZ
: num_bits
, 16);
1360 LOG_WARNING("value captured during scan didn't pass the requested check:");
1361 LOG_WARNING("captured: 0x%s check_value: 0x%s check_mask: 0x%s",
1362 captured_char
, in_check_value_char
, in_check_mask_char
);
1363 free(in_check_mask_char
);
1367 LOG_WARNING("value captured during scan didn't pass the requested check: captured: 0x%s check_value: 0x%s", captured_char
, in_check_value_char
);
1370 free(captured_char
);
1371 free(in_check_value_char
);
1373 retval
= ERROR_JTAG_QUEUE_FAILED
;
1381 set up checking of this field using the in_handler. The values passed in must be valid until
1382 after jtag_execute() has completed.
1384 void jtag_set_check_value(scan_field_t
*field
, u8
*value
, u8
*mask
, error_handler_t
*in_error_handler
)
1387 field
->in_handler
= jtag_check_value
;
1389 field
->in_handler
= NULL
; /* No check, e.g. embeddedice uses value==NULL to indicate no check */
1390 field
->in_handler_priv
= NULL
;
1391 field
->in_check_value
= value
;
1392 field
->in_check_mask
= mask
;
1395 enum scan_type
jtag_scan_type(scan_command_t
*cmd
)
1400 for (i
= 0; i
< cmd
->num_fields
; i
++)
1402 if (cmd
->fields
[i
].in_value
|| cmd
->fields
[i
].in_handler
)
1404 if (cmd
->fields
[i
].out_value
)
1411 int MINIDRIVER(interface_jtag_execute_queue
)(void)
1417 LOG_ERROR("No JTAG interface configured yet. Issue 'init' command in startup scripts before communicating with targets.");
1421 retval
= jtag
->execute_queue();
1425 jtag_command_queue
= NULL
;
1426 last_comand_pointer
= &jtag_command_queue
;
1431 int jtag_execute_queue(void)
1433 int retval
=interface_jtag_execute_queue();
1434 if (retval
==ERROR_OK
)
1438 jtag_error
=ERROR_OK
;
1442 int jtag_reset_callback(enum jtag_event event
, void *priv
)
1444 jtag_tap_t
*tap
= priv
;
1448 if (event
== JTAG_TRST_ASSERTED
)
1450 buf_set_ones(tap
->cur_instr
, tap
->ir_length
);
1457 void jtag_sleep(u32 us
)
1459 alive_sleep(us
/1000);
1462 /* Try to examine chain layout according to IEEE 1149.1 §12
1464 int jtag_examine_chain(void)
1468 u8 idcode_buffer
[JTAG_MAX_CHAIN_SIZE
* 4];
1471 int device_count
= 0;
1472 u8 zero_check
= 0x0;
1473 u8 one_check
= 0xff;
1476 field
.num_bits
= sizeof(idcode_buffer
) * 8;
1477 field
.out_value
= idcode_buffer
;
1478 field
.out_mask
= NULL
;
1479 field
.in_value
= idcode_buffer
;
1480 field
.in_check_value
= NULL
;
1481 field
.in_check_mask
= NULL
;
1482 field
.in_handler
= NULL
;
1483 field
.in_handler_priv
= NULL
;
1485 for (i
= 0; i
< JTAG_MAX_CHAIN_SIZE
; i
++)
1487 buf_set_u32(idcode_buffer
, i
* 32, 32, 0x000000FF);
1490 jtag_add_plain_dr_scan(1, &field
, TAP_RESET
);
1491 jtag_execute_queue();
1493 for (i
= 0; i
< JTAG_MAX_CHAIN_SIZE
* 4; i
++)
1495 zero_check
|= idcode_buffer
[i
];
1496 one_check
&= idcode_buffer
[i
];
1499 /* if there wasn't a single non-zero bit or if all bits were one, the scan isn't valid */
1500 if ((zero_check
== 0x00) || (one_check
== 0xff))
1502 LOG_ERROR("JTAG communication failure, check connection, JTAG interface, target power etc.");
1503 return ERROR_JTAG_INIT_FAILED
;
1506 // point at the 1st tap
1507 tap
= jtag_NextEnabledTap(NULL
);
1509 LOG_ERROR("JTAG: No taps enabled?");
1510 return ERROR_JTAG_INIT_FAILED
;
1513 for (bit_count
= 0; bit_count
< (JTAG_MAX_CHAIN_SIZE
* 32) - 31;)
1515 u32 idcode
= buf_get_u32(idcode_buffer
, bit_count
, 32);
1516 if ((idcode
& 1) == 0)
1518 /* LSB must not be 0, this indicates a device in bypass */
1519 LOG_WARNING("Tap/Device does not have IDCODE");
1530 if (idcode
== 0x000000FF)
1533 /* End of chain (invalid manufacturer ID)
1535 * The JTAG examine is the very first thing that happens
1537 * A single JTAG device requires only 64 bits to be read back correctly.
1539 * The code below adds a check that the rest of the data scanned (640 bits)
1540 * are all as expected. This helps diagnose/catch problems with the JTAG chain
1542 * earlier and gives more helpful/explicit error messages.
1544 for (bit_count
+= 32; bit_count
< (JTAG_MAX_CHAIN_SIZE
* 32) - 31;bit_count
+= 32)
1546 idcode
= buf_get_u32(idcode_buffer
, bit_count
, 32);
1547 if (unexpected
||(idcode
!= 0x000000FF))
1549 LOG_WARNING("Unexpected idcode after end of chain! %d 0x%08x", bit_count
, idcode
);
1557 #define EXTRACT_MFG(X) (((X) & 0xffe) >> 1)
1558 manufacturer
= EXTRACT_MFG(idcode
);
1559 #define EXTRACT_PART(X) (((X) & 0xffff000) >> 12)
1560 part
= EXTRACT_PART(idcode
);
1561 #define EXTRACT_VER(X) (((X) & 0xf0000000) >> 28)
1562 version
= EXTRACT_VER(idcode
);
1564 LOG_INFO("JTAG tap: %s tap/device found: 0x%8.8x (Manufacturer: 0x%3.3x, Part: 0x%4.4x, Version: 0x%1.1x)",
1565 ((tap
!= NULL
) ? (tap
->dotted_name
) : "(not-named)"),
1566 idcode
, manufacturer
, part
, version
);
1572 tap
->idcode
= idcode
;
1574 if (tap
->expected_ids_cnt
> 0) {
1575 /* Loop over the expected identification codes and test for a match */
1577 for (ii
= 0; ii
< tap
->expected_ids_cnt
; ii
++) {
1578 if( tap
->idcode
== tap
->expected_ids
[ii
] ){
1583 /* If none of the expected ids matched, log an error */
1584 if (ii
== tap
->expected_ids_cnt
) {
1585 LOG_ERROR("JTAG tap: %s got: 0x%08x (mfg: 0x%3.3x, part: 0x%4.4x, ver: 0x%1.1x)",
1588 EXTRACT_MFG( tap
->idcode
),
1589 EXTRACT_PART( tap
->idcode
),
1590 EXTRACT_VER( tap
->idcode
) );
1591 for (ii
= 0; ii
< tap
->expected_ids_cnt
; ii
++) {
1592 LOG_ERROR("JTAG tap: %s expected %hhu of %hhu: 0x%08x (mfg: 0x%3.3x, part: 0x%4.4x, ver: 0x%1.1x)",
1595 tap
->expected_ids_cnt
,
1596 tap
->expected_ids
[ii
],
1597 EXTRACT_MFG( tap
->expected_ids
[ii
] ),
1598 EXTRACT_PART( tap
->expected_ids
[ii
] ),
1599 EXTRACT_VER( tap
->expected_ids
[ii
] ) );
1602 return ERROR_JTAG_INIT_FAILED
;
1604 LOG_INFO("JTAG Tap/device matched");
1608 LOG_INFO("JTAG TAP ID: 0x%08x - Unknown - please report (A) chipname and (B) idcode to the openocd project",
1612 tap
= jtag_NextEnabledTap(tap
);
1617 /* see if number of discovered devices matches configuration */
1618 if (device_count
!= jtag_NumEnabledTaps())
1620 LOG_ERROR("number of discovered devices in JTAG chain (%i) doesn't match (enabled) configuration (%i), total taps: %d",
1621 device_count
, jtag_NumEnabledTaps(), jtag_NumTotalTaps());
1622 LOG_ERROR("check the config file and ensure proper JTAG communication (connections, speed, ...)");
1623 return ERROR_JTAG_INIT_FAILED
;
1629 int jtag_validate_chain(void)
1632 int total_ir_length
= 0;
1638 total_ir_length
= 0;
1640 tap
= jtag_NextEnabledTap(tap
);
1644 total_ir_length
+= tap
->ir_length
;
1647 total_ir_length
+= 2;
1648 ir_test
= malloc(CEIL(total_ir_length
, 8));
1649 buf_set_ones(ir_test
, total_ir_length
);
1652 field
.num_bits
= total_ir_length
;
1653 field
.out_value
= ir_test
;
1654 field
.out_mask
= NULL
;
1655 field
.in_value
= ir_test
;
1656 field
.in_check_value
= NULL
;
1657 field
.in_check_mask
= NULL
;
1658 field
.in_handler
= NULL
;
1659 field
.in_handler_priv
= NULL
;
1661 jtag_add_plain_ir_scan(1, &field
, TAP_RESET
);
1662 jtag_execute_queue();
1668 tap
= jtag_NextEnabledTap(tap
);
1673 val
= buf_get_u32(ir_test
, chain_pos
, 2);
1676 char *cbuf
= buf_to_str(ir_test
, total_ir_length
, 16);
1677 LOG_ERROR("Could not validate JTAG scan chain, IR mismatch, scan returned 0x%s. tap=%s pos=%d expected 0x1 got %0x", cbuf
, jtag_tap_name(tap
), chain_pos
, val
);
1680 return ERROR_JTAG_INIT_FAILED
;
1682 chain_pos
+= tap
->ir_length
;
1685 val
= buf_get_u32(ir_test
, chain_pos
, 2);
1688 char *cbuf
= buf_to_str(ir_test
, total_ir_length
, 16);
1689 LOG_ERROR("Could not validate end of JTAG scan chain, IR mismatch, scan returned 0x%s. pos=%d expected 0x3 got %0x", cbuf
, chain_pos
, val
);
1692 return ERROR_JTAG_INIT_FAILED
;
1700 enum jtag_tap_cfg_param
{
1704 static Jim_Nvp nvp_config_opts
[] = {
1705 { .name
= "-event", .value
= JCFG_EVENT
},
1707 { .name
= NULL
, .value
= -1 }
1711 jtag_tap_configure_cmd( Jim_GetOptInfo
*goi
,
1718 /* parse config or cget options */
1719 while (goi
->argc
> 0) {
1720 Jim_SetEmptyResult (goi
->interp
);
1722 e
= Jim_GetOpt_Nvp(goi
, nvp_config_opts
, &n
);
1724 Jim_GetOpt_NvpUnknown(goi
, nvp_config_opts
, 0);
1730 if (goi
->argc
== 0) {
1731 Jim_WrongNumArgs( goi
->interp
, goi
->argc
, goi
->argv
, "-event ?event-name? ..." );
1735 e
= Jim_GetOpt_Nvp( goi
, nvp_jtag_tap_event
, &n
);
1737 Jim_GetOpt_NvpUnknown(goi
, nvp_jtag_tap_event
, 1);
1741 if (goi
->isconfigure
) {
1742 if (goi
->argc
!= 1) {
1743 Jim_WrongNumArgs(goi
->interp
, goi
->argc
, goi
->argv
, "-event ?event-name? ?EVENT-BODY?");
1747 if (goi
->argc
!= 0) {
1748 Jim_WrongNumArgs(goi
->interp
, goi
->argc
, goi
->argv
, "-event ?event-name?");
1754 jtag_tap_event_action_t
*jteap
;
1756 jteap
= tap
->event_action
;
1757 /* replace existing? */
1759 if (jteap
->event
== n
->value
) {
1762 jteap
= jteap
->next
;
1765 if (goi
->isconfigure
) {
1766 if (jteap
== NULL
) {
1768 jteap
= calloc(1, sizeof (*jteap
));
1770 jteap
->event
= n
->value
;
1771 Jim_GetOpt_Obj( goi
, &o
);
1773 Jim_DecrRefCount(interp
, jteap
->body
);
1775 jteap
->body
= Jim_DuplicateObj(goi
->interp
, o
);
1776 Jim_IncrRefCount(jteap
->body
);
1778 /* add to head of event list */
1779 jteap
->next
= tap
->event_action
;
1780 tap
->event_action
= jteap
;
1781 Jim_SetEmptyResult(goi
->interp
);
1784 if (jteap
== NULL
) {
1785 Jim_SetEmptyResult(goi
->interp
);
1787 Jim_SetResult(goi
->interp
, Jim_DuplicateObj(goi
->interp
, jteap
->body
));
1794 } /* while (goi->argc) */
1799 static int jim_newtap_cmd( Jim_GetOptInfo
*goi
)
1809 const Jim_Nvp opts
[] = {
1810 #define NTAP_OPT_IRLEN 0
1811 { .name
= "-irlen" , .value
= NTAP_OPT_IRLEN
},
1812 #define NTAP_OPT_IRMASK 1
1813 { .name
= "-irmask" , .value
= NTAP_OPT_IRMASK
},
1814 #define NTAP_OPT_IRCAPTURE 2
1815 { .name
= "-ircapture" , .value
= NTAP_OPT_IRCAPTURE
},
1816 #define NTAP_OPT_ENABLED 3
1817 { .name
= "-enable" , .value
= NTAP_OPT_ENABLED
},
1818 #define NTAP_OPT_DISABLED 4
1819 { .name
= "-disable" , .value
= NTAP_OPT_DISABLED
},
1820 #define NTAP_OPT_EXPECTED_ID 5
1821 { .name
= "-expected-id" , .value
= NTAP_OPT_EXPECTED_ID
},
1822 { .name
= NULL
, .value
= -1 },
1825 pTap
= malloc( sizeof(jtag_tap_t
) );
1826 memset( pTap
, 0, sizeof(*pTap
) );
1828 Jim_SetResult_sprintf( goi
->interp
, "no memory");
1832 * we expect CHIP + TAP + OPTIONS
1834 if( goi
->argc
< 3 ){
1835 Jim_SetResult_sprintf(goi
->interp
, "Missing CHIP TAP OPTIONS ....");
1838 Jim_GetOpt_String( goi
, &cp
, NULL
);
1839 pTap
->chip
= strdup(cp
);
1841 Jim_GetOpt_String( goi
, &cp
, NULL
);
1842 pTap
->tapname
= strdup(cp
);
1844 /* name + dot + name + null */
1845 x
= strlen(pTap
->chip
) + 1 + strlen(pTap
->tapname
) + 1;
1847 sprintf( cp
, "%s.%s", pTap
->chip
, pTap
->tapname
);
1848 pTap
->dotted_name
= cp
;
1850 LOG_DEBUG("Creating New Tap, Chip: %s, Tap: %s, Dotted: %s, %d params",
1851 pTap
->chip
, pTap
->tapname
, pTap
->dotted_name
, goi
->argc
);
1853 /* default is enabled */
1856 /* deal with options */
1857 #define NTREQ_IRLEN 1
1858 #define NTREQ_IRCAPTURE 2
1859 #define NTREQ_IRMASK 4
1861 /* clear them as we find them */
1862 reqbits
= (NTREQ_IRLEN
| NTREQ_IRCAPTURE
| NTREQ_IRMASK
);
1865 e
= Jim_GetOpt_Nvp( goi
, opts
, &n
);
1867 Jim_GetOpt_NvpUnknown( goi
, opts
, 0 );
1870 LOG_DEBUG("Processing option: %s", n
->name
);
1872 case NTAP_OPT_ENABLED
:
1875 case NTAP_OPT_DISABLED
:
1878 case NTAP_OPT_EXPECTED_ID
:
1880 u32
*new_expected_ids
;
1882 e
= Jim_GetOpt_Wide( goi
, &w
);
1884 Jim_SetResult_sprintf(goi
->interp
, "option: %s bad parameter", n
->name
);
1888 new_expected_ids
= malloc(sizeof(u32
) * (pTap
->expected_ids_cnt
+ 1));
1889 if (new_expected_ids
== NULL
) {
1890 Jim_SetResult_sprintf( goi
->interp
, "no memory");
1894 memcpy(new_expected_ids
, pTap
->expected_ids
, sizeof(u32
) * pTap
->expected_ids_cnt
);
1896 new_expected_ids
[pTap
->expected_ids_cnt
] = w
;
1898 free(pTap
->expected_ids
);
1899 pTap
->expected_ids
= new_expected_ids
;
1900 pTap
->expected_ids_cnt
++;
1903 case NTAP_OPT_IRLEN
:
1904 case NTAP_OPT_IRMASK
:
1905 case NTAP_OPT_IRCAPTURE
:
1906 e
= Jim_GetOpt_Wide( goi
, &w
);
1908 Jim_SetResult_sprintf( goi
->interp
, "option: %s bad parameter", n
->name
);
1911 if( (w
< 0) || (w
> 0xffff) ){
1913 Jim_SetResult_sprintf( goi
->interp
, "option: %s - wacky value: %d (0x%x)",
1914 n
->name
, (int)(w
), (int)(w
));
1918 case NTAP_OPT_IRLEN
:
1919 pTap
->ir_length
= w
;
1920 reqbits
&= (~(NTREQ_IRLEN
));
1922 case NTAP_OPT_IRMASK
:
1923 pTap
->ir_capture_mask
= w
;
1924 reqbits
&= (~(NTREQ_IRMASK
));
1926 case NTAP_OPT_IRCAPTURE
:
1927 pTap
->ir_capture_value
= w
;
1928 reqbits
&= (~(NTREQ_IRCAPTURE
));
1931 } /* switch(n->value) */
1932 } /* while( goi->argc ) */
1934 /* Did we get all the options? */
1937 Jim_SetResult_sprintf( goi
->interp
,
1938 "newtap: %s missing required parameters",
1940 /* TODO: Tell user what is missing :-( */
1941 /* no memory leaks pelase */
1942 free(((void *)(pTap
->expected_ids
)));
1943 free(((void *)(pTap
->chip
)));
1944 free(((void *)(pTap
->tapname
)));
1945 free(((void *)(pTap
->dotted_name
)));
1946 free(((void *)(pTap
)));
1950 pTap
->expected
= malloc( pTap
->ir_length
);
1951 pTap
->expected_mask
= malloc( pTap
->ir_length
);
1952 pTap
->cur_instr
= malloc( pTap
->ir_length
);
1954 buf_set_u32( pTap
->expected
,
1957 pTap
->ir_capture_value
);
1958 buf_set_u32( pTap
->expected_mask
,
1961 pTap
->ir_capture_mask
);
1962 buf_set_ones( pTap
->cur_instr
,
1967 jtag_register_event_callback(jtag_reset_callback
, pTap
);
1969 ppTap
= &(jtag_all_taps
);
1970 while( (*ppTap
) != NULL
){
1971 ppTap
= &((*ppTap
)->next_tap
);
1975 static int n_taps
= 0;
1976 pTap
->abs_chain_position
= n_taps
++;
1978 LOG_DEBUG( "Created Tap: %s @ abs position %d, irlen %d, capture: 0x%x mask: 0x%x",
1979 (*ppTap
)->dotted_name
,
1980 (*ppTap
)->abs_chain_position
,
1981 (*ppTap
)->ir_length
,
1982 (*ppTap
)->ir_capture_value
,
1983 (*ppTap
)->ir_capture_mask
);
1988 static int jim_jtag_command( Jim_Interp
*interp
, int argc
, Jim_Obj
*const *argv
)
1994 struct command_context_s
*context
;
1998 JTAG_CMD_INIT_RESET
,
2001 JTAG_CMD_TAPDISABLE
,
2002 JTAG_CMD_TAPISENABLED
,
2007 const Jim_Nvp jtag_cmds
[] = {
2008 { .name
= "interface" , .value
= JTAG_CMD_INTERFACE
},
2009 { .name
= "arp_init-reset", .value
= JTAG_CMD_INIT_RESET
},
2010 { .name
= "newtap" , .value
= JTAG_CMD_NEWTAP
},
2011 { .name
= "tapisenabled" , .value
= JTAG_CMD_TAPISENABLED
},
2012 { .name
= "tapenable" , .value
= JTAG_CMD_TAPENABLE
},
2013 { .name
= "tapdisable" , .value
= JTAG_CMD_TAPDISABLE
},
2014 { .name
= "configure" , .value
= JTAG_CMD_CONFIGURE
},
2015 { .name
= "cget" , .value
= JTAG_CMD_CGET
},
2017 { .name
= NULL
, .value
= -1 },
2020 context
= Jim_GetAssocData(interp
, "context");
2021 /* go past the command */
2022 Jim_GetOpt_Setup( &goi
, interp
, argc
-1, argv
+1 );
2024 e
= Jim_GetOpt_Nvp( &goi
, jtag_cmds
, &n
);
2026 Jim_GetOpt_NvpUnknown( &goi
, jtag_cmds
, 0 );
2029 Jim_SetEmptyResult( goi
.interp
);
2031 case JTAG_CMD_INTERFACE
:
2032 /* return the name of the interface */
2033 /* TCL code might need to know the exact type... */
2034 /* FUTURE: we allow this as a means to "set" the interface. */
2035 if( goi
.argc
!= 0 ){
2036 Jim_WrongNumArgs( goi
.interp
, 1, goi
.argv
-1, "(no params)");
2039 Jim_SetResultString( goi
.interp
, jtag_interface
->name
, -1 );
2041 case JTAG_CMD_INIT_RESET
:
2042 if( goi
.argc
!= 0 ){
2043 Jim_WrongNumArgs( goi
.interp
, 1, goi
.argv
-1, "(no params)");
2046 e
= jtag_init_reset(context
);
2047 if( e
!= ERROR_OK
){
2048 Jim_SetResult_sprintf( goi
.interp
, "error: %d", e
);
2052 case JTAG_CMD_NEWTAP
:
2053 return jim_newtap_cmd( &goi
);
2055 case JTAG_CMD_TAPISENABLED
:
2056 case JTAG_CMD_TAPENABLE
:
2057 case JTAG_CMD_TAPDISABLE
:
2058 if( goi
.argc
!= 1 ){
2059 Jim_SetResultString( goi
.interp
, "Too many parameters",-1 );
2065 t
= jtag_TapByJimObj( goi
.interp
, goi
.argv
[0] );
2070 case JTAG_CMD_TAPISENABLED
:
2073 case JTAG_CMD_TAPENABLE
:
2074 jtag_tap_handle_event( t
, JTAG_TAP_EVENT_ENABLE
);
2078 case JTAG_CMD_TAPDISABLE
:
2079 jtag_tap_handle_event( t
, JTAG_TAP_EVENT_DISABLE
);
2084 Jim_SetResult( goi
.interp
, Jim_NewIntObj( goi
.interp
, e
) );
2091 Jim_WrongNumArgs( goi
.interp
, 0, NULL
, "?tap-name? -option ...");
2098 Jim_GetOpt_Obj(&goi
, &o
);
2099 t
= jtag_TapByJimObj( goi
.interp
, o
);
2104 goi
.isconfigure
= 0;
2105 return jtag_tap_configure_cmd( &goi
, t
);
2109 case JTAG_CMD_CONFIGURE
:
2111 Jim_WrongNumArgs( goi
.interp
, 0, NULL
, "?tap-name? -option ?VALUE? ...");
2118 Jim_GetOpt_Obj(&goi
, &o
);
2119 t
= jtag_TapByJimObj( goi
.interp
, o
);
2124 goi
.isconfigure
= 1;
2125 return jtag_tap_configure_cmd( &goi
, t
);
2132 int jtag_register_commands(struct command_context_s
*cmd_ctx
)
2134 register_jim( cmd_ctx
, "jtag", jim_jtag_command
, "perform jtag tap actions");
2136 register_command(cmd_ctx
, NULL
, "interface", handle_interface_command
,
2137 COMMAND_CONFIG
, "try to configure interface");
2138 register_command(cmd_ctx
, NULL
, "jtag_speed", handle_jtag_speed_command
,
2139 COMMAND_ANY
, "set jtag speed (if supported)");
2140 register_command(cmd_ctx
, NULL
, "jtag_khz", handle_jtag_khz_command
,
2141 COMMAND_ANY
, "same as jtag_speed, except it takes maximum khz as arguments. 0 KHz = RTCK.");
2142 register_command(cmd_ctx
, NULL
, "jtag_device", handle_jtag_device_command
,
2143 COMMAND_CONFIG
, "jtag_device <ir_length> <ir_expected> <ir_mask>");
2144 register_command(cmd_ctx
, NULL
, "reset_config", handle_reset_config_command
,
2146 "[none/trst_only/srst_only/trst_and_srst] [srst_pulls_trst/trst_pulls_srst] [combined/separate] [trst_push_pull/trst_open_drain] [srst_push_pull/srst_open_drain]");
2147 register_command(cmd_ctx
, NULL
, "jtag_nsrst_delay", handle_jtag_nsrst_delay_command
,
2148 COMMAND_ANY
, "jtag_nsrst_delay <ms> - delay after deasserting srst in ms");
2149 register_command(cmd_ctx
, NULL
, "jtag_ntrst_delay", handle_jtag_ntrst_delay_command
,
2150 COMMAND_ANY
, "jtag_ntrst_delay <ms> - delay after deasserting trst in ms");
2152 register_command(cmd_ctx
, NULL
, "scan_chain", handle_scan_chain_command
,
2153 COMMAND_EXEC
, "print current scan chain configuration");
2155 register_command(cmd_ctx
, NULL
, "endstate", handle_endstate_command
,
2156 COMMAND_EXEC
, "finish JTAG operations in <tap_state>");
2157 register_command(cmd_ctx
, NULL
, "jtag_reset", handle_jtag_reset_command
,
2158 COMMAND_EXEC
, "toggle reset lines <trst> <srst>");
2159 register_command(cmd_ctx
, NULL
, "runtest", handle_runtest_command
,
2160 COMMAND_EXEC
, "move to Run-Test/Idle, and execute <num_cycles>");
2161 register_command(cmd_ctx
, NULL
, "irscan", handle_irscan_command
,
2162 COMMAND_EXEC
, "execute IR scan <device> <instr> [dev2] [instr2] ...");
2163 register_jim(cmd_ctx
, "drscan", Jim_Command_drscan
, "execute DR scan <device> <num_bits> <value> <num_bits1> <value2> ...");
2165 register_command(cmd_ctx
, NULL
, "verify_ircapture", handle_verify_ircapture_command
,
2166 COMMAND_ANY
, "verify value captured during Capture-IR <enable|disable>");
2170 int jtag_interface_init(struct command_context_s
*cmd_ctx
)
2175 if (!jtag_interface
)
2177 /* nothing was previously specified by "interface" command */
2178 LOG_ERROR("JTAG interface has to be specified, see \"interface\" command");
2179 return ERROR_JTAG_INVALID_INTERFACE
;
2183 jtag_interface
->khz(speed_khz
, &jtag_speed
);
2187 if (jtag_interface
->init() != ERROR_OK
)
2188 return ERROR_JTAG_INIT_FAILED
;
2190 jtag
= jtag_interface
;
2194 static int jtag_init_inner(struct command_context_s
*cmd_ctx
)
2199 LOG_DEBUG("Init JTAG chain");
2201 tap
= jtag_NextEnabledTap(NULL
);
2203 LOG_ERROR("There are no enabled taps?");
2204 return ERROR_JTAG_INIT_FAILED
;
2208 if ((retval
=jtag_execute_queue())!=ERROR_OK
)
2211 /* examine chain first, as this could discover the real chain layout */
2212 if (jtag_examine_chain() != ERROR_OK
)
2214 LOG_ERROR("trying to validate configured JTAG chain anyway...");
2217 if (jtag_validate_chain() != ERROR_OK
)
2219 LOG_WARNING("Could not validate JTAG chain, continuing anyway...");
2225 int jtag_init_reset(struct command_context_s
*cmd_ctx
)
2229 if ((retval
=jtag_interface_init(cmd_ctx
)) != ERROR_OK
)
2232 LOG_DEBUG("Trying to bring the JTAG controller to life by asserting TRST / RESET");
2234 /* Reset can happen after a power cycle.
2236 * Ideally we would only assert TRST or run RESET before the target reset.
2238 * However w/srst_pulls_trst, trst is asserted together with the target
2239 * reset whether we want it or not.
2241 * NB! Some targets have JTAG circuitry disabled until a
2242 * trst & srst has been asserted.
2244 * NB! here we assume nsrst/ntrst delay are sufficient!
2246 * NB! order matters!!!! srst *can* disconnect JTAG circuitry
2249 jtag_add_reset(1, 0); /* RESET or TRST */
2250 if (jtag_reset_config
& RESET_HAS_SRST
)
2252 jtag_add_reset(1, 1);
2253 if ((jtag_reset_config
& RESET_SRST_PULLS_TRST
)==0)
2254 jtag_add_reset(0, 1);
2256 jtag_add_reset(0, 0);
2257 if ((retval
= jtag_execute_queue()) != ERROR_OK
)
2260 /* Check that we can communication on the JTAG chain + eventually we want to
2261 * be able to perform enumeration only after OpenOCD has started
2262 * telnet and GDB server
2264 * That would allow users to more easily perform any magic they need to before
2267 return jtag_init_inner(cmd_ctx
);
2270 int jtag_init(struct command_context_s
*cmd_ctx
)
2273 if ((retval
=jtag_interface_init(cmd_ctx
)) != ERROR_OK
)
2275 if (jtag_init_inner(cmd_ctx
)==ERROR_OK
)
2279 return jtag_init_reset(cmd_ctx
);
2282 static int default_khz(int khz
, int *jtag_speed
)
2284 LOG_ERROR("Translation from khz to jtag_speed not implemented");
2288 static int default_speed_div(int speed
, int *khz
)
2290 LOG_ERROR("Translation from jtag_speed to khz not implemented");
2294 static int default_power_dropout(int *dropout
)
2296 *dropout
=0; /* by default we can't detect power dropout */
2300 static int default_srst_asserted(int *srst_asserted
)
2302 *srst_asserted
=0; /* by default we can't detect srst asserted */
2306 int handle_interface_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2311 /* check whether the interface is already configured */
2314 LOG_WARNING("Interface already configured, ignoring");
2318 /* interface name is a mandatory argument */
2319 if (argc
< 1 || args
[0][0] == '\0')
2321 return ERROR_COMMAND_SYNTAX_ERROR
;
2324 for (i
=0; jtag_interfaces
[i
]; i
++)
2326 if (strcmp(args
[0], jtag_interfaces
[i
]->name
) == 0)
2328 if ((retval
= jtag_interfaces
[i
]->register_commands(cmd_ctx
)) != ERROR_OK
)
2333 jtag_interface
= jtag_interfaces
[i
];
2335 if (jtag_interface
->khz
== NULL
)
2337 jtag_interface
->khz
= default_khz
;
2339 if (jtag_interface
->speed_div
== NULL
)
2341 jtag_interface
->speed_div
= default_speed_div
;
2343 if (jtag_interface
->power_dropout
== NULL
)
2345 jtag_interface
->power_dropout
= default_power_dropout
;
2347 if (jtag_interface
->srst_asserted
== NULL
)
2349 jtag_interface
->srst_asserted
= default_srst_asserted
;
2356 /* no valid interface was found (i.e. the configuration option,
2357 * didn't match one of the compiled-in interfaces
2359 LOG_ERROR("No valid jtag interface found (%s)", args
[0]);
2360 LOG_ERROR("compiled-in jtag interfaces:");
2361 for (i
= 0; jtag_interfaces
[i
]; i
++)
2363 LOG_ERROR("%i: %s", i
, jtag_interfaces
[i
]->name
);
2366 return ERROR_JTAG_INVALID_INTERFACE
;
2369 int handle_jtag_device_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2373 Jim_Obj
*newargs
[ 10 ];
2376 * argv[-1] = command
2377 * argv[ 0] = ir length
2378 * argv[ 1] = ir capture
2379 * argv[ 2] = ir mask
2380 * argv[ 3] = not actually used by anything but in the docs
2384 command_print( cmd_ctx
, "OLD DEPRECATED SYNTAX: Please use the NEW syntax");
2387 command_print( cmd_ctx
, "OLD SYNTAX: DEPRECATED - translating to new syntax");
2388 command_print( cmd_ctx
, "jtag newtap CHIP TAP -irlen %s -ircapture %s -irvalue %s",
2392 command_print( cmd_ctx
, "Example: STM32 has 2 taps, the cortexM3(len4) + boundryscan(len5)");
2393 command_print( cmd_ctx
, "jtag newtap stm32 cortexm3 ....., thus creating the tap: \"stm32.cortexm3\"");
2394 command_print( cmd_ctx
, "jtag newtap stm32 boundry ....., and the tap: \"stm32.boundery\"");
2395 command_print( cmd_ctx
, "And then refer to the taps by the dotted name.");
2397 newargs
[0] = Jim_NewStringObj( interp
, "jtag", -1 );
2398 newargs
[1] = Jim_NewStringObj( interp
, "newtap", -1 );
2399 sprintf( buf
, "chip%d", jtag_NumTotalTaps() );
2400 newargs
[2] = Jim_NewStringObj( interp
, buf
, -1 );
2401 sprintf( buf
, "tap%d", jtag_NumTotalTaps() );
2402 newargs
[3] = Jim_NewStringObj( interp
, buf
, -1 );
2403 newargs
[4] = Jim_NewStringObj( interp
, "-irlen", -1 );
2404 newargs
[5] = Jim_NewStringObj( interp
, args
[0], -1 );
2405 newargs
[6] = Jim_NewStringObj( interp
, "-ircapture", -1 );
2406 newargs
[7] = Jim_NewStringObj( interp
, args
[1], -1 );
2407 newargs
[8] = Jim_NewStringObj( interp
, "-irmask", -1 );
2408 newargs
[9] = Jim_NewStringObj( interp
, args
[2], -1 );
2410 command_print( cmd_ctx
, "NEW COMMAND:");
2411 sprintf( buf
, "%s %s %s %s %s %s %s %s %s %s",
2412 Jim_GetString( newargs
[0], NULL
),
2413 Jim_GetString( newargs
[1], NULL
),
2414 Jim_GetString( newargs
[2], NULL
),
2415 Jim_GetString( newargs
[3], NULL
),
2416 Jim_GetString( newargs
[4], NULL
),
2417 Jim_GetString( newargs
[5], NULL
),
2418 Jim_GetString( newargs
[6], NULL
),
2419 Jim_GetString( newargs
[7], NULL
),
2420 Jim_GetString( newargs
[8], NULL
),
2421 Jim_GetString( newargs
[9], NULL
) );
2423 e
= jim_jtag_command( interp
, 10, newargs
);
2425 command_print( cmd_ctx
, "%s", Jim_GetString( Jim_GetResult(interp
), NULL
) );
2430 int handle_scan_chain_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2434 tap
= jtag_all_taps
;
2435 command_print(cmd_ctx
, " TapName | Enabled | IdCode Expected IrLen IrCap IrMask Instr ");
2436 command_print(cmd_ctx
, "---|--------------------|---------|------------|------------|------|------|------|---------");
2439 u32 expected
, expected_mask
, cur_instr
, ii
;
2440 expected
= buf_get_u32(tap
->expected
, 0, tap
->ir_length
);
2441 expected_mask
= buf_get_u32(tap
->expected_mask
, 0, tap
->ir_length
);
2442 cur_instr
= buf_get_u32(tap
->cur_instr
, 0, tap
->ir_length
);
2444 command_print(cmd_ctx
,
2445 "%2d | %-18s | %c | 0x%08x | 0x%08x | 0x%02x | 0x%02x | 0x%02x | 0x%02x",
2446 tap
->abs_chain_position
,
2448 tap
->enabled
? 'Y' : 'n',
2450 (tap
->expected_ids_cnt
> 0 ? tap
->expected_ids
[0] : 0),
2456 for (ii
= 1; ii
< tap
->expected_ids_cnt
; ii
++) {
2457 command_print(cmd_ctx
, " | | | | 0x%08x | | | | ",
2458 tap
->expected_ids
[ii
]);
2461 tap
= tap
->next_tap
;
2467 int handle_reset_config_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2470 return ERROR_COMMAND_SYNTAX_ERROR
;
2474 if (strcmp(args
[0], "none") == 0)
2475 jtag_reset_config
= RESET_NONE
;
2476 else if (strcmp(args
[0], "trst_only") == 0)
2477 jtag_reset_config
= RESET_HAS_TRST
;
2478 else if (strcmp(args
[0], "srst_only") == 0)
2479 jtag_reset_config
= RESET_HAS_SRST
;
2480 else if (strcmp(args
[0], "trst_and_srst") == 0)
2481 jtag_reset_config
= RESET_TRST_AND_SRST
;
2484 LOG_ERROR("(1) invalid reset_config argument (%s), defaulting to none", args
[0]);
2485 jtag_reset_config
= RESET_NONE
;
2486 return ERROR_INVALID_ARGUMENTS
;
2492 if (strcmp(args
[1], "separate") == 0)
2494 /* seperate reset lines - default */
2497 if (strcmp(args
[1], "srst_pulls_trst") == 0)
2498 jtag_reset_config
|= RESET_SRST_PULLS_TRST
;
2499 else if (strcmp(args
[1], "trst_pulls_srst") == 0)
2500 jtag_reset_config
|= RESET_TRST_PULLS_SRST
;
2501 else if (strcmp(args
[1], "combined") == 0)
2502 jtag_reset_config
|= RESET_SRST_PULLS_TRST
| RESET_TRST_PULLS_SRST
;
2505 LOG_ERROR("(2) invalid reset_config argument (%s), defaulting to none", args
[1]);
2506 jtag_reset_config
= RESET_NONE
;
2507 return ERROR_INVALID_ARGUMENTS
;
2514 if (strcmp(args
[2], "trst_open_drain") == 0)
2515 jtag_reset_config
|= RESET_TRST_OPEN_DRAIN
;
2516 else if (strcmp(args
[2], "trst_push_pull") == 0)
2517 jtag_reset_config
&= ~RESET_TRST_OPEN_DRAIN
;
2520 LOG_ERROR("(3) invalid reset_config argument (%s) defaulting to none", args
[2] );
2521 jtag_reset_config
= RESET_NONE
;
2522 return ERROR_INVALID_ARGUMENTS
;
2528 if (strcmp(args
[3], "srst_push_pull") == 0)
2529 jtag_reset_config
|= RESET_SRST_PUSH_PULL
;
2530 else if (strcmp(args
[3], "srst_open_drain") == 0)
2531 jtag_reset_config
&= ~RESET_SRST_PUSH_PULL
;
2534 LOG_ERROR("(4) invalid reset_config argument (%s), defaulting to none", args
[3]);
2535 jtag_reset_config
= RESET_NONE
;
2536 return ERROR_INVALID_ARGUMENTS
;
2543 int handle_jtag_nsrst_delay_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2547 LOG_ERROR("jtag_nsrst_delay <ms> command takes one required argument");
2552 jtag_nsrst_delay
= strtoul(args
[0], NULL
, 0);
2558 int handle_jtag_ntrst_delay_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2562 LOG_ERROR("jtag_ntrst_delay <ms> command takes one required argument");
2567 jtag_ntrst_delay
= strtoul(args
[0], NULL
, 0);
2573 int handle_jtag_speed_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2575 int retval
=ERROR_OK
;
2579 LOG_DEBUG("handle jtag speed");
2582 cur_speed
= jtag_speed
= strtoul(args
[0], NULL
, 0);
2584 /* this command can be called during CONFIG,
2585 * in which case jtag isn't initialized */
2588 retval
=jtag
->speed(cur_speed
);
2590 } else if (argc
== 0)
2594 return ERROR_COMMAND_SYNTAX_ERROR
;
2596 command_print(cmd_ctx
, "jtag_speed: %d", jtag_speed
);
2601 int handle_jtag_khz_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2603 int retval
=ERROR_OK
;
2604 LOG_DEBUG("handle jtag khz");
2608 speed_khz
= strtoul(args
[0], NULL
, 0);
2612 LOG_DEBUG("have interface set up");
2614 if ((retval
=jtag
->khz(speed_khz
, &speed_div1
))!=ERROR_OK
)
2620 cur_speed
= jtag_speed
= speed_div1
;
2622 retval
=jtag
->speed(cur_speed
);
2631 return ERROR_COMMAND_SYNTAX_ERROR
;
2636 if ((retval
=jtag
->speed_div(jtag_speed
, &speed_khz
))!=ERROR_OK
)
2642 command_print(cmd_ctx
, "RCLK - adaptive");
2645 command_print(cmd_ctx
, "%d kHz", speed_khz
);
2651 int handle_endstate_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2657 return ERROR_COMMAND_SYNTAX_ERROR
;
2661 for (state
= 0; state
< 16; state
++)
2663 if (strcmp(args
[0], tap_state_name(state
)) == 0)
2665 jtag_add_end_state(state
);
2666 jtag_execute_queue();
2670 command_print(cmd_ctx
, "current endstate: %s", tap_state_name(cmd_queue_end_state
));
2675 int handle_jtag_reset_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2682 return ERROR_COMMAND_SYNTAX_ERROR
;
2685 if (args
[0][0] == '1')
2687 else if (args
[0][0] == '0')
2691 return ERROR_COMMAND_SYNTAX_ERROR
;
2694 if (args
[1][0] == '1')
2696 else if (args
[1][0] == '0')
2700 return ERROR_COMMAND_SYNTAX_ERROR
;
2703 if (jtag_interface_init(cmd_ctx
) != ERROR_OK
)
2704 return ERROR_JTAG_INIT_FAILED
;
2706 jtag_add_reset(trst
, srst
);
2707 jtag_execute_queue();
2712 int handle_runtest_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2716 return ERROR_COMMAND_SYNTAX_ERROR
;
2719 jtag_add_runtest(strtol(args
[0], NULL
, 0), -1);
2720 jtag_execute_queue();
2726 int handle_irscan_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2729 scan_field_t
*fields
;
2732 if ((argc
< 2) || (argc
% 2))
2734 return ERROR_COMMAND_SYNTAX_ERROR
;
2737 fields
= malloc(sizeof(scan_field_t
) * argc
/ 2);
2739 for (i
= 0; i
< argc
/ 2; i
++)
2741 tap
= jtag_TapByString( args
[i
*2] );
2744 command_print( cmd_ctx
, "Tap: %s unknown", args
[i
*2] );
2747 int field_size
= tap
->ir_length
;
2748 fields
[i
].tap
= tap
;
2749 fields
[i
].out_value
= malloc(CEIL(field_size
, 8));
2750 buf_set_u32(fields
[i
].out_value
, 0, field_size
, strtoul(args
[i
*2+1], NULL
, 0));
2751 fields
[i
].out_mask
= NULL
;
2752 fields
[i
].in_value
= NULL
;
2753 fields
[i
].in_check_mask
= NULL
;
2754 fields
[i
].in_handler
= NULL
;
2755 fields
[i
].in_handler_priv
= NULL
;
2758 jtag_add_ir_scan(argc
/ 2, fields
, -1);
2759 jtag_execute_queue();
2761 for (i
= 0; i
< argc
/ 2; i
++)
2762 free(fields
[i
].out_value
);
2769 int Jim_Command_drscan(Jim_Interp
*interp
, int argc
, Jim_Obj
*const *args
)
2772 scan_field_t
*fields
;
2774 int field_count
= 0;
2779 * args[2] = num_bits
2780 * args[3] = hex string
2781 * ... repeat num bits and hex string ...
2783 if ((argc
< 4) || ((argc
% 2)!=0))
2785 Jim_WrongNumArgs(interp
, 1, args
, "wrong arguments");
2789 for (i
= 2; i
< argc
; i
+=2)
2793 e
= Jim_GetLong(interp
, args
[i
], &bits
);
2798 tap
= jtag_TapByJimObj( interp
, args
[1] );
2803 num_fields
=(argc
-2)/2;
2804 fields
= malloc(sizeof(scan_field_t
) * num_fields
);
2805 for (i
= 2; i
< argc
; i
+=2)
2811 Jim_GetLong(interp
, args
[i
], &bits
);
2812 str
= Jim_GetString(args
[i
+1], &len
);
2814 fields
[field_count
].tap
= tap
;
2815 fields
[field_count
].num_bits
= bits
;
2816 fields
[field_count
].out_value
= malloc(CEIL(bits
, 8));
2817 str_to_buf(str
, len
, fields
[field_count
].out_value
, bits
, 0);
2818 fields
[field_count
].out_mask
= NULL
;
2819 fields
[field_count
].in_value
= fields
[field_count
].out_value
;
2820 fields
[field_count
].in_check_mask
= NULL
;
2821 fields
[field_count
].in_check_value
= NULL
;
2822 fields
[field_count
].in_handler
= NULL
;
2823 fields
[field_count
++].in_handler_priv
= NULL
;
2826 jtag_add_dr_scan(num_fields
, fields
, -1);
2827 retval
= jtag_execute_queue();
2828 if (retval
!= ERROR_OK
)
2830 Jim_SetResultString(interp
, "drscan: jtag execute failed",-1);
2835 Jim_Obj
*list
= Jim_NewListObj(interp
, NULL
, 0);
2836 for (i
= 2; i
< argc
; i
+=2)
2841 Jim_GetLong(interp
, args
[i
], &bits
);
2842 str
= buf_to_str(fields
[field_count
].in_value
, bits
, 16);
2843 free(fields
[field_count
].out_value
);
2845 Jim_ListAppendElement(interp
, list
, Jim_NewStringObj(interp
, str
, strlen(str
)));
2850 Jim_SetResult(interp
, list
);
2857 int handle_verify_ircapture_command(struct command_context_s
*cmd_ctx
, char *cmd
, char **args
, int argc
)
2861 if (strcmp(args
[0], "enable") == 0)
2863 jtag_verify_capture_ir
= 1;
2865 else if (strcmp(args
[0], "disable") == 0)
2867 jtag_verify_capture_ir
= 0;
2870 return ERROR_COMMAND_SYNTAX_ERROR
;
2872 } else if (argc
!= 0)
2874 return ERROR_COMMAND_SYNTAX_ERROR
;
2877 command_print(cmd_ctx
, "verify Capture-IR is %s", (jtag_verify_capture_ir
) ? "enabled": "disabled");
2882 int jtag_power_dropout(int *dropout
)
2884 return jtag
->power_dropout(dropout
);
2887 int jtag_srst_asserted(int *srst_asserted
)
2889 return jtag
->srst_asserted(srst_asserted
);
2892 void jtag_tap_handle_event( jtag_tap_t
* tap
, enum jtag_tap_event e
)
2894 jtag_tap_event_action_t
* jteap
;
2897 jteap
= tap
->event_action
;
2901 if (jteap
->event
== e
) {
2903 LOG_DEBUG( "JTAG tap: %s event: %d (%s) action: %s\n",
2906 Jim_Nvp_value2name_simple(nvp_jtag_tap_event
, e
)->name
,
2907 Jim_GetString(jteap
->body
, NULL
) );
2908 if (Jim_EvalObj(interp
, jteap
->body
) != JIM_OK
) {
2909 Jim_PrintErrorMessage(interp
);
2913 jteap
= jteap
->next
;
2917 LOG_DEBUG( "event %d %s - no action",
2919 Jim_Nvp_value2name_simple( nvp_jtag_tap_event
, e
)->name
);
2923 /*-----<Cable Helper API>---------------------------------------*/
2925 /* these Cable Helper API functions are all documented in the jtag.h header file,
2926 using a Doxygen format. And since Doxygen's configuration file "Doxyfile",
2927 is setup to prefer its docs in the header file, no documentation is here, for
2928 if it were, it would have to be doubly maintained.
2932 * @see tap_set_state() and tap_get_state() accessors.
2933 * Actual name is not important since accessors hide it.
2935 static tap_state_t state_follower
= TAP_RESET
;
2937 void tap_set_state_impl( tap_state_t new_state
)
2939 /* this is the state we think the TAPs are in now, was cur_state */
2940 state_follower
= new_state
;
2943 tap_state_t
tap_get_state()
2945 return state_follower
;
2949 * @see tap_set_end_state() and tap_get_end_state() accessors.
2950 * Actual name is not important because accessors hide it.
2952 static tap_state_t end_state_follower
= TAP_RESET
;
2954 void tap_set_end_state( tap_state_t new_end_state
)
2956 /* this is the state we think the TAPs will be in at completion of the
2957 current TAP operation, was end_state
2959 end_state_follower
= new_end_state
;
2962 tap_state_t
tap_get_end_state()
2964 return end_state_follower
;
2967 int tap_move_ndx( tap_state_t astate
)
2969 /* given a stable state, return the index into the tms_seqs[] array within tap_get_tms_path() */
2972 const static int move_map[16] =
2974 0, -1, -1, 2, -1, 3, -1, -1,
2975 1, -1, -1, 4, -1, 5, -1, -1
2983 case TAP_RESET
: ndx
= 0; break;
2984 case TAP_DRSHIFT
: ndx
= 2; break;
2985 case TAP_DRPAUSE
: ndx
= 3; break;
2986 case TAP_IDLE
: ndx
= 1; break;
2987 case TAP_IRSHIFT
: ndx
= 4; break;
2988 case TAP_IRPAUSE
: ndx
= 5; break;
2990 LOG_ERROR( "fatal: unstable state \"%s\" used in tap_move_ndx()", tap_state_name(astate
) );
2997 int tap_get_tms_path( tap_state_t from
, tap_state_t to
)
2999 /* tap_move[i][j]: tap movement command to go from state i to state j
3000 * 0: Test-Logic-Reset
3007 * DRSHIFT->DRSHIFT and IRSHIFT->IRSHIFT have to be caught in interface specific code
3009 const static u8 tms_seqs
[6][6] =
3011 /* value clocked to TMS to move from one of six stable states to another */
3013 /* RESET IDLE DRSHIFT DRPAUSE IRSHIFT IRPAUSE */
3014 { 0x7f, 0x00, 0x17, 0x0a, 0x1b, 0x16 }, /* RESET */
3015 { 0x7f, 0x00, 0x25, 0x05, 0x2b, 0x0b }, /* IDLE */
3016 { 0x7f, 0x31, 0x00, 0x01, 0x0f, 0x2f }, /* DRSHIFT */
3017 { 0x7f, 0x30, 0x20, 0x17, 0x1e, 0x2f }, /* DRPAUSE */
3018 { 0x7f, 0x31, 0x07, 0x17, 0x00, 0x01 }, /* IRSHIFT */
3019 { 0x7f, 0x30, 0x1c, 0x17, 0x20, 0x2f } /* IRPAUSE */
3022 if( !tap_is_state_stable(from
) )
3024 LOG_ERROR( "fatal: tap_state \"from\" (=%s) is not stable", tap_state_name(from
) );
3028 if( !tap_is_state_stable(to
) )
3030 LOG_ERROR( "fatal: tap_state \"to\" (=%s) is not stable", tap_state_name(to
) );
3034 /* @todo: support other than 7 clocks ? */
3035 return tms_seqs
[tap_move_ndx(from
)][tap_move_ndx(to
)];
3038 int tap_is_state_stable(tap_state_t astate
)
3042 /* A switch() is used because it is symbol dependent
3043 (not value dependent like an array), and can also check bounds.
3062 tap_state_t
tap_state_transition(tap_state_t cur_state
, int tms
)
3064 tap_state_t new_state
;
3066 /* A switch is used because it is symbol dependent and not value dependent
3067 like an array. Also it can check for out of range conditions.
3075 new_state
= cur_state
;
3080 new_state
= TAP_DRSELECT
;
3083 new_state
= TAP_IRSELECT
;
3087 new_state
= TAP_DREXIT1
;
3091 new_state
= TAP_DRUPDATE
;
3094 new_state
= TAP_DREXIT2
;
3097 new_state
= TAP_RESET
;
3101 new_state
= TAP_IREXIT1
;
3105 new_state
= TAP_IRUPDATE
;
3108 new_state
= TAP_IREXIT2
;
3111 LOG_ERROR( "fatal: invalid argument cur_state=%d", cur_state
);
3124 new_state
= TAP_IDLE
;
3127 new_state
= TAP_DRCAPTURE
;
3132 new_state
= TAP_DRSHIFT
;
3136 new_state
= TAP_DRPAUSE
;
3139 new_state
= TAP_IRCAPTURE
;
3144 new_state
= TAP_IRSHIFT
;
3148 new_state
= TAP_IRPAUSE
;
3151 LOG_ERROR( "fatal: invalid argument cur_state=%d", cur_state
);
3160 const char* tap_state_name(tap_state_t state
)
3166 case TAP_RESET
: ret
= "RESET"; break;
3167 case TAP_IDLE
: ret
= "IDLE"; break;
3168 case TAP_DRSELECT
: ret
= "DRSELECT"; break;
3169 case TAP_DRCAPTURE
: ret
= "DRCAPTURE"; break;
3170 case TAP_DRSHIFT
: ret
= "DRSHIFT"; break;
3171 case TAP_DREXIT1
: ret
= "DREXIT1"; break;
3172 case TAP_DRPAUSE
: ret
= "DRPAUSE"; break;
3173 case TAP_DREXIT2
: ret
= "DREXIT2"; break;
3174 case TAP_DRUPDATE
: ret
= "DRUPDATE"; break;
3175 case TAP_IRSELECT
: ret
= "IRSELECT"; break;
3176 case TAP_IRCAPTURE
: ret
= "IRCAPTURE"; break;
3177 case TAP_IRSHIFT
: ret
= "IRSHIFT"; break;
3178 case TAP_IREXIT1
: ret
= "IREXIT1"; break;
3179 case TAP_IRPAUSE
: ret
= "IRPAUSE"; break;
3180 case TAP_IREXIT2
: ret
= "IREXIT2"; break;
3181 case TAP_IRUPDATE
: ret
= "IRUPDATE"; break;
3182 default: ret
= "???";
3188 /*-----</Cable Helper API>--------------------------------------*/
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)