From c07b774e8f490984f749c2693f83483af7c0d098 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Wed, 14 Aug 2019 14:51:06 +0200 Subject: [PATCH] jtag: replace command "jtag_reset" with "adapter [de]assert" Replace the JTAG transport specific command with a more generic one. Deprecate "jtag_reset" and update the documentation. While there, fix an error in the documentation, where the command "jtag_reset" was used in place of command "reset_config". Change-Id: I41a988d37ce69f7b35a960cbaf5306aab0299b99 Signed-off-by: Antonio Borneo Reviewed-on: http://openocd.zylin.com/5286 Tested-by: jenkins Reviewed-by: Tomas Vanek --- doc/openocd.texi | 61 +++++++++++++++++++++++++------------------- src/jtag/startup.tcl | 16 ++++++++++++ src/jtag/tcl.c | 36 -------------------------- 3 files changed, 51 insertions(+), 62 deletions(-) diff --git a/doc/openocd.texi b/doc/openocd.texi index 349998b35..5da0f806b 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -3599,7 +3599,8 @@ the @command{reset_config} mechanism doesn't address; or asserting both might trigger a stronger reset, which needs special attention. -Experiment with lower level operations, such as @command{jtag_reset} +Experiment with lower level operations, such as +@command{adapter assert}, @command{adapter deassert} and the @command{jtag arp_*} operations shown here, to find a sequence of operations that works. @xref{JTAG Commands}. @@ -3626,7 +3627,7 @@ or potentially some other value. The default implementation just invokes @command{jtag arp_init-reset}. Replacements will normally build on low level JTAG -operations such as @command{jtag_reset}. +operations such as @command{adapter assert} and @command{adapter deassert}. Operations here must not address individual TAPs (or their associated targets) until the JTAG scan chain has first been verified to work. @@ -6984,7 +6985,7 @@ configured for flash bank 0. @example # assert srst, we do not want core running # while accessing str9xpec flash driver -jtag_reset 0 1 +adapter assert srst # turn off target polling poll off # disable str9 core @@ -7885,6 +7886,36 @@ the code that was executed may have left the hardware in an unknown state. @end deffn +@deffn Command {adapter assert} [signal [assert|deassert signal]] +@deffnx Command {adapter deassert} [signal [assert|deassert signal]] +Set values of reset signals. +Without parameters returns current status of the signals. +The @var{signal} parameter values may be +@option{srst}, indicating that srst signal is to be asserted or deasserted, +@option{trst}, indicating that trst signal is to be asserted or deasserted. + +The @command{reset_config} command should already have been used +to configure how the board and the adapter treat these two +signals, and to say if either signal is even present. +@xref{Reset Configuration}. +Trying to assert a signal that is not present triggers an error. +If a signal is present on the adapter and not specified in the command, +the signal will not be modified. + +@quotation Note +TRST is specially handled. +It actually signifies JTAG's @sc{reset} state. +So if the board doesn't support the optional TRST signal, +or it doesn't support it along with the specified SRST value, +JTAG reset is triggered with TMS and TCK signals +instead of the TRST signal. +And no matter how that JTAG reset is triggered, once +the scan chain enters @sc{reset} with TRST inactive, +TAP @code{post-reset} events are delivered to all TAPs +with handlers for that event. +@end quotation +@end deffn + @section I/O Utilities These commands are available when @@ -9767,28 +9798,6 @@ portable scripts currently must issue only BYPASS instructions. @end quotation @end deffn -@deffn Command {jtag_reset} trst srst -Set values of reset signals. -The @var{trst} and @var{srst} parameter values may be -@option{0}, indicating that reset is inactive (pulled or driven high), -or @option{1}, indicating it is active (pulled or driven low). -The @command{reset_config} command should already have been used -to configure how the board and JTAG adapter treat these two -signals, and to say if either signal is even present. -@xref{Reset Configuration}. - -Note that TRST is specially handled. -It actually signifies JTAG's @sc{reset} state. -So if the board doesn't support the optional TRST signal, -or it doesn't support it along with the specified SRST value, -JTAG reset is triggered with TMS and TCK signals -instead of the TRST signal. -And no matter how that JTAG reset is triggered, once -the scan chain enters @sc{reset} with TRST inactive, -TAP @code{post-reset} events are delivered to all TAPs -with handlers for that event. -@end deffn - @deffn Command {pathmove} start_state [next_state ...] Start by moving to @var{start_state}, which must be one of the @emph{stable} states. @@ -10756,7 +10765,7 @@ bytes. Painful... "Warning: arm7_9_common.c:679 arm7_9_assert_reset(): srst resets test logic, too". This warning doesn't indicate any serious problem, as long as you don't want to -debug your core right out of reset. Your .cfg file specified @option{jtag_reset +debug your core right out of reset. Your .cfg file specified @option{reset_config trst_and_srst srst_pulls_trst} to tell OpenOCD that either your board, your debugger or your target uC (e.g. LPC2000) can't assert the two reset signals independently. With this setup, it's not possible to halt the core right out of diff --git a/src/jtag/startup.tcl b/src/jtag/startup.tcl index d57cafb23..355152136 100644 --- a/src/jtag/startup.tcl +++ b/src/jtag/startup.tcl @@ -134,6 +134,22 @@ proc jtag_nsrst_assert_width args { eval adapter_nsrst_assert_width $args } +proc jtag_reset args { + echo "DEPRECATED! use 'adapter [de]assert' not 'jtag_reset'" + switch $args { + "0 0" + {eval adapter deassert trst deassert srst} + "0 1" + {eval adapter deassert trst assert srst} + "1 0" + {eval adapter assert trst deassert srst} + "1 1" + {eval adapter assert trst assert srst} + default + {return -code 1 -level 1 "jtag_reset: syntax error"} + } +} + # stlink migration helpers proc stlink_device_desc args { echo "DEPRECATED! use 'hla_device_desc' not 'stlink_device_desc'" diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index cbdf2adfc..ef0cd3f53 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -1059,34 +1059,6 @@ COMMAND_HANDLER(handle_jtag_rclk_command) return retval; } -COMMAND_HANDLER(handle_jtag_reset_command) -{ - if (CMD_ARGC != 2) - return ERROR_COMMAND_SYNTAX_ERROR; - - int trst = -1; - if (CMD_ARGV[0][0] == '1') - trst = 1; - else if (CMD_ARGV[0][0] == '0') - trst = 0; - else - return ERROR_COMMAND_SYNTAX_ERROR; - - int srst = -1; - if (CMD_ARGV[1][0] == '1') - srst = 1; - else if (CMD_ARGV[1][0] == '0') - srst = 0; - else - return ERROR_COMMAND_SYNTAX_ERROR; - - if (adapter_init(CMD_CTX) != ERROR_OK) - return ERROR_JTAG_INIT_FAILED; - - jtag_add_reset(trst, srst); - return jtag_execute_queue(); -} - COMMAND_HANDLER(handle_runtest_command) { if (CMD_ARGC != 1) @@ -1331,14 +1303,6 @@ static const struct command_registration jtag_command_handlers[] = { .help = "print current scan chain configuration", .usage = "" }, - { - .name = "jtag_reset", - .handler = handle_jtag_reset_command, - .mode = COMMAND_EXEC, - .help = "Set reset line values. Value '1' is active, " - "value '0' is inactive.", - .usage = "trst_active srst_active", - }, { .name = "runtest", .handler = handle_runtest_command, -- 2.30.2