svf: new command line options -noreset and -addcycles 33/7433/7
authorKai Schmitz <kai.schmitz@advantest.com>
Thu, 5 Jan 2023 12:50:53 +0000 (13:50 +0100)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 18 Mar 2023 22:01:34 +0000 (22:01 +0000)
-noreset: when using several SVF input files in a sequence it is not always
 desireable to have a JTAG reset between the execution of the files.
 The -noreset option skips this unwanted reset.

-addcycles <x>: some tests rely on a certain number of extra clock cycles
 between the actual JTAG commands. The -addcycles option injects a number
 x cycles after each SDR instruction.

Signed-off-by: Kai Schmitz <kai.schmitz@advantest.com>
Change-Id: I31932d6041dbc803be00016cd0a4f23fb2e7dbe1
Reviewed-on: https://review.openocd.org/c/openocd/+/7433
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
doc/openocd.texi
src/svf/svf.c

index 414b4c405728366539b07d144753a1d39021af4d..0de101b6da142ca41351059d2df0e19ec99914bc 100644 (file)
@@ -11433,7 +11433,8 @@ In a debug session using JTAG for its transport protocol,
 OpenOCD supports running such test files.
 
 @deffn {Command} {svf} @file{filename} [@option{-tap @var{tapname}}] [@option{[-]quiet}] @
-                     [@option{[-]nil}] [@option{[-]progress}] [@option{[-]ignore_error}]
+                     [@option{[-]nil}] [@option{[-]progress}] [@option{[-]ignore_error}] @
+                     [@option{-noreset}] [@option{-addcycles @var{cyclecount}}]
 This issues a JTAG reset (Test-Logic-Reset) and then
 runs the SVF script from @file{filename}.
 
@@ -11452,6 +11453,10 @@ on the real interface;
 @item @option{[-]progress} enable progress indication;
 @item @option{[-]ignore_error} continue execution despite TDO check
 errors.
+@item @option{-noreset} omit JTAG reset (Test-Logic-Reset) before executing
+content of the SVF file;
+@item @option{-addcycles @var{cyclecount}} inject @var{cyclecount} number of
+additional TCLK cycles after each SDR scan instruction;
 @end itemize
 @end deffn
 
index a5374316eafa5f8b6a9d2e026feaca295b9a7a73..7195880670970a9bbce5a6dc86bc1779f14e4fc3 100644 (file)
@@ -22,6 +22,7 @@
 #include "svf.h"
 #include "helper/system.h"
 #include <helper/time_support.h>
+#include <stdbool.h>
 
 /* SVF command */
 enum svf_command {
@@ -139,6 +140,9 @@ static const struct svf_statemove svf_statemoves[] = {
 #define XXR_TDO                                (1 << 1)
 #define XXR_MASK                       (1 << 2)
 #define XXR_SMASK                      (1 << 3)
+
+#define SVF_MAX_ADDCYCLES      255
+
 struct svf_xxr_para {
        int len;
        int data_mask;
@@ -220,6 +224,8 @@ static int svf_buffer_index, svf_buffer_size;
 static int svf_quiet;
 static int svf_nil;
 static int svf_ignore_error;
+static bool svf_noreset;
+static int svf_addcycles;
 
 /* Targeting particular tap */
 static int svf_tap_is_specified;
@@ -343,7 +349,7 @@ int svf_add_statemove(tap_state_t state_to)
 COMMAND_HANDLER(handle_svf_command)
 {
 #define SVF_MIN_NUM_OF_OPTIONS 1
-#define SVF_MAX_NUM_OF_OPTIONS 5
+#define SVF_MAX_NUM_OF_OPTIONS 8
        int command_num = 0;
        int ret = ERROR_OK;
        int64_t time_measure_ms;
@@ -363,8 +369,18 @@ COMMAND_HANDLER(handle_svf_command)
        svf_nil = 0;
        svf_progress_enabled = 0;
        svf_ignore_error = 0;
+       svf_noreset = false;
+       svf_addcycles = 0;
+
        for (unsigned int i = 0; i < CMD_ARGC; i++) {
-               if (strcmp(CMD_ARGV[i], "-tap") == 0) {
+               if (strcmp(CMD_ARGV[i], "-addcycles") == 0) {
+                       svf_addcycles = atoi(CMD_ARGV[i + 1]);
+                       if (svf_addcycles > SVF_MAX_ADDCYCLES) {
+                               command_print(CMD, "addcycles: %s out of range", CMD_ARGV[i + 1]);
+                               return ERROR_FAIL;
+                       }
+                       i++;
+               } else if (strcmp(CMD_ARGV[i], "-tap") == 0) {
                        tap = jtag_tap_by_string(CMD_ARGV[i+1]);
                        if (!tap) {
                                command_print(CMD, "Tap: %s unknown", CMD_ARGV[i+1]);
@@ -382,6 +398,8 @@ COMMAND_HANDLER(handle_svf_command)
                else if ((strcmp(CMD_ARGV[i],
                                  "ignore_error") == 0) || (strcmp(CMD_ARGV[i], "-ignore_error") == 0))
                        svf_ignore_error = 1;
+               else if (strcmp(CMD_ARGV[i], "-noreset") == 0)
+                       svf_noreset = true;
                else {
                        svf_fd = fopen(CMD_ARGV[i], "r");
                        if (!svf_fd) {
@@ -424,7 +442,7 @@ COMMAND_HANDLER(handle_svf_command)
 
        memcpy(&svf_para, &svf_para_init, sizeof(svf_para));
 
-       if (!svf_nil) {
+       if (!svf_nil && !svf_noreset) {
                /* TAP_RESET */
                jtag_add_tlr();
        }
@@ -1189,6 +1207,9 @@ xxr_common:
                                                        svf_para.dr_end_state);
                                }
 
+                               if (svf_addcycles)
+                                       jtag_add_clocks(svf_addcycles);
+
                                svf_buffer_index += (i + 7) >> 3;
                        } else if (command == SIR) {
                                /* check buffer size first, reallocate if necessary */
@@ -1545,7 +1566,7 @@ static const struct command_registration svf_command_handlers[] = {
                .handler = handle_svf_command,
                .mode = COMMAND_EXEC,
                .help = "Runs a SVF file.",
-               .usage = "[-tap device.tap] <file> [quiet] [nil] [progress] [ignore_error]",
+               .usage = "[-tap device.tap] <file> [quiet] [nil] [progress] [ignore_error] [-noreset] [-addcycles numcycles]",
        },
        COMMAND_REGISTRATION_DONE
 };

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)