This is an automated email from Gerrit. Antonio Borneo ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/5027
-- gerrit commit 37b295b39868405357b4729f89cc13cb421842f1 Author: Antonio Borneo <[email protected]> Date: Wed Mar 27 10:22:35 2019 +0100 adapter: produce a TCL array as output of command "reset_config" To query the reset configuration in TCL scripts, let the command "reset_config" to produce output suitable to be assigned to a TCL associative array. The array is indexed by the mode_flags of the command "reset_config" and has value 0 or 1, depending if the mode_flag is disabled or enabled. Set the array with the command array set r [ocd_reset_config -array] and query/use it with echo $r(srst_push_pull) or set early_reset_init [expr $r(trst_only) || ...] Change-Id: I581566c9b2f0941ff3c2588ef32e087f465863d8 Signed-off-by: Antonio Borneo <[email protected]> diff --git a/doc/openocd.texi b/doc/openocd.texi index 027e6d2..1d4d9eb 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -3480,10 +3480,18 @@ nTRST (active-low JTAG TAP reset) before starting new JTAG operations. @end deffn @anchor {reset_config} -@deffn {Command} reset_config mode_flag ... +@deffn {Command} reset_config [-array] [mode_flag ...] This command displays or modifies the reset configuration of your combination of JTAG board and target in target configuration scripts. +By default the displayed output is the list of @var{mode_flag} enabled. +With the option @var{-array} the output is suitable to be loaded in a +TCL associative array, e.g. using the command +@code{array set r [ocd_reset_config -array]} +then the array can be indexed by the @var{mode_flag} of the command +and has value 0 or 1, depending if the @var{mode_flag} is disabled or +enabled, e.g. +@code{echo $r(srst_push_pull)} . Information earlier in this section describes the kind of problems the command is intended to address (@pxref{srstandtrstissues,,SRST and TRST Issues}). diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index 3fb52a7..5b86d90 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -188,6 +188,7 @@ COMMAND_HANDLER(handle_reset_config_command) { int new_cfg = 0; int mask = 0; + bool display_array = false; /* Original versions cared about the order of these tokens: * reset_config signals [combination [trst_type [srst_type]]] @@ -200,6 +201,12 @@ COMMAND_HANDLER(handle_reset_config_command) int tmp = 0; int m; + /* display configuration in array mode */ + if (strcmp(*CMD_ARGV, "-array") == 0) { + display_array = true; + continue; + } + /* gating */ m = RESET_SRST_NO_GATING; if (strcmp(*CMD_ARGV, "srst_gates_jtag") == 0) @@ -329,6 +336,40 @@ next: /* * Display the (now-)current reset mode */ + if (display_array) { + int tmp; + + tmp = new_cfg & (RESET_HAS_TRST | RESET_HAS_SRST); + command_print(CMD_CTX, "none %d", tmp == 0); + command_print(CMD_CTX, "srst_only %d", tmp == RESET_HAS_SRST); + command_print(CMD_CTX, "trst_only %d", tmp == RESET_HAS_TRST); + command_print(CMD_CTX, "trst_and_srst %d", tmp == (RESET_HAS_TRST | RESET_HAS_SRST)); + + tmp = new_cfg & (RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST); + command_print(CMD_CTX, "separate %d", tmp == 0); + command_print(CMD_CTX, "srst_pulls_trst %d", tmp == RESET_SRST_PULLS_TRST); + command_print(CMD_CTX, "trst_pulls_srst %d", tmp == RESET_TRST_PULLS_SRST); + command_print(CMD_CTX, "combined %d", tmp == (RESET_SRST_PULLS_TRST | RESET_TRST_PULLS_SRST)); + + tmp = new_cfg & (RESET_HAS_TRST | RESET_TRST_OPEN_DRAIN); + command_print(CMD_CTX, "trst_push_pull %d", tmp == RESET_HAS_TRST); + command_print(CMD_CTX, "trst_open_drain %d", tmp == (RESET_HAS_TRST | RESET_TRST_OPEN_DRAIN)); + + tmp = new_cfg & (RESET_HAS_SRST | RESET_SRST_NO_GATING); + command_print(CMD_CTX, "srst_gates_jtag %d", tmp == RESET_HAS_SRST); + command_print(CMD_CTX, "srst_nogate %d", tmp == (RESET_HAS_SRST | RESET_SRST_NO_GATING)); + + tmp = new_cfg & (RESET_HAS_SRST | RESET_SRST_PUSH_PULL); + command_print(CMD_CTX, "srst_open_drain %d", tmp == RESET_HAS_SRST); + command_print(CMD_CTX, "srst_push_pull %d", tmp == (RESET_HAS_SRST | RESET_SRST_PUSH_PULL)); + + tmp = new_cfg & (RESET_HAS_SRST | RESET_CNCT_UNDER_SRST); + command_print(CMD_CTX, "connect_deassert_srst %d", tmp == RESET_HAS_SRST); + command_print(CMD_CTX, "connect_assert_srst %d", tmp == (RESET_HAS_SRST | RESET_CNCT_UNDER_SRST)); + + return ERROR_OK; + } + char *modes[6]; /* minimal JTAG has neither SRST nor TRST (so that's the default) */ @@ -561,7 +602,8 @@ static const struct command_registration interface_command_handlers[] = { .handler = handle_reset_config_command, .mode = COMMAND_ANY, .help = "configure adapter reset behavior", - .usage = "[none|trst_only|srst_only|trst_and_srst] " + .usage = "[-array] " + "[none|trst_only|srst_only|trst_and_srst] " "[srst_pulls_trst|trst_pulls_srst|combined|separate] " "[srst_gates_jtag|srst_nogate] " "[trst_push_pull|trst_open_drain] " -- _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
