1 // SPDX-License-Identifier: GPL-2.0-or-later
3 /***************************************************************************
4 * Copyright (C) 2009 by Simon Qian *
5 * SimonQian@SimonQian.com *
6 ***************************************************************************/
8 /* The specification for SVF is available here:
9 * http://www.asset-intertech.com/support/svf.pdf
10 * Below, this document is referred to as the "SVF spec".
12 * The specification for XSVF is available here:
13 * http://www.xilinx.com/support/documentation/application_notes/xapp503.pdf
14 * Below, this document is referred to as the "XSVF spec".
21 #include <jtag/jtag.h>
23 #include "helper/system.h"
24 #include <helper/time_support.h>
25 #include <helper/nvp.h>
46 static const char *svf_command_name
[14] = {
70 static const char *svf_trst_mode_name
[4] = {
77 struct svf_statemove
{
80 uint32_t num_of_moves
;
85 * These paths are from the SVF specification for the STATE command, to be
86 * used when the STATE command only includes the final state. The first
87 * element of the path is the "from" (current) state, and the last one is
88 * the "to" (target) state.
90 * All specified paths are the shortest ones in the JTAG spec, and are thus
91 * not (!!) exact matches for the paths used elsewhere in OpenOCD. Note
92 * that PAUSE-to-PAUSE transitions all go through UPDATE and then CAPTURE,
93 * which has specific effects on the various registers; they are not NOPs.
95 * Paths to RESET are disabled here. As elsewhere in OpenOCD, and in XSVF
96 * and many SVF implementations, we don't want to risk missing that state.
97 * To get to RESET, always we ignore the current state.
99 static const struct svf_statemove svf_statemoves
[] = {
100 /* from to num_of_moves, paths[8] */
101 /* {TAP_RESET, TAP_RESET, 1, {TAP_RESET}}, */
102 {TAP_RESET
, TAP_IDLE
, 2, {TAP_RESET
, TAP_IDLE
} },
103 {TAP_RESET
, TAP_DRPAUSE
, 6, {TAP_RESET
, TAP_IDLE
, TAP_DRSELECT
,
104 TAP_DRCAPTURE
, TAP_DREXIT1
, TAP_DRPAUSE
} },
105 {TAP_RESET
, TAP_IRPAUSE
, 7, {TAP_RESET
, TAP_IDLE
, TAP_DRSELECT
,
106 TAP_IRSELECT
, TAP_IRCAPTURE
,
107 TAP_IREXIT1
, TAP_IRPAUSE
} },
109 /* {TAP_IDLE, TAP_RESET, 4, {TAP_IDLE,
110 * TAP_DRSELECT, TAP_IRSELECT, TAP_RESET}}, */
111 {TAP_IDLE
, TAP_IDLE
, 1, {TAP_IDLE
} },
112 {TAP_IDLE
, TAP_DRPAUSE
, 5, {TAP_IDLE
, TAP_DRSELECT
, TAP_DRCAPTURE
,
113 TAP_DREXIT1
, TAP_DRPAUSE
} },
114 {TAP_IDLE
, TAP_IRPAUSE
, 6, {TAP_IDLE
, TAP_DRSELECT
, TAP_IRSELECT
,
115 TAP_IRCAPTURE
, TAP_IREXIT1
, TAP_IRPAUSE
} },
117 /* {TAP_DRPAUSE, TAP_RESET, 6, {TAP_DRPAUSE,
118 * TAP_DREXIT2, TAP_DRUPDATE, TAP_DRSELECT, TAP_IRSELECT, TAP_RESET}}, */
119 {TAP_DRPAUSE
, TAP_IDLE
, 4, {TAP_DRPAUSE
, TAP_DREXIT2
, TAP_DRUPDATE
,
121 {TAP_DRPAUSE
, TAP_DRPAUSE
, 7, {TAP_DRPAUSE
, TAP_DREXIT2
, TAP_DRUPDATE
,
122 TAP_DRSELECT
, TAP_DRCAPTURE
,
123 TAP_DREXIT1
, TAP_DRPAUSE
} },
124 {TAP_DRPAUSE
, TAP_IRPAUSE
, 8, {TAP_DRPAUSE
, TAP_DREXIT2
, TAP_DRUPDATE
,
125 TAP_DRSELECT
, TAP_IRSELECT
,
126 TAP_IRCAPTURE
, TAP_IREXIT1
, TAP_IRPAUSE
} },
128 /* {TAP_IRPAUSE, TAP_RESET, 6, {TAP_IRPAUSE,
129 * TAP_IREXIT2, TAP_IRUPDATE, TAP_DRSELECT, TAP_IRSELECT, TAP_RESET}}, */
130 {TAP_IRPAUSE
, TAP_IDLE
, 4, {TAP_IRPAUSE
, TAP_IREXIT2
, TAP_IRUPDATE
,
132 {TAP_IRPAUSE
, TAP_DRPAUSE
, 7, {TAP_IRPAUSE
, TAP_IREXIT2
, TAP_IRUPDATE
,
133 TAP_DRSELECT
, TAP_DRCAPTURE
,
134 TAP_DREXIT1
, TAP_DRPAUSE
} },
135 {TAP_IRPAUSE
, TAP_IRPAUSE
, 8, {TAP_IRPAUSE
, TAP_IREXIT2
, TAP_IRUPDATE
,
136 TAP_DRSELECT
, TAP_IRSELECT
,
137 TAP_IRCAPTURE
, TAP_IREXIT1
, TAP_IRPAUSE
} }
140 #define XXR_TDI (1 << 0)
141 #define XXR_TDO (1 << 1)
142 #define XXR_MASK (1 << 2)
143 #define XXR_SMASK (1 << 3)
145 #define SVF_MAX_ADDCYCLES 255
147 struct svf_xxr_para
{
158 tap_state_t ir_end_state
;
159 tap_state_t dr_end_state
;
160 tap_state_t runtest_run_state
;
161 tap_state_t runtest_end_state
;
162 enum trst_mode trst_mode
;
164 struct svf_xxr_para hir_para
;
165 struct svf_xxr_para hdr_para
;
166 struct svf_xxr_para tir_para
;
167 struct svf_xxr_para tdr_para
;
168 struct svf_xxr_para sir_para
;
169 struct svf_xxr_para sdr_para
;
172 static struct svf_para svf_para
;
173 static const struct svf_para svf_para_init
= {
174 /* frequency, ir_end_state, dr_end_state, runtest_run_state, runtest_end_state, trst_mode */
175 0, TAP_IDLE
, TAP_IDLE
, TAP_IDLE
, TAP_IDLE
, TRST_Z
,
177 /* {len, data_mask, tdi, tdo, mask, smask}, */
178 {0, 0, NULL
, NULL
, NULL
, NULL
},
180 /* {len, data_mask, tdi, tdo, mask, smask}, */
181 {0, 0, NULL
, NULL
, NULL
, NULL
},
183 /* {len, data_mask, tdi, tdo, mask, smask}, */
184 {0, 0, NULL
, NULL
, NULL
, NULL
},
186 /* {len, data_mask, tdi, tdo, mask, smask}, */
187 {0, 0, NULL
, NULL
, NULL
, NULL
},
189 /* {len, data_mask, tdi, tdo, mask, smask}, */
190 {0, 0, NULL
, NULL
, NULL
, NULL
},
192 /* {len, data_mask, tdi, tdo, mask, smask}, */
193 {0, 0, NULL
, NULL
, NULL
, NULL
},
196 struct svf_check_tdo_para
{
197 int line_num
; /* used to record line number of the check operation */
198 /* so more information could be printed */
199 int enabled
; /* check is enabled or not */
200 int buffer_offset
; /* buffer_offset to buffers */
201 int bit_len
; /* bit length to check */
204 #define SVF_CHECK_TDO_PARA_SIZE 1024
205 static struct svf_check_tdo_para
*svf_check_tdo_para
;
206 static int svf_check_tdo_para_index
;
208 static int svf_read_command_from_file(FILE *fd
);
209 static int svf_check_tdo(void);
210 static int svf_add_check_para(uint8_t enabled
, int buffer_offset
, int bit_len
);
211 static int svf_run_command(struct command_context
*cmd_ctx
, char *cmd_str
);
212 static int svf_execute_tap(void);
215 static char *svf_read_line
;
216 static size_t svf_read_line_size
;
217 static char *svf_command_buffer
;
218 static size_t svf_command_buffer_size
;
219 static int svf_line_number
;
220 static int svf_getline(char **lineptr
, size_t *n
, FILE *stream
);
222 #define SVF_MAX_BUFFER_SIZE_TO_COMMIT (1024 * 1024)
223 static uint8_t *svf_tdi_buffer
, *svf_tdo_buffer
, *svf_mask_buffer
;
224 static int svf_buffer_index
, svf_buffer_size
;
225 static int svf_quiet
;
227 static int svf_ignore_error
;
228 static bool svf_noreset
;
229 static int svf_addcycles
;
231 /* Targeting particular tap */
232 static int svf_tap_is_specified
;
233 static int svf_set_padding(struct svf_xxr_para
*para
, int len
, unsigned char tdi
);
235 /* Progress Indicator */
236 static int svf_progress_enabled
;
237 static long svf_total_lines
;
238 static int svf_percentage
;
239 static int svf_last_printed_percentage
= -1;
242 * macro is used to print the svf hex buffer at desired debug level
243 * DEBUG, INFO, ERROR, USER
245 #define SVF_BUF_LOG(_lvl, _buf, _nbits, _desc) \
246 svf_hexbuf_print(LOG_LVL_##_lvl, __FILE__, __LINE__, __func__, _buf, _nbits, _desc)
248 static void svf_hexbuf_print(int dbg_lvl
, const char *file
, unsigned line
,
249 const char *function
, const uint8_t *buf
,
250 int bit_len
, const char *desc
)
253 int byte_len
= DIV_ROUND_UP(bit_len
, 8);
254 int msbits
= bit_len
% 8;
256 /* allocate 2 bytes per hex digit */
257 char *prbuf
= malloc((byte_len
* 2) + 2 + 1);
261 /* print correct number of bytes, mask excess bits where applicable */
262 uint8_t msb
= buf
[byte_len
- 1] & (msbits
? (1 << msbits
) - 1 : 0xff);
263 len
= sprintf(prbuf
, msbits
<= 4 ? "0x%01"PRIx8
: "0x%02"PRIx8
, msb
);
264 for (j
= byte_len
- 2; j
>= 0; j
--)
265 len
+= sprintf(prbuf
+ len
, "%02"PRIx8
, buf
[j
]);
267 log_printf_lf(dbg_lvl
, file
, line
, function
, "%8s = %s", desc
? desc
: " ", prbuf
);
272 static int svf_realloc_buffers(size_t len
)
276 if (svf_execute_tap() != ERROR_OK
)
279 ptr
= realloc(svf_tdi_buffer
, len
);
282 svf_tdi_buffer
= ptr
;
284 ptr
= realloc(svf_tdo_buffer
, len
);
287 svf_tdo_buffer
= ptr
;
289 ptr
= realloc(svf_mask_buffer
, len
);
292 svf_mask_buffer
= ptr
;
294 svf_buffer_size
= len
;
299 static void svf_free_xxd_para(struct svf_xxr_para
*para
)
316 int svf_add_statemove(tap_state_t state_to
)
318 tap_state_t state_from
= cmd_queue_cur_state
;
321 /* when resetting, be paranoid and ignore current state */
322 if (state_to
== TAP_RESET
) {
330 for (index_var
= 0; index_var
< ARRAY_SIZE(svf_statemoves
); index_var
++) {
331 if ((svf_statemoves
[index_var
].from
== state_from
)
332 && (svf_statemoves
[index_var
].to
== state_to
)) {
335 /* recorded path includes current state ... avoid
337 if (svf_statemoves
[index_var
].num_of_moves
> 1)
338 jtag_add_pathmove(svf_statemoves
[index_var
].num_of_moves
- 1,
339 svf_statemoves
[index_var
].paths
+ 1);
341 jtag_add_pathmove(svf_statemoves
[index_var
].num_of_moves
,
342 svf_statemoves
[index_var
].paths
);
346 LOG_ERROR("SVF: can not move to %s", tap_state_name(state_to
));
359 DEPRECATED_OPT_IGNORE_ERROR
,
361 DEPRECATED_OPT_PROGRESS
,
362 DEPRECATED_OPT_QUIET
,
365 static const struct nvp svf_cmd_opts
[] = {
366 { .name
= "-addcycles", .value
= OPT_ADDCYCLES
},
367 { .name
= "-ignore_error", .value
= OPT_IGNORE_ERROR
},
368 { .name
= "-nil", .value
= OPT_NIL
},
369 { .name
= "-noreset", .value
= OPT_NORESET
},
370 { .name
= "-progress", .value
= OPT_PROGRESS
},
371 { .name
= "-quiet", .value
= OPT_QUIET
},
372 { .name
= "-tap", .value
= OPT_TAP
},
374 { .name
= "ignore_error", .value
= DEPRECATED_OPT_IGNORE_ERROR
},
375 { .name
= "nil", .value
= DEPRECATED_OPT_NIL
},
376 { .name
= "progress", .value
= DEPRECATED_OPT_PROGRESS
},
377 { .name
= "quiet", .value
= DEPRECATED_OPT_QUIET
},
378 { .name
= NULL
, .value
= -1 }
381 COMMAND_HANDLER(handle_svf_command
)
383 #define SVF_MIN_NUM_OF_OPTIONS 1
384 #define SVF_MAX_NUM_OF_OPTIONS 8
387 int64_t time_measure_ms
;
388 int time_measure_s
, time_measure_m
;
391 * use NULL to indicate a "plain" svf file which accounts for
392 * any additional devices in the scan chain, otherwise the device
393 * that should be affected
395 struct jtag_tap
*tap
= NULL
;
397 if ((CMD_ARGC
< SVF_MIN_NUM_OF_OPTIONS
) || (CMD_ARGC
> SVF_MAX_NUM_OF_OPTIONS
))
398 return ERROR_COMMAND_SYNTAX_ERROR
;
400 /* parse command line */
403 svf_progress_enabled
= 0;
404 svf_ignore_error
= 0;
408 for (unsigned int i
= 0; i
< CMD_ARGC
; i
++) {
409 const struct nvp
*n
= nvp_name2value(svf_cmd_opts
, CMD_ARGV
[i
]);
412 svf_addcycles
= atoi(CMD_ARGV
[i
+ 1]);
413 if (svf_addcycles
> SVF_MAX_ADDCYCLES
) {
414 command_print(CMD
, "addcycles: %s out of range", CMD_ARGV
[i
+ 1]);
418 return ERROR_COMMAND_ARGUMENT_INVALID
;
424 tap
= jtag_tap_by_string(CMD_ARGV
[i
+1]);
426 command_print(CMD
, "Tap: %s unknown", CMD_ARGV
[i
+1]);
430 return ERROR_COMMAND_ARGUMENT_INVALID
;
435 case DEPRECATED_OPT_QUIET
:
436 LOG_INFO("DEPRECATED flag '%s'; use '-%s'", CMD_ARGV
[i
], CMD_ARGV
[i
]);
442 case DEPRECATED_OPT_NIL
:
443 LOG_INFO("DEPRECATED flag '%s'; use '-%s'", CMD_ARGV
[i
], CMD_ARGV
[i
]);
449 case DEPRECATED_OPT_PROGRESS
:
450 LOG_INFO("DEPRECATED flag '%s'; use '-%s'", CMD_ARGV
[i
], CMD_ARGV
[i
]);
453 svf_progress_enabled
= 1;
456 case DEPRECATED_OPT_IGNORE_ERROR
:
457 LOG_INFO("DEPRECATED flag '%s'; use '-%s'", CMD_ARGV
[i
], CMD_ARGV
[i
]);
459 case OPT_IGNORE_ERROR
:
460 svf_ignore_error
= 1;
468 svf_fd
= fopen(CMD_ARGV
[i
], "r");
471 command_print(CMD
, "open(\"%s\"): %s", CMD_ARGV
[i
], strerror(err
));
472 /* no need to free anything now */
473 return ERROR_COMMAND_SYNTAX_ERROR
;
475 LOG_USER("svf processing file: \"%s\"", CMD_ARGV
[i
]);
481 return ERROR_COMMAND_SYNTAX_ERROR
;
484 time_measure_ms
= timeval_ms();
488 svf_command_buffer_size
= 0;
490 svf_check_tdo_para_index
= 0;
491 svf_check_tdo_para
= malloc(sizeof(struct svf_check_tdo_para
) * SVF_CHECK_TDO_PARA_SIZE
);
492 if (!svf_check_tdo_para
) {
493 LOG_ERROR("not enough memory");
498 svf_buffer_index
= 0;
499 /* double the buffer size */
500 /* in case current command cannot be committed, and next command is a bit scan command */
501 /* here is 32K bits for this big scan command, it should be enough */
502 /* buffer will be reallocated if buffer size is not enough */
503 if (svf_realloc_buffers(2 * SVF_MAX_BUFFER_SIZE_TO_COMMIT
) != ERROR_OK
) {
508 memcpy(&svf_para
, &svf_para_init
, sizeof(svf_para
));
510 if (!svf_nil
&& !svf_noreset
) {
516 /* Tap is specified, set header/trailer paddings */
517 int header_ir_len
= 0, header_dr_len
= 0, trailer_ir_len
= 0, trailer_dr_len
= 0;
518 struct jtag_tap
*check_tap
;
520 svf_tap_is_specified
= 1;
522 for (check_tap
= jtag_all_taps(); check_tap
; check_tap
= check_tap
->next_tap
) {
523 if (check_tap
->abs_chain_position
< tap
->abs_chain_position
) {
525 header_ir_len
+= check_tap
->ir_length
;
527 } else if (check_tap
->abs_chain_position
> tap
->abs_chain_position
) {
529 trailer_ir_len
+= check_tap
->ir_length
;
535 ret
= svf_set_padding(&svf_para
.hdr_para
, header_dr_len
, 0);
536 if (ret
!= ERROR_OK
) {
537 command_print(CMD
, "failed to set data header");
541 /* HIR %d TDI (0xFF) */
542 ret
= svf_set_padding(&svf_para
.hir_para
, header_ir_len
, 0xFF);
543 if (ret
!= ERROR_OK
) {
544 command_print(CMD
, "failed to set instruction header");
549 ret
= svf_set_padding(&svf_para
.tdr_para
, trailer_dr_len
, 0);
550 if (ret
!= ERROR_OK
) {
551 command_print(CMD
, "failed to set data trailer");
555 /* TIR %d TDI (0xFF) */
556 ret
= svf_set_padding(&svf_para
.tir_para
, trailer_ir_len
, 0xFF);
557 if (ret
!= ERROR_OK
) {
558 command_print(CMD
, "failed to set instruction trailer");
563 if (svf_progress_enabled
) {
564 /* Count total lines in file. */
565 while (!feof(svf_fd
)) {
566 svf_getline(&svf_command_buffer
, &svf_command_buffer_size
, svf_fd
);
571 while (svf_read_command_from_file(svf_fd
) == ERROR_OK
) {
574 if (svf_progress_enabled
) {
575 svf_percentage
= ((svf_line_number
* 20) / svf_total_lines
) * 5;
576 if (svf_last_printed_percentage
!= svf_percentage
) {
577 LOG_USER_N("\r%d%% ", svf_percentage
);
578 svf_last_printed_percentage
= svf_percentage
;
582 if (svf_progress_enabled
) {
583 svf_percentage
= ((svf_line_number
* 20) / svf_total_lines
) * 5;
584 LOG_USER_N("%3d%% %s", svf_percentage
, svf_read_line
);
586 LOG_USER_N("%s", svf_read_line
);
589 if (svf_run_command(CMD_CTX
, svf_command_buffer
) != ERROR_OK
) {
590 LOG_ERROR("fail to run command at line %d", svf_line_number
);
597 if ((!svf_nil
) && (jtag_execute_queue() != ERROR_OK
))
599 else if (svf_check_tdo() != ERROR_OK
)
603 time_measure_ms
= timeval_ms() - time_measure_ms
;
604 time_measure_s
= time_measure_ms
/ 1000;
605 time_measure_ms
%= 1000;
606 time_measure_m
= time_measure_s
/ 60;
607 time_measure_s
%= 60;
608 if (time_measure_ms
< 1000)
610 "\r\nTime used: %dm%ds%" PRId64
"ms ",
621 free(svf_command_buffer
);
622 svf_command_buffer
= NULL
;
623 svf_command_buffer_size
= 0;
625 free(svf_check_tdo_para
);
626 svf_check_tdo_para
= NULL
;
627 svf_check_tdo_para_index
= 0;
629 free(svf_tdi_buffer
);
630 svf_tdi_buffer
= NULL
;
632 free(svf_tdo_buffer
);
633 svf_tdo_buffer
= NULL
;
635 free(svf_mask_buffer
);
636 svf_mask_buffer
= NULL
;
638 svf_buffer_index
= 0;
641 svf_free_xxd_para(&svf_para
.hdr_para
);
642 svf_free_xxd_para(&svf_para
.hir_para
);
643 svf_free_xxd_para(&svf_para
.tdr_para
);
644 svf_free_xxd_para(&svf_para
.tir_para
);
645 svf_free_xxd_para(&svf_para
.sdr_para
);
646 svf_free_xxd_para(&svf_para
.sir_para
);
650 "svf file programmed %s for %d commands with %d errors",
651 (svf_ignore_error
> 1) ? "unsuccessfully" : "successfully",
653 (svf_ignore_error
> 1) ? (svf_ignore_error
- 1) : 0);
655 command_print(CMD
, "svf file programmed failed");
657 svf_ignore_error
= 0;
661 static int svf_getline(char **lineptr
, size_t *n
, FILE *stream
)
663 #define MIN_CHUNK 16 /* Buffer is increased by this size each time as required */
668 *lineptr
= malloc(*n
);
673 (*lineptr
)[0] = fgetc(stream
);
674 while ((*lineptr
)[i
] != '\n') {
675 (*lineptr
)[++i
] = fgetc(stream
);
682 *lineptr
= realloc(*lineptr
, *n
);
688 return sizeof(*lineptr
);
691 #define SVFP_CMD_INC_CNT 1024
692 static int svf_read_command_from_file(FILE *fd
)
697 int cmd_ok
= 0, slash
= 0;
699 if (svf_getline(&svf_read_line
, &svf_read_line_size
, svf_fd
) <= 0)
702 ch
= svf_read_line
[0];
703 while (!cmd_ok
&& (ch
!= 0)) {
707 if (svf_getline(&svf_read_line
, &svf_read_line_size
, svf_fd
) <= 0)
715 if (svf_getline(&svf_read_line
, &svf_read_line_size
,
728 if (svf_getline(&svf_read_line
, &svf_read_line_size
, svf_fd
) <= 0)
734 /* Don't save '\r' and '\n' if no data is parsed */
739 /* The parsing code currently expects a space
740 * before parentheses -- "TDI (123)". Also a
741 * space afterwards -- "TDI (123) TDO(456)".
742 * But such spaces are optional... instead of
743 * parser updates, cope with that by adding the
746 * Ensure there are 3 bytes available, for:
747 * - current character
749 * - terminating NUL ('\0')
751 if (cmd_pos
+ 3 > svf_command_buffer_size
) {
752 svf_command_buffer
= realloc(svf_command_buffer
, cmd_pos
+ 3);
753 svf_command_buffer_size
= cmd_pos
+ 3;
754 if (!svf_command_buffer
) {
755 LOG_ERROR("not enough memory");
760 /* insert a space before '(' */
762 svf_command_buffer
[cmd_pos
++] = ' ';
764 svf_command_buffer
[cmd_pos
++] = (char)toupper(ch
);
766 /* insert a space after ')' */
768 svf_command_buffer
[cmd_pos
++] = ' ';
771 ch
= svf_read_line
[++i
];
775 svf_command_buffer
[cmd_pos
] = '\0';
781 static int svf_parse_cmd_string(char *str
, int len
, char **argus
, int *num_of_argu
)
783 int pos
= 0, num
= 0, space_found
= 1, in_bracket
= 0;
789 LOG_ERROR("fail to parse svf command");
799 if (!in_bracket
&& isspace((int) str
[pos
])) {
802 } else if (space_found
) {
803 argus
[num
++] = &str
[pos
];
819 bool svf_tap_state_is_stable(tap_state_t state
)
821 return (state
== TAP_RESET
) || (state
== TAP_IDLE
)
822 || (state
== TAP_DRPAUSE
) || (state
== TAP_IRPAUSE
);
825 static int svf_find_string_in_array(char *str
, char **strs
, int num_of_element
)
829 for (i
= 0; i
< num_of_element
; i
++) {
830 if (!strcmp(str
, strs
[i
]))
836 static int svf_adjust_array_length(uint8_t **arr
, int orig_bit_len
, int new_bit_len
)
838 int new_byte_len
= (new_bit_len
+ 7) >> 3;
840 if ((!*arr
) || (((orig_bit_len
+ 7) >> 3) < ((new_bit_len
+ 7) >> 3))) {
842 *arr
= calloc(1, new_byte_len
);
844 LOG_ERROR("not enough memory");
851 static int svf_set_padding(struct svf_xxr_para
*para
, int len
, unsigned char tdi
)
853 int error
= ERROR_OK
;
854 error
|= svf_adjust_array_length(¶
->tdi
, para
->len
, len
);
855 memset(para
->tdi
, tdi
, (len
+ 7) >> 3);
856 error
|= svf_adjust_array_length(¶
->tdo
, para
->len
, len
);
857 error
|= svf_adjust_array_length(¶
->mask
, para
->len
, len
);
859 para
->data_mask
= XXR_TDI
;
864 static int svf_copy_hexstring_to_binary(char *str
, uint8_t **bin
, int orig_bit_len
, int bit_len
)
866 int i
, str_len
= strlen(str
), str_hbyte_len
= (bit_len
+ 3) >> 2;
869 if (svf_adjust_array_length(bin
, orig_bit_len
, bit_len
) != ERROR_OK
) {
870 LOG_ERROR("fail to adjust length of array");
874 /* fill from LSB (end of str) to MSB (beginning of str) */
875 for (i
= 0; i
< str_hbyte_len
; i
++) {
877 while (str_len
> 0) {
880 /* Skip whitespace. The SVF specification (rev E) is
881 * deficient in terms of basic lexical issues like
882 * where whitespace is allowed. Long bitstrings may
883 * require line ends for correctness, since there is
884 * a hard limit on line length.
887 if ((ch
>= '0') && (ch
<= '9')) {
890 } else if ((ch
>= 'A') && (ch
<= 'F')) {
894 LOG_ERROR("invalid hex string");
905 (*bin
)[i
/ 2] |= ch
<< 4;
913 /* consume optional leading '0' MSBs or whitespace */
914 while (str_len
> 0 && ((str
[str_len
- 1] == '0')
915 || isspace((int) str
[str_len
- 1])))
918 /* check validity: we must have consumed everything */
919 if (str_len
> 0 || (ch
& ~((2 << ((bit_len
- 1) % 4)) - 1)) != 0) {
920 LOG_ERROR("value exceeds length");
927 static int svf_check_tdo(void)
929 int i
, len
, index_var
;
931 for (i
= 0; i
< svf_check_tdo_para_index
; i
++) {
932 index_var
= svf_check_tdo_para
[i
].buffer_offset
;
933 len
= svf_check_tdo_para
[i
].bit_len
;
934 if ((svf_check_tdo_para
[i
].enabled
)
935 && buf_cmp_mask(&svf_tdi_buffer
[index_var
], &svf_tdo_buffer
[index_var
],
936 &svf_mask_buffer
[index_var
], len
)) {
937 LOG_ERROR("tdo check error at line %d",
938 svf_check_tdo_para
[i
].line_num
);
939 SVF_BUF_LOG(ERROR
, &svf_tdi_buffer
[index_var
], len
, "READ");
940 SVF_BUF_LOG(ERROR
, &svf_tdo_buffer
[index_var
], len
, "WANT");
941 SVF_BUF_LOG(ERROR
, &svf_mask_buffer
[index_var
], len
, "MASK");
943 if (svf_ignore_error
== 0)
949 svf_check_tdo_para_index
= 0;
954 static int svf_add_check_para(uint8_t enabled
, int buffer_offset
, int bit_len
)
956 if (svf_check_tdo_para_index
>= SVF_CHECK_TDO_PARA_SIZE
) {
957 LOG_ERROR("toooooo many operation undone");
961 svf_check_tdo_para
[svf_check_tdo_para_index
].line_num
= svf_line_number
;
962 svf_check_tdo_para
[svf_check_tdo_para_index
].bit_len
= bit_len
;
963 svf_check_tdo_para
[svf_check_tdo_para_index
].enabled
= enabled
;
964 svf_check_tdo_para
[svf_check_tdo_para_index
].buffer_offset
= buffer_offset
;
965 svf_check_tdo_para_index
++;
970 static int svf_execute_tap(void)
972 if ((!svf_nil
) && (jtag_execute_queue() != ERROR_OK
))
974 else if (svf_check_tdo() != ERROR_OK
)
977 svf_buffer_index
= 0;
982 static int svf_run_command(struct command_context
*cmd_ctx
, char *cmd_str
)
984 char *argus
[256], command
;
985 int num_of_argu
= 0, i
;
994 struct svf_xxr_para
*xxr_para_tmp
;
995 uint8_t **pbuffer_tmp
;
996 struct scan_field field
;
998 tap_state_t
*path
= NULL
, state
;
999 /* flag padding commands skipped due to -tap command */
1000 int padding_command_skipped
= 0;
1002 if (svf_parse_cmd_string(cmd_str
, strlen(cmd_str
), argus
, &num_of_argu
) != ERROR_OK
)
1005 /* NOTE: we're a bit loose here, because we ignore case in
1006 * TAP state names (instead of insisting on uppercase).
1009 command
= svf_find_string_in_array(argus
[0],
1010 (char **)svf_command_name
, ARRAY_SIZE(svf_command_name
));
1014 if (num_of_argu
!= 2) {
1015 LOG_ERROR("invalid parameter of %s", argus
[0]);
1019 i_tmp
= tap_state_by_name(argus
[1]);
1021 if (svf_tap_state_is_stable(i_tmp
)) {
1022 if (command
== ENDIR
) {
1023 svf_para
.ir_end_state
= i_tmp
;
1024 LOG_DEBUG("\tIR end_state = %s",
1025 tap_state_name(i_tmp
));
1027 svf_para
.dr_end_state
= i_tmp
;
1028 LOG_DEBUG("\tDR end_state = %s",
1029 tap_state_name(i_tmp
));
1032 LOG_ERROR("%s: %s is not a stable state",
1033 argus
[0], argus
[1]);
1038 if ((num_of_argu
!= 1) && (num_of_argu
!= 3)) {
1039 LOG_ERROR("invalid parameter of %s", argus
[0]);
1042 if (num_of_argu
== 1) {
1043 /* TODO: set jtag speed to full speed */
1044 svf_para
.frequency
= 0;
1046 if (strcmp(argus
[2], "HZ")) {
1047 LOG_ERROR("HZ not found in FREQUENCY command");
1050 if (svf_execute_tap() != ERROR_OK
)
1052 svf_para
.frequency
= atof(argus
[1]);
1053 /* TODO: set jtag speed to */
1054 if (svf_para
.frequency
> 0) {
1055 command_run_linef(cmd_ctx
,
1057 (int)svf_para
.frequency
/ 1000);
1058 LOG_DEBUG("\tfrequency = %f", svf_para
.frequency
);
1063 if (svf_tap_is_specified
) {
1064 padding_command_skipped
= 1;
1067 xxr_para_tmp
= &svf_para
.hdr_para
;
1070 if (svf_tap_is_specified
) {
1071 padding_command_skipped
= 1;
1074 xxr_para_tmp
= &svf_para
.hir_para
;
1077 if (svf_tap_is_specified
) {
1078 padding_command_skipped
= 1;
1081 xxr_para_tmp
= &svf_para
.tdr_para
;
1084 if (svf_tap_is_specified
) {
1085 padding_command_skipped
= 1;
1088 xxr_para_tmp
= &svf_para
.tir_para
;
1091 xxr_para_tmp
= &svf_para
.sdr_para
;
1094 xxr_para_tmp
= &svf_para
.sir_para
;
1097 /* XXR length [TDI (tdi)] [TDO (tdo)][MASK (mask)] [SMASK (smask)] */
1098 if ((num_of_argu
> 10) || (num_of_argu
% 2)) {
1099 LOG_ERROR("invalid parameter of %s", argus
[0]);
1102 i_tmp
= xxr_para_tmp
->len
;
1103 xxr_para_tmp
->len
= atoi(argus
[1]);
1104 /* If we are to enlarge the buffers, all parts of xxr_para_tmp
1105 * need to be freed */
1106 if (i_tmp
< xxr_para_tmp
->len
) {
1107 free(xxr_para_tmp
->tdi
);
1108 xxr_para_tmp
->tdi
= NULL
;
1109 free(xxr_para_tmp
->tdo
);
1110 xxr_para_tmp
->tdo
= NULL
;
1111 free(xxr_para_tmp
->mask
);
1112 xxr_para_tmp
->mask
= NULL
;
1113 free(xxr_para_tmp
->smask
);
1114 xxr_para_tmp
->smask
= NULL
;
1117 LOG_DEBUG("\tlength = %d", xxr_para_tmp
->len
);
1118 xxr_para_tmp
->data_mask
= 0;
1119 for (i
= 2; i
< num_of_argu
; i
+= 2) {
1120 if ((strlen(argus
[i
+ 1]) < 3) || (argus
[i
+ 1][0] != '(') ||
1121 (argus
[i
+ 1][strlen(argus
[i
+ 1]) - 1] != ')')) {
1122 LOG_ERROR("data section error");
1125 argus
[i
+ 1][strlen(argus
[i
+ 1]) - 1] = '\0';
1126 /* TDI, TDO, MASK, SMASK */
1127 if (!strcmp(argus
[i
], "TDI")) {
1129 pbuffer_tmp
= &xxr_para_tmp
->tdi
;
1130 xxr_para_tmp
->data_mask
|= XXR_TDI
;
1131 } else if (!strcmp(argus
[i
], "TDO")) {
1133 pbuffer_tmp
= &xxr_para_tmp
->tdo
;
1134 xxr_para_tmp
->data_mask
|= XXR_TDO
;
1135 } else if (!strcmp(argus
[i
], "MASK")) {
1137 pbuffer_tmp
= &xxr_para_tmp
->mask
;
1138 xxr_para_tmp
->data_mask
|= XXR_MASK
;
1139 } else if (!strcmp(argus
[i
], "SMASK")) {
1141 pbuffer_tmp
= &xxr_para_tmp
->smask
;
1142 xxr_para_tmp
->data_mask
|= XXR_SMASK
;
1144 LOG_ERROR("unknown parameter: %s", argus
[i
]);
1148 svf_copy_hexstring_to_binary(&argus
[i
+ 1][1], pbuffer_tmp
, i_tmp
,
1149 xxr_para_tmp
->len
)) {
1150 LOG_ERROR("fail to parse hex value");
1153 SVF_BUF_LOG(DEBUG
, *pbuffer_tmp
, xxr_para_tmp
->len
, argus
[i
]);
1155 /* If a command changes the length of the last scan of the same type and the
1156 * MASK parameter is absent, */
1157 /* the mask pattern used is all cares */
1158 if (!(xxr_para_tmp
->data_mask
& XXR_MASK
) && (i_tmp
!= xxr_para_tmp
->len
)) {
1159 /* MASK not defined and length changed */
1161 svf_adjust_array_length(&xxr_para_tmp
->mask
, i_tmp
,
1162 xxr_para_tmp
->len
)) {
1163 LOG_ERROR("fail to adjust length of array");
1166 buf_set_ones(xxr_para_tmp
->mask
, xxr_para_tmp
->len
);
1168 /* If TDO is absent, no comparison is needed, set the mask to 0 */
1169 if (!(xxr_para_tmp
->data_mask
& XXR_TDO
)) {
1170 if (!xxr_para_tmp
->tdo
) {
1172 svf_adjust_array_length(&xxr_para_tmp
->tdo
, i_tmp
,
1173 xxr_para_tmp
->len
)) {
1174 LOG_ERROR("fail to adjust length of array");
1178 if (!xxr_para_tmp
->mask
) {
1180 svf_adjust_array_length(&xxr_para_tmp
->mask
, i_tmp
,
1181 xxr_para_tmp
->len
)) {
1182 LOG_ERROR("fail to adjust length of array");
1186 memset(xxr_para_tmp
->mask
, 0, (xxr_para_tmp
->len
+ 7) >> 3);
1188 /* do scan if necessary */
1189 if (command
== SDR
) {
1190 /* check buffer size first, reallocate if necessary */
1191 i
= svf_para
.hdr_para
.len
+ svf_para
.sdr_para
.len
+
1192 svf_para
.tdr_para
.len
;
1193 if ((svf_buffer_size
- svf_buffer_index
) < ((i
+ 7) >> 3)) {
1194 /* reallocate buffer */
1195 if (svf_realloc_buffers(svf_buffer_index
+ ((i
+ 7) >> 3)) != ERROR_OK
) {
1196 LOG_ERROR("not enough memory");
1201 /* assemble dr data */
1203 buf_set_buf(svf_para
.hdr_para
.tdi
,
1205 &svf_tdi_buffer
[svf_buffer_index
],
1207 svf_para
.hdr_para
.len
);
1208 i
+= svf_para
.hdr_para
.len
;
1209 buf_set_buf(svf_para
.sdr_para
.tdi
,
1211 &svf_tdi_buffer
[svf_buffer_index
],
1213 svf_para
.sdr_para
.len
);
1214 i
+= svf_para
.sdr_para
.len
;
1215 buf_set_buf(svf_para
.tdr_para
.tdi
,
1217 &svf_tdi_buffer
[svf_buffer_index
],
1219 svf_para
.tdr_para
.len
);
1220 i
+= svf_para
.tdr_para
.len
;
1222 /* add check data */
1223 if (svf_para
.sdr_para
.data_mask
& XXR_TDO
) {
1224 /* assemble dr mask data */
1226 buf_set_buf(svf_para
.hdr_para
.mask
,
1228 &svf_mask_buffer
[svf_buffer_index
],
1230 svf_para
.hdr_para
.len
);
1231 i
+= svf_para
.hdr_para
.len
;
1232 buf_set_buf(svf_para
.sdr_para
.mask
,
1234 &svf_mask_buffer
[svf_buffer_index
],
1236 svf_para
.sdr_para
.len
);
1237 i
+= svf_para
.sdr_para
.len
;
1238 buf_set_buf(svf_para
.tdr_para
.mask
,
1240 &svf_mask_buffer
[svf_buffer_index
],
1242 svf_para
.tdr_para
.len
);
1244 /* assemble dr check data */
1246 buf_set_buf(svf_para
.hdr_para
.tdo
,
1248 &svf_tdo_buffer
[svf_buffer_index
],
1250 svf_para
.hdr_para
.len
);
1251 i
+= svf_para
.hdr_para
.len
;
1252 buf_set_buf(svf_para
.sdr_para
.tdo
,
1254 &svf_tdo_buffer
[svf_buffer_index
],
1256 svf_para
.sdr_para
.len
);
1257 i
+= svf_para
.sdr_para
.len
;
1258 buf_set_buf(svf_para
.tdr_para
.tdo
,
1260 &svf_tdo_buffer
[svf_buffer_index
],
1262 svf_para
.tdr_para
.len
);
1263 i
+= svf_para
.tdr_para
.len
;
1265 svf_add_check_para(1, svf_buffer_index
, i
);
1267 svf_add_check_para(0, svf_buffer_index
, i
);
1269 field
.out_value
= &svf_tdi_buffer
[svf_buffer_index
];
1270 field
.in_value
= (xxr_para_tmp
->data_mask
& XXR_TDO
) ? &svf_tdi_buffer
[svf_buffer_index
] : NULL
;
1272 /* NOTE: doesn't use SVF-specified state paths */
1273 jtag_add_plain_dr_scan(field
.num_bits
,
1276 svf_para
.dr_end_state
);
1280 jtag_add_clocks(svf_addcycles
);
1282 svf_buffer_index
+= (i
+ 7) >> 3;
1283 } else if (command
== SIR
) {
1284 /* check buffer size first, reallocate if necessary */
1285 i
= svf_para
.hir_para
.len
+ svf_para
.sir_para
.len
+
1286 svf_para
.tir_para
.len
;
1287 if ((svf_buffer_size
- svf_buffer_index
) < ((i
+ 7) >> 3)) {
1288 if (svf_realloc_buffers(svf_buffer_index
+ ((i
+ 7) >> 3)) != ERROR_OK
) {
1289 LOG_ERROR("not enough memory");
1294 /* assemble ir data */
1296 buf_set_buf(svf_para
.hir_para
.tdi
,
1298 &svf_tdi_buffer
[svf_buffer_index
],
1300 svf_para
.hir_para
.len
);
1301 i
+= svf_para
.hir_para
.len
;
1302 buf_set_buf(svf_para
.sir_para
.tdi
,
1304 &svf_tdi_buffer
[svf_buffer_index
],
1306 svf_para
.sir_para
.len
);
1307 i
+= svf_para
.sir_para
.len
;
1308 buf_set_buf(svf_para
.tir_para
.tdi
,
1310 &svf_tdi_buffer
[svf_buffer_index
],
1312 svf_para
.tir_para
.len
);
1313 i
+= svf_para
.tir_para
.len
;
1315 /* add check data */
1316 if (svf_para
.sir_para
.data_mask
& XXR_TDO
) {
1317 /* assemble dr mask data */
1319 buf_set_buf(svf_para
.hir_para
.mask
,
1321 &svf_mask_buffer
[svf_buffer_index
],
1323 svf_para
.hir_para
.len
);
1324 i
+= svf_para
.hir_para
.len
;
1325 buf_set_buf(svf_para
.sir_para
.mask
,
1327 &svf_mask_buffer
[svf_buffer_index
],
1329 svf_para
.sir_para
.len
);
1330 i
+= svf_para
.sir_para
.len
;
1331 buf_set_buf(svf_para
.tir_para
.mask
,
1333 &svf_mask_buffer
[svf_buffer_index
],
1335 svf_para
.tir_para
.len
);
1337 /* assemble dr check data */
1339 buf_set_buf(svf_para
.hir_para
.tdo
,
1341 &svf_tdo_buffer
[svf_buffer_index
],
1343 svf_para
.hir_para
.len
);
1344 i
+= svf_para
.hir_para
.len
;
1345 buf_set_buf(svf_para
.sir_para
.tdo
,
1347 &svf_tdo_buffer
[svf_buffer_index
],
1349 svf_para
.sir_para
.len
);
1350 i
+= svf_para
.sir_para
.len
;
1351 buf_set_buf(svf_para
.tir_para
.tdo
,
1353 &svf_tdo_buffer
[svf_buffer_index
],
1355 svf_para
.tir_para
.len
);
1356 i
+= svf_para
.tir_para
.len
;
1358 svf_add_check_para(1, svf_buffer_index
, i
);
1360 svf_add_check_para(0, svf_buffer_index
, i
);
1362 field
.out_value
= &svf_tdi_buffer
[svf_buffer_index
];
1363 field
.in_value
= (xxr_para_tmp
->data_mask
& XXR_TDO
) ? &svf_tdi_buffer
[svf_buffer_index
] : NULL
;
1365 /* NOTE: doesn't use SVF-specified state paths */
1366 jtag_add_plain_ir_scan(field
.num_bits
,
1369 svf_para
.ir_end_state
);
1372 svf_buffer_index
+= (i
+ 7) >> 3;
1377 LOG_ERROR("PIO and PIOMAP are not supported");
1380 /* RUNTEST [run_state] run_count run_clk [min_time SEC [MAXIMUM max_time
1381 * SEC]] [ENDSTATE end_state] */
1382 /* RUNTEST [run_state] min_time SEC [MAXIMUM max_time SEC] [ENDSTATE
1384 if ((num_of_argu
< 3) || (num_of_argu
> 11)) {
1385 LOG_ERROR("invalid parameter of %s", argus
[0]);
1394 i_tmp
= tap_state_by_name(argus
[i
]);
1395 if (i_tmp
!= TAP_INVALID
) {
1396 if (svf_tap_state_is_stable(i_tmp
)) {
1397 svf_para
.runtest_run_state
= i_tmp
;
1399 /* When a run_state is specified, the new
1400 * run_state becomes the default end_state.
1402 svf_para
.runtest_end_state
= i_tmp
;
1403 LOG_DEBUG("\trun_state = %s", tap_state_name(i_tmp
));
1406 LOG_ERROR("%s: %s is not a stable state", argus
[0], tap_state_name(i_tmp
));
1411 /* run_count run_clk */
1412 if (((i
+ 2) <= num_of_argu
) && strcmp(argus
[i
+ 1], "SEC")) {
1413 if (!strcmp(argus
[i
+ 1], "TCK")) {
1414 /* clock source is TCK */
1415 run_count
= atoi(argus
[i
]);
1416 LOG_DEBUG("\trun_count@TCK = %d", run_count
);
1418 LOG_ERROR("%s not supported for clock", argus
[i
+ 1]);
1424 if (((i
+ 2) <= num_of_argu
) && !strcmp(argus
[i
+ 1], "SEC")) {
1425 min_time
= atof(argus
[i
]);
1426 LOG_DEBUG("\tmin_time = %fs", min_time
);
1429 /* MAXIMUM max_time SEC */
1430 if (((i
+ 3) <= num_of_argu
) &&
1431 !strcmp(argus
[i
], "MAXIMUM") && !strcmp(argus
[i
+ 2], "SEC")) {
1433 max_time
= atof(argus
[i
+ 1]);
1434 LOG_DEBUG("\tmax_time = %fs", max_time
);
1437 /* ENDSTATE end_state */
1438 if (((i
+ 2) <= num_of_argu
) && !strcmp(argus
[i
], "ENDSTATE")) {
1439 i_tmp
= tap_state_by_name(argus
[i
+ 1]);
1441 if (svf_tap_state_is_stable(i_tmp
)) {
1442 svf_para
.runtest_end_state
= i_tmp
;
1443 LOG_DEBUG("\tend_state = %s", tap_state_name(i_tmp
));
1445 LOG_ERROR("%s: %s is not a stable state", argus
[0], tap_state_name(i_tmp
));
1451 /* all parameter should be parsed */
1452 if (i
== num_of_argu
) {
1454 /* FIXME handle statemove failures */
1455 uint32_t min_usec
= 1000000 * min_time
;
1457 /* enter into run_state if necessary */
1458 if (cmd_queue_cur_state
!= svf_para
.runtest_run_state
)
1459 svf_add_statemove(svf_para
.runtest_run_state
);
1461 /* add clocks and/or min wait */
1462 if (run_count
> 0) {
1464 jtag_add_clocks(run_count
);
1469 jtag_add_sleep(min_usec
);
1472 /* move to end_state if necessary */
1473 if (svf_para
.runtest_end_state
!= svf_para
.runtest_run_state
)
1474 svf_add_statemove(svf_para
.runtest_end_state
);
1477 if (svf_para
.runtest_run_state
!= TAP_IDLE
) {
1478 LOG_ERROR("cannot runtest in %s state",
1479 tap_state_name(svf_para
.runtest_run_state
));
1484 jtag_add_runtest(run_count
, svf_para
.runtest_end_state
);
1487 LOG_ERROR("fail to parse parameter of RUNTEST, %d out of %d is parsed",
1494 /* STATE [pathstate1 [pathstate2 ...[pathstaten]]] stable_state */
1495 if (num_of_argu
< 2) {
1496 LOG_ERROR("invalid parameter of %s", argus
[0]);
1499 if (num_of_argu
> 2) {
1500 /* STATE pathstate1 ... stable_state */
1501 path
= malloc((num_of_argu
- 1) * sizeof(tap_state_t
));
1503 LOG_ERROR("not enough memory");
1506 num_of_argu
--; /* num of path */
1507 i_tmp
= 1; /* path is from parameter 1 */
1508 for (i
= 0; i
< num_of_argu
; i
++, i_tmp
++) {
1509 path
[i
] = tap_state_by_name(argus
[i_tmp
]);
1510 if (path
[i
] == TAP_INVALID
) {
1511 LOG_ERROR("%s: %s is not a valid state", argus
[0], argus
[i_tmp
]);
1515 /* OpenOCD refuses paths containing TAP_RESET */
1516 if (path
[i
] == TAP_RESET
) {
1517 /* FIXME last state MUST be stable! */
1520 jtag_add_pathmove(i
, path
);
1524 num_of_argu
-= i
+ 1;
1528 if (num_of_argu
> 0) {
1529 /* execute last path if necessary */
1530 if (svf_tap_state_is_stable(path
[num_of_argu
- 1])) {
1531 /* last state MUST be stable state */
1533 jtag_add_pathmove(num_of_argu
, path
);
1534 LOG_DEBUG("\tmove to %s by path_move",
1535 tap_state_name(path
[num_of_argu
- 1]));
1537 LOG_ERROR("%s: %s is not a stable state",
1539 tap_state_name(path
[num_of_argu
- 1]));
1548 /* STATE stable_state */
1549 state
= tap_state_by_name(argus
[1]);
1550 if (svf_tap_state_is_stable(state
)) {
1551 LOG_DEBUG("\tmove to %s by svf_add_statemove",
1552 tap_state_name(state
));
1553 /* FIXME handle statemove failures */
1554 svf_add_statemove(state
);
1556 LOG_ERROR("%s: %s is not a stable state",
1557 argus
[0], tap_state_name(state
));
1563 /* TRST trst_mode */
1564 if (num_of_argu
!= 2) {
1565 LOG_ERROR("invalid parameter of %s", argus
[0]);
1568 if (svf_para
.trst_mode
!= TRST_ABSENT
) {
1569 if (svf_execute_tap() != ERROR_OK
)
1571 i_tmp
= svf_find_string_in_array(argus
[1],
1572 (char **)svf_trst_mode_name
,
1573 ARRAY_SIZE(svf_trst_mode_name
));
1577 jtag_add_reset(1, 0);
1582 jtag_add_reset(0, 0);
1587 LOG_ERROR("unknown TRST mode: %s", argus
[1]);
1590 svf_para
.trst_mode
= i_tmp
;
1591 LOG_DEBUG("\ttrst_mode = %s", svf_trst_mode_name
[svf_para
.trst_mode
]);
1593 LOG_ERROR("can not accept TRST command if trst_mode is ABSENT");
1598 LOG_ERROR("invalid svf command: %s", argus
[0]);
1603 if (padding_command_skipped
)
1604 LOG_USER("(Above Padding command skipped, as per -tap argument)");
1607 if (debug_level
>= LOG_LVL_DEBUG
) {
1608 /* for convenient debugging, execute tap if possible */
1609 if ((svf_buffer_index
> 0) &&
1610 (((command
!= STATE
) && (command
!= RUNTEST
)) ||
1611 ((command
== STATE
) && (num_of_argu
== 2)))) {
1612 if (svf_execute_tap() != ERROR_OK
)
1615 /* output debug info */
1616 if ((command
== SIR
) || (command
== SDR
))
1617 SVF_BUF_LOG(DEBUG
, svf_tdi_buffer
, svf_check_tdo_para
[0].bit_len
, "TDO read");
1620 /* for fast executing, execute tap if necessary */
1621 /* half of the buffer is for the next command */
1622 if (((svf_buffer_index
>= SVF_MAX_BUFFER_SIZE_TO_COMMIT
) ||
1623 (svf_check_tdo_para_index
>= SVF_CHECK_TDO_PARA_SIZE
/ 2)) &&
1624 (((command
!= STATE
) && (command
!= RUNTEST
)) ||
1625 ((command
== STATE
) && (num_of_argu
== 2))))
1626 return svf_execute_tap();
1632 static const struct command_registration svf_command_handlers
[] = {
1635 .handler
= handle_svf_command
,
1636 .mode
= COMMAND_EXEC
,
1637 .help
= "Runs a SVF file.",
1638 .usage
= "[-tap device.tap] [-quiet] [-nil] [-progress] [-ignore_error] [-noreset] [-addcycles numcycles] file",
1640 COMMAND_REGISTRATION_DONE
1643 int svf_register_commands(struct command_context
*cmd_ctx
)
1645 return register_commands(cmd_ctx
, NULL
, svf_command_handlers
);
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)