This is an automated email from Gerrit. "Gabriel Volpicelli <gabe.volpice...@synaptics.com>" just uploaded a new patch set to Gerrit, which you can find at https://review.openocd.org/c/openocd/+/8688
-- gerrit commit efcd210ae1ac830f6eba2ec3ef1479452c75176a Author: Gabriel Volpicelli <gabe.volpice...@synaptics.com> Date: Thu Jan 2 15:51:26 2025 -0800 jtag: Add an option to disable autoprobing Some Arm926ej-s CPUs do not present a correct end of chain marker. After the jtag code sets up the user defined TAPs it will autoprobe for the end of chain marker and this can result in 20 invalid TAPs. The creation of the invalid TAPs prevents the valid user-defined TAPs from functioning. This patch adds a new option called jtag_autoprobe which can be set to true or false. This option defaults to true. If set to false via the new jtag_autoprobe enable/disable command, then the jtag code will get max_taps from the jtag_tap_count like usual, but it will not create room for auto taps or the end of chain marker. This means it will not perform the check for the end of chain marker and it will not generate extra TAPs that are not already defined. This allows misbehaving CPUs to work correctly as long as the user has correctly defined the valid TAPs that are present. Change-Id: I5867b667c8f19a401d1c801b23090fe52453f97c Signed-off-by: Gabriel Volpicelli <gabe.volpice...@synaptics.com> diff --git a/doc/openocd.texi b/doc/openocd.texi index 594f7a7f0c..0a926e41a9 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -4658,6 +4658,17 @@ with these TAPs, any targets associated with them, and any on-chip resources; then a @file{board.cfg} with off-chip resources, clocking, and so forth. +In some cases it may be necessary to disable the autoprobe ability, +such as when a board presents an incorrect end of chain marker. +The @command{jtag_autoprobe} command allows the autoprobe ability to be +disabled: + +@deffn {Command} {jtag_autoprobe} (@option{enable}|@option{disable}) +Displays or specifies whether to autoprobe TAPs beyond the defined TAPs, +including detection of the end of chain marker. +Default behaviour is @option{enable}. +@end deffn + @anchor{dapdeclaration} @section DAP declaration (ARMv6-M, ARMv7 and ARMv8 targets) @cindex DAP declaration diff --git a/src/jtag/core.c b/src/jtag/core.c index 769e07571f..04cca11619 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -91,6 +91,7 @@ tap_state_t cmd_queue_cur_state = TAP_RESET; static bool jtag_verify_capture_ir = true; static bool jtag_verify = true; +static bool jtag_autoprobe = true; /* how long the OpenOCD should wait before attempting JTAG communication after reset lines *deasserted (in ms) */ @@ -1224,12 +1225,14 @@ static int jtag_examine_chain(void) int retval; unsigned int max_taps = jtag_tap_count(); - /* Autoprobe up to this many. */ - if (max_taps < JTAG_MAX_AUTO_TAPS) - max_taps = JTAG_MAX_AUTO_TAPS; + if (jtag_autoprobe) { + /* Autoprobe up to this many. */ + if (max_taps < JTAG_MAX_AUTO_TAPS) + max_taps = JTAG_MAX_AUTO_TAPS; - /* Add room for end-of-chain marker. */ - max_taps++; + /* Add room for end-of-chain marker. */ + max_taps++; + } uint8_t *idcode_buffer = calloc(4, max_taps); if (!idcode_buffer) @@ -1713,6 +1716,16 @@ bool jtag_will_verify_capture_ir(void) return jtag_verify_capture_ir; } +void jtag_set_autoprobe(bool enable) +{ + jtag_autoprobe = enable; +} + +bool jtag_will_autoprobe(void) +{ + return jtag_autoprobe; +} + int jtag_power_dropout(int *dropout) { if (!is_adapter_initialized()) { diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h index 86526a09a1..c5394c8fe8 100644 --- a/src/jtag/jtag.h +++ b/src/jtag/jtag.h @@ -250,6 +250,11 @@ void jtag_set_verify(bool enable); /** @returns True if data scan verification will be performed. */ bool jtag_will_verify(void); +/** Enable or disable jtag autoprobe. */ +void jtag_set_autoprobe(bool enable); +/** @returns True if jtag autoprobe will be performed. */ +bool jtag_will_autoprobe(void); + /** Enable or disable verification of IR scan checking. */ void jtag_set_verify_capture_ir(bool enable); /** @returns True if IR scan verification will be performed. */ diff --git a/src/jtag/tcl.c b/src/jtag/tcl.c index 790aedfc46..8c27e2ae8d 100644 --- a/src/jtag/tcl.c +++ b/src/jtag/tcl.c @@ -866,6 +866,23 @@ COMMAND_HANDLER(handle_jtag_ntrst_assert_width_command) return ERROR_OK; } +COMMAND_HANDLER(handle_jtag_autoprobe) +{ + if (CMD_ARGC > 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + if (CMD_ARGC == 1) { + bool enable; + COMMAND_PARSE_ENABLE(CMD_ARGV[0], enable); + jtag_set_autoprobe(enable); + } + + const char *status = jtag_will_autoprobe() ? "enabled" : "disabled"; + command_print(CMD, "jtag autoprobe is %s", status); + + return ERROR_OK; +} + COMMAND_HANDLER(handle_jtag_rclk_command) { if (CMD_ARGC > 1) @@ -1134,6 +1151,15 @@ static const struct command_registration jtag_command_handlers[] = { .help = "delay after asserting trst in ms", .usage = "[milliseconds]", }, + { + .name = "jtag_autoprobe", + .handler = handle_jtag_autoprobe, + .mode = COMMAND_ANY, + .help = "Display or assign flag controlling whether to " + "autoprobe TAPs beyond the defined TAPs, " + "including detection of the end of chain marker.", + .usage = "['enable'|'disable']", + }, { .name = "scan_chain", .handler = handle_scan_chain_command, --