aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKai Schmitz <kai.schmitz@advantest.com>2023-01-05 13:50:53 +0100
committerAntonio Borneo <borneo.antonio@gmail.com>2023-03-18 22:01:34 +0000
commitb6b4f9d46a48aadc1de6bb5152ff4913661c9059 (patch)
tree95bb59edaa6b6d8ec98f67e86a6df92eab87c8df /src
parentb4e28446b8f2a116b088eef78744c8b529c1a747 (diff)
downloadriscv-openocd-b6b4f9d46a48aadc1de6bb5152ff4913661c9059.zip
riscv-openocd-b6b4f9d46a48aadc1de6bb5152ff4913661c9059.tar.gz
riscv-openocd-b6b4f9d46a48aadc1de6bb5152ff4913661c9059.tar.bz2
svf: new command line options -noreset and -addcycles
-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>
Diffstat (limited to 'src')
-rw-r--r--src/svf/svf.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/src/svf/svf.c b/src/svf/svf.c
index a537431..7195880 100644
--- a/src/svf/svf.c
+++ b/src/svf/svf.c
@@ -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
};