svf: make command 'svf' syntax consistent
The command 'svf' is the only command in OpenOCD that accepts options in both forms 'option' and '-option'. Deprecate the option format without the leading '-'. Update the documentation and fix the on-line help. While there: - switch to use the new nvp.h helper; - return ERROR_COMMAND_ARGUMENT_INVALID on invalid command args; - fix some minor coding style rule. Change-Id: I5b944403d92a3fa1e12d5faafc1d2a139bc16a7d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/7534 Tested-by: jenkins
This commit is contained in:
parent
f8631c3650
commit
5f6ceebbba
|
@ -11432,8 +11432,8 @@ way to represent JTAG test patterns in text files.
|
||||||
In a debug session using JTAG for its transport protocol,
|
In a debug session using JTAG for its transport protocol,
|
||||||
OpenOCD supports running such test files.
|
OpenOCD supports running such test files.
|
||||||
|
|
||||||
@deffn {Command} {svf} @file{filename} [@option{-tap @var{tapname}}] [@option{[-]quiet}] @
|
@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}}]
|
[@option{-noreset}] [@option{-addcycles @var{cyclecount}}]
|
||||||
This issues a JTAG reset (Test-Logic-Reset) and then
|
This issues a JTAG reset (Test-Logic-Reset) and then
|
||||||
runs the SVF script from @file{filename}.
|
runs the SVF script from @file{filename}.
|
||||||
|
@ -11447,11 +11447,11 @@ Command options:
|
||||||
specified by the SVF file with HIR, TIR, HDR and TDR commands;
|
specified by the SVF file with HIR, TIR, HDR and TDR commands;
|
||||||
instead, calculate them automatically according to the current JTAG
|
instead, calculate them automatically according to the current JTAG
|
||||||
chain configuration, targeting @var{tapname};
|
chain configuration, targeting @var{tapname};
|
||||||
@item @option{[-]quiet} do not log every command before execution;
|
@item @option{-quiet} do not log every command before execution;
|
||||||
@item @option{[-]nil} ``dry run'', i.e., do not perform any operations
|
@item @option{-nil} ``dry run'', i.e., do not perform any operations
|
||||||
on the real interface;
|
on the real interface;
|
||||||
@item @option{[-]progress} enable progress indication;
|
@item @option{-progress} enable progress indication;
|
||||||
@item @option{[-]ignore_error} continue execution despite TDO check
|
@item @option{-ignore_error} continue execution despite TDO check
|
||||||
errors.
|
errors.
|
||||||
@item @option{-noreset} omit JTAG reset (Test-Logic-Reset) before executing
|
@item @option{-noreset} omit JTAG reset (Test-Logic-Reset) before executing
|
||||||
content of the SVF file;
|
content of the SVF file;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "svf.h"
|
#include "svf.h"
|
||||||
#include "helper/system.h"
|
#include "helper/system.h"
|
||||||
#include <helper/time_support.h>
|
#include <helper/time_support.h>
|
||||||
|
#include <helper/nvp.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
/* SVF command */
|
/* SVF command */
|
||||||
|
@ -346,6 +347,37 @@ int svf_add_statemove(tap_state_t state_to)
|
||||||
return ERROR_FAIL;
|
return ERROR_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum svf_cmd_param {
|
||||||
|
OPT_ADDCYCLES,
|
||||||
|
OPT_IGNORE_ERROR,
|
||||||
|
OPT_NIL,
|
||||||
|
OPT_NORESET,
|
||||||
|
OPT_PROGRESS,
|
||||||
|
OPT_QUIET,
|
||||||
|
OPT_TAP,
|
||||||
|
/* DEPRECATED */
|
||||||
|
DEPRECATED_OPT_IGNORE_ERROR,
|
||||||
|
DEPRECATED_OPT_NIL,
|
||||||
|
DEPRECATED_OPT_PROGRESS,
|
||||||
|
DEPRECATED_OPT_QUIET,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct nvp svf_cmd_opts[] = {
|
||||||
|
{ .name = "-addcycles", .value = OPT_ADDCYCLES },
|
||||||
|
{ .name = "-ignore_error", .value = OPT_IGNORE_ERROR },
|
||||||
|
{ .name = "-nil", .value = OPT_NIL },
|
||||||
|
{ .name = "-noreset", .value = OPT_NORESET },
|
||||||
|
{ .name = "-progress", .value = OPT_PROGRESS },
|
||||||
|
{ .name = "-quiet", .value = OPT_QUIET },
|
||||||
|
{ .name = "-tap", .value = OPT_TAP },
|
||||||
|
/* DEPRECATED */
|
||||||
|
{ .name = "ignore_error", .value = DEPRECATED_OPT_IGNORE_ERROR },
|
||||||
|
{ .name = "nil", .value = DEPRECATED_OPT_NIL },
|
||||||
|
{ .name = "progress", .value = DEPRECATED_OPT_PROGRESS },
|
||||||
|
{ .name = "quiet", .value = DEPRECATED_OPT_QUIET },
|
||||||
|
{ .name = NULL, .value = -1 }
|
||||||
|
};
|
||||||
|
|
||||||
COMMAND_HANDLER(handle_svf_command)
|
COMMAND_HANDLER(handle_svf_command)
|
||||||
{
|
{
|
||||||
#define SVF_MIN_NUM_OF_OPTIONS 1
|
#define SVF_MIN_NUM_OF_OPTIONS 1
|
||||||
|
@ -355,10 +387,11 @@ COMMAND_HANDLER(handle_svf_command)
|
||||||
int64_t time_measure_ms;
|
int64_t time_measure_ms;
|
||||||
int time_measure_s, time_measure_m;
|
int time_measure_s, time_measure_m;
|
||||||
|
|
||||||
/* use NULL to indicate a "plain" svf file which accounts for
|
/*
|
||||||
|
* use NULL to indicate a "plain" svf file which accounts for
|
||||||
* any additional devices in the scan chain, otherwise the device
|
* any additional devices in the scan chain, otherwise the device
|
||||||
* that should be affected
|
* that should be affected
|
||||||
*/
|
*/
|
||||||
struct jtag_tap *tap = NULL;
|
struct jtag_tap *tap = NULL;
|
||||||
|
|
||||||
if ((CMD_ARGC < SVF_MIN_NUM_OF_OPTIONS) || (CMD_ARGC > SVF_MAX_NUM_OF_OPTIONS))
|
if ((CMD_ARGC < SVF_MIN_NUM_OF_OPTIONS) || (CMD_ARGC > SVF_MAX_NUM_OF_OPTIONS))
|
||||||
|
@ -373,48 +406,74 @@ COMMAND_HANDLER(handle_svf_command)
|
||||||
svf_addcycles = 0;
|
svf_addcycles = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < CMD_ARGC; i++) {
|
for (unsigned int i = 0; i < CMD_ARGC; i++) {
|
||||||
if (strcmp(CMD_ARGV[i], "-addcycles") == 0) {
|
const struct nvp *n = nvp_name2value(svf_cmd_opts, CMD_ARGV[i]);
|
||||||
|
switch (n->value) {
|
||||||
|
case OPT_ADDCYCLES:
|
||||||
svf_addcycles = atoi(CMD_ARGV[i + 1]);
|
svf_addcycles = atoi(CMD_ARGV[i + 1]);
|
||||||
if (svf_addcycles > SVF_MAX_ADDCYCLES) {
|
if (svf_addcycles > SVF_MAX_ADDCYCLES) {
|
||||||
command_print(CMD, "addcycles: %s out of range", CMD_ARGV[i + 1]);
|
command_print(CMD, "addcycles: %s out of range", CMD_ARGV[i + 1]);
|
||||||
if (svf_fd)
|
if (svf_fd)
|
||||||
fclose(svf_fd);
|
fclose(svf_fd);
|
||||||
svf_fd = NULL;
|
svf_fd = NULL;
|
||||||
return ERROR_FAIL;
|
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
} else if (strcmp(CMD_ARGV[i], "-tap") == 0) {
|
break;
|
||||||
|
|
||||||
|
case OPT_TAP:
|
||||||
tap = jtag_tap_by_string(CMD_ARGV[i+1]);
|
tap = jtag_tap_by_string(CMD_ARGV[i+1]);
|
||||||
if (!tap) {
|
if (!tap) {
|
||||||
command_print(CMD, "Tap: %s unknown", CMD_ARGV[i+1]);
|
command_print(CMD, "Tap: %s unknown", CMD_ARGV[i+1]);
|
||||||
if (svf_fd)
|
if (svf_fd)
|
||||||
fclose(svf_fd);
|
fclose(svf_fd);
|
||||||
svf_fd = NULL;
|
svf_fd = NULL;
|
||||||
return ERROR_FAIL;
|
return ERROR_COMMAND_ARGUMENT_INVALID;
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
} else if ((strcmp(CMD_ARGV[i],
|
break;
|
||||||
"quiet") == 0) || (strcmp(CMD_ARGV[i], "-quiet") == 0))
|
|
||||||
|
case DEPRECATED_OPT_QUIET:
|
||||||
|
LOG_INFO("DEPRECATED flag '%s'; use '-%s'", CMD_ARGV[i], CMD_ARGV[i]);
|
||||||
|
/* fallthrough */
|
||||||
|
case OPT_QUIET:
|
||||||
svf_quiet = 1;
|
svf_quiet = 1;
|
||||||
else if ((strcmp(CMD_ARGV[i], "nil") == 0) || (strcmp(CMD_ARGV[i], "-nil") == 0))
|
break;
|
||||||
|
|
||||||
|
case DEPRECATED_OPT_NIL:
|
||||||
|
LOG_INFO("DEPRECATED flag '%s'; use '-%s'", CMD_ARGV[i], CMD_ARGV[i]);
|
||||||
|
/* fallthrough */
|
||||||
|
case OPT_NIL:
|
||||||
svf_nil = 1;
|
svf_nil = 1;
|
||||||
else if ((strcmp(CMD_ARGV[i],
|
break;
|
||||||
"progress") == 0) || (strcmp(CMD_ARGV[i], "-progress") == 0))
|
|
||||||
|
case DEPRECATED_OPT_PROGRESS:
|
||||||
|
LOG_INFO("DEPRECATED flag '%s'; use '-%s'", CMD_ARGV[i], CMD_ARGV[i]);
|
||||||
|
/* fallthrough */
|
||||||
|
case OPT_PROGRESS:
|
||||||
svf_progress_enabled = 1;
|
svf_progress_enabled = 1;
|
||||||
else if ((strcmp(CMD_ARGV[i],
|
break;
|
||||||
"ignore_error") == 0) || (strcmp(CMD_ARGV[i], "-ignore_error") == 0))
|
|
||||||
|
case DEPRECATED_OPT_IGNORE_ERROR:
|
||||||
|
LOG_INFO("DEPRECATED flag '%s'; use '-%s'", CMD_ARGV[i], CMD_ARGV[i]);
|
||||||
|
/* fallthrough */
|
||||||
|
case OPT_IGNORE_ERROR:
|
||||||
svf_ignore_error = 1;
|
svf_ignore_error = 1;
|
||||||
else if (strcmp(CMD_ARGV[i], "-noreset") == 0)
|
break;
|
||||||
|
|
||||||
|
case OPT_NORESET:
|
||||||
svf_noreset = true;
|
svf_noreset = true;
|
||||||
else {
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
svf_fd = fopen(CMD_ARGV[i], "r");
|
svf_fd = fopen(CMD_ARGV[i], "r");
|
||||||
if (!svf_fd) {
|
if (!svf_fd) {
|
||||||
int err = errno;
|
int err = errno;
|
||||||
command_print(CMD, "open(\"%s\"): %s", CMD_ARGV[i], strerror(err));
|
command_print(CMD, "open(\"%s\"): %s", CMD_ARGV[i], strerror(err));
|
||||||
/* no need to free anything now */
|
/* no need to free anything now */
|
||||||
return ERROR_COMMAND_SYNTAX_ERROR;
|
return ERROR_COMMAND_SYNTAX_ERROR;
|
||||||
} else
|
}
|
||||||
LOG_USER("svf processing file: \"%s\"", CMD_ARGV[i]);
|
LOG_USER("svf processing file: \"%s\"", CMD_ARGV[i]);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1576,7 +1635,7 @@ static const struct command_registration svf_command_handlers[] = {
|
||||||
.handler = handle_svf_command,
|
.handler = handle_svf_command,
|
||||||
.mode = COMMAND_EXEC,
|
.mode = COMMAND_EXEC,
|
||||||
.help = "Runs a SVF file.",
|
.help = "Runs a SVF file.",
|
||||||
.usage = "[-tap device.tap] <file> [quiet] [nil] [progress] [ignore_error] [-noreset] [-addcycles numcycles]",
|
.usage = "[-tap device.tap] [-quiet] [-nil] [-progress] [-ignore_error] [-noreset] [-addcycles numcycles] file",
|
||||||
},
|
},
|
||||||
COMMAND_REGISTRATION_DONE
|
COMMAND_REGISTRATION_DONE
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue