You can subscribe to this list here.
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(75) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2009 |
Jan
(70) |
Feb
(20) |
Mar
(52) |
Apr
(149) |
May
(387) |
Jun
(466) |
Jul
(133) |
Aug
(87) |
Sep
(122) |
Oct
(140) |
Nov
(185) |
Dec
(105) |
2010 |
Jan
(85) |
Feb
(45) |
Mar
(75) |
Apr
(17) |
May
(41) |
Jun
(52) |
Jul
(33) |
Aug
(29) |
Sep
(36) |
Oct
(15) |
Nov
(26) |
Dec
(34) |
2011 |
Jan
(26) |
Feb
(25) |
Mar
(26) |
Apr
(29) |
May
(20) |
Jun
(27) |
Jul
(15) |
Aug
(32) |
Sep
(13) |
Oct
(64) |
Nov
(60) |
Dec
(10) |
2012 |
Jan
(64) |
Feb
(63) |
Mar
(39) |
Apr
(43) |
May
(54) |
Jun
(11) |
Jul
(30) |
Aug
(45) |
Sep
(11) |
Oct
(70) |
Nov
(24) |
Dec
(23) |
2013 |
Jan
(17) |
Feb
(8) |
Mar
(35) |
Apr
(40) |
May
(20) |
Jun
(24) |
Jul
(36) |
Aug
(25) |
Sep
(42) |
Oct
(40) |
Nov
(9) |
Dec
(21) |
2014 |
Jan
(29) |
Feb
(24) |
Mar
(60) |
Apr
(22) |
May
(22) |
Jun
(46) |
Jul
(11) |
Aug
(23) |
Sep
(26) |
Oct
(10) |
Nov
(14) |
Dec
(2) |
2015 |
Jan
(28) |
Feb
(47) |
Mar
(33) |
Apr
(58) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(8) |
Sep
(12) |
Oct
(25) |
Nov
(58) |
Dec
(21) |
2016 |
Jan
(12) |
Feb
(40) |
Mar
(2) |
Apr
(1) |
May
(67) |
Jun
(2) |
Jul
(5) |
Aug
(36) |
Sep
|
Oct
(24) |
Nov
(17) |
Dec
(50) |
2017 |
Jan
(14) |
Feb
(16) |
Mar
(2) |
Apr
(35) |
May
(14) |
Jun
(16) |
Jul
(3) |
Aug
(3) |
Sep
|
Oct
(19) |
Nov
|
Dec
(16) |
2018 |
Jan
(55) |
Feb
(11) |
Mar
(34) |
Apr
(14) |
May
(4) |
Jun
(20) |
Jul
(39) |
Aug
(16) |
Sep
(17) |
Oct
(16) |
Nov
(20) |
Dec
(30) |
2019 |
Jan
(29) |
Feb
(24) |
Mar
(37) |
Apr
(26) |
May
(19) |
Jun
(21) |
Jul
(2) |
Aug
(3) |
Sep
(9) |
Oct
(12) |
Nov
(12) |
Dec
(12) |
2020 |
Jan
(47) |
Feb
(36) |
Mar
(54) |
Apr
(44) |
May
(37) |
Jun
(19) |
Jul
(32) |
Aug
(13) |
Sep
(16) |
Oct
(24) |
Nov
(32) |
Dec
(11) |
2021 |
Jan
(14) |
Feb
(5) |
Mar
(40) |
Apr
(32) |
May
(42) |
Jun
(31) |
Jul
(29) |
Aug
(47) |
Sep
(38) |
Oct
(17) |
Nov
(74) |
Dec
(33) |
2022 |
Jan
(11) |
Feb
(15) |
Mar
(40) |
Apr
(21) |
May
(39) |
Jun
(44) |
Jul
(19) |
Aug
(46) |
Sep
(79) |
Oct
(35) |
Nov
(21) |
Dec
(15) |
2023 |
Jan
(56) |
Feb
(13) |
Mar
(43) |
Apr
(28) |
May
(60) |
Jun
(15) |
Jul
(29) |
Aug
(28) |
Sep
(32) |
Oct
(21) |
Nov
(42) |
Dec
(39) |
2024 |
Jan
(35) |
Feb
(17) |
Mar
(28) |
Apr
(7) |
May
(14) |
Jun
(35) |
Jul
(30) |
Aug
(35) |
Sep
(30) |
Oct
(28) |
Nov
(38) |
Dec
(18) |
2025 |
Jan
(21) |
Feb
(28) |
Mar
(36) |
Apr
(35) |
May
(34) |
Jun
(58) |
Jul
(9) |
Aug
(54) |
Sep
(36) |
Oct
|
Nov
|
Dec
|
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:29:08
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 1042a8d1795a284f29653cb19360cb0938ad897e (commit) from d123cfdc5811052ad4937653dc5bd6795ab96028 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1042a8d1795a284f29653cb19360cb0938ad897e Author: Antonio Borneo <bor...@gm...> Date: Sat Jun 28 10:34:00 2025 +0200 flash: nand: prepare for aligning switch and case statements To prepare for aligning switch and case statements, fix in advance some checkpatch error due to existing code: - remove useless parenthesis; - don't end line with an open parenthesis; - expand multiple assignments. While there, put the 'default' case as last in the list. Change-Id: I17bf5e88b145ef9b5b188424182f4e54b818eeae Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9011 Tested-by: jenkins diff --git a/src/flash/nand/core.c b/src/flash/nand/core.c index c5430aeb0..e5f330d2d 100644 --- a/src/flash/nand/core.c +++ b/src/flash/nand/core.c @@ -314,8 +314,7 @@ int nand_probe(struct nand_device *nand) LOG_DEBUG("controller initialization failed"); return ERROR_NAND_OPERATION_FAILED; case ERROR_NAND_OPERATION_NOT_SUPPORTED: - LOG_ERROR( - "BUG: controller reported that it doesn't support default parameters"); + LOG_ERROR("BUG: controller reported that it doesn't support default parameters"); return ERROR_NAND_OPERATION_FAILED; default: LOG_ERROR("BUG: unknown controller initialization failure"); @@ -474,11 +473,10 @@ int nand_probe(struct nand_device *nand) LOG_DEBUG("controller initialization failed"); return ERROR_NAND_OPERATION_FAILED; case ERROR_NAND_OPERATION_NOT_SUPPORTED: - LOG_ERROR( - "controller doesn't support requested parameters (buswidth: %i, address cycles: %i, page size: %i)", - nand->bus_width, - nand->address_cycles, - nand->page_size); + LOG_ERROR("controller doesn't support requested parameters (buswidth: %i, address cycles: %i, page size: %i)", + nand->bus_width, + nand->address_cycles, + nand->page_size); return ERROR_NAND_OPERATION_FAILED; default: LOG_ERROR("BUG: unknown controller initialization failure"); diff --git a/src/flash/nand/mx3.c b/src/flash/nand/mx3.c index 86e94685b..abcc44c3f 100644 --- a/src/flash/nand/mx3.c +++ b/src/flash/nand/mx3.c @@ -663,7 +663,7 @@ static int do_data_output(struct nand_device *nand) /* * ECC stuff */ - if ((mx3_nf_info->optype == MX3_NF_DATAOUT_PAGE) + if (mx3_nf_info->optype == MX3_NF_DATAOUT_PAGE && mx3_nf_info->flags.hw_ecc_enabled) { uint16_t ecc_status; target_read_u16 (target, MX3_NF_ECCSTATUS, &ecc_status); diff --git a/src/flash/nand/tcl.c b/src/flash/nand/tcl.c index 67a62770f..d40377cc0 100644 --- a/src/flash/nand/tcl.c +++ b/src/flash/nand/tcl.c @@ -50,21 +50,22 @@ COMMAND_HANDLER(handle_nand_info_command) int last = -1; switch (CMD_ARGC) { - default: - return ERROR_COMMAND_SYNTAX_ERROR; case 1: first = 0; last = INT32_MAX; break; case 2: COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], i); - first = last = i; + first = i; + last = i; i = 0; break; case 3: COMMAND_PARSE_NUMBER(int, CMD_ARGV[1], first); COMMAND_PARSE_NUMBER(int, CMD_ARGV[2], last); break; + default: + return ERROR_COMMAND_SYNTAX_ERROR; } struct nand_device *p; ----------------------------------------------------------------------- Summary of changes: src/flash/nand/core.c | 12 +++++------- src/flash/nand/mx3.c | 2 +- src/flash/nand/tcl.c | 7 ++++--- 3 files changed, 10 insertions(+), 11 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:28:51
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via d123cfdc5811052ad4937653dc5bd6795ab96028 (commit) from d10c839596a843871de9d0f5f9673e6e1e884026 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d123cfdc5811052ad4937653dc5bd6795ab96028 Author: Antonio Borneo <bor...@gm...> Date: Sat Jun 28 14:27:15 2025 +0200 helper: align switch and case statements The coding style requires the 'case' to be at the same indentation level of its 'switch' statement. Align the code accordingly. No changes are reported by git log -p -w --ignore-blank-lines --patience Change-Id: Iea3b60b3f01afbe31c495e8ea4ddc2b4c8efa936 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9010 Tested-by: jenkins diff --git a/src/helper/command.c b/src/helper/command.c index 742eea1b1..9c29ceff8 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -401,16 +401,16 @@ static bool command_can_run(struct command_context *cmd_ctx, struct command *c, /* Many commands may be run only before/after 'init' */ const char *when; switch (c->mode) { - case COMMAND_CONFIG: - when = "before"; - break; - case COMMAND_EXEC: - when = "after"; - break; - /* handle the impossible with humor; it guarantees a bug report! */ - default: - when = "if Cthulhu is summoned by"; - break; + case COMMAND_CONFIG: + when = "before"; + break; + case COMMAND_EXEC: + when = "after"; + break; + /* handle the impossible with humor; it guarantees a bug report! */ + default: + when = "if Cthulhu is summoned by"; + break; } LOG_ERROR("The '%s' command must be used %s 'init'.", full_name ? full_name : c->name, when); @@ -732,16 +732,16 @@ static COMMAND_HELPER(command_help_show, struct help_entry *c, const char *stage_msg = ""; switch (mode) { - case COMMAND_CONFIG: - stage_msg = " (configuration command)"; - break; - case COMMAND_ANY: - stage_msg = " (command valid any time)"; - break; - case COMMAND_UNKNOWN: - default: - stage_msg = " (?mode error?)"; - break; + case COMMAND_CONFIG: + stage_msg = " (configuration command)"; + break; + case COMMAND_ANY: + stage_msg = " (command valid any time)"; + break; + case COMMAND_UNKNOWN: + default: + stage_msg = " (?mode error?)"; + break; } msg = alloc_printf("%s%s", c->help ? c->help : "", stage_msg); } else @@ -902,19 +902,19 @@ COMMAND_HANDLER(handle_command_mode) const char *mode_str; switch (mode) { - case COMMAND_ANY: - mode_str = "any"; - break; - case COMMAND_CONFIG: - mode_str = "config"; - break; - case COMMAND_EXEC: - mode_str = "exec"; - break; - case COMMAND_UNKNOWN: - default: - mode_str = "unknown"; - break; + case COMMAND_ANY: + mode_str = "any"; + break; + case COMMAND_CONFIG: + mode_str = "config"; + break; + case COMMAND_EXEC: + mode_str = "exec"; + break; + case COMMAND_UNKNOWN: + default: + mode_str = "unknown"; + break; } command_print(CMD, "%s", mode_str); return ERROR_OK; @@ -1319,19 +1319,19 @@ COMMAND_HELPER(command_parse_str_to_buf, const char *str, void *buf, unsigned in COMMAND_HELPER(handle_command_parse_bool, bool *out, const char *label) { switch (CMD_ARGC) { - case 1: { - const char *in = CMD_ARGV[0]; - if (command_parse_bool_arg(in, out) != ERROR_OK) { - LOG_ERROR("%s: argument '%s' is not valid", CMD_NAME, in); - return ERROR_COMMAND_SYNTAX_ERROR; - } - } - /* fallthrough */ - case 0: - LOG_INFO("%s is %s", label, *out ? "enabled" : "disabled"); - break; - default: + case 1: { + const char *in = CMD_ARGV[0]; + if (command_parse_bool_arg(in, out) != ERROR_OK) { + LOG_ERROR("%s: argument '%s' is not valid", CMD_NAME, in); return ERROR_COMMAND_SYNTAX_ERROR; + } + } + /* fallthrough */ + case 0: + LOG_INFO("%s is %s", label, *out ? "enabled" : "disabled"); + break; + default: + return ERROR_COMMAND_SYNTAX_ERROR; } return ERROR_OK; } diff --git a/src/helper/fileio.c b/src/helper/fileio.c index a290a5d2f..1059c6706 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -49,24 +49,24 @@ static inline int fileio_open_local(struct fileio *fileio) ssize_t file_size; switch (fileio->access) { - case FILEIO_READ: - strcpy(file_access, "r"); - break; - case FILEIO_WRITE: - strcpy(file_access, "w"); - break; - case FILEIO_READWRITE: - strcpy(file_access, "w+"); - break; - case FILEIO_APPEND: - strcpy(file_access, "a"); - break; - case FILEIO_APPENDREAD: - strcpy(file_access, "a+"); - break; - default: - LOG_ERROR("BUG: access neither read, write nor readwrite"); - return ERROR_COMMAND_SYNTAX_ERROR; + case FILEIO_READ: + strcpy(file_access, "r"); + break; + case FILEIO_WRITE: + strcpy(file_access, "w"); + break; + case FILEIO_READWRITE: + strcpy(file_access, "w+"); + break; + case FILEIO_APPEND: + strcpy(file_access, "a"); + break; + case FILEIO_APPENDREAD: + strcpy(file_access, "a+"); + break; + default: + LOG_ERROR("BUG: access neither read, write nor readwrite"); + return ERROR_COMMAND_SYNTAX_ERROR; } /* win32 always opens in binary mode */ diff --git a/src/helper/options.c b/src/helper/options.c index 735b8af5f..28e222171 100644 --- a/src/helper/options.c +++ b/src/helper/options.c @@ -277,44 +277,44 @@ int parse_cmdline_args(struct command_context *cmd_ctx, int argc, char *argv[]) break; switch (c) { - case 0: - break; - case 'h': /* --help | -h */ - help_flag = 1; - break; - case 'v': /* --version | -v */ - version_flag = 1; - break; - case 'f': /* --file | -f */ - { - char *command = alloc_printf("script {%s}", optarg); - add_config_command(command); - free(command); - break; - } - case 's': /* --search | -s */ - add_script_search_dir(optarg); - break; - case 'd': /* --debug | -d */ - { - int retval = command_run_linef(cmd_ctx, "debug_level %s", optarg ? optarg : "3"); - if (retval != ERROR_OK) - return retval; - break; - } - case 'l': /* --log_output | -l */ - { - int retval = command_run_linef(cmd_ctx, "log_output %s", optarg); - if (retval != ERROR_OK) - return retval; - break; - } - case 'c': /* --command | -c */ - add_config_command(optarg); - break; - default: /* '?' */ - /* getopt will emit an error message, all we have to do is bail. */ - return ERROR_FAIL; + case 0: + break; + case 'h': /* --help | -h */ + help_flag = 1; + break; + case 'v': /* --version | -v */ + version_flag = 1; + break; + case 'f': /* --file | -f */ + { + char *command = alloc_printf("script {%s}", optarg); + add_config_command(command); + free(command); + break; + } + case 's': /* --search | -s */ + add_script_search_dir(optarg); + break; + case 'd': /* --debug | -d */ + { + int retval = command_run_linef(cmd_ctx, "debug_level %s", optarg ? optarg : "3"); + if (retval != ERROR_OK) + return retval; + break; + } + case 'l': /* --log_output | -l */ + { + int retval = command_run_linef(cmd_ctx, "log_output %s", optarg); + if (retval != ERROR_OK) + return retval; + break; + } + case 'c': /* --command | -c */ + add_config_command(optarg); + break; + default: /* '?' */ + /* getopt will emit an error message, all we have to do is bail. */ + return ERROR_FAIL; } } ----------------------------------------------------------------------- Summary of changes: src/helper/command.c | 90 ++++++++++++++++++++++++++-------------------------- src/helper/fileio.c | 36 ++++++++++----------- src/helper/options.c | 76 ++++++++++++++++++++++---------------------- 3 files changed, 101 insertions(+), 101 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:28:30
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via d10c839596a843871de9d0f5f9673e6e1e884026 (commit) from db79156fd528e0a9729ae8bc260452489fc2d4af (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit d10c839596a843871de9d0f5f9673e6e1e884026 Author: Antonio Borneo <bor...@gm...> Date: Sat Jun 28 01:24:34 2025 +0200 openocd: align switch and case statements The coding style requires the 'case' to be at the same indentation level of its 'switch' statement. Align the code accordingly. No changes are reported by git log -p -w --ignore-blank-lines --patience Change-Id: I2a4c33f12506e898e1efbbfd711cc5834d81dda1 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9009 Tested-by: jenkins diff --git a/src/openocd.c b/src/openocd.c index e63a9661a..f3e1bee48 100644 --- a/src/openocd.c +++ b/src/openocd.c @@ -75,20 +75,20 @@ static int log_target_callback_event_handler(struct target *target, void *priv) { switch (event) { - case TARGET_EVENT_GDB_START: - target->verbose_halt_msg = false; - break; - case TARGET_EVENT_GDB_END: - target->verbose_halt_msg = true; - break; - case TARGET_EVENT_HALTED: - if (target->verbose_halt_msg) { - /* do not display information when debugger caused the halt */ - target_arch_state(target); - } - break; - default: - break; + case TARGET_EVENT_GDB_START: + target->verbose_halt_msg = false; + break; + case TARGET_EVENT_GDB_END: + target->verbose_halt_msg = true; + break; + case TARGET_EVENT_HALTED: + if (target->verbose_halt_msg) { + /* do not display information when debugger caused the halt */ + target_arch_state(target); + } + break; + default: + break; } return ERROR_OK; ----------------------------------------------------------------------- Summary of changes: src/openocd.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:25:39
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via db79156fd528e0a9729ae8bc260452489fc2d4af (commit) from a68856102f64b57cc56b1b201faf3c88590f6d3f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit db79156fd528e0a9729ae8bc260452489fc2d4af Author: Antonio Borneo <bor...@gm...> Date: Fri Aug 22 14:49:16 2025 +0200 doc: drop incorrect lack of namespaces in Jim Tcl Since 2011 [1], Jim Tcl supports namespaces as an optional package that is compiled-in by default. Drop the incorrect sentence in OpenOCD documentation that reports namespaces as not supported by Jim Tcl. It was true in 2008 when the sentence was added with [2]. The meaning of the paragraph in the documentation does not change. Change-Id: I30b422e369d106e70f5e1e20b21f0b6ea0fe6b8d Signed-off-by: Antonio Borneo <bor...@gm...> Link: https://github.com/msteveb/jimtcl/commit/7f383c6726fd [1] Fixes: a28eaa85f ("jtag newtap change & huge manual update") [2] Reviewed-on: https://review.openocd.org/c/openocd/+/9093 Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 987339eb7..7f7c8892f 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -1440,7 +1440,6 @@ In addition to target-specific utility code, another way that board and target config files communicate is by following a convention on how to use certain variables. -The full Tcl/Tk language supports ``namespaces'', but Jim Tcl does not. Thus the rule we follow in OpenOCD is this: Variables that begin with a leading underscore are temporary in nature, and can be modified and used at will within a target configuration file. ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 1 - 1 file changed, 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:25:23
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via a68856102f64b57cc56b1b201faf3c88590f6d3f (commit) from 20ca4f4bee16d7571356dada3d56bd1025003a8c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit a68856102f64b57cc56b1b201faf3c88590f6d3f Author: Antonio Borneo <bor...@gm...> Date: Thu Aug 21 11:14:36 2025 +0200 openocd: remove further obsolete hooks for building on eCos The eCos build has been dropped in 2012 with commit 39650e2273bc ("ecosboard: delete bit-rotted eCos code"). Drop last eCos related code. Change-Id: I6b0de6386386c0102d540504236dda58d7a664b9 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9092 Tested-by: jenkins diff --git a/doc/manual/server.txt b/doc/manual/server.txt index 20e48c1f4..3c31e6fc6 100644 --- a/doc/manual/server.txt +++ b/doc/manual/server.txt @@ -190,7 +190,6 @@ Remember: OpenOCD runs on: -# FreeBSD -# Cygwin -# MinGW32 --# Ecos How can we get that to work? diff --git a/src/helper/system.h b/src/helper/system.h index bd96d626a..60308abcd 100644 --- a/src/helper/system.h +++ b/src/helper/system.h @@ -39,13 +39,6 @@ #include <poll.h> #endif -#ifdef __ECOS -/* missing from eCos */ -#ifndef EFAULT -#define EFAULT 14 /* Bad address */ -#endif -#endif - #ifdef HAVE_NETINET_IN_H #include <netinet/in.h> #endif diff --git a/src/helper/types.h b/src/helper/types.h index b3edd2118..8b02d213b 100644 --- a/src/helper/types.h +++ b/src/helper/types.h @@ -276,62 +276,6 @@ static inline int parity_u32(uint32_t x) #endif } -#if defined(__ECOS) - -/* eCos plain lacks these definition... A series of upstream patches - * could probably repair it, but it seems like too much work to be - * worth it. - */ - -#if !defined(_STDINT_H) -#define PRId32 "d" -#define PRIi32 "i" -#define PRIo32 "o" -#define PRIu32 "u" -#define PRIx32 "x" -#define PRIX32 "X" -#define SCNx32 "x" -#define PRId8 PRId32 -#define SCNx64 "llx" -#define PRId64 "lld" -#define PRIi64 "lli" -#define PRIo64 "llo" -#define PRIu64 "llu" -#define PRIx64 "llx" -#define PRIX64 "llX" - -typedef CYG_ADDRWORD intptr_t; -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; -#define INT8_MAX 0x7f -#define INT8_MIN (-INT8_MAX - 1) -# define UINT8_MAX (255) -#define INT16_MAX 0x7fff -#define INT16_MIN (-INT16_MAX - 1) -# define UINT16_MAX (65535) -#define INT32_MAX 0x7fffffffL -#define INT32_MIN (-INT32_MAX - 1L) -# define UINT32_MAX (4294967295U) -#define INT64_MAX 0x7fffffffffffffffLL -#define INT64_MIN (-INT64_MAX - 1LL) -#define UINT64_MAX (__CONCAT(INT64_MAX, U) * 2ULL + 1ULL) -#endif - - #ifndef LLONG_MAX - #define ULLONG_MAX UINT64_C(0xFFFFFFFFFFFFFFFF) - #define LLONG_MAX INT64_C(0x7FFFFFFFFFFFFFFF) - #define LLONG_MIN ULLONG_MAX - #endif - - -#define ULLONG_MAX 18446744073709551615 - -/* C99, eCos is C90 compliant (with bits of C99) */ -#define isblank(c) ((c) == ' ' || (c) == '\t') - - -#endif - typedef uint64_t target_addr_t; #define TARGET_ADDR_MAX UINT64_MAX #define TARGET_PRIdADDR PRId64 ----------------------------------------------------------------------- Summary of changes: doc/manual/server.txt | 1 - src/helper/system.h | 7 ------- src/helper/types.h | 56 --------------------------------------------------- 3 files changed, 64 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:22:23
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 20ca4f4bee16d7571356dada3d56bd1025003a8c (commit) from 9a5212560b3f02a3eaad771c7bc68486a640bdc3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 20ca4f4bee16d7571356dada3d56bd1025003a8c Author: Marc Schink <de...@za...> Date: Sun Jul 13 19:56:45 2025 +0000 flash/nor/stm32l4x: Change 'option_read' output Remove the verbose command output to enable processing with Tcl. Change-Id: I97c2ffbd7bbbb3064a98f8977373f6c48272e71e Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9000 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/doc/openocd.texi b/doc/openocd.texi index bfcdc857e..987339eb7 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -8486,10 +8486,8 @@ is the register offset of the Option byte to read. For example to read the FLASH_OPTR register: @example -stm32l4x option_read 0 0x20 -# Option Register (for STM32L4x): <0x40022020> = 0xffeff8aa -# Option Register (for STM32WBx): <0x58004020> = ... -# The correct flash base address will be used automatically +> stm32l4x option_read 0 0x20 +0xffeff8aa @end example The above example will read out the FLASH_OPTR register which contains the RDP diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c index 0c56ef6d9..4c25875ab 100644 --- a/src/flash/nor/stm32l4x.c +++ b/src/flash/nor/stm32l4x.c @@ -2441,19 +2441,18 @@ COMMAND_HANDLER(stm32l4_handle_option_read_command) if (retval != ERROR_OK) return retval; - uint32_t reg_offset, reg_addr; + uint32_t reg_offset; uint32_t value = 0; COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], reg_offset); - reg_addr = stm32l4_get_flash_reg(bank, reg_offset); retval = stm32l4_read_flash_reg(bank, reg_offset, &value); if (retval != ERROR_OK) return retval; - command_print(CMD, "Option Register: <0x%" PRIx32 "> = 0x%" PRIx32, reg_addr, value); + command_print(CMD, "0x%" PRIx32, value); - return retval; + return ERROR_OK; } COMMAND_HANDLER(stm32l4_handle_option_write_command) ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 6 ++---- src/flash/nor/stm32l4x.c | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:20:14
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 9a5212560b3f02a3eaad771c7bc68486a640bdc3 (commit) from 7bc74de62d8b3d4fa90b9fe6dc32f7084342121d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 9a5212560b3f02a3eaad771c7bc68486a640bdc3 Author: Daniel Anselmi <dan...@gm...> Date: Sat Jan 27 01:49:53 2024 +0100 tcl/board: Add digilent Zybo Zynq-7000 board Add configuration for digilents Zybo Z7 board. Documentation: https://digilent.com/reference/programmable-logic/zybo-z7/start Change-Id: I4b607e60f2bf531ee8f96739deb737376248fb8b Signed-off-by: Daniel Anselmi <dan...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8088 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/tcl/board/digilent_zybo.cfg b/tcl/board/digilent_zybo.cfg new file mode 100644 index 000000000..97d54302a --- /dev/null +++ b/tcl/board/digilent_zybo.cfg @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# digilent zybo +# https://digilent.com/reference/programmable-logic/zybo/start + + +adapter driver ftdi +ftdi channel 0 +#ftdi_device_desc "Digilent Adept USB Device" +ftdi vid_pid 0x0403 0x6010 +ftdi layout_init 0x3088 0x1f8b +ftdi layout_signal nSRST -data 0x3000 -oe 0x1000 +ftdi layout_signal LED -data 0x0010 +reset_config srst_pulls_trst +transport select jtag + +source [find target/zynq_7000.cfg] + +adapter speed 10000 + +# "ipdbg create-hub zynq.ipdbghub -pld zynq_pl.pld" -c init -c "zynq.ipdbghub ipdbg start -tool 0 -port 5555" ----------------------------------------------------------------------- Summary of changes: tcl/board/digilent_zybo.cfg | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tcl/board/digilent_zybo.cfg hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:19:54
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 7bc74de62d8b3d4fa90b9fe6dc32f7084342121d (commit) from 3bec165e2590ae72bb67ba4913b92e18b1275600 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7bc74de62d8b3d4fa90b9fe6dc32f7084342121d Author: Marc Schink <de...@za...> Date: Thu Feb 20 20:58:08 2025 +0000 adapter: Rework parallel port driver Make the driver more flexible and define adapter-specific configurations in Tcl instead of C using the adapter GPIO subsystem. The rework also includes coding style fixes and improvements of the documentation. All modifications are done such that backwards compatibility is ensured. Tested with Olimex ARM-JTAG cable [1] and APM32F103 target device on Linux and FreeBSD. The driver works on Linux using direct I/O and PPDEV. On FreeBSD, only PPDEV works. The build with direct I/O already failed before the patch. This problem will be fixed in a subsequent patch. The patch is not tested on Windows because there is no documentation for it. [1] https://www.olimex.com/Products/ARM/JTAG/ARM-JTAG/ Change-Id: Ib671d52a919eaf2959cf6365f2c8004257ae074c Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/8943 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 1e9f80dce..bfcdc857e 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -529,9 +529,8 @@ debuggers to ARM Cortex based targets @url{http://www.keil.com/support/man/docs/ @section IBM PC Parallel Printer Port Based -The two well-known ``JTAG Parallel Ports'' cables are the Xilinx DLC5 -and the Macraigor Wiggler. There are many clones and variations of -these on the market. +The two well-known JTAG parallel port cables are the Xilinx DLC5 and the Macraigor Wiggler. +There are many clones and variations of these on the market. Note that parallel ports are becoming much less common, so if you have the choice you should probably avoid these adapters in favor @@ -553,7 +552,7 @@ produced, PDF schematics are easily found and it is easy to make. @* Link: @url{http://www.ccac.rwth-aachen.de/~michaels/index.php/hardware/armjtag} @item @b{Wiggler_ntrst_inverted} -@* Yet another variation - See the source code, src/jtag/parport.c +@* Yet another variation, see configuration in @file{interface/parport/wiggler-ntrst-inverted.cfg} @item @b{old_amt_wiggler} @* Unknown - probably not on the market today @@ -3193,61 +3192,64 @@ version, and target voltage. @end deffn @deffn {Interface Driver} {parport} -Supports PC parallel port bit-banging cables: -Wigglers, PLD download cable, and more. -These interfaces have several commands, used to configure the driver -before initializing the JTAG scan chain: - -@deffn {Config Command} {parport cable} name -Set the layout of the parallel port cable used to connect to the target. -This is a write-once setting. -Currently valid cable @var{name} values include: -@itemize @minus -@item @b{altium} Altium Universal JTAG cable. -@item @b{arm-jtag} Same as original wiggler except SRST and -TRST connections reversed and TRST is also inverted. -@item @b{chameleon} The Amontec Chameleon's CPLD when operated -in configuration mode. This is only used to -program the Chameleon itself, not a connected target. -@item @b{dlc5} The Xilinx Parallel cable III. -@item @b{flashlink} The ST Parallel cable. -@item @b{lattice} Lattice ispDOWNLOAD Cable -@item @b{old_amt_wiggler} The Wiggler configuration that comes with -some versions of -Amontec's Chameleon Programmer. The new version available from -the website uses the original Wiggler layout ('@var{wiggler}') -@item @b{triton} The parallel port adapter found on the -``Karo Triton 1 Development Board''. -This is also the layout used by the HollyGates design -(see @uref{http://www.lartmaker.nl/projects/jtag/}). -@item @b{wiggler} The original Wiggler layout, also supported by -several clones, such as the Olimex ARM-JTAG -@item @b{wiggler2} Same as original wiggler except an led is fitted on D5. -@item @b{wiggler_ntrst_inverted} Same as original wiggler except TRST is inverted. -@end itemize +This driver supports PC parallel port bit-banging adapters. +Only JTAG is supported as transport protocol. +The driver supports Linux, FreeBSD, and Windows. +However, the Windows support is untested and unmaintained. + +The pin configuration is handled by the generic command @ref{adapter gpio, @command{adapter gpio}}. +In addition to the JTAG signals, the driver also supports the activity LED signal. + +The data and status pins of the parallel port are used as output and input pins, respectively. +The pin direction is given in the following table. + +@multitable @columnfractions .2 .1 .1 .1 .1 .1 .1 .1 .1 +@headitem Pin direction +@item Input +@tab ~11 +@tab 10 +@tab 12 +@tab 13 +@tab 15 +@tab - +@tab - +@tab - +@item Output +@tab 9 +@tab 8 +@tab 7 +@tab 6 +@tab 5 +@tab 4 +@tab 3 +@tab 2 +@end multitable + +@deffn {Config Command} {parport port} port_number +Configure the number of the parallel port. + +When using PPDEV to access the parallel port, use the number of the parallel port file @file{/dev/parport} (Linux) or @file{/dev/ppi} (FreeBSD). +The default port number is 0. + +When using direct I/O, the number is the I/O port number. +The default port number is 0x378 (LTP1). @end deffn -@deffn {Config Command} {parport port} [port_number] -Display either the address of the I/O port -(default: 0x378 for LPT1) or the number of the @file{/dev/parport} device. -If a parameter is provided, first switch to use that port. -This is a write-once setting. +@deffn {Config Command} {parport write_on_exit} (@option{on}|@option{off}) +@b{Note:} This command is deprecated and will be removed in the future. +Use the command @command{adapter gpio} to configure the pin states before the adapter terminates its operation. -When using PPDEV to access the parallel port, use the number of the parallel port: -@option{parport port 0} (the default). If @option{parport port 0x378} is specified -you may encounter a problem. +Configure whether the driver sets the value specified by @command{adapter gpio} to the output pins on shutdown. @end deffn -@deffn {Config Command} {parport toggling_time} [nanoseconds] -Displays how many nanoseconds the hardware needs to toggle TCK; -the parport driver uses this value to obey the -@command{adapter speed} configuration. -When the optional @var{nanoseconds} parameter is given, -that setting is changed before displaying the current value. +@deffn {Config Command} {parport toggling_time} time +Configure how many nanoseconds the hardware needs to toggle TCK. +The driver uses this value to obey the @command{adapter speed} configuration. The default setting should work reasonably well on commodity PC hardware. However, you may want to calibrate for your specific hardware. + @quotation Tip To measure the toggling time with a logic analyzer or a digital storage oscilloscope, follow the procedure below: @@ -3255,15 +3257,18 @@ oscilloscope, follow the procedure below: > parport toggling_time 1000 > adapter speed 500 @end example + This sets the maximum JTAG clock speed of the hardware, but the actual speed probably deviates from the requested 500 kHz. Now, measure the time between the two closest spaced TCK transitions. You can use @command{runtest 1000} or something similar to generate a large set of samples. Update the setting to match your measurement: + @example > parport toggling_time <measured nanoseconds> @end example + Now the clock speed will be a better match for @command{adapter speed} command given in OpenOCD scripts and event handlers. @@ -3275,20 +3280,6 @@ match with the rate you specified in the @command{adapter speed} command; be conservative. @end quotation @end deffn - -@deffn {Config Command} {parport write_on_exit} (@option{on}|@option{off}) -This will configure the parallel driver to write a known -cable-specific value to the parallel interface on exiting OpenOCD. -@end deffn - -For example, the interface configuration file for a -classic ``Wiggler'' cable on LPT2 might look something like this: - -@example -adapter driver parport -parport port 0x278 -parport cable wiggler -@end example @end deffn @deffn {Interface Driver} {presto} diff --git a/src/jtag/drivers/parport.c b/src/jtag/drivers/parport.c index 433c20c89..09e312ec2 100644 --- a/src/jtag/drivers/parport.c +++ b/src/jtag/drivers/parport.c @@ -20,7 +20,7 @@ #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #include <machine/sysarch.h> #include <machine/cpufunc.h> -#define ioperm(startport, length, enable)\ +#define ioperm(startport, length, enable) \ i386_set_ioperm((startport), (length), (enable)) #endif /* __FreeBSD__ */ @@ -45,67 +45,14 @@ #include <windows.h> #endif -// Parallel port cable description. -struct cable { - const char *name; - // Status port bit containing current TDO value. - uint8_t tdo_mask; - // Data port bit for TRST. - uint8_t trst_mask; - // Data port bit for TMD. - uint8_t tms_mask; - // Data port bit for TCK. - uint8_t tck_mask; - // Data port bit for TDI. - uint8_t tdi_mask; - // Data port bit for SRST. - uint8_t srst_mask; - // Data port bits that should be inverted. - uint8_t output_invert; - // Status port that should be inverted. - uint8_t input_invert; - // Initialize data port with this value. - uint8_t port_init; - // De-initialize data port with this value. - uint8_t port_exit; - // Data port bit for LED. - uint8_t led_mask; -}; - -static const struct cable cables[] = { - /* name tdo trst tms tck tdi srst o_inv i_inv init exit led */ - { "wiggler", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x01, 0x80, 0x80, 0x80, 0x00 }, - { "wiggler2", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x01, 0x80, 0x80, 0x00, 0x20 }, - { "wiggler_ntrst_inverted", 0x80, 0x10, 0x02, 0x04, 0x08, 0x01, 0x11, 0x80, 0x80, 0x80, 0x00 }, - { "old_amt_wiggler", 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x11, 0x80, 0x80, 0x80, 0x00 }, - { "arm-jtag", 0x80, 0x01, 0x02, 0x04, 0x08, 0x10, 0x01, 0x80, 0x80, 0x80, 0x00 }, - { "chameleon", 0x80, 0x00, 0x04, 0x01, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 }, - { "dlc5", 0x10, 0x00, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x10, 0x10, 0x00 }, - { "triton", 0x80, 0x08, 0x04, 0x01, 0x02, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00 }, - { "lattice", 0x40, 0x10, 0x04, 0x02, 0x01, 0x08, 0x00, 0x00, 0x18, 0x18, 0x00 }, - { "flashlink", 0x20, 0x10, 0x02, 0x01, 0x04, 0x20, 0x30, 0x20, 0x00, 0x00, 0x00 }, -/* Altium Universal JTAG cable. Set the cable to Xilinx Mode and wire to target as follows: - HARD TCK - Target TCK - HARD TMS - Target TMS - HARD TDI - Target TDI - HARD TDO - Target TDO - SOFT TCK - Target TRST - SOFT TDI - Target SRST -*/ - { "altium", 0x10, 0x20, 0x04, 0x02, 0x01, 0x80, 0x00, 0x00, 0x10, 0x00, 0x08 }, - { "aspo", 0x10, 0x01, 0x04, 0x08, 0x02, 0x10, 0x17, 0x00, 0x17, 0x17, 0x00 }, - { NULL, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } -}; +static const struct adapter_gpio_config *adapter_gpio_config; -// Configuration variables. -static char *parport_cable; static uint16_t parport_port; -static bool parport_exit; +static bool parport_write_exit_state; static uint32_t parport_toggling_time_ns = 1000; static int wait_states; // Interface variables. -static const struct cable *cable; static uint8_t dataport_value; #if PARPORT_USE_PPDEV == 1 @@ -115,6 +62,20 @@ static unsigned long dataport; static unsigned long statusport; #endif +// Bitmask map for the input pins. +static struct { + uint8_t mask; +} input_pin_bitmask_map[] = { + [10] = {0x40}, + [11] = {0x80}, + [12] = {0x20}, + [13] = {0x10}, + [15] = {0x08}, +}; + +// Generate an output pin bitmask for an adapter signal. +#define OUTPUT_BITMASK(gpio_index) BIT((adapter_gpio_config[(gpio_index)].gpio_num - 2)) + static enum bb_value parport_read(void) { int data = 0; @@ -125,16 +86,15 @@ static enum bb_value parport_read(void) data = inb(statusport); #endif - if ((data ^ cable->input_invert) & cable->tdo_mask) - return BB_HIGH; - else - return BB_LOW; + const struct adapter_gpio_config *gpio_config = &adapter_gpio_config[ADAPTER_GPIO_IDX_TDO]; + const bool tdo_state = data & input_pin_bitmask_map[gpio_config->gpio_num].mask; + + return (tdo_state ^ gpio_config->active_low) ? BB_HIGH : BB_LOW; } -static inline void parport_write_data(void) +static void parport_write_data(void) { - uint8_t output; - output = dataport_value ^ cable->output_invert; + const uint8_t output = dataport_value; #if PARPORT_USE_PPDEV == 1 ioctl(device_handle, PPWDATA, &output); @@ -147,26 +107,27 @@ static inline void parport_write_data(void) #endif } -static int parport_write(int tck, int tms, int tdi) +static bool is_gpio_configured(enum adapter_gpio_config_index gpio_index) { - int i = wait_states + 1; - - if (tck) - dataport_value |= cable->tck_mask; - else - dataport_value &= ~cable->tck_mask; + return adapter_gpio_config[gpio_index].gpio_num != ADAPTER_GPIO_NOT_SET; +} - if (tms) - dataport_value |= cable->tms_mask; +static void set_pin_state(enum adapter_gpio_config_index gpio_index, + bool state) +{ + if (state ^ adapter_gpio_config[gpio_index].active_low) + dataport_value |= OUTPUT_BITMASK(gpio_index); else - dataport_value &= ~cable->tms_mask; + dataport_value &= ~OUTPUT_BITMASK(gpio_index); +} - if (tdi) - dataport_value |= cable->tdi_mask; - else - dataport_value &= ~cable->tdi_mask; +static int parport_write(int tck, int tms, int tdi) +{ + set_pin_state(ADAPTER_GPIO_IDX_TCK, tck == 1); + set_pin_state(ADAPTER_GPIO_IDX_TMS, tms == 1); + set_pin_state(ADAPTER_GPIO_IDX_TDI, tdi == 1); - while (i-- > 0) + for (int i = 0; i < wait_states + 1; i++) parport_write_data(); return ERROR_OK; @@ -177,15 +138,11 @@ static int parport_reset(int trst, int srst) { LOG_DEBUG("trst: %i, srst: %i", trst, srst); - if (trst == 0) - dataport_value |= cable->trst_mask; - else if (trst == 1) - dataport_value &= ~cable->trst_mask; + if (is_gpio_configured(ADAPTER_GPIO_IDX_TRST)) + set_pin_state(ADAPTER_GPIO_IDX_TRST, trst == 0); - if (srst == 0) - dataport_value |= cable->srst_mask; - else if (srst == 1) - dataport_value &= ~cable->srst_mask; + if (is_gpio_configured(ADAPTER_GPIO_IDX_SRST)) + set_pin_state(ADAPTER_GPIO_IDX_SRST, srst == 0); parport_write_data(); @@ -194,11 +151,10 @@ static int parport_reset(int trst, int srst) static int parport_led(bool on) { - if (on) - dataport_value |= cable->led_mask; - else - dataport_value &= ~cable->led_mask; + if (!is_gpio_configured(ADAPTER_GPIO_IDX_LED)) + return ERROR_OK; + set_pin_state(ADAPTER_GPIO_IDX_LED, on); parport_write_data(); return ERROR_OK; @@ -213,11 +169,12 @@ static int parport_speed(int speed) static int parport_khz(int khz, int *jtag_speed) { if (!khz) { - LOG_DEBUG("RCLK not supported"); + LOG_ERROR("RCLK is not supported by the adapter"); return ERROR_FAIL; } *jtag_speed = 499999 / (khz * parport_toggling_time_ns); + return ERROR_OK; } @@ -226,32 +183,35 @@ static int parport_speed_div(int speed, int *khz) uint32_t denominator = (speed + 1) * parport_toggling_time_ns; *khz = (499999 + denominator) / denominator; + return ERROR_OK; } #if PARPORT_USE_GIVEIO == 1 -static int parport_get_giveio_access(void) +static bool parport_get_giveio_access(void) { - HANDLE h; OSVERSIONINFO version; version.dwOSVersionInfoSize = sizeof(version); if (!GetVersionEx(&version)) { errno = EINVAL; - return -1; + return false; } + if (version.dwPlatformId != VER_PLATFORM_WIN32_NT) - return 0; + return true; + + HANDLE h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); - h = CreateFile("\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (h == INVALID_HANDLE_VALUE) { errno = ENODEV; - return -1; + return false; } CloseHandle(h); - return 0; + return true; } #endif @@ -261,80 +221,121 @@ static const struct bitbang_interface parport_bitbang = { .blink = &parport_led, }; +static const struct { + enum adapter_gpio_config_index gpio_index; + bool required; +} all_signals[] = { + { ADAPTER_GPIO_IDX_TDO, true }, + { ADAPTER_GPIO_IDX_TDI, true }, + { ADAPTER_GPIO_IDX_TMS, true }, + { ADAPTER_GPIO_IDX_TCK, true }, + { ADAPTER_GPIO_IDX_TRST, false }, + { ADAPTER_GPIO_IDX_SRST, false }, + { ADAPTER_GPIO_IDX_LED, false }, + { ADAPTER_GPIO_IDX_USER0, false }, +}; + static int parport_init(void) { - const struct cable *cur_cable; -#if PARPORT_USE_PPDEV == 1 - char buffer[256]; -#endif + adapter_gpio_config = adapter_gpio_get_config(); - cur_cable = cables; + // Check if all signals are configured properly. + for (size_t i = 0; i < ARRAY_SIZE(all_signals); i++) { + const enum adapter_gpio_config_index gpio_index = all_signals[i].gpio_index; + const struct adapter_gpio_config gpio = adapter_gpio_config[gpio_index]; - if (!parport_cable) { - parport_cable = strdup("wiggler"); - LOG_WARNING("No parport cable specified, using default 'wiggler'"); - } + if (gpio.gpio_num == ADAPTER_GPIO_NOT_SET) { + if (all_signals[i].required) { + LOG_ERROR("The signal '%s' is required and must be configured", + adapter_gpio_get_name(gpio_index)); + return ERROR_FAIL; + } - while (cur_cable->name) { - if (!strcmp(cur_cable->name, parport_cable)) { - cable = cur_cable; - break; + continue; } - cur_cable++; - } - if (!cable) { - LOG_ERROR("No matching cable found for %s", parport_cable); - return ERROR_JTAG_INIT_FAILED; + if (gpio_index == ADAPTER_GPIO_IDX_TDO) { + if (gpio.gpio_num < 10 || gpio.gpio_num > 15 || gpio.gpio_num == 14) { + LOG_ERROR("The '%s' signal pin must be 10, 11, 12, 13, or 15", + adapter_gpio_get_name(gpio_index)); + return ERROR_FAIL; + } + } else { + if (gpio.gpio_num < 2 || gpio.gpio_num > 9) { + LOG_ERROR("The '%s' signal pin must be 2, 3, 4, 5, 6, 7, 8, or 9", + adapter_gpio_get_name(gpio_index)); + return ERROR_FAIL; + } + } } - dataport_value = cable->port_init; + // Initialize signal pin states. + for (size_t i = 0; i < ARRAY_SIZE(all_signals); i++) { + const enum adapter_gpio_config_index gpio_index = all_signals[i].gpio_index; + const struct adapter_gpio_config gpio = adapter_gpio_config[gpio_index]; + + // The TDO (input) and LED (controlled by the adapter) pins cannot be + // initialized. + if (gpio_index == ADAPTER_GPIO_IDX_TDO || gpio_index == ADAPTER_GPIO_IDX_LED) + continue; + + // Do not initialize unconfigured GPIO pins. + if (gpio.gpio_num == ADAPTER_GPIO_NOT_SET) + continue; + + if (gpio.init_state == ADAPTER_GPIO_INIT_STATE_ACTIVE) + set_pin_state(gpio_index, true); + else if (gpio.init_state == ADAPTER_GPIO_INIT_STATE_INACTIVE) + set_pin_state(gpio_index, false); + } #if PARPORT_USE_PPDEV == 1 if (device_handle > 0) { - LOG_ERROR("device is already opened"); + LOG_ERROR("Parallel port is already open"); return ERROR_JTAG_INIT_FAILED; } + char device_path[256]; + #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - LOG_DEBUG("opening /dev/ppi%d...", parport_port); + snprintf(device_path, sizeof(device_path), "/dev/ppi%d", parport_port); +#else + snprintf(device_path, sizeof(device_path), "/dev/parport%d", parport_port); +#endif /* __FreeBSD__, __FreeBSD_kernel__ */ - snprintf(buffer, 256, "/dev/ppi%d", parport_port); - device_handle = open(buffer, O_WRONLY); -#else /* not __FreeBSD__, __FreeBSD_kernel__ */ - LOG_DEBUG("opening /dev/parport%d...", parport_port); + LOG_DEBUG("Using parallel port %s", device_path); - snprintf(buffer, 256, "/dev/parport%d", parport_port); - device_handle = open(buffer, O_WRONLY); -#endif /* __FreeBSD__, __FreeBSD_kernel__ */ + device_handle = open(device_path, O_WRONLY); if (device_handle < 0) { int err = errno; - LOG_ERROR("cannot open device. check it exists and that user read and write rights are set. errno=%d", err); + LOG_ERROR("Failed to open parallel port %s (errno = %d)", device_path, + err); + LOG_ERROR("Check whether the device exists and if you have the required access rights"); return ERROR_JTAG_INIT_FAILED; } - LOG_DEBUG("...open"); - #if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) - int i = ioctl(device_handle, PPCLAIM); + int retval = ioctl(device_handle, PPCLAIM); - if (i < 0) { - LOG_ERROR("cannot claim device"); + if (retval < 0) { + LOG_ERROR("Failed to claim parallel port %s", device_path); return ERROR_JTAG_INIT_FAILED; } - i = PARPORT_MODE_COMPAT; - i = ioctl(device_handle, PPSETMODE, &i); - if (i < 0) { - LOG_ERROR(" cannot set compatible mode to device"); + int value = PARPORT_MODE_COMPAT; + retval = ioctl(device_handle, PPSETMODE, &value); + + if (retval < 0) { + LOG_ERROR("Cannot set compatible mode to device"); return ERROR_JTAG_INIT_FAILED; } - i = IEEE1284_MODE_COMPAT; - i = ioctl(device_handle, PPNEGOT, &i); - if (i < 0) { - LOG_ERROR("cannot set compatible 1284 mode to device"); + value = IEEE1284_MODE_COMPAT; + retval = ioctl(device_handle, PPNEGOT, &value); + + if (retval < 0) { + LOG_ERROR("Cannot set compatible 1284 mode to device"); return ERROR_JTAG_INIT_FAILED; } #endif /* not __FreeBSD__, __FreeBSD_kernel__ */ @@ -342,24 +343,24 @@ static int parport_init(void) #else /* not PARPORT_USE_PPDEV */ if (!parport_port) { parport_port = 0x378; - LOG_WARNING("No parport port specified, using default '0x378' (LPT1)"); + LOG_WARNING("No parallel port specified, using default 0x378 (LPT1)"); } + LOG_DEBUG("Using parallel port 0x%x", parport_port); + dataport = parport_port; statusport = parport_port + 1; - LOG_DEBUG("requesting privileges for parallel port 0x%lx...", dataport); #if PARPORT_USE_GIVEIO == 1 - if (parport_get_giveio_access() != 0) { + if (!parport_get_giveio_access()) { #else /* PARPORT_USE_GIVEIO */ if (ioperm(dataport, 3, 1) != 0) { #endif /* PARPORT_USE_GIVEIO */ - LOG_ERROR("missing privileges for direct i/o"); + LOG_ERROR("Missing privileges for direct I/O"); return ERROR_JTAG_INIT_FAILED; } - LOG_DEBUG("...privileges granted"); - // Make sure parallel port is in right mode (clear tristate and interrupt. + // Make sure parallel port is in right mode (clear tristate and interrupt). #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) outb(parport_port + 2, 0x0); #else @@ -370,8 +371,10 @@ static int parport_init(void) if (parport_reset(0, 0) != ERROR_OK) return ERROR_FAIL; + if (parport_write(0, 0, 0) != ERROR_OK) return ERROR_FAIL; + if (parport_led(true) != ERROR_OK) return ERROR_FAIL; @@ -382,56 +385,59 @@ static int parport_init(void) static int parport_quit(void) { - if (parport_led(false) != ERROR_OK) - return ERROR_FAIL; + // Deinitialize signal pin states. + for (size_t i = 0; i < ARRAY_SIZE(all_signals); i++) { + const enum adapter_gpio_config_index gpio_index = all_signals[i].gpio_index; + const struct adapter_gpio_config gpio = adapter_gpio_config[gpio_index]; + + // The TDO (input) and LED (controlled by the adapter) pins cannot be + // deinitialized. + if (gpio_index == ADAPTER_GPIO_IDX_TDO || gpio_index == ADAPTER_GPIO_IDX_LED) + continue; + + // Do not deinitialize unconfigured GPIO pins. + if (gpio.gpio_num == ADAPTER_GPIO_NOT_SET) + continue; + + if (gpio.exit_state == ADAPTER_GPIO_EXIT_STATE_ACTIVE) + set_pin_state(gpio_index, true); + else if (gpio.exit_state == ADAPTER_GPIO_EXIT_STATE_INACTIVE) + set_pin_state(gpio_index, false); + } - if (parport_exit) { - dataport_value = cable->port_exit; + if (parport_write_exit_state) parport_write_data(); - } - free(parport_cable); - parport_cable = NULL; + if (parport_led(false) != ERROR_OK) + return ERROR_FAIL; return ERROR_OK; } COMMAND_HANDLER(parport_handle_port_command) { - if (CMD_ARGC == 1) { - // Only if the port wasn't overwritten by cmdline. - if (!parport_port) { - COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], parport_port); - } else { - LOG_ERROR("The parport port was already configured!"); - return ERROR_FAIL; - } + if (CMD_ARGC != 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + // Only if the port wasn't overwritten by command-line. + if (parport_port > 0) { + command_print(CMD, "The parallel port is already configured"); + return ERROR_FAIL; } - command_print(CMD, "parport port = 0x%" PRIx16, parport_port); + COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], parport_port); return ERROR_OK; } +// This command is only for backward compatibility and will be removed in the +// future. COMMAND_HANDLER(parport_handle_cable_command) { - if (!CMD_ARGC) - return ERROR_OK; - - // Only if the cable name wasn't overwritten by cmdline. - if (!parport_cable) { - // TODO: REVISIT first verify that it's listed in cables[]. - parport_cable = malloc(strlen(CMD_ARGV[0]) + sizeof(char)); - if (!parport_cable) { - LOG_ERROR("Out of memory"); - return ERROR_FAIL; - } - strcpy(parport_cable, CMD_ARGV[0]); - } - - // TODO: REVISIT it's probably worth returning the current value. + if (CMD_ARGC != 1) + return ERROR_COMMAND_SYNTAX_ERROR; - return ERROR_OK; + return command_run_linef(CMD_CTX, "parport_select_cable %s", CMD_ARGV[0]); } COMMAND_HANDLER(parport_handle_write_on_exit_command) @@ -439,40 +445,39 @@ COMMAND_HANDLER(parport_handle_write_on_exit_command) if (CMD_ARGC != 1) return ERROR_COMMAND_SYNTAX_ERROR; - COMMAND_PARSE_ON_OFF(CMD_ARGV[0], parport_exit); + LOG_WARNING("DEPRECATED: 'parport write_on_exit' will be removed in the future, use the 'adapter gpio' command to configure the exit state for pins"); + + COMMAND_PARSE_ON_OFF(CMD_ARGV[0], parport_write_exit_state); return ERROR_OK; } COMMAND_HANDLER(parport_handle_toggling_time_command) { - if (CMD_ARGC == 1) { - uint32_t ns; - int retval = parse_u32(CMD_ARGV[0], &ns); + if (CMD_ARGC != 1) + return ERROR_COMMAND_SYNTAX_ERROR; - if (retval != ERROR_OK) - return retval; + uint32_t toggling_time; - if (!ns) { - LOG_ERROR("0 ns is not a valid parport toggling time"); - return ERROR_FAIL; - } + COMMAND_PARSE_NUMBER(u32, CMD_ARGV[0], toggling_time); - parport_toggling_time_ns = ns; - retval = adapter_get_speed(&wait_states); - if (retval != ERROR_OK) { - /* - * If adapter_get_speed fails then the clock_mode has - * not been configured, this happens if toggling_time is - * called before the adapter speed is set. - */ - LOG_INFO("no parport speed set - defaulting to zero wait states"); - wait_states = 0; - } + if (!toggling_time) { + command_print(CMD, "toggling time must not be 0 ns"); + return ERROR_COMMAND_ARGUMENT_INVALID; } - command_print(CMD, "parport toggling time = %" PRIu32 " ns", - parport_toggling_time_ns); + parport_toggling_time_ns = toggling_time; + int retval = adapter_get_speed(&wait_states); + + if (retval != ERROR_OK) { + /* + * If adapter_get_speed fails then the clock_mode has not been + * configured, this happens if toggling_time is called before the + * adapter speed is set. + */ + LOG_INFO("No parallel port speed set, using zero wait states"); + wait_states = 0; + } return ERROR_OK; } @@ -482,35 +487,31 @@ static const struct command_registration parport_subcommand_handlers[] = { .name = "port", .handler = parport_handle_port_command, .mode = COMMAND_CONFIG, - .help = "Display the address of the I/O port (e.g. 0x378) " - "or the number of the '/dev/parport' device used. " - "If a parameter is provided, first change that port.", - .usage = "[port_number]", + .help = "Configure the address of the I/O port (e.g. 0x378) " + "or the number of the '/dev/parport' (Linux) or '/dev/ppi' (FreeBSD) device used", + .usage = "port_number", }, { .name = "cable", .handler = parport_handle_cable_command, .mode = COMMAND_CONFIG, .help = "Set the layout of the parallel port cable " - "used to connect to the target.", - // TODO: REVISIT there's no way to list layouts we know. - .usage = "[layout]", + "used to connect to the target", + .usage = "cable", }, { .name = "write_on_exit", .handler = parport_handle_write_on_exit_command, .mode = COMMAND_CONFIG, - .help = "Configure the parallel driver to write " - "a known value to the parallel interface on exit.", + .help = "Configure the driver to write a value to the parallel port on shutdown", .usage = "('on'|'off')", }, { .name = "toggling_time", .handler = parport_handle_toggling_time_command, .mode = COMMAND_CONFIG, - .help = "Displays or assigns how many nanoseconds it " - "takes for the hardware to toggle TCK.", - .usage = "[nanoseconds]", + .help = "Configure how many nanoseconds it takes for the hardware to toggle TCK", + .usage = "time", }, COMMAND_REGISTRATION_DONE }; diff --git a/src/jtag/startup.tcl b/src/jtag/startup.tcl index 88d802fcb..5c466c628 100644 --- a/src/jtag/startup.tcl +++ b/src/jtag/startup.tcl @@ -359,6 +359,27 @@ proc parport_cable args { eval parport cable $args } +lappend _telnet_autocomplete_skip parport_select_cable +proc parport_select_cable {cable} { + echo "DEPRECATED! Do not use 'parport cable' but use a cable configuration file in interface/parport" + + switch $cable { + "wiggler" { source [find interface/parport/wiggler.cfg] } + "wiggler2" { source [find interface/parport/wiggler2.cfg] } + "wiggler_ntrst_inverted" { source [find interface/parport/wiggler-ntrst-inverted.cfg] } + "old_amt_wiggler" { source [find interface/parport/amt-wiggler-old.cfg ] } + "arm-jtag" { source [find interface/parport/arm-jtag.cfg] } + "chameleon" { source [find interface/parport/chameleon.cfg] } + "dlc5" { source [find interface/parport/dlc5.cfg] } + "triton" { source [find interface/parport/triton.cfg] } + "lattice" { source [find interface/parport/lattice.cfg] } + "flashlink" { source [find interface/parport/flashlink.cfg] } + "altium" { source [find interface/parport/altium.cfg] } + "aspo" { source [find interface/parport/aspo.cfg] } + default { error "invalid parallel port cable '$cable'" } + } +} + lappend _telnet_autocomplete_skip parport_write_on_exit proc parport_write_on_exit args { echo "DEPRECATED! use 'parport write_on_exit' not 'parport_write_on_exit'" diff --git a/tcl/interface/parport/altium.cfg b/tcl/interface/parport/altium.cfg new file mode 100644 index 000000000..9389d47ef --- /dev/null +++ b/tcl/interface/parport/altium.cfg @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# Altium Universal JTAG cable. Set the cable to Xilinx Mode and wire to target as follows: +# +# HARD TCK - Target TCK +# HARD TMS - Target TMS +# HARD TDI - Target TDI +# HARD TDO - Target TDO +# SOFT TCK - Target TRST +# SOFT TDI - Target SRST + +adapter driver parport + +adapter gpio tdo 13 -exit-inactive +adapter gpio trst 7 -active-high -exit-inactive +adapter gpio tms 4 -exit-inactive +adapter gpio tck 3 -exit-inactive +adapter gpio tdi 2 -exit-inactive +adapter gpio srst 9 -active-high -exit-inactive +adapter gpio led 5 -exit-inactive + +# Non-JTAG signal that is only necessary for the functionality of the adapter. +# For details, refer to the documentation of the adapter. +adapter gpio user0 6 -init-active -exit-inactive + +transport select jtag diff --git a/tcl/interface/parport/amt-wiggler-old.cfg b/tcl/interface/parport/amt-wiggler-old.cfg new file mode 100644 index 000000000..bba30c8b2 --- /dev/null +++ b/tcl/interface/parport/amt-wiggler-old.cfg @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +adapter driver parport + +adapter gpio tdo 11 -active-low -exit-inactive +adapter gpio trst 2 -exit-inactive +adapter gpio tms 3 -exit-inactive +adapter gpio tck 4 -exit-inactive +adapter gpio tdi 5 -exit-inactive +adapter gpio srst 6 -exit-inactive + +# Non-JTAG signal that is only necessary for the functionality of the adapter. +# For details, refer to the documentation of the adapter. +adapter gpio user0 9 -init-active -exit-active + +transport select jtag diff --git a/tcl/interface/parport/arm-jtag.cfg b/tcl/interface/parport/arm-jtag.cfg new file mode 100644 index 000000000..3b2a10daa --- /dev/null +++ b/tcl/interface/parport/arm-jtag.cfg @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +adapter driver parport + +adapter gpio tdo 11 -active-low -exit-inactive +adapter gpio trst 2 -exit-inactive +adapter gpio tms 3 -exit-inactive +adapter gpio tck 4 -exit-inactive +adapter gpio tdi 5 -exit-inactive +adapter gpio srst 6 -active-high -exit-inactive + +# Non-JTAG signal that is only necessary for the functionality of the adapter. +# For details, refer to the documentation of the adapter. +adapter gpio user0 9 -init-active -exit-active + +transport select jtag diff --git a/tcl/interface/parport/aspo.cfg b/tcl/interface/parport/aspo.cfg new file mode 100644 index 000000000..0d14719db --- /dev/null +++ b/tcl/interface/parport/aspo.cfg @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +adapter driver parport + +adapter gpio tdo 13 -exit-inactive +adapter gpio trst 2 -init-active -exit-active +adapter gpio tms 4 -active-low -exit-active +adapter gpio tck 5 -exit-inactive +adapter gpio tdi 3 -active-low -init-active -exit-active +adapter gpio srst 6 -init-active -exit-active + +transport select jtag diff --git a/tcl/interface/parport/chameleon.cfg b/tcl/interface/parport/chameleon.cfg new file mode 100644 index 000000000..f0ebcdd50 --- /dev/null +++ b/tcl/interface/parport/chameleon.cfg @@ -0,0 +1,10 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +adapter driver parport + +adapter gpio tdo 11 -active-low -exit-inactive +adapter gpio tms 4 -exit-inactive +adapter gpio tck 2 -exit-inactive +adapter gpio tdi 3 -exit-inactive + +transport select jtag diff --git a/tcl/interface/parport/dlc5.cfg b/tcl/interface/parport/dlc5.cfg index 24acea7a9..fb8494321 100644 --- a/tcl/interface/parport/dlc5.cfg +++ b/tcl/interface/parport/dlc5.cfg @@ -1,17 +1,16 @@ # SPDX-License-Identifier: GPL-2.0-or-later -# # Xilinx Parallel Cable III 'DLC 5' (and various clones) -# -# http://www.xilinx.com/itp/xilinx4/data/docs/pac/appendixb.html -# - -if { [info exists PARPORTADDR] } { - set _PARPORTADDR $PARPORTADDR -} else { - set _PARPORTADDR 0 -} adapter driver parport -parport port $_PARPORTADDR -parport cable dlc5 + +adapter gpio tdo 13 -exit-inactive +adapter gpio tms 4 -exit-inactive +adapter gpio tck 3 -exit-inactive +adapter gpio tdi 2 -exit-inactive + +# Non-JTAG signal that is only necessary for the functionality of the adapter. +# For details, refer to the documentation of the adapter. +adapter gpio user0 6 -init-active -exit-active + +transport select jtag diff --git a/tcl/interface/parport/flashlink.cfg b/tcl/interface/parport/flashlink.cfg new file mode 100644 index 000000000..b1a261d0b --- /dev/null +++ b/tcl/interface/parport/flashlink.cfg @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +adapter driver parport + +adapter gpio tdo 12 -active-low -exit-inactive +adapter gpio trst 6 -exit-inactive +adapter gpio tms 3 -exit-inactive +adapter gpio tck 2 -exit-inactive +adapter gpio tdi 4 -exit-inactive +adapter gpio srst 7 -exit-inactive + +transport select jtag diff --git a/tcl/interface/parport/lattice.cfg b/tcl/interface/parport/lattice.cfg new file mode 100644 index 000000000..aa7322812 --- /dev/null +++ b/tcl/interface/parport/lattice.cfg @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +adapter driver parport + +adapter gpio tdo 10 -exit-inactive +adapter gpio trst 6 -active-high -init-active -exit-active +adapter gpio tms 4 -exit-inactive +adapter gpio tck 3 -exit-inactive +adapter gpio tdi 2 -exit-inactive +adapter gpio srst 5 -active-high -init-active -exit-active + +transport select jtag diff --git a/tcl/interface/parport/triton.cfg b/tcl/interface/parport/triton.cfg new file mode 100644 index 000000000..b24d223a9 --- /dev/null +++ b/tcl/interface/parport/triton.cfg @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +adapter driver parport + +adapter gpio tdo 11 -active-low -exit-inactive +adapter gpio trst 5 -active-high -exit-inactive +adapter gpio tms 4 -exit-inactive +adapter gpio tck 2 -exit-inactive +adapter gpio tdi 3 -exit-inactive + +transport select jtag diff --git a/tcl/interface/parport/wiggler-ntrst-inverted.cfg b/tcl/interface/parport/wiggler-ntrst-inverted.cfg new file mode 100644 index 000000000..3b2fc0f28 --- /dev/null +++ b/tcl/interface/parport/wiggler-ntrst-inverted.cfg @@ -0,0 +1,16 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +adapter driver parport + +adapter gpio tdo 11 -active-low -exit-inactive +adapter gpio trst 6 -exit-inactive +adapter gpio tms 3 -exit-inactive +adapter gpio tck 4 -exit-inactive +adapter gpio tdi 5 -exit-inactive +adapter gpio srst 2 -exit-inactive + +# Non-JTAG signal that is only necessary for the functionality of the adapter. +# For details, refer to the documentation of the adapter. +adapter gpio user0 9 -init-active -exit-active + +transport select jtag diff --git a/tcl/interface/parport/wiggler.cfg b/tcl/interface/parport/wiggler.cfg index b9fceeb85..84c1c8302 100644 --- a/tcl/interface/parport/wiggler.cfg +++ b/tcl/interface/parport/wiggler.cfg @@ -1,21 +1,16 @@ # SPDX-License-Identifier: GPL-2.0-or-later -# -# Parallel port wiggler (many clones available) on port 0x378 -# -# Addresses: 0x378/LPT1 or 0x278/LPT2 ... -# +adapter driver parport -if { [info exists PARPORTADDR] } { - set _PARPORTADDR $PARPORTADDR -} else { - if {$tcl_platform(platform) eq "windows"} { - set _PARPORTADDR 0x378 - } { - set _PARPORTADDR 0 - } -} +adapter gpio tdo 11 -active-low -exit-inactive +adapter gpio trst 6 -active-high -exit-inactive +adapter gpio tms 3 -exit-inactive +adapter gpio tck 4 -exit-inactive +adapter gpio tdi 5 -exit-inactive +adapter gpio srst 2 -exit-inactive -adapter driver parport -parport port $_PARPORTADDR -parport cable wiggler +# Non-JTAG signal that is only necessary for the functionality of the adapter. +# For details, refer to the documentation of the adapter. +adapter gpio user0 9 -init-active -exit-active + +transport select jtag diff --git a/tcl/interface/parport/wiggler2.cfg b/tcl/interface/parport/wiggler2.cfg new file mode 100644 index 000000000..839e7f9b4 --- /dev/null +++ b/tcl/interface/parport/wiggler2.cfg @@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +adapter driver parport + +adapter gpio tdo 11 -active-low -exit-inactive +adapter gpio trst 6 -active-high -exit-inactive +adapter gpio tms 3 -exit-inactive +adapter gpio tck 4 -exit-inactive +adapter gpio tdi 5 -exit-inactive +adapter gpio srst 2 -exit-inactive +adapter gpio led 7 -exit-inactive + +# Non-JTAG signal that is only necessary for the functionality of the adapter. +# For details, refer to the documentation of the adapter. +adapter gpio user0 9 -init-active -exit-inactive + +transport select jtag ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 119 +++---- src/jtag/drivers/parport.c | 427 ++++++++++++----------- src/jtag/startup.tcl | 21 ++ tcl/interface/parport/altium.cfg | 26 ++ tcl/interface/parport/amt-wiggler-old.cfg | 16 + tcl/interface/parport/arm-jtag.cfg | 16 + tcl/interface/parport/aspo.cfg | 12 + tcl/interface/parport/chameleon.cfg | 10 + tcl/interface/parport/dlc5.cfg | 23 +- tcl/interface/parport/flashlink.cfg | 12 + tcl/interface/parport/lattice.cfg | 12 + tcl/interface/parport/triton.cfg | 11 + tcl/interface/parport/wiggler-ntrst-inverted.cfg | 16 + tcl/interface/parport/wiggler.cfg | 29 +- tcl/interface/parport/wiggler2.cfg | 17 + 15 files changed, 461 insertions(+), 306 deletions(-) create mode 100644 tcl/interface/parport/altium.cfg create mode 100644 tcl/interface/parport/amt-wiggler-old.cfg create mode 100644 tcl/interface/parport/arm-jtag.cfg create mode 100644 tcl/interface/parport/aspo.cfg create mode 100644 tcl/interface/parport/chameleon.cfg create mode 100644 tcl/interface/parport/flashlink.cfg create mode 100644 tcl/interface/parport/lattice.cfg create mode 100644 tcl/interface/parport/triton.cfg create mode 100644 tcl/interface/parport/wiggler-ntrst-inverted.cfg create mode 100644 tcl/interface/parport/wiggler2.cfg hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-06 08:19:13
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 3bec165e2590ae72bb67ba4913b92e18b1275600 (commit) via d02389bbfaf0fe78e9944194e08a389447b8f84f (commit) from fcff4b712c53a6169f0f96dd63f0adb1b12a1789 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 3bec165e2590ae72bb67ba4913b92e18b1275600 Author: Marc Schink <de...@za...> Date: Thu Jul 31 07:48:46 2025 +0000 adapter: Add 'user0' GPIO signal Add a user-specific signal 'user0' which can be used for custom functionality. For now, only a single user-specific signal is supported. Additional signals 'userX' or a more generic handling can be added in the future. Also, the signal state can only be configured during the adapter initialization and termination. Commands to change the signal state at run-time may be added in the future. Change-Id: I3f31242f6a693e11565542c3bd4521a245b4ff95 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9088 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 8ebb468d4..1e9f80dce 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2440,7 +2440,7 @@ dict get [adapter list] ftdi @deffn {Config Command} {adapter gpio [ @ @option{tdo} | @option{tdi} | @option{tms} | @option{tck} | @option{trst} | @ @option{swdio} | @option{swdio_dir} | @option{swclk} | @option{srst} | @ - @option{led} @ + @option{led} | @option{user0} @ [ @ gpio_number | @option{-chip} chip_number | @ @option{-active-high} | @option{-active-low} | @ @@ -2460,6 +2460,7 @@ JTAG transport signals @item @option{swdio_dir}: optional swdio buffer control signal @item @option{srst}: system reset signal @item @option{led}: optional activity led +@item @option{user0}: optional, user-specific signal @end itemize diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index 07560f0db..87c65719c 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -65,6 +65,7 @@ static const struct gpio_map { [ADAPTER_GPIO_IDX_TRST] = { "trst", ADAPTER_GPIO_DIRECTION_OUTPUT, false, true, true }, [ADAPTER_GPIO_IDX_SRST] = { "srst", ADAPTER_GPIO_DIRECTION_OUTPUT, false, true, true }, [ADAPTER_GPIO_IDX_LED] = { "led", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, true }, + [ADAPTER_GPIO_IDX_USER0] = { "user0", ADAPTER_GPIO_DIRECTION_BIDIRECTIONAL, true, true, true }, }; static int adapter_config_khz(unsigned int khz); diff --git a/src/jtag/adapter.h b/src/jtag/adapter.h index ed58fe5aa..d76ea5e32 100644 --- a/src/jtag/adapter.h +++ b/src/jtag/adapter.h @@ -60,6 +60,7 @@ enum adapter_gpio_config_index { ADAPTER_GPIO_IDX_SWCLK, ADAPTER_GPIO_IDX_SRST, ADAPTER_GPIO_IDX_LED, + ADAPTER_GPIO_IDX_USER0, ADAPTER_GPIO_IDX_NUM, /* must be the last item */ }; commit d02389bbfaf0fe78e9944194e08a389447b8f84f Author: Marc Schink <de...@za...> Date: Sun Jun 15 10:52:49 2025 +0000 adapter: Add support for 'exit state' of GPIO signal In addition to a signal's 'init state', add support to configure its 'exit state'. This option determines the state and configuration of a pin when the adapter terminates its operation. Change-Id: I0577ed9e3bc79715290b4e6a21e3f64c66f2ff9a Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9087 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 6c7aa86ec..8ebb468d4 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2447,6 +2447,7 @@ dict get [adapter list] ftdi @option{-push-pull} | @option{-open-drain} | @option{-open-source} | @ @option{-pull-none} | @option{-pull-up} | @option{-pull-down} | @ @option{-init-inactive} | @option{-init-active} | @option{-init-input} @ + @option{-exit-inactive} | @option{-exit-active} | @option{-exit-input} | @option{-exit-no-change} @ ] ]} Define the GPIO mapping that the adapter will use. The following signals can be @@ -2481,11 +2482,14 @@ equivalent to issuing the single command @command{gpio led 7 -chip 1 signals which are inputs. The drive mode for the srst and trst signals must be set with the @command{adapter reset_config} command. It is not permissible to set the initial state of swdio_dir as it is derived from the initial state of -swdio. The command @command{adapter gpio} prints the current configuration for -all GPIOs while the command @command{adapter gpio gpio_name} prints the current -configuration for gpio_name. Not all adapters support this generic GPIO mapping, -some require their own commands to define the GPIOs used. Adapters that support -the generic mapping may not support all of the listed options. +swdio. Accordingly, the final state before the adapter terminates its operation, +so-called âexit stateâ, can be set. By default the state and configuration of an +output pin is not changed when the driver terminates its operation. The +command @command{adapter gpio} prints the current configuration for all GPIOs +while the command @command{adapter gpio gpio_name} prints the current configuration +for gpio_name. Not all adapters support this generic GPIO mapping, some require +their own commands to define the GPIOs used. Adapters that support the generic +mapping may not support all of the listed options. @end deffn @deffn {Command} {adapter name} diff --git a/src/jtag/adapter.c b/src/jtag/adapter.c index 6785a74ef..07560f0db 100644 --- a/src/jtag/adapter.c +++ b/src/jtag/adapter.c @@ -53,17 +53,18 @@ static const struct gpio_map { enum adapter_gpio_direction direction; bool permit_drive_option; bool permit_init_state_option; + bool permit_exit_state_option; } gpio_map[ADAPTER_GPIO_IDX_NUM] = { - [ADAPTER_GPIO_IDX_TDO] = { "tdo", ADAPTER_GPIO_DIRECTION_INPUT, false, true, }, - [ADAPTER_GPIO_IDX_TDI] = { "tdi", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, }, - [ADAPTER_GPIO_IDX_TMS] = { "tms", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, }, - [ADAPTER_GPIO_IDX_TCK] = { "tck", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, }, - [ADAPTER_GPIO_IDX_SWDIO] = { "swdio", ADAPTER_GPIO_DIRECTION_BIDIRECTIONAL, true, true, }, - [ADAPTER_GPIO_IDX_SWDIO_DIR] = { "swdio_dir", ADAPTER_GPIO_DIRECTION_OUTPUT, true, false, }, - [ADAPTER_GPIO_IDX_SWCLK] = { "swclk", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, }, - [ADAPTER_GPIO_IDX_TRST] = { "trst", ADAPTER_GPIO_DIRECTION_OUTPUT, false, true, }, - [ADAPTER_GPIO_IDX_SRST] = { "srst", ADAPTER_GPIO_DIRECTION_OUTPUT, false, true, }, - [ADAPTER_GPIO_IDX_LED] = { "led", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, }, + [ADAPTER_GPIO_IDX_TDO] = { "tdo", ADAPTER_GPIO_DIRECTION_INPUT, false, true, true }, + [ADAPTER_GPIO_IDX_TDI] = { "tdi", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, true }, + [ADAPTER_GPIO_IDX_TMS] = { "tms", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, true }, + [ADAPTER_GPIO_IDX_TCK] = { "tck", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, true }, + [ADAPTER_GPIO_IDX_SWDIO] = { "swdio", ADAPTER_GPIO_DIRECTION_BIDIRECTIONAL, true, true, true }, + [ADAPTER_GPIO_IDX_SWDIO_DIR] = { "swdio_dir", ADAPTER_GPIO_DIRECTION_OUTPUT, true, false, false }, + [ADAPTER_GPIO_IDX_SWCLK] = { "swclk", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, true }, + [ADAPTER_GPIO_IDX_TRST] = { "trst", ADAPTER_GPIO_DIRECTION_OUTPUT, false, true, true }, + [ADAPTER_GPIO_IDX_SRST] = { "srst", ADAPTER_GPIO_DIRECTION_OUTPUT, false, true, true }, + [ADAPTER_GPIO_IDX_LED] = { "led", ADAPTER_GPIO_DIRECTION_OUTPUT, true, true, true }, }; static int adapter_config_khz(unsigned int khz); @@ -850,6 +851,7 @@ static COMMAND_HELPER(helper_adapter_gpio_print_config, enum adapter_gpio_config const char *drive = ""; const char *pull = ""; const char *init_state = ""; + const char *exit_state = ""; if (gpio_config->gpio_num == ADAPTER_GPIO_NOT_SET) { command_print(CMD, "adapter gpio %s: not configured", gpio_map[gpio_idx].name); @@ -908,9 +910,27 @@ static COMMAND_HELPER(helper_adapter_gpio_print_config, enum adapter_gpio_config } } - command_print(CMD, "adapter gpio %s (%s): num %u, chip %d, active-%s%s%s%s", + if (gpio_map[gpio_idx].permit_exit_state_option) { + switch (gpio_config->exit_state) { + case ADAPTER_GPIO_EXIT_STATE_NO_CHANGE: + exit_state = ", exit-state no-change"; + break; + case ADAPTER_GPIO_EXIT_STATE_INACTIVE: + exit_state = ", exit-state inactive"; + break; + case ADAPTER_GPIO_EXIT_STATE_ACTIVE: + exit_state = ", exit-state active"; + break; + case ADAPTER_GPIO_EXIT_STATE_INPUT: + exit_state = ", exit-state input"; + break; + } + } + + + command_print(CMD, "adapter gpio %s (%s): num %u, chip %d, active-%s%s%s%s%s", gpio_map[gpio_idx].name, dir, gpio_config->gpio_num, (int)gpio_config->chip_num, active_state, - drive, pull, init_state); + drive, pull, init_state, exit_state); return ERROR_OK; } @@ -1031,6 +1051,31 @@ COMMAND_HANDLER(adapter_gpio_config_handler) } } + if (gpio_map[gpio_idx].permit_exit_state_option) { + if (strcmp(CMD_ARGV[i], "-exit-no-change") == 0) { + ++i; + gpio_config->exit_state = ADAPTER_GPIO_EXIT_STATE_NO_CHANGE; + continue; + } + if (strcmp(CMD_ARGV[i], "-exit-inactive") == 0) { + ++i; + gpio_config->exit_state = ADAPTER_GPIO_EXIT_STATE_INACTIVE; + continue; + } + if (strcmp(CMD_ARGV[i], "-exit-active") == 0) { + ++i; + gpio_config->exit_state = ADAPTER_GPIO_EXIT_STATE_ACTIVE; + continue; + } + + if (gpio_map[gpio_idx].direction == ADAPTER_GPIO_DIRECTION_BIDIRECTIONAL && + strcmp(CMD_ARGV[i], "-exit-input") == 0) { + ++i; + gpio_config->exit_state = ADAPTER_GPIO_EXIT_STATE_INPUT; + continue; + } + } + LOG_ERROR("illegal option for adapter %s %s: %s", CMD_NAME, gpio_map[gpio_idx].name, CMD_ARGV[i]); return ERROR_COMMAND_SYNTAX_ERROR; @@ -1168,7 +1213,8 @@ static const struct command_registration adapter_command_handlers[] = { "[-active-high|-active-low] " "[-push-pull|-open-drain|-open-source] " "[-pull-none|-pull-up|-pull-down]" - "[-init-inactive|-init-active|-init-input] ]", + "[-init-inactive|-init-active|-init-input] ]" + "[-exit-no-change|-exit-inactive|-exit-active|-exit-input] ]", }, COMMAND_REGISTRATION_DONE }; diff --git a/src/jtag/adapter.h b/src/jtag/adapter.h index 556952f8d..ed58fe5aa 100644 --- a/src/jtag/adapter.h +++ b/src/jtag/adapter.h @@ -33,6 +33,14 @@ enum adapter_gpio_init_state { ADAPTER_GPIO_INIT_STATE_INPUT, }; +/** Supported exit states for GPIO */ +enum adapter_gpio_exit_state { + ADAPTER_GPIO_EXIT_STATE_NO_CHANGE, /* Should be zero so it is the default state */ + ADAPTER_GPIO_EXIT_STATE_INACTIVE, + ADAPTER_GPIO_EXIT_STATE_ACTIVE, + ADAPTER_GPIO_EXIT_STATE_INPUT, +}; + /** Supported pull directions for GPIO */ enum adapter_gpio_pull { ADAPTER_GPIO_PULL_NONE, @@ -61,6 +69,7 @@ struct adapter_gpio_config { unsigned int chip_num; enum adapter_gpio_drive_mode drive; /* For outputs only */ enum adapter_gpio_init_state init_state; + enum adapter_gpio_exit_state exit_state; bool active_low; enum adapter_gpio_pull pull; }; ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 17 ++++++++----- src/jtag/adapter.c | 73 ++++++++++++++++++++++++++++++++++++++++++++---------- src/jtag/adapter.h | 10 ++++++++ 3 files changed, 81 insertions(+), 19 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-01 07:47:19
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via fcff4b712c53a6169f0f96dd63f0adb1b12a1789 (commit) from 64ed1c74d5d4eb8808047881d074cb8e9579dbe3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fcff4b712c53a6169f0f96dd63f0adb1b12a1789 Author: Brian Kuschak <bku...@gm...> Date: Wed Jun 11 12:41:04 2025 +0800 jtag/drivers/cmsis_dap: add new backend cmsis_dap_tcp Create a new backend for cmsis_dap driver that allows CMSIS-DAP protocol to run over TCP/IP instead of USB. An example implementation of the firmware for an SWD programmer that uses this cmsis_dap_tcp protocol can be found at the link below. https://github.com/bkuschak/cmsis_dap_tcp_esp32 Using this cmsis_dap_tcp backend with the firmware above on an ESP32-C6 programmer and STM32F401RE target shows the following performance: - loading 96KB image to RAM: 80 KB/sec - dumping 96KB image from RAM: 72 KB/sec - flashing 512KB image completes in about 13.5 seconds (including erase, program, and verify). Change-Id: I6e3e45016bd16ef2259561b1046788f5536b0687 Signed-off-by: Brian Kuschak <bku...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8973 Reviewed-by: Tomas Vanek <va...@fb...> Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/configure.ac b/configure.ac index b508f2ade..01077847b 100644 --- a/configure.ac +++ b/configure.ac @@ -204,6 +204,9 @@ m4_define([RSHIM_ADAPTER], m4_define([AMTJTAGACCEL_ADAPTER], [[[amtjtagaccel], [Amontec JTAG-Accelerator driver], [AMTJTAGACCEL]]]) +m4_define([CMSIS_DAP_TCP_ADAPTER], + [[[cmsis_dap_tcp], [CMSIS-DAP v2 compliant dongle (TCP)], [CMSIS_DAP_TCP]]]) + m4_define([HOST_ARM_BITBANG_ADAPTERS], [[[ep93xx], [Bitbanging on EP93xx-based SBCs], [EP93XX]], [[at91rm9200], [Bitbanging on AT91RM9200-based SBCs], [AT91RM9200]]]) @@ -327,7 +330,8 @@ AC_ARG_ADAPTERS([ JTAG_VPI_ADAPTER, RSHIM_ADAPTER, XVC_ADAPTERS, - LIBJAYLINK_ADAPTERS + LIBJAYLINK_ADAPTERS, + CMSIS_DAP_TCP_ADAPTER ],[auto]) AC_ARG_ADAPTERS([ @@ -623,6 +627,7 @@ PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [Linux libgpi PROCESS_ADAPTERS([DMEM_ADAPTER], ["x$is_linux" = "xyes"], [Linux /dev/mem]) PROCESS_ADAPTERS([SYSFSGPIO_ADAPTER], ["x$is_linux" = "xyes"], [Linux sysfs]) PROCESS_ADAPTERS([REMOTE_BITBANG_ADAPTER], [true], [unused]) +PROCESS_ADAPTERS([CMSIS_DAP_TCP_ADAPTER], [true], [unused]) PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libjaylink-0.2]) PROCESS_ADAPTERS([XVC_ADAPTERS], ["x$is_linux" = "xyes" -a "x$ac_cv_header_linux_pci_h" = "xyes"], [Linux build]) PROCESS_ADAPTERS([SERIAL_PORT_ADAPTERS], ["x$can_build_buspirate" = "xyes"], @@ -682,6 +687,8 @@ AS_IF([test "x$enable_stlink" != "xno" -o "x$enable_ti_icdi" != "xno" -o "x$enab AM_CONDITIONAL([HLADAPTER_STLINK], [test "x$enable_stlink" != "xno"]) AM_CONDITIONAL([HLADAPTER_ICDI], [test "x$enable_ti_icdi" != "xno"]) AM_CONDITIONAL([HLADAPTER_NULINK], [test "x$enable_nulink" != "xno"]) +AM_CONDITIONAL([CMSIS_DAP_CORE], + [test "x$enable_cmsis_dap" != "xno" -o "x$enable_cmsis_dap_v2" != "xno" -o "x$enable_cmsis_dap_tcp" != "xno"]) AS_IF([test "x$enable_jlink" != "xno"], [ AS_IF([test "x$use_internal_libjaylink" = "xyes"], [ @@ -832,6 +839,7 @@ m4_foreach([adapterTuple], [USB1_ADAPTERS, AMTJTAGACCEL_ADAPTER, HOST_ARM_BITBANG_ADAPTERS, HOST_ARM_OR_AARCH64_BITBANG_ADAPTERS, + CMSIS_DAP_TCP_ADAPTER, DUMMY_ADAPTER, OPTIONAL_LIBRARIES, COVERAGE], diff --git a/doc/openocd.texi b/doc/openocd.texi index 4d8f79558..6c7aa86ec 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2621,7 +2621,7 @@ ch347 activity_led n4 @deffn {Interface Driver} {cmsis-dap} ARM CMSIS-DAP compliant based adapter v1 (USB HID based) -or v2 (USB bulk). +or v2 (USB bulk or TCP/IP). @deffn {Config Command} {cmsis-dap vid_pid} [vid pid]+ The vendor ID and product ID of the CMSIS-DAP device. If not specified @@ -2632,14 +2632,17 @@ cmsis-dap vid_pid 0xc251 0xf001 0x0d28 0x0204 @end example @end deffn -@deffn {Config Command} {cmsis-dap backend} [@option{auto}|@option{usb_bulk}|@option{hid}] +@deffn {Config Command} {cmsis-dap backend} [@option{auto}|@option{usb_bulk}|@option{hid}|@option{tcp}] Specifies how to communicate with the adapter: @itemize @minus -@item @option{hid} Use HID generic reports - CMSIS-DAP v1 +@item @option{hid} Use USB HID generic reports - CMSIS-DAP v1 @item @option{usb_bulk} Use USB bulk - CMSIS-DAP v2 -@item @option{auto} First try USB bulk CMSIS-DAP v2, if not found try HID CMSIS-DAP v1. -This is the default if @command{cmsis-dap backend} is not specified. +@item @option{tcp} Use TCP/IP instead of USB +@item @option{auto} First try USB bulk CMSIS-DAP v2, if not found try USB HID +CMSIS-DAP v1, if not found try TCP (if @command{cmsis-dap tcp host} is +configured). This is the default if @command{cmsis-dap backend} is not +specified. @end itemize @end deffn @@ -2649,6 +2652,36 @@ In most cases need not to be specified and interfaces are searched by interface string or for user class interface. @end deffn +@deffn {Config Command} {cmsis-dap tcp host} hostname +Specifies the @var{hostname} or IP address of the remote programmer. For use +with 'tcp' backend only. +@example +cmsis-dap backend tcp +cmsis-dap tcp host 192.168.1.4 +@end example +@end deffn + +@deffn {Config Command} {cmsis-dap tcp port} port +Specifies the TCP @var{port} number used by the remote programmer for DAP +commands. The default port is 4441. For use with 'tcp' backend only. +@example +cmsis-dap backend tcp +cmsis-dap tcp host 192.168.1.4 +cmsis-dap tcp port 4441 +@end example +@end deffn + +@deffn {Config Command} {cmsis-dap tcp min_timeout} milliseconds +Sets a lower bound on the requested timeout in @var{milliseconds} to wait for +response packets from the remote programmer when using the 'tcp' backend. The +user may want to use a larger value on slower networks, to avoid getting +command mismatch errors. Default value is 150 milliseconds. For use with 'tcp' +backend only. +@example +cmsis-dap tcp min_timeout 200 +@end example +@end deffn + @deffn {Command} {cmsis-dap quirk} [@option{enable}|@option{disable}] Enables or disables the following workarounds of known CMSIS-DAP adapter quirks: diff --git a/src/helper/replacements.h b/src/helper/replacements.h index ecc0e5e95..747c2ae09 100644 --- a/src/helper/replacements.h +++ b/src/helper/replacements.h @@ -225,6 +225,20 @@ static inline int socket_select(int max_fd, #endif } +static inline int socket_recv_timeout(int fd, unsigned long timeout_msec) +{ +#ifdef _WIN32 + DWORD timeout = timeout_msec; + return setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&timeout, + sizeof(timeout)); +#else + struct timeval tv; + tv.tv_sec = timeout_msec / 1000; + tv.tv_usec = (timeout_msec % 1000) * 1000; + return setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, (const char *)&tv, sizeof(tv)); +#endif +} + #ifndef HAVE_ELF_H typedef uint32_t Elf32_Addr; diff --git a/src/jtag/drivers/Makefile.am b/src/jtag/drivers/Makefile.am index 3a3fe0772..5216e5d77 100644 --- a/src/jtag/drivers/Makefile.am +++ b/src/jtag/drivers/Makefile.am @@ -186,15 +186,17 @@ endif if OPENJTAG DRIVERFILES += %D%/openjtag.c endif +if CMSIS_DAP_CORE +DRIVERFILES += %D%/cmsis_dap.c +endif if CMSIS_DAP_HID DRIVERFILES += %D%/cmsis_dap_usb_hid.c -DRIVERFILES += %D%/cmsis_dap.c endif if CMSIS_DAP_USB DRIVERFILES += %D%/cmsis_dap_usb_bulk.c -if !CMSIS_DAP_HID -DRIVERFILES += %D%/cmsis_dap.c endif +if CMSIS_DAP_TCP +DRIVERFILES += %D%/cmsis_dap_tcp.c endif if IMX_GPIO DRIVERFILES += %D%/imx_gpio.c diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index b82647da7..3e1a3c5f0 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -52,9 +52,16 @@ const struct cmsis_dap_backend cmsis_dap_hid_backend = { }; #endif +#if BUILD_CMSIS_DAP_TCP == 0 +const struct cmsis_dap_backend cmsis_dap_tcp_backend = { + .name = "tcp" +}; +#endif + static const struct cmsis_dap_backend *const cmsis_dap_backends[] = { &cmsis_dap_usb_backend, &cmsis_dap_hid_backend, + &cmsis_dap_tcp_backend, }; /* USB Config */ @@ -2275,8 +2282,8 @@ static const struct command_registration cmsis_dap_subcommand_handlers[] = { .name = "backend", .handler = &cmsis_dap_handle_backend_command, .mode = COMMAND_CONFIG, - .help = "set the communication backend to use (USB bulk or HID).", - .usage = "(auto | usb_bulk | hid)", + .help = "set the communication backend to use (USB bulk or HID, or TCP).", + .usage = "(auto | usb_bulk | hid | tcp)", }, { .name = "quirk", @@ -2293,6 +2300,15 @@ static const struct command_registration cmsis_dap_subcommand_handlers[] = { .help = "USB bulk backend-specific commands", .usage = "<cmd>", }, +#endif +#if BUILD_CMSIS_DAP_TCP + { + .name = "tcp", + .chain = cmsis_dap_tcp_subcommand_handlers, + .mode = COMMAND_ANY, + .help = "TCP backend-specific commands", + .usage = "<cmd>", + }, #endif COMMAND_REGISTRATION_DONE }; diff --git a/src/jtag/drivers/cmsis_dap.h b/src/jtag/drivers/cmsis_dap.h index 26dc6f0cf..880fc3350 100644 --- a/src/jtag/drivers/cmsis_dap.h +++ b/src/jtag/drivers/cmsis_dap.h @@ -77,7 +77,9 @@ struct cmsis_dap_backend { extern const struct cmsis_dap_backend cmsis_dap_hid_backend; extern const struct cmsis_dap_backend cmsis_dap_usb_backend; +extern const struct cmsis_dap_backend cmsis_dap_tcp_backend; extern const struct command_registration cmsis_dap_usb_subcommand_handlers[]; +extern const struct command_registration cmsis_dap_tcp_subcommand_handlers[]; #define REPORT_ID_SIZE 1 diff --git a/src/jtag/drivers/cmsis_dap_tcp.c b/src/jtag/drivers/cmsis_dap_tcp.c new file mode 100644 index 000000000..a654c6bff --- /dev/null +++ b/src/jtag/drivers/cmsis_dap_tcp.c @@ -0,0 +1,439 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +/*************************************************************************** + * Provides CMSIS-DAP protocol over a TCP/IP socket. * + * UART and SWO are currently unsupported. * + * * + * Copyright (C) 2025 by Brian Kuschak <bku...@gm...> * + * * + * Adapted from cmsis_dap_usb_hid.c. Copyright (C) 2013-2018 by: * + * Mickaël Thomas <mic...@gm...> * + * Maksym Hilliaka <ot...@fr...> * + * Phillip Pearson <pp...@my...> * + * Paul Fertser <fer...@gm...> * + * mike brown <mi...@th...> * + * Spencer Oliver <sp...@sp...> * + * * + ***************************************************************************/ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <hidapi.h> +#ifdef HAVE_NETDB_H +#include <netdb.h> +#endif +#ifdef HAVE_NETINET_TCP_H +#include <netinet/tcp.h> +#endif +#include <stdbool.h> +#include <string.h> +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif +#include <sys/types.h> + +#include "helper/command.h" +#include "helper/log.h" +#include "helper/replacements.h" +#include "helper/system.h" +#include "cmsis_dap.h" + +#define STRINGIFY(x) #x + +// If the protocol changes in the future, the SIGNATURE should also be changed. +#define DAP_PKT_HDR_SIGNATURE 0x00504144 // "DAP" +#define DAP_PKT_TYPE_REQUEST 0x01 +#define DAP_PKT_TYPE_RESPONSE 0x02 + +#define CMSIS_DAP_TCP_PORT 4441 // Default. Can be overridden. +#define CMSIS_DAP_PACKET_SIZE 1024 // Max payload size not including + // header. + +/* When flushing after an error, the CMSIS-DAP driver assumes the pipeline is + * empty if it doesn't get a response after a short 10 msec timeout. While this + * works for USB, it may not work for TCP/IP due to higher network latency. TCP + * response packets may take longer to arrive. We set a lower bound on timeout + * for blocking reads, to give enough time for packets to arrive. + * + * The user may override this default value by setting the parameter + * 'cmsis-dap tcp min_timeout' + */ +#define DEFAULT_MIN_TIMEOUT_MS 150 + +/* CMSIS-DAP requests are variable length. With CMSIS-DAP over USB, the + * transfer sizes are preserved by the USB stack. However, TCP/IP is stream + * oriented so we perform our own packetization to preserve the boundaries + * between each request. This short header is prepended to each CMSIS-DAP + * request and response before being sent over the socket. Little endian format + * is used for multibyte values. + */ +struct __attribute__((packed)) cmsis_dap_tcp_packet_hdr { + uint32_t signature; // "DAP" + uint16_t length; // Not including header length. + uint8_t packet_type; + uint8_t reserved; // Reserved for future use. +}; + +/* Defines for struct cmsis_dap_tcp_packet_hdr requested by reviewer. */ +#define HEADER_SIGNATURE_OFFSET 0 +#define HEADER_LENGTH_OFFSET sizeof(uint32_t) +#define HEADER_PACKET_TYPE_OFFSET (sizeof(uint32_t) + sizeof(uint16_t)) +#define HEADER_RESERVED_OFFSET (sizeof(uint32_t) + sizeof(uint16_t) + \ + sizeof(uint8_t)) +#define HEADER_SIZE (sizeof(uint32_t) + sizeof(uint16_t) + \ + 2 * sizeof(uint8_t)) + +struct cmsis_dap_backend_data { + int sockfd; +}; + +static char *cmsis_dap_tcp_host; +static char *const cmsis_dap_tcp_port_default = STRINGIFY(CMSIS_DAP_TCP_PORT); +static char *cmsis_dap_tcp_port = cmsis_dap_tcp_port_default; +static int cmsis_dap_tcp_min_timeout_ms = DEFAULT_MIN_TIMEOUT_MS; + +static void cmsis_dap_tcp_close(struct cmsis_dap *dap); +static int cmsis_dap_tcp_alloc(struct cmsis_dap *dap, unsigned int pkt_sz); +static void cmsis_dap_tcp_free(struct cmsis_dap *dap); + +static int cmsis_dap_tcp_open(struct cmsis_dap *dap, + uint16_t vids[] __attribute__((unused)), + uint16_t pids[] __attribute__((unused)), + const char *serial __attribute__((unused))) +{ + // Skip the open if the user has not provided a hostname. + if (!cmsis_dap_tcp_host) { + LOG_DEBUG("No TCP hostname, skipping open."); + return ERROR_FAIL; + } + + // Ignore vids, pids, serial. We use host and port subcommands instead. + + dap->bdata = malloc(sizeof(struct cmsis_dap_backend_data)); + if (!dap->bdata) { + LOG_ERROR("CMSIS-DAP: unable to allocate memory"); + return ERROR_FAIL; + } + + struct addrinfo hints = { + .ai_family = AF_UNSPEC, + .ai_socktype = SOCK_STREAM + }; + struct addrinfo *result, *rp; + int fd = 0; + + LOG_INFO("CMSIS-DAP: Connecting to %s:%s using TCP backend", + cmsis_dap_tcp_host ? cmsis_dap_tcp_host : "localhost", + cmsis_dap_tcp_port); + + /* Some of the following code was taken from remote_bitbang.c */ + /* Obtain address(es) matching host/port */ + int s = getaddrinfo(cmsis_dap_tcp_host, cmsis_dap_tcp_port, &hints, + &result); + if (s != 0) { + LOG_ERROR("CMSIS-DAP: getaddrinfo: %s\n", gai_strerror(s)); + free(dap->bdata); + return ERROR_FAIL; + } + + /* getaddrinfo() returns a list of address structures. + Try each address until we successfully connect(2). + If socket(2) (or connect(2)) fails, we (close the socket + and) try the next address. */ + + for (rp = result; rp ; rp = rp->ai_next) { + fd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol); + if (fd == -1) + continue; + + if (connect(fd, rp->ai_addr, rp->ai_addrlen) != -1) { + LOG_DEBUG("Connected."); + break; /* Success */ + } + + close(fd); + } + + freeaddrinfo(result); + + if (!rp) { /* No address succeeded */ + LOG_ERROR("CMSIS-DAP: unable to connect to device %s:%s", + cmsis_dap_tcp_host ? cmsis_dap_tcp_host : "localhost", + cmsis_dap_tcp_port); + log_socket_error("Failed to connect"); + free(dap->bdata); + dap->bdata = NULL; + return ERROR_FAIL; + } + + /* Set NODELAY to minimize latency. */ + int one = 1; + /* On Windows optval has to be a const char *. */ + setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (const char *)&one, sizeof(one)); + + dap->bdata->sockfd = fd; + + int retval = cmsis_dap_tcp_alloc(dap, CMSIS_DAP_PACKET_SIZE); + if (retval != ERROR_OK) { + cmsis_dap_tcp_close(dap); + return retval; + } + return ERROR_OK; +} + +static void cmsis_dap_tcp_close(struct cmsis_dap *dap) +{ + if (close_socket(dap->bdata->sockfd) != 0) + log_socket_error("close_socket"); + + if (dap->bdata) + free(dap->bdata); + dap->bdata = NULL; + cmsis_dap_tcp_free(dap); +} + +static inline int readall_socket(int handle, void *buffer, unsigned int count) +{ + // Return after all count bytes available, or timeout, or error. + return recv(handle, buffer, count, MSG_WAITALL); +} + +static inline int peekall_socket(int handle, void *buffer, unsigned int count) +{ + /* Data remains unread on the socket until recv() is called later without + * the MSG_PEEK flag. Return after all count bytes available, or timeout, + * or error. + */ + return recv(handle, buffer, count, MSG_PEEK | MSG_WAITALL); +} + +static int cmsis_dap_tcp_read(struct cmsis_dap *dap, int transfer_timeout_ms, + enum cmsis_dap_blocking blocking) +{ + int wait_ms = (blocking == CMSIS_DAP_NON_BLOCKING) ? 0 : + transfer_timeout_ms; + if (wait_ms) { + LOG_DEBUG_IO("CMSIS-DAP: using tcp timeout %d msec", wait_ms); + + // Don't use very short timeouts with TCP/IP as it may not be as fast + // to respond as USB. User configurable minimum value. + if (wait_ms < cmsis_dap_tcp_min_timeout_ms) { + wait_ms = cmsis_dap_tcp_min_timeout_ms; + LOG_DEBUG_IO("CMSIS-DAP: extending timeout to %d msec", wait_ms); + } + } + socket_recv_timeout(dap->bdata->sockfd, wait_ms); + + if (blocking == CMSIS_DAP_NON_BLOCKING) + socket_nonblock(dap->bdata->sockfd); + else + socket_block(dap->bdata->sockfd); + + // Peek at the header first to find the length. + int retval = peekall_socket(dap->bdata->sockfd, dap->packet_buffer, + HEADER_SIZE); + LOG_DEBUG_IO("Reading header returned %d", retval); + if (retval == 0) { + LOG_DEBUG_IO("CMSIS-DAP: tcp timeout reached 1"); + return ERROR_TIMEOUT_REACHED; + } else if (retval == -1) { + if (errno == EAGAIN || errno == EWOULDBLOCK) { + if (blocking == CMSIS_DAP_NON_BLOCKING) + return ERROR_TIMEOUT_REACHED; + + LOG_DEBUG_IO("CMSIS-DAP: tcp timeout reached 2. timeout = %d msec", + wait_ms); + return ERROR_TIMEOUT_REACHED; + } + + LOG_ERROR("CMSIS-DAP: error reading header"); + log_socket_error("peek_socket"); + return ERROR_FAIL; + } else if (retval != HEADER_SIZE) { + LOG_ERROR("CMSIS-DAP: short header read"); + log_socket_error("peek_socket header short read"); + return ERROR_FAIL; + } + + struct cmsis_dap_tcp_packet_hdr header; + header.signature = le_to_h_u32(dap->packet_buffer + + HEADER_SIGNATURE_OFFSET); + header.length = le_to_h_u16(dap->packet_buffer + HEADER_LENGTH_OFFSET); + header.packet_type = dap->packet_buffer[HEADER_PACKET_TYPE_OFFSET]; + header.reserved = dap->packet_buffer[HEADER_RESERVED_OFFSET]; + + if (header.signature != DAP_PKT_HDR_SIGNATURE) { + LOG_ERROR("CMSIS-DAP: Unrecognized packet signature 0x%08x", + header.signature); + return ERROR_FAIL; + } else if (header.packet_type != DAP_PKT_TYPE_RESPONSE) { + LOG_ERROR("CMSIS-DAP: Unrecognized packet type 0x%02x", + header.packet_type); + return ERROR_FAIL; + } else if (header.length + HEADER_SIZE > dap->packet_buffer_size) { + LOG_ERROR("CMSIS-DAP: Packet length %d too large to fit.", + header.length); + return ERROR_FAIL; + } + + // Read the complete packet. + int read_len = HEADER_SIZE + header.length; + LOG_DEBUG_IO("Reading %d bytes (%d payload)...", read_len, header.length); + retval = readall_socket(dap->bdata->sockfd, dap->packet_buffer, read_len); + + if (retval == 0) { + LOG_DEBUG_IO("CMSIS-DAP: tcp timeout reached 3"); + return ERROR_TIMEOUT_REACHED; + } else if (retval == -1) { + LOG_ERROR("CMSIS-DAP: error reading data"); + log_socket_error("read_socket"); + return ERROR_FAIL; + } else if (retval != read_len) { + LOG_ERROR("CMSIS-DAP: short read. retval = %d. read_len = %d. " + "blocking = %s. wait_ms = %d", retval, read_len, + (blocking == CMSIS_DAP_NON_BLOCKING) ? "yes" : "no", wait_ms); + log_socket_error("read_socket short read"); + return ERROR_FAIL; + } + return retval; +} + +static int cmsis_dap_tcp_write(struct cmsis_dap *dap, int txlen, + int timeout_ms __attribute__((unused))) +{ + const unsigned int len = txlen + HEADER_SIZE; + if (len > dap->packet_buffer_size) { + LOG_ERROR("CMSIS-DAP: Packet length %d exceeds TCP buffer size!", len); + return ERROR_FAIL; + } + + /* Set the header values. */ + h_u32_to_le(dap->packet_buffer + HEADER_SIGNATURE_OFFSET, + DAP_PKT_HDR_SIGNATURE); + h_u16_to_le(dap->packet_buffer + HEADER_LENGTH_OFFSET, txlen); + dap->packet_buffer[HEADER_PACKET_TYPE_OFFSET] = DAP_PKT_TYPE_REQUEST; + dap->packet_buffer[HEADER_RESERVED_OFFSET] = 0; + + /* write data to device */ + LOG_DEBUG_IO("Writing %d bytes (%d payload)", len, txlen); + int retval = write_socket(dap->bdata->sockfd, dap->packet_buffer, len); + if (retval < 0) { + log_socket_error("write_socket"); + return ERROR_FAIL; + } else if (retval != (int)len) { + LOG_ERROR("CMSIS-DAP: error writing data"); + log_socket_error("write_socket short write"); + return ERROR_FAIL; + } + return retval; +} + +static int cmsis_dap_tcp_alloc(struct cmsis_dap *dap, unsigned int pkt_sz) +{ + // Reserve space for the packet header. + unsigned int packet_buffer_size = pkt_sz + HEADER_SIZE; + uint8_t *buf = malloc(packet_buffer_size); + if (!buf) { + LOG_ERROR("CMSIS-DAP: unable to allocate CMSIS-DAP packet buffer"); + return ERROR_FAIL; + } + + dap->packet_buffer = buf; + dap->packet_size = pkt_sz; + dap->packet_usable_size = pkt_sz; + dap->packet_buffer_size = packet_buffer_size; + + dap->command = dap->packet_buffer + HEADER_SIZE; + dap->response = dap->packet_buffer + HEADER_SIZE; + return ERROR_OK; +} + +static void cmsis_dap_tcp_free(struct cmsis_dap *dap) +{ + free(dap->packet_buffer); + dap->packet_buffer = NULL; +} + +static void cmsis_dap_tcp_cancel_all(struct cmsis_dap *dap) +{ +} + +COMMAND_HANDLER(cmsis_dap_handle_tcp_port) +{ + if (CMD_ARGC != 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + if (cmsis_dap_tcp_port != cmsis_dap_tcp_port_default) + free(cmsis_dap_tcp_port); + + cmsis_dap_tcp_port = strdup(CMD_ARGV[0]); + if (!cmsis_dap_tcp_port) { + LOG_ERROR("CMSIS-DAP: out of memory"); + return ERROR_FAIL; + } + return ERROR_OK; +} + +COMMAND_HANDLER(cmsis_dap_handle_tcp_host) +{ + if (CMD_ARGC != 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + free(cmsis_dap_tcp_host); + cmsis_dap_tcp_host = strdup(CMD_ARGV[0]); + if (!cmsis_dap_tcp_host) { + LOG_ERROR("CMSIS-DAP: out of memory"); + return ERROR_FAIL; + } + return ERROR_OK; +} + +COMMAND_HANDLER(cmsis_dap_handle_tcp_min_timeout) +{ + if (CMD_ARGC != 1) + return ERROR_COMMAND_SYNTAX_ERROR; + + COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], cmsis_dap_tcp_min_timeout_ms); + LOG_INFO("CMSIS-DAP: using minimum timeout of %d ms for TCP packets.", + cmsis_dap_tcp_min_timeout_ms); + return ERROR_OK; +} + +const struct command_registration cmsis_dap_tcp_subcommand_handlers[] = { + { + .name = "host", + .handler = &cmsis_dap_handle_tcp_host, + .mode = COMMAND_CONFIG, + .help = "set the host name to use (for TCP backend only)", + .usage = "<host_name>", + }, + { + .name = "port", + .handler = &cmsis_dap_handle_tcp_port, + .mode = COMMAND_CONFIG, + .help = "set the port number to use for DAP (for TCP backend only)", + .usage = "<port_number>", + }, + { + .name = "min_timeout", + .handler = &cmsis_dap_handle_tcp_min_timeout, + .mode = COMMAND_CONFIG, + .help = "set the minimum timeout in milliseconds to wait for response " + "packets (for TCP backend only)", + .usage = "<milliseconds>", + }, + COMMAND_REGISTRATION_DONE +}; + +const struct cmsis_dap_backend cmsis_dap_tcp_backend = { + .name = "tcp", + .open = cmsis_dap_tcp_open, + .close = cmsis_dap_tcp_close, + .read = cmsis_dap_tcp_read, + .write = cmsis_dap_tcp_write, + .packet_buffer_alloc = cmsis_dap_tcp_alloc, + .packet_buffer_free = cmsis_dap_tcp_free, + .cancel_all = cmsis_dap_tcp_cancel_all, +}; diff --git a/tcl/interface/cmsis-dap-tcp.cfg b/tcl/interface/cmsis-dap-tcp.cfg new file mode 100644 index 000000000..7889fb944 --- /dev/null +++ b/tcl/interface/cmsis-dap-tcp.cfg @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# +# cmsis-dap-tcp - CMSIS-DAP protocol over TCP/IP. +# + +adapter driver cmsis-dap +cmsis-dap backend tcp + +# Specify the hostname or IP address of your programmer. +# cmsis-dap tcp host 192.168.1.4 + +# Optionally specify a port number. Default port is 4441. +# cmsis-dap tcp port 4441 + +# Optionally set a lower bound on packet timeouts (milliseconds), if using a +# slow network. +# cmsis-dap tcp min_timeout 300 ----------------------------------------------------------------------- Summary of changes: configure.ac | 10 +- doc/openocd.texi | 43 +++- src/helper/replacements.h | 14 ++ src/jtag/drivers/Makefile.am | 8 +- src/jtag/drivers/cmsis_dap.c | 20 +- src/jtag/drivers/cmsis_dap.h | 2 + src/jtag/drivers/cmsis_dap_tcp.c | 439 +++++++++++++++++++++++++++++++++++++++ tcl/interface/cmsis-dap-tcp.cfg | 18 ++ 8 files changed, 543 insertions(+), 11 deletions(-) create mode 100644 src/jtag/drivers/cmsis_dap_tcp.c create mode 100644 tcl/interface/cmsis-dap-tcp.cfg hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-01 07:44:18
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 64ed1c74d5d4eb8808047881d074cb8e9579dbe3 (commit) from 61d1d13a0248fc6f0b131210d816b823816f14d6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 64ed1c74d5d4eb8808047881d074cb8e9579dbe3 Author: HAOUES Ahmed <ahm...@st...> Date: Wed May 7 16:25:39 2025 +0100 flash/stm32l4x: Support STM32U37/U38x devices STM32U37/U38x devices have 1Mb flash (split into pages of 4 Kb) Note: add wait for the BSY bit to be cleared in FLASH_SR Change-Id: I8208aa81951b9e2f7b0a6bbfce3f7c8ad0f78ade Signed-off-by: HAOUES Ahmed <ahm...@st...> Reviewed-on: https://review.openocd.org/c/openocd/+/8874 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/flash/nor/stm32l4x.c b/src/flash/nor/stm32l4x.c index 2da2c69fe..0c56ef6d9 100644 --- a/src/flash/nor/stm32l4x.c +++ b/src/flash/nor/stm32l4x.c @@ -287,7 +287,7 @@ struct stm32l4_wrp { }; /* human readable list of families this drivers supports (sorted alphabetically) */ -static const char *device_families = "STM32C0/G0/G4/L4/L4+/L5/U0/U5/WB/WL"; +static const char *device_families = "STM32C0/G0/G4/L4/L4+/L5/U0/U3/U5/WB/WL"; static const struct stm32l4_rev stm32l47_l48xx_revs[] = { { 0x1000, "1" }, { 0x1001, "2" }, { 0x1003, "3" }, { 0x1007, "4" } @@ -350,6 +350,10 @@ static const struct stm32l4_rev stm32u0xx_revs[] = { { 0x1000, "A" }, }; +static const struct stm32l4_rev stm32u37_u38xx_revs[] = { + { 0x1000, "A" }, { 0x1001, "Z" }, +}; + static const struct stm32l4_rev stm32g43_g44xx_revs[] = { { 0x1000, "A" }, { 0x2000, "B" }, { 0x2001, "Z" }, }; @@ -690,6 +694,18 @@ static const struct stm32l4_part_info stm32l4_parts[] = { .otp_base = 0x1FFF6800, .otp_size = 1024, }, + { + .id = DEVID_STM32U37_U38XX, + .revs = stm32u37_u38xx_revs, + .num_revs = ARRAY_SIZE(stm32u37_u38xx_revs), + .device_str = "STM32U37/U38xx", + .max_flash_size_kb = 1024, + .flags = F_HAS_DUAL_BANK | F_HAS_TZ | F_HAS_L5_FLASH_REGS | F_WRP_HAS_LOCK, + .flash_regs_base = 0x40022000, + .fsize_addr = 0x0BFA07A0, + .otp_base = 0x0BFA0000, + .otp_size = 512, + }, { .id = DEVID_STM32U59_U5AXX, .revs = stm32u59_u5axx_revs, @@ -1380,6 +1396,10 @@ static int stm32l4_erase(struct flash_bank *bank, unsigned int first, 4. Wait for the BSY bit to be cleared */ + retval = stm32l4_wait_status_busy(bank, FLASH_ERASE_TIMEOUT); + if (retval != ERROR_OK) + goto err_lock; + for (unsigned int i = first; i <= last; i++) { uint32_t erase_flags; erase_flags = FLASH_PER | FLASH_STRT; @@ -1785,6 +1805,9 @@ static int stm32l4_write(struct flash_bank *bank, const uint8_t *buffer, if (retval != ERROR_OK) goto err_lock; + retval = stm32l4_wait_status_busy(bank, FLASH_WRITE_TIMEOUT); + if (retval != ERROR_OK) + goto err_lock; /* For TrustZone enabled devices, when TZEN is set and RDP level is 0.5, * the debug is possible only in non-secure state. @@ -2151,6 +2174,15 @@ static int stm32l4_probe(struct flash_bank *bank) stm32l4_info->bank1_sectors = num_pages / 2; } break; + case DEVID_STM32U37_U38XX: + page_size_kb = 4; + num_pages = flash_size_kb / page_size_kb; + stm32l4_info->bank1_sectors = num_pages; + if (is_max_flash_size || (stm32l4_info->optr & FLASH_U5_DUALBANK)) { + stm32l4_info->dual_bank_mode = true; + stm32l4_info->bank1_sectors = num_pages / 2; + } + break; case DEVID_STM32U53_U54XX: case DEVID_STM32U57_U58XX: case DEVID_STM32U59_U5AXX: diff --git a/src/flash/nor/stm32l4x.h b/src/flash/nor/stm32l4x.h index 1f4f2344f..8e6cb4309 100644 --- a/src/flash/nor/stm32l4x.h +++ b/src/flash/nor/stm32l4x.h @@ -94,6 +94,7 @@ #define DEVID_STM32C05XX 0x44C #define DEVID_STM32C09XX 0x44D #define DEVID_STM32C03XX 0x453 +#define DEVID_STM32U37_U38XX 0x454 #define DEVID_STM32U53_U54XX 0x455 #define DEVID_STM32G05_G06XX 0x456 #define DEVID_STM32U031XX 0x459 diff --git a/tcl/target/stm32u3x.cfg b/tcl/target/stm32u3x.cfg new file mode 100644 index 000000000..449c04217 --- /dev/null +++ b/tcl/target/stm32u3x.cfg @@ -0,0 +1,45 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +# script for stm32u3x family +# stm32u3x devices support both JTAG and SWD transports. + +source [find target/swj-dp.tcl] +source [find mem_helper.tcl] + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME stm32u3x +} + +source [find target/stm32x5x_common.cfg] + +# In order to allow the flash program and erase operations, +# we need to set the voltage scale to range 1 + +proc config_voltage_range {} { + set offset [expr {[stm32x5x_is_secure] ? 0x10000000 : 0}] + # PWR voltage scaling register + set PWR_VOSR [expr {0x4003080C + $offset}] + # PWR supply voltage monitoring control register + set PWR_SVMCR [expr {0x40030810 + $offset}] + # RCC AHB1 peripheral clock enable register 2 + # RCC_AHB1ENR2 = PWREN + mww [expr {0x40030C94 + $offset}] 0x4 + if {(([mrw $PWR_VOSR] & 0x10001) != 0x10001)} { + # PWR_SVMCR = IO2SV + mmw $PWR_SVMCR 0x20000000 0 + # PWR_VOSR : R1EN: Voltage scaling range 1 + mmw $PWR_VOSR 1 3 + # while !(PWR_VOSR & R1RDY) + while {([mrw $PWR_VOSR] & 0x10001) != 0x10001} {} + # Enable EPOD Booster + mmw $PWR_VOSR 0x00000100 0 + # while !(PWR_VOSR & BOOSTRDY) + while {([mrw $PWR_VOSR] & 0x1000000) != 0} {} + } +} + +$_TARGETNAME configure -event reset-init { + config_voltage_range +} diff --git a/tcl/target/stm32x5x_common.cfg b/tcl/target/stm32x5x_common.cfg index fb3aeb18c..b6370e493 100644 --- a/tcl/target/stm32x5x_common.cfg +++ b/tcl/target/stm32x5x_common.cfg @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-or-later -# common script for stm32l5x and stm32u5x families +# common script for stm32l5x, stm32u3x and stm32u5x families # Work-area is a space in RAM used for flash programming # By default use 64kB @@ -16,6 +16,7 @@ if { [info exists CPUTAPID] } { } else { if { [using_jtag] } { # STM32L5x: RM0438 Rev5, Section 52.2.8 JTAG debug port - Table 425. JTAG-DP data registers + # STM32U3x: RM0487 Rev1, Section 53.3.1 JTAG debug port - Table 569. JTAG-DP data registers # STM32U5x: RM0456 Rev1, Section 65.2.8 JTAG debug port - Table 661. JTAG-DP data registers # Corresponds to Cortex®-M33 JTAG debug port ID code set _CPUTAPID 0x0ba04477 ----------------------------------------------------------------------- Summary of changes: src/flash/nor/stm32l4x.c | 34 ++++++++++++++++++++++++++++++- src/flash/nor/stm32l4x.h | 1 + tcl/target/stm32u3x.cfg | 45 ++++++++++++++++++++++++++++++++++++++++++ tcl/target/stm32x5x_common.cfg | 3 ++- 4 files changed, 81 insertions(+), 2 deletions(-) create mode 100644 tcl/target/stm32u3x.cfg hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-29 12:08:52
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 61d1d13a0248fc6f0b131210d816b823816f14d6 (commit) from fcbe243c0b7543d5a46c72d44117104368236c58 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 61d1d13a0248fc6f0b131210d816b823816f14d6 Author: Michal Lenc <mic...@se...> Date: Mon Aug 25 15:39:15 2025 +0200 doc/openocd.texi: add entry describing atsamv user signature area Adds documentation entry for newly added possibility to program ATSAMV family embedded flash signature area page. Change-Id: I3bbaba304868dca49d6dd7006276d2d3a95facad Signed-off-by: Michal Lenc <mic...@se...> Reviewed-on: https://review.openocd.org/c/openocd/+/9096 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 22c7fcedd..4d8f79558 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -6965,6 +6965,18 @@ This driver uses the same command names/syntax as @xref{at91sam3}. flash bank $_FLASHNAME atsamv 0x00400000 0 0 0 $_TARGETNAME @end example +These families also have a user signature area located at the beginning +of an embedded flash. This is a 512 bytes large page whose data are not +erased by assering ERASE pin or by software ERASE command. It can be +used to store configuration, keys, trimming values and so on. The area +overlaps with the beginning of standard flash and uses special commands +to perform write/read operations. OpenOCD locates the signature area +at fake address above 32 bit address space, specifically at 0x100000000. + +@example +flash bank $_SIGNATURENAME atsamv 0x100000000 0 0 0 $_TARGETNAME +@end example + @deffn {Command} {atsamv gpnvm} [@option{show} [@option{all}|number]] @deffnx {Command} {atsamv gpnvm} (@option{clr}|@option{set}) number With no parameters, @option{show} or @option{show all}, ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 12 ++++++++++++ 1 file changed, 12 insertions(+) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-29 12:08:03
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via fcbe243c0b7543d5a46c72d44117104368236c58 (commit) via 0819c3939f1f9d331b262a07565311efacc1b8d8 (commit) from 5d333337b667121077df317e377b120d9fea4ca3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit fcbe243c0b7543d5a46c72d44117104368236c58 Author: Tomas Vanek <va...@fb...> Date: Mon Jul 28 09:50:55 2025 +0200 flash/nor/atsamv: reduce flash driver verbosity Remove useless LOG_INFO in samv_flash_bank_command(). Change LOG_INFO to LOG_DEBUG in samv_erase(). Change-Id: I46923ea4f020197ba902b1a7226cc8ee91831a5a Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/9061 Reviewed-by: zapb <de...@za...> Reviewed-by: Michal Lenc <mic...@se...> Tested-by: jenkins diff --git a/src/flash/nor/atsamv.c b/src/flash/nor/atsamv.c index 3cad1e113..c8de90900 100644 --- a/src/flash/nor/atsamv.c +++ b/src/flash/nor/atsamv.c @@ -410,7 +410,6 @@ static int samv_protect_check(struct flash_bank *bank) FLASH_BANK_COMMAND_HANDLER(samv_flash_bank_command) { - LOG_INFO("flash bank command"); struct samv_flash_bank *samv_info; samv_info = calloc(1, sizeof(struct samv_flash_bank)); bank->driver_priv = samv_info; @@ -510,12 +509,12 @@ static int samv_erase(struct flash_bank *bank, unsigned int first, if ((first == 0) && ((last + 1) == bank->num_sectors)) return samv_efc_perform_command(bank->target, SAMV_EFC_FCMD_EA, 0, NULL); - LOG_INFO("erasing lock regions %u-%u...", first, last); + LOG_DEBUG("erasing lock regions %u-%u...", first, last); for (unsigned int i = first; i <= last; i++) { uint32_t status; r = samv_erase_pages(bank->target, (i * page_count), page_count, &status); - LOG_INFO("erasing lock region %u", i); + LOG_DEBUG("erasing lock region %u", i); if (r != ERROR_OK) LOG_ERROR("error performing erase page @ lock region number %u", i); if (status & (1 << 2)) { commit 0819c3939f1f9d331b262a07565311efacc1b8d8 Author: Tomas Vanek <va...@fb...> Date: Mon Jul 28 09:36:18 2025 +0200 tcl/target/atsamv: disable watchdog in reset-init event Prevent disrupting of 'flash erase_check' or 'flash verify_image' running longer than 16 seconds. Change-Id: I545a1155ac0d237c49f2f3a27235d8a67df2a61b Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/9060 Tested-by: jenkins Reviewed-by: Michal Lenc <mic...@se...> diff --git a/tcl/target/atsamv.cfg b/tcl/target/atsamv.cfg index 1adf1af0e..9fd89795b 100644 --- a/tcl/target/atsamv.cfg +++ b/tcl/target/atsamv.cfg @@ -41,6 +41,11 @@ target create $_TARGETNAME cortex_m -endian $_ENDIAN -dap $_CHIPNAME.dap $_TARGETNAME configure -work-area-phys 0x20400000 -work-area-size $_WORKAREASIZE -work-area-backup 0 +$_TARGETNAME configure -event reset-init { + # WDT_MR = WDDIS (disable watchdog) + mww 0x400E1854 0x8000 +} + adapter speed 1800 if {![using_hla]} { ----------------------------------------------------------------------- Summary of changes: src/flash/nor/atsamv.c | 5 ++--- tcl/target/atsamv.cfg | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-29 12:07:34
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 5d333337b667121077df317e377b120d9fea4ca3 (commit) from e971d677c0a5a8b55c257886466e7bfd3a73ce54 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 5d333337b667121077df317e377b120d9fea4ca3 Author: Michal Lenc <mic...@se...> Date: Fri May 31 11:27:38 2024 +0200 atsamv: add support for user signature partition write Embedded flash also has a user signature area. This is a 512 bytes large page whose data are not erased by asserting ERASE pin or by software ERASE command. It may be used to store configuration, keys, trimming values etc. This commit adds option to access this area from OpenOCD. Change-Id: If870aa85938b9cccd94f958dd1f3d93dbdf779f0 Signed-off-by: Michal Lenc <mic...@se...> Reviewed-on: https://review.openocd.org/c/openocd/+/8302 Reviewed-by: Tomas Vanek <va...@fb...> Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/src/flash/nor/atsamv.c b/src/flash/nor/atsamv.c index 56db23d36..3cad1e113 100644 --- a/src/flash/nor/atsamv.c +++ b/src/flash/nor/atsamv.c @@ -12,6 +12,9 @@ * atsamv, atsams, and atsame support * Copyright (C) 2015 Morgan Quigley * + * atsamv extension of user signature area + * Copyright (C) 2024-2025 Elektroline Inc. + * * Some of the lower level code was based on code supplied by * ATMEL under BSD-Source-Code License and this copyright. * ATMEL Microcontroller Software Support @@ -24,6 +27,7 @@ #include "imp.h" #include <helper/time_support.h> +#include <helper/bits.h> #define REG_NAME_WIDTH (12) @@ -40,18 +44,39 @@ #define SAMV_EFC_FCMD_SFB (0xB) /* (EFC) Set Fuse Bit */ #define SAMV_EFC_FCMD_CFB (0xC) /* (EFC) Clear Fuse Bit */ #define SAMV_EFC_FCMD_GFB (0xD) /* (EFC) Get Fuse Bit */ +#define SAMV_EFC_FCMD_WUS (0x12) /* (EFC) Write User Signature */ +#define SAMV_EFC_FCMD_EUS (0x13) /* (EFC) Erase User Signature */ +#define SAMV_EFC_FCMD_STUS (0x14) /* (EFC) Start Read User Signature */ +#define SAMV_EFC_FCMD_SPUS (0x15) /* (EFC) Stop Read User Signature */ + +#define SAMV_EFC_FMR_SCOD BIT(16) /* Sequantial Code Optimalization Disable */ + +#define SAMV_EFC_FSR_FRDY_SET 1 +#define SAMV_EFC_FRS_FRDY_CLR 0 #define OFFSET_EFC_FMR 0 #define OFFSET_EFC_FCR 4 #define OFFSET_EFC_FSR 8 #define OFFSET_EFC_FRR 12 +#define TIMEOUT_MS_FRS_CHANGE 10 /* Timeout for FRS ready bit change */ +#define TIMEOUT_MS_CMD_DEFAULT 50 /* Default timeout for command */ +#define TIMEOUT_MS_CMD_ERASE 24000 /* Timeout for erase commands */ + #define SAMV_CHIPID_CIDR (0x400E0940) #define SAMV_NUM_GPNVM_BITS 9 #define SAMV_CONTROLLER_ADDR (0x400e0c00) #define SAMV_SECTOR_SIZE 16384 #define SAMV_PAGE_SIZE 512 #define SAMV_FLASH_BASE 0x00400000 +/* This is a workaround. Flash Signature area is actually located at the + * beginning of the flash memory at the address range overlapping the + * first page of program flash. Since OpenOCD does not support write to + * a bank outside of address range, we use address above maximum 32-bit + * address space. + */ +#define SAMV_FLASH_SIGNATURE_BASE 0x100000000 +#define SAMV_FLASH_SIGNATURE_SIZE SAMV_PAGE_SIZE struct samv_flash_bank { bool probed; @@ -59,6 +84,7 @@ struct samv_flash_bank { unsigned int gpnvm[SAMV_NUM_GPNVM_BITS]; }; + /* The actual sector size of the SAMV7 flash memory is 128K bytes. * 16 sectors for a 2048KB device. The lock regions are 16KB per lock * region, with a 2048KB device having 128 lock regions. @@ -72,6 +98,36 @@ static int samv_efc_get_status(struct target *target, uint32_t *v) return r; } +static int samv_efc_wait_status(struct target *target, uint8_t desired, + int64_t timeout, uint32_t *status) +{ + uint32_t v; + int64_t ms_now, ms_end; + int r; + + if (status) + *status = 0; + + ms_end = timeout + timeval_ms(); + + do { + r = samv_efc_get_status(target, &v); + if (r != ERROR_OK) + return r; + + if (status) + *status = v; + ms_now = timeval_ms(); + if (ms_now > ms_end) { + /* error */ + LOG_ERROR("Command timeout"); + return ERROR_FLASH_BUSY; + } + } while ((v & 1) != desired); + + return ERROR_OK; +} + static int samv_efc_get_result(struct target *target, uint32_t *v) { uint32_t rv; @@ -81,15 +137,20 @@ static int samv_efc_get_result(struct target *target, uint32_t *v) return r; } +static inline int samv_efc_get_mode(struct target *target, uint32_t *v) +{ + return target_read_u32(target, SAMV_CONTROLLER_ADDR + OFFSET_EFC_FMR, v); +} + +static inline int samv_efc_set_mode(struct target *target, uint32_t v) +{ + return target_write_u32(target, SAMV_CONTROLLER_ADDR + OFFSET_EFC_FMR, v); +} + static int samv_efc_start_command(struct target *target, - unsigned int command, unsigned int argument) + uint8_t command, unsigned int argument) { uint32_t v; - samv_efc_get_status(target, &v); - if (!(v & 1)) { - LOG_ERROR("flash controller is not ready"); - return ERROR_FAIL; - } v = (0x5A << 24) | (argument << 8) | command; LOG_DEBUG("starting flash command: 0x%08x", (unsigned int)(v)); @@ -100,32 +161,33 @@ static int samv_efc_start_command(struct target *target, } static int samv_efc_perform_command(struct target *target, - unsigned int command, unsigned int argument, uint32_t *status) + uint8_t command, unsigned int argument, uint32_t *status) { int r; uint32_t v; - int64_t ms_now, ms_end; + int64_t timeout; if (status) *status = 0; + r = samv_efc_get_status(target, &v); + if (r != ERROR_OK) + return r; + if ((v & 1) != 0x1) + return ERROR_FAIL; r = samv_efc_start_command(target, command, argument); if (r != ERROR_OK) return r; - ms_end = 10000 + timeval_ms(); + if (command == SAMV_EFC_FCMD_EA || command == SAMV_EFC_FCMD_EPA || + command == SAMV_EFC_FCMD_EUS) + timeout = TIMEOUT_MS_CMD_ERASE; + else + timeout = TIMEOUT_MS_CMD_DEFAULT; - do { - r = samv_efc_get_status(target, &v); - if (r != ERROR_OK) - return r; - ms_now = timeval_ms(); - if (ms_now > ms_end) { - /* error */ - LOG_ERROR("Command timeout"); - return ERROR_FAIL; - } - } while ((v & 1) == 0); + r = samv_efc_wait_status(target, SAMV_EFC_FSR_FRDY_SET, timeout, &v); + if (r != ERROR_OK) + return r; /* if requested, copy the flash controller error bits back to the caller */ if (status) @@ -133,6 +195,51 @@ static int samv_efc_perform_command(struct target *target, return ERROR_OK; } +static int samv_efc_read_sequence(struct target *target, uint8_t start_cmd, + uint8_t stop_cmd, uint8_t *buf, size_t read_size) +{ + uint32_t v; + uint32_t addr = SAMV_FLASH_BASE; + int r; + + samv_efc_get_mode(target, &v); + v |= SAMV_EFC_FMR_SCOD; + samv_efc_set_mode(target, v); + + r = samv_efc_start_command(target, start_cmd, 0); + if (r != ERROR_OK) { + samv_efc_start_command(target, stop_cmd, 0); + goto rs_finish; + } + + r = samv_efc_wait_status(target, SAMV_EFC_FRS_FRDY_CLR, + TIMEOUT_MS_FRS_CHANGE, NULL); + if (r != ERROR_OK) + goto rs_finish; + + r = target_read_memory(target, addr, sizeof(uint32_t), + read_size / sizeof(uint32_t), buf); + if (r != ERROR_OK) { + LOG_ERROR("flash program failed to read page @ 0x%" PRIx32 "", addr); + goto rs_finish; + } + + r = samv_efc_start_command(target, stop_cmd, 0); + if (r != ERROR_OK) + goto rs_finish; + + r = samv_efc_wait_status(target, SAMV_EFC_FSR_FRDY_SET, + TIMEOUT_MS_FRS_CHANGE, NULL); + if (r != ERROR_OK) + goto rs_finish; + +rs_finish: + v &= ~SAMV_EFC_FMR_SCOD; + samv_efc_set_mode(target, v); + + return r; +} + static int samv_erase_pages(struct target *target, int first_page, int num_pages, uint32_t *status) { @@ -230,6 +337,17 @@ static int samv_set_gpnvm(struct target *target, unsigned int gpnvm) return r; } +static int samv_erase_user_signature(struct target *target) +{ + int r; + + r = samv_efc_perform_command(target, SAMV_EFC_FCMD_EUS, 0, NULL); + if (r != ERROR_OK) + LOG_ERROR("error performing user signature write"); + + return r; +} + static int samv_flash_unlock(struct target *target, unsigned int start_sector, unsigned int end_sector) { @@ -306,6 +424,14 @@ static int samv_get_device_id(struct flash_bank *bank, uint32_t *device_id) static int samv_probe(struct flash_bank *bank) { + if (bank->base == SAMV_FLASH_SIGNATURE_BASE) { + bank->size = SAMV_FLASH_SIGNATURE_SIZE; + bank->num_sectors = 1; + bank->sectors = calloc(bank->num_sectors, sizeof(struct flash_sector)); + bank->sectors[0].size = SAMV_FLASH_SIGNATURE_SIZE; + return ERROR_OK; + } + uint32_t device_id; int r = samv_get_device_id(bank, &device_id); if (r != ERROR_OK) @@ -377,6 +503,9 @@ static int samv_erase(struct flash_bank *bank, unsigned int first, if (r != ERROR_OK) return r; + if (bank->base == SAMV_FLASH_SIGNATURE_BASE) + return samv_erase_user_signature(bank->target); + /* easy case: we've been requested to erase the entire flash */ if ((first == 0) && ((last + 1) == bank->num_sectors)) return samv_efc_perform_command(bank->target, SAMV_EFC_FCMD_EA, 0, NULL); @@ -418,45 +547,134 @@ static int samv_protect(struct flash_bank *bank, int set, unsigned int first, return r; } -static int samv_page_read(struct target *target, +static int samv_read_standard_page(struct target *target, unsigned int page_num, uint8_t *buf) { uint32_t addr = SAMV_FLASH_BASE + page_num * SAMV_PAGE_SIZE; int r = target_read_memory(target, addr, 4, SAMV_PAGE_SIZE / 4, buf); if (r != ERROR_OK) - LOG_ERROR("flash program failed to read page @ 0x%08x", - (unsigned int)(addr)); + LOG_ERROR("flash program failed to read page @ 0x%08" PRIx32 "", + addr); return r; } -static int samv_page_write(struct target *target, +static int samv_read_user_signature(struct target *target, uint8_t *buf) +{ + int r; + + r = samv_efc_read_sequence(target, SAMV_EFC_FCMD_STUS, SAMV_EFC_FCMD_SPUS, + buf, SAMV_PAGE_SIZE); + + return r; +} + +static int samv_page_read(struct target *target, + target_addr_t base, unsigned int page_num, uint8_t *buf) +{ + int r; + if (base == SAMV_FLASH_SIGNATURE_BASE) + r = samv_read_user_signature(target, buf); + else + r = samv_read_standard_page(target, page_num, buf); + + return r; +} + +static int samv_write_user_signature(struct target *target, + unsigned int pagenum, const uint8_t *buf) +{ + const uint32_t addr = SAMV_FLASH_BASE; + int r; + + r = target_write_memory(target, addr, sizeof(uint32_t), + SAMV_PAGE_SIZE / sizeof(uint32_t), buf); + if (r != ERROR_OK) { + LOG_ERROR("failed to buffer page at 0x%08" PRIx32 "", addr); + return r; + } + + r = samv_efc_perform_command(target, SAMV_EFC_FCMD_WUS, 0, NULL); + if (r != ERROR_OK) + LOG_ERROR("error performing user signature write"); + + return r; +} + +static int samv_write_standard_page(struct target *target, unsigned int pagenum, const uint8_t *buf) { uint32_t status; const uint32_t addr = SAMV_FLASH_BASE + pagenum * SAMV_PAGE_SIZE; int r; - LOG_DEBUG("write page %u at address 0x%08x", pagenum, (unsigned int)addr); + LOG_DEBUG("write page %u at address 0x%08" PRIx32 "", pagenum, addr); r = target_write_memory(target, addr, 4, SAMV_PAGE_SIZE / 4, buf); if (r != ERROR_OK) { - LOG_ERROR("failed to buffer page at 0x%08x", (unsigned int)addr); + LOG_ERROR("failed to buffer page at 0x%08" PRIx32 "", addr); return r; } r = samv_efc_perform_command(target, SAMV_EFC_FCMD_WP, pagenum, &status); if (r != ERROR_OK) - LOG_ERROR("error performing write page at 0x%08x", (unsigned int)addr); + LOG_ERROR("error performing write page at 0x%08" PRIx32 "", addr); if (status & (1 << 2)) { - LOG_ERROR("page at 0x%08x is locked", (unsigned int)addr); + LOG_ERROR("page at 0x%08" PRIx32 " is locked", addr); return ERROR_FAIL; } if (status & (1 << 1)) { - LOG_ERROR("flash command error at 0x%08x", (unsigned int)addr); + LOG_ERROR("flash command error at 0x%08" PRIx32 "", addr); return ERROR_FAIL; } return ERROR_OK; } +static int samv_page_write(struct target *target, + target_addr_t base, unsigned int pagenum, const uint8_t *buf) +{ + int r; + if (base == SAMV_FLASH_SIGNATURE_BASE) + r = samv_write_user_signature(target, pagenum, buf); + else + r = samv_write_standard_page(target, pagenum, buf); + + return r; +} + +static int samv_read(struct flash_bank *bank, uint8_t *buffer, + uint32_t offset, uint32_t count) +{ + int r; + uint8_t pagebuffer[SAMV_PAGE_SIZE] = {0}; + struct target *target = bank->target; + + LOG_DEBUG("offset=0x%08" PRIx32 " count=0x%08" PRIx32 "", offset, count); + + if (target->state != TARGET_HALTED) { + LOG_ERROR("Target not halted"); + return ERROR_TARGET_NOT_HALTED; + } + + if (offset + count > bank->size) { + LOG_WARNING("Reads past end of flash. Extra data discarded."); + count = bank->size - offset; + } + + LOG_DEBUG("offset: 0x%08" PRIx32 ", count: 0x%08" PRIx32 "", offset, count); + + if (bank->base == SAMV_FLASH_SIGNATURE_BASE) { + r = samv_read_user_signature(target, pagebuffer); + if (r != ERROR_OK) + return r; + memcpy(buffer, pagebuffer + offset, count); + } else { + r = target_read_memory(target, offset, 1, count, buffer); + if (r != ERROR_OK) + return r; + } + + return ERROR_OK; +} + static int samv_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t offset, uint32_t count) { @@ -470,10 +688,10 @@ static int samv_write(struct flash_bank *bank, const uint8_t *buffer, if ((offset + count) > bank->size) { LOG_ERROR("flash write error - past end of bank"); - LOG_ERROR(" offset: 0x%08x, count 0x%08x, bank end: 0x%08x", - (unsigned int)(offset), - (unsigned int)(count), - (unsigned int)(bank->size)); + LOG_ERROR(" offset: 0x%08" PRIx32 ", count 0x%08" PRIx32 ", bank end: 0x%08" PRIx32 "", + offset, + count, + bank->size); return ERROR_FAIL; } @@ -481,9 +699,8 @@ static int samv_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t page_cur = offset / SAMV_PAGE_SIZE; uint32_t page_end = (offset + count - 1) / SAMV_PAGE_SIZE; - LOG_DEBUG("offset: 0x%08x, count: 0x%08x", - (unsigned int)(offset), (unsigned int)(count)); - LOG_DEBUG("page start: %d, page end: %d", (int)(page_cur), (int)(page_end)); + LOG_DEBUG("offset: 0x%08" PRIx32 ", count: 0x%08" PRIx32 "", offset, count); + LOG_DEBUG("page start: %" PRIu32 ", page end: %" PRIu32 "", page_cur, page_end); /* Special case: all one page */ /* Otherwise: */ @@ -497,14 +714,14 @@ static int samv_write(struct flash_bank *bank, const uint8_t *buffer, /* handle special case - all one page. */ if (page_cur == page_end) { LOG_DEBUG("special case, all in one page"); - r = samv_page_read(bank->target, page_cur, pagebuffer); + r = samv_page_read(bank->target, bank->base, page_cur, pagebuffer); if (r != ERROR_OK) return r; - page_offset = offset & (SAMV_PAGE_SIZE-1); + page_offset = offset & (SAMV_PAGE_SIZE - 1); memcpy(pagebuffer + page_offset, buffer, count); - r = samv_page_write(bank->target, page_cur, pagebuffer); + r = samv_page_write(bank->target, bank->base, page_cur, pagebuffer); if (r != ERROR_OK) return r; return ERROR_OK; @@ -515,7 +732,7 @@ static int samv_write(struct flash_bank *bank, const uint8_t *buffer, if (page_offset) { LOG_DEBUG("non-aligned start"); /* read the partial page */ - r = samv_page_read(bank->target, page_cur, pagebuffer); + r = samv_page_read(bank->target, bank->base, page_cur, pagebuffer); if (r != ERROR_OK) return r; @@ -523,11 +740,11 @@ static int samv_write(struct flash_bank *bank, const uint8_t *buffer, uint32_t n = SAMV_PAGE_SIZE - page_offset; memcpy(pagebuffer + page_offset, buffer, n); - r = samv_page_write(bank->target, page_cur, pagebuffer); + r = samv_page_write(bank->target, bank->base, page_cur, pagebuffer); if (r != ERROR_OK) return r; - count -= n; + count -= n; offset += n; buffer += n; page_cur++; @@ -537,11 +754,11 @@ static int samv_write(struct flash_bank *bank, const uint8_t *buffer, assert(offset % SAMV_PAGE_SIZE == 0); /* step 2) handle the full pages */ - LOG_DEBUG("full page loop: cur=%d, end=%d, count = 0x%08x", - (int)page_cur, (int)page_end, (unsigned int)(count)); + LOG_DEBUG("full page loop: cur=%" PRIu32 ", end=%" PRIu32 ", count = 0x%08" PRIx32 "", + page_cur, page_end, count); while ((page_cur < page_end) && (count >= SAMV_PAGE_SIZE)) { - r = samv_page_write(bank->target, page_cur, buffer); + r = samv_page_write(bank->target, bank->base, page_cur, buffer); if (r != ERROR_OK) return r; count -= SAMV_PAGE_SIZE; @@ -551,13 +768,13 @@ static int samv_write(struct flash_bank *bank, const uint8_t *buffer, /* step 3) write final page, if it's partial (otherwise it's already done) */ if (count) { - LOG_DEBUG("final partial page, count = 0x%08x", (unsigned int)(count)); + LOG_DEBUG("final partial page, count = 0x%08" PRIx32 "", count); /* we have a partial page */ - r = samv_page_read(bank->target, page_cur, pagebuffer); + r = samv_page_read(bank->target, bank->base, page_cur, pagebuffer); if (r != ERROR_OK) return r; memcpy(pagebuffer, buffer, count); /* data goes at start of page */ - r = samv_page_write(bank->target, page_cur, pagebuffer); + r = samv_page_write(bank->target, bank->base, page_cur, pagebuffer); if (r != ERROR_OK) return r; } @@ -691,7 +908,7 @@ const struct flash_driver atsamv_flash = { .erase = samv_erase, .protect = samv_protect, .write = samv_write, - .read = default_flash_read, + .read = samv_read, .probe = samv_probe, .auto_probe = samv_auto_probe, .erase_check = default_flash_blank_check, diff --git a/tcl/target/atsamv.cfg b/tcl/target/atsamv.cfg index 7e9f6c57e..1adf1af0e 100644 --- a/tcl/target/atsamv.cfg +++ b/tcl/target/atsamv.cfg @@ -58,4 +58,6 @@ if {![using_hla]} { } set _FLASHNAME $_CHIPNAME.flash +set _SIGNATURENAME $_CHIPNAME.usersignature flash bank $_FLASHNAME atsamv 0x00400000 0 0 0 $_TARGETNAME +flash bank $_SIGNATURENAME atsamv 0x100000000 0 0 0 $_TARGETNAME ----------------------------------------------------------------------- Summary of changes: src/flash/nor/atsamv.c | 315 +++++++++++++++++++++++++++++++++++++++++-------- tcl/target/atsamv.cfg | 2 + 2 files changed, 268 insertions(+), 49 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-27 14:37:15
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via e971d677c0a5a8b55c257886466e7bfd3a73ce54 (commit) via 96c219a40848710c8d94a08f235c12f4d6202c9e (commit) from 56d67dac2eebf44b2d34e9aba13359e3e3947975 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit e971d677c0a5a8b55c257886466e7bfd3a73ce54 Author: Antonio Borneo <bor...@gm...> Date: Sun Aug 24 12:36:09 2025 +0200 drivers ch347: drop useless initialization Drop some useless initialization in the driver. Replace a constant value returned through a variable with the value itself. Change-Id: I7b7c0b30c6d36e9763ff78bf826742792546fa7f Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9095 Tested-by: jenkins Reviewed-by: Matthias Jentsch <in...@ea...> Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c index a0404a21f..6a848ba7c 100644 --- a/src/jtag/drivers/ch347.c +++ b/src/jtag/drivers/ch347.c @@ -793,11 +793,10 @@ static int ch347_cmd_start_next(uint8_t type) { // different command type or non chainable command? (GPIO commands can't be concat) uint8_t prev_type = ch347.scratchpad_cmd_type; - int retval = ERROR_OK; if (prev_type != type || ch347_is_single_cmd_type(type)) { // something written in the scratchpad? => store it as command if (prev_type != 0 && ch347.scratchpad_idx > 0) { - retval = ch347_cmd_from_scratchpad(); + int retval = ch347_cmd_from_scratchpad(); if (retval != ERROR_OK) return retval; @@ -813,7 +812,7 @@ static int ch347_cmd_start_next(uint8_t type) /* before we can send non chainable command ("single" like GPIO command) we should send all other commands because we can't send it together with other commands */ if (ch347_is_single_cmd_type(type)) { - retval = ch347_cmd_transmit_queue(); + int retval = ch347_cmd_transmit_queue(); if (retval != ERROR_OK) return retval; } @@ -822,7 +821,7 @@ static int ch347_cmd_start_next(uint8_t type) ch347.scratchpad_cmd_type = type; } - return retval; + return ERROR_OK; } /** @@ -980,16 +979,15 @@ static int ch347_scratchpad_add_clock_tms(bool tms) */ static int ch347_scratchpad_add_stableclocks(int count) { - int retval = ERROR_OK; if (ch347.scratchpad_cmd_type == 0) { - retval = ch347_cmd_start_next(CH347_CMD_JTAG_BIT_OP); + int retval = ch347_cmd_start_next(CH347_CMD_JTAG_BIT_OP); if (retval != ERROR_OK) return retval; } bool tms = ch347.tms_pin == TMS_H; for (int i = 0; i < count; i++) { - retval = ch347_scratchpad_add_clock_tms(tms); + int retval = ch347_scratchpad_add_clock_tms(tms); if (retval != ERROR_OK) return retval; } @@ -1197,7 +1195,7 @@ static int ch347_scratchpad_add_write_read(struct scan_command *cmd, uint8_t *bi static int ch347_scratchpad_add_run_test(int cycles, enum tap_state state) { LOG_DEBUG_IO("cycles=%d, end_state=%d", cycles, state); - int retval = ERROR_OK; + int retval; if (tap_get_state() != TAP_IDLE) { retval = ch347_scratchpad_add_move_state(TAP_IDLE, 0); if (retval != ERROR_OK) @@ -1226,7 +1224,7 @@ static int ch347_scratchpad_add_scan(struct scan_command *cmd) int scan_bits = jtag_build_buffer(cmd, &buf); // add a move to IRSHIFT or DRSHIFT state - int retval = ERROR_OK; + int retval; if (cmd->ir_scan) retval = ch347_scratchpad_add_move_state(TAP_IRSHIFT, 0); else commit 96c219a40848710c8d94a08f235c12f4d6202c9e Author: Antonio Borneo <bor...@gm...> Date: Sun Aug 24 12:30:52 2025 +0200 drivers: ch347: fix scan-build warnings The newly merged driver ch347 triggers two new scan-build warnings about dead assignment to variables. Fix them. Change-Id: Ided14272c3573be1498584e68ac4653cde029f31 Signed-off-by: Antonio Borneo <bor...@gm...> Fixes: 7d0e12589629 ("jtag/drivers: Add support for CH347-based JTAG adapters") Reviewed-on: https://review.openocd.org/c/openocd/+/9094 Tested-by: jenkins Reviewed-by: Matthias Jentsch <in...@ea...> Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c index 8f563acaf..a0404a21f 100644 --- a/src/jtag/drivers/ch347.c +++ b/src/jtag/drivers/ch347.c @@ -863,7 +863,6 @@ static int ch347_single_read_get_byte(int read_buf_idx, uint8_t *byte) if (read_buf_idx > CH347_SINGLE_CMD_MAX_READ || read_buf_idx < 0) { LOG_ERROR("read_buf_idx out of range"); - read_buf_idx = 0; return ERROR_FAIL; } @@ -989,7 +988,6 @@ static int ch347_scratchpad_add_stableclocks(int count) } bool tms = ch347.tms_pin == TMS_H; - retval = ERROR_OK; for (int i = 0; i < count; i++) { retval = ch347_scratchpad_add_clock_tms(tms); if (retval != ERROR_OK) ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/ch347.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-24 11:20:21
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 56d67dac2eebf44b2d34e9aba13359e3e3947975 (commit) from f381945567096763548b9daeb2ef9a5c58b66251 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 56d67dac2eebf44b2d34e9aba13359e3e3947975 Author: Daniel Anselmi <dan...@gm...> Date: Mon Aug 18 23:17:09 2025 +0200 flash/nor/max32: fix: call to calloc With gcc 15.2.1 we get the following error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument. Change-Id: Ib34d758bc09d34d86d29dd02ea9c7f05b1e83327 Signed-off-by: Daniel Anselmi <dan...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9014 Reviewed-by: zapb <de...@za...> Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/flash/nor/max32xxx.c b/src/flash/nor/max32xxx.c index ed6083441..e91b9b67d 100644 --- a/src/flash/nor/max32xxx.c +++ b/src/flash/nor/max32xxx.c @@ -113,7 +113,7 @@ FLASH_BANK_COMMAND_HANDLER(max32xxx_flash_bank_command) return ERROR_FLASH_BANK_INVALID; } - info = calloc(sizeof(struct max32xxx_flash_bank), 1); + info = calloc(1, sizeof(struct max32xxx_flash_bank)); COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], info->flash_size); COMMAND_PARSE_NUMBER(u32, CMD_ARGV[6], info->flc_base); COMMAND_PARSE_NUMBER(u32, CMD_ARGV[7], info->sector_size); ----------------------------------------------------------------------- Summary of changes: src/flash/nor/max32xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-24 11:19:54
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via f381945567096763548b9daeb2ef9a5c58b66251 (commit) from 65b886812bc0ea4d6d31b58a5786159e1f48c323 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit f381945567096763548b9daeb2ef9a5c58b66251 Author: Marc Schink <de...@za...> Date: Sun Aug 17 12:38:36 2025 +0200 tcl/file_renaming: Remove simple renames The target configuration entries are simple renames and are handled automatically. Change-Id: Icae6b9b0f20b3c31df2900119f9ed2dadb2b768a Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9085 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/tcl/file_renaming.cfg b/tcl/file_renaming.cfg index 6f88ddd90..8950f6cd6 100644 --- a/tcl/file_renaming.cfg +++ b/tcl/file_renaming.cfg @@ -20,8 +20,4 @@ set _file_renaming { board/stm32mp13x_dk.cfg board/st/stm32mp135f-dk.cfg board/stm32mp15x_dk2.cfg board/st/stm32mp157f-dk2.cfg board/sifive-hifive1-revb.cfg board/sifive/hifive1-rev-b.cfg - target/nrf51.cfg target/nordic/nrf51.cfg - target/nrf52.cfg target/nordic/nrf52.cfg - target/nrf53.cfg target/nordic/nrf53.cfg - target/nrf91.cfg target/nordic/nrf91.cfg } ----------------------------------------------------------------------- Summary of changes: tcl/file_renaming.cfg | 4 ---- 1 file changed, 4 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-24 11:19:22
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 65b886812bc0ea4d6d31b58a5786159e1f48c323 (commit) via 23ab2062e7f0ae40b33abc6c5477388978f6dc48 (commit) from 4e493229c6c2d84e8f52341be0328ce31e57a6f2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 65b886812bc0ea4d6d31b58a5786159e1f48c323 Author: Marc Schink <de...@za...> Date: Thu Aug 14 15:01:27 2025 +0200 tcl/board: Move SiFive configs into vendor directory Move the configuration files into a dedicated vendor folder as required by the developer guidelines. Change-Id: I5bf048f2d8d0fccbcfe40e0a0e7b30dfbab192d1 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9082 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/src/helper/startup.tcl b/src/helper/startup.tcl index e328cbe07..89ed71b90 100644 --- a/src/helper/startup.tcl +++ b/src/helper/startup.tcl @@ -39,7 +39,7 @@ proc find {filename} { return $t } - foreach vendor {nordic ti st} { + foreach vendor {nordic ti sifive st} { # - path/to/a/certain/config_file # replaced with # - path/to/a/certain/${vendor}/config_file diff --git a/tcl/board/sifive-e31arty.cfg b/tcl/board/sifive/e31-arty.cfg similarity index 94% rename from tcl/board/sifive-e31arty.cfg rename to tcl/board/sifive/e31-arty.cfg index b3e980f40..bdf79dae6 100644 --- a/tcl/board/sifive-e31arty.cfg +++ b/tcl/board/sifive/e31-arty.cfg @@ -3,7 +3,7 @@ # # Be sure you include the speed and interface before this file # Example: -# -c "adapter speed 5000" -f "interface/ftdi/olimex-arm-usb-tiny-h.cfg" -f "board/sifive-e31arty.cfg" +# -c "adapter speed 5000" -f "interface/ftdi/olimex-arm-usb-tiny-h.cfg" -f "board/sifive/e31-arty.cfg" set _CHIPNAME riscv jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000001 diff --git a/tcl/board/sifive-e51arty.cfg b/tcl/board/sifive/e51-arty.cfg similarity index 94% rename from tcl/board/sifive-e51arty.cfg rename to tcl/board/sifive/e51-arty.cfg index 3133c3902..1476d503e 100644 --- a/tcl/board/sifive-e51arty.cfg +++ b/tcl/board/sifive/e51-arty.cfg @@ -3,7 +3,7 @@ # # Be sure you include the speed and interface before this file # Example: -# -c "adapter speed 5000" -f "interface/ftdi/olimex-arm-usb-tiny-h.cfg" -f "board/sifive-e51arty.cfg" +# -c "adapter speed 5000" -f "interface/ftdi/olimex-arm-usb-tiny-h.cfg" -f "board/sifive/e51-arty.cfg" set _CHIPNAME riscv jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20000001 diff --git a/tcl/board/sifive-hifive1-revb.cfg b/tcl/board/sifive/hifive1-rev-b.cfg similarity index 100% rename from tcl/board/sifive-hifive1-revb.cfg rename to tcl/board/sifive/hifive1-rev-b.cfg diff --git a/tcl/board/sifive-hifive1.cfg b/tcl/board/sifive/hifive1.cfg similarity index 100% rename from tcl/board/sifive-hifive1.cfg rename to tcl/board/sifive/hifive1.cfg diff --git a/tcl/file_renaming.cfg b/tcl/file_renaming.cfg index 20679b6ab..6f88ddd90 100644 --- a/tcl/file_renaming.cfg +++ b/tcl/file_renaming.cfg @@ -19,6 +19,7 @@ set _file_renaming { board/nordic_nrf52_dk.cfg board/nordic/nrf52-dk.cfg board/stm32mp13x_dk.cfg board/st/stm32mp135f-dk.cfg board/stm32mp15x_dk2.cfg board/st/stm32mp157f-dk2.cfg + board/sifive-hifive1-revb.cfg board/sifive/hifive1-rev-b.cfg target/nrf51.cfg target/nordic/nrf51.cfg target/nrf52.cfg target/nordic/nrf52.cfg target/nrf53.cfg target/nordic/nrf53.cfg commit 23ab2062e7f0ae40b33abc6c5477388978f6dc48 Author: Parshintsev Anatoly <ana...@sy...> Date: Tue May 20 10:10:43 2025 +0300 server: global state updated by signal handlers should have a volatile sig_atomic_t type Signal handlers currently violate both C language and POSIX requirements: 1. To avoid undefined behavior (UB), variables accessed or modified by signal handlers be of atomic lock-free type. 2. The respected variables should be marked as volatile. 3. Signal handlers may only call a very limited subset of standard library functions. 4. Additionally, POSIX restricts signal handlers to signal-safe functions. This patch addresses the first two issues by changing the type of global variables that are accessed inside signal handler to `sig_atomic_t` and adding `volatile` qualifiers. Items 3 and 4 must be handled separately but are outside the scope of this change. Change-Id: I9c344e87bab9eefe7d99b0aad300a3ef4712df51 Signed-off-by: Parshintsev Anatoly <ana...@sy...> Reviewed-on: https://review.openocd.org/c/openocd/+/8927 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> Reviewed-by: Chris Head <ch...@za...> diff --git a/src/server/server.c b/src/server/server.c index 0649ec942..5f6bb584e 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -43,10 +43,10 @@ enum shutdown_reason { SHUTDOWN_WITH_ERROR_CODE, /* set by shutdown command; quit with non-zero return code */ SHUTDOWN_WITH_SIGNAL_CODE /* set by sig_handler; exec shutdown then exit with signal as return code */ }; -static enum shutdown_reason shutdown_openocd = CONTINUE_MAIN_LOOP; +static volatile sig_atomic_t shutdown_openocd = CONTINUE_MAIN_LOOP; /* store received signal to exit application by killing ourselves */ -static int last_signal; +static volatile sig_atomic_t last_signal; /* set the polling period to 100ms */ static int polling_period = 100; @@ -604,6 +604,7 @@ static void sig_handler(int sig) /* store only first signal that hits us */ if (shutdown_openocd == CONTINUE_MAIN_LOOP) { shutdown_openocd = SHUTDOWN_WITH_SIGNAL_CODE; + assert(sig >= SIG_ATOMIC_MIN && sig <= SIG_ATOMIC_MAX); last_signal = sig; LOG_DEBUG("Terminating on Signal %d", sig); } else ----------------------------------------------------------------------- Summary of changes: src/helper/startup.tcl | 2 +- src/server/server.c | 5 +++-- tcl/board/{sifive-e31arty.cfg => sifive/e31-arty.cfg} | 2 +- tcl/board/{sifive-e51arty.cfg => sifive/e51-arty.cfg} | 2 +- tcl/board/{sifive-hifive1-revb.cfg => sifive/hifive1-rev-b.cfg} | 0 tcl/board/{sifive-hifive1.cfg => sifive/hifive1.cfg} | 0 tcl/file_renaming.cfg | 1 + 7 files changed, 7 insertions(+), 5 deletions(-) rename tcl/board/{sifive-e31arty.cfg => sifive/e31-arty.cfg} (94%) rename tcl/board/{sifive-e51arty.cfg => sifive/e51-arty.cfg} (94%) rename tcl/board/{sifive-hifive1-revb.cfg => sifive/hifive1-rev-b.cfg} (100%) rename tcl/board/{sifive-hifive1.cfg => sifive/hifive1.cfg} (100%) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-24 11:18:47
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 4e493229c6c2d84e8f52341be0328ce31e57a6f2 (commit) from 160e2343bd7ab4f3b5f2bd8c89535709cc4bf519 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 4e493229c6c2d84e8f52341be0328ce31e57a6f2 Author: Ashi Gupta <qui...@qu...> Date: Fri Jan 10 15:35:14 2025 +0530 tcl/target: Added target configuration for Qualcomm QCS6490 IOT Processors. QCS6490 and QCM6490 are 6nm processors designed for enterprise and IOT applications featuring global 5G and Wi-Fi 6E support with similar architecture. This configuration file will allow debugging applications on these processors. Verified with Olimex(ARM-USB-OCD-H): openocd -f tcl/interface/ftdi/olimex-arm-usb-ocd-h.cfg -c 'transport select jtag' -f <path_to_qcs6490_cfg> and Jlink: openocd -f tcl/interface/jlink.cfg -c 'transport select jtag' -f <path_to_qcs6490_cfg> Change-Id: I05e923293134eaa9b70d3cf0d18efac9a024b6c7 Signed-off-by: Ashi Gupta <qui...@qu...> Reviewed-on: https://review.openocd.org/c/openocd/+/8615 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/tcl/target/qualcomm/qcs6490.cfg b/tcl/target/qualcomm/qcs6490.cfg new file mode 100644 index 000000000..d12708c8a --- /dev/null +++ b/tcl/target/qualcomm/qcs6490.cfg @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# The QCS6490/QCM6490 is a 6nm processor designed for enterprise and Internet of Things (IOT) applications, +# featuring global 5G and Wi-Fi 6E support +# +# Product Page: +# https://www.qualcomm.com/products/internet-of-things/industrial/building-enterprise/qcs6490 +# https://www.qualcomm.com/products/internet-of-things/industrial/building-enterprise/qcm6490 + +source [find target/swj-dp.tcl] + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME QCS6490 +} + +if { [info exists ENDIAN] } { + set _ENDIAN $ENDIAN +} else { + set _ENDIAN little +} + +adapter speed 500 +reset_config trst_and_srst + +# Set CUP TAP ID based on protocol selection +if { [using_jtag] } { + set _CPUTAPID 0x5ba00477 +} else { + set _CPUTAPID 0x5ba02477 +} + +swj_newdap $_CHIPNAME cpu -expected-id $_CPUTAPID -irlen 4 + +dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu -ignore-syspwrupack + +cti create $_CHIPNAME.cti -dap $_CHIPNAME.dap -baseaddr 0x87020000 -ap-num 1 + +target create $_CHIPNAME.cpu0 aarch64 -endian $_ENDIAN -dap $_CHIPNAME.dap -coreid 0 \ + -dbgbase 0x87010000 -cti $_CHIPNAME.cti -event reset-assert-post { dap init } + +$_CHIPNAME.cpu0 configure -event examine-end { + eval $_CHIPNAME.cpu0 arp_halt +} + +# Default breakpoints to hardware breakpoints +gdb_breakpoint_override hard ----------------------------------------------------------------------- Summary of changes: tcl/target/qualcomm/qcs6490.cfg | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tcl/target/qualcomm/qcs6490.cfg hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-24 11:17:59
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 160e2343bd7ab4f3b5f2bd8c89535709cc4bf519 (commit) from 7e403d9d3be58b1965f230831ac7bf84d5371189 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 160e2343bd7ab4f3b5f2bd8c89535709cc4bf519 Author: Marek Vrbka <mar...@co...> Date: Wed Aug 13 15:36:21 2025 +0200 replacements: make socket_select() work on Windows if no sockets are provided On Windows 11, if select() is called with empty sets, it fails and returns WSAINVAL. On POSIX this works fine. This patch addresses it by detecting this case in OpenOCD replacements and returning 0 in these cases. This fixes OpenOCD crash on Windows if no services are enabled (gdb server, tcl server and telnet server all disabled). Change-Id: I601878671caf4ae44e105d6a819251d2d96c607c Signed-off-by: Marek Vrbka <mar...@co...> Reviewed-on: https://review.openocd.org/c/openocd/+/9081 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/helper/replacements.c b/src/helper/replacements.c index 782d97518..9fb7b4a35 100644 --- a/src/helper/replacements.c +++ b/src/helper/replacements.c @@ -152,6 +152,21 @@ int win_select(int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds, struct time FD_ZERO(&sock_write); FD_ZERO(&sock_except); + /* On Windows, if all provided sets are empty/NULL an error code of -1 is returned + * and WSAGetLastError() returns WSAEINVAL instead of delaying. + * We check for this case, delay and return 0 instead of calling select(). */ + if (rfds && rfds->fd_count == 0) + rfds = NULL; + if (wfds && wfds->fd_count == 0) + wfds = NULL; + if (efds && efds->fd_count == 0) + efds = NULL; + if (!rfds && !wfds && !efds && tv) { + sleep(tv->tv_sec); + usleep(tv->tv_usec); + return 0; + } + /* build an array of handles for non-sockets */ for (i = 0; i < max_fd; i++) { if (SAFE_FD_ISSET(i, rfds) || SAFE_FD_ISSET(i, wfds) || SAFE_FD_ISSET(i, efds)) { ----------------------------------------------------------------------- Summary of changes: src/helper/replacements.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-24 11:16:56
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 7e403d9d3be58b1965f230831ac7bf84d5371189 (commit) via 93f16eed4d4db379671293277e9b6e7d5aba6c9b (commit) from 7effc6f825fe8aacfb15ea198994b212f55897cb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7e403d9d3be58b1965f230831ac7bf84d5371189 Author: Andreas Dannenberg <an...@mi...> Date: Wed Aug 13 21:22:11 2025 +0900 tcl/target: add Rockchip RK3588 target The Rockchip RK3588 SoC is used in systems such as the GenBook RK3588 open-hardware laptop and the Coolpi CM5 compute module. This patch adds support for debugging those. Tested using the ST-LINK/V2 debug adapter in SWD mode connected to the SDMMC_D2 (SWCLK) and SDMMC_D3 (SWDIO) pins on the 50-pin J17 connector inside the GenBook RK3588 laptop. Change-Id: Ia5da403054b6c9aa41184a4e092a74aa882a267d Signed-off-by: Andreas Dannenberg <an...@mi...> Reviewed-on: https://review.openocd.org/c/openocd/+/9013 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/tcl/target/rk3588.cfg b/tcl/target/rk3588.cfg new file mode 100644 index 000000000..7b470268a --- /dev/null +++ b/tcl/target/rk3588.cfg @@ -0,0 +1,86 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Rockchip RK3588 Target +# https://www.rock-chips.com/a/en/products/RK35_Series/2022/0926/1660.html +# Andreas Dannenberg <an...@mi...> + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME rk3588 +} + +if { [info exists DAP_TAPID] } { + set _DAP_TAPID $DAP_TAPID +} else { + set _DAP_TAPID 0x2ba01477 +} + +adapter speed 4000 + +transport select swd + +# Declare the one SWD tap to access the DAP +swd newdap $_CHIPNAME cpu -expected-id $_DAP_TAPID + +# Create the DAP +dap create $_CHIPNAME.dap -chain-position $_CHIPNAME.cpu + +# Create target to allow accessing system memory directly +target create $_CHIPNAME.ahb mem_ap -dap $_CHIPNAME.dap -ap-num 0 + +# Declare the 8 main application cores (4 little cores + 4 big cores) + +# Little cluster (cores 0..3) +set _TARGETNAME $_CHIPNAME.lcore +set $_TARGETNAME.base(0) 0x81004000 +set $_TARGETNAME.base(1) 0x81005000 +set $_TARGETNAME.base(2) 0x81006000 +set $_TARGETNAME.base(3) 0x81007000 +set $_TARGETNAME.cti(0) 0x81014000 +set $_TARGETNAME.cti(1) 0x81015000 +set $_TARGETNAME.cti(2) 0x81016000 +set $_TARGETNAME.cti(3) 0x81017000 + +# Big cluster (cores 4..7) +set _TARGETNAME $_CHIPNAME.bcore +set $_TARGETNAME.base(4) 0x81024000 +set $_TARGETNAME.base(5) 0x81025000 +set $_TARGETNAME.base(6) 0x81026000 +set $_TARGETNAME.base(7) 0x81027000 +set $_TARGETNAME.cti(4) 0x81034000 +set $_TARGETNAME.cti(5) 0x81035000 +set $_TARGETNAME.cti(6) 0x81036000 +set $_TARGETNAME.cti(7) 0x81037000 + +# Build string used to enable SMP mode +set _smp_command "target smp" + +set _cores 8 +for { set _core 0 } { $_core < $_cores } { incr _core 1 } { + if {$_core < 4} { + set _TARGETNAME $_CHIPNAME.lcore + } else { + set _TARGETNAME $_CHIPNAME.bcore + } + + cti create cti$_core -dap $_CHIPNAME.dap -baseaddr [set $_TARGETNAME.cti($_core)] -ap-num 0 + + target create ${_TARGETNAME}$_core aarch64 \ + -dap $_CHIPNAME.dap -coreid $_core -cti cti$_core \ + -dbgbase [set $_TARGETNAME.base($_core)] + + if { $_core != 0 } { + # non-boot core examination may fail + ${_TARGETNAME}$_core configure -defer-examine + } else { + # uncomment to use hardware threads pseudo rtos + # ${_TARGETNAME}$_core configure -rtos hwthread + } + + set _smp_command "$_smp_command ${_TARGETNAME}$_core" +} + +eval $_smp_command + +# Set default target to boot core +targets $_CHIPNAME.lcore0 commit 93f16eed4d4db379671293277e9b6e7d5aba6c9b Author: Antonio Borneo <bor...@gm...> Date: Fri Aug 15 14:53:34 2025 +0200 command: fix OpenOCD commands return value for next jimtcl JimTcl has been so far quite comfortable with new commands that return error codes not supported by JimTcl itself. This has been exploited by OpenOCD, allowing the OpenOCD commands to return OpenOCD error codes mixed with JimTcl error code. With the change [1] merged in JimTcl branch 'master' for 0.84, any negative value returned by a command gets interpreted as a syntax error detected at runtime by the command itself; JimTcl dumps the correct syntax and returns a valid JimTcl error code that replaces the negative value. Since all OpenOCD error codes are negative values, they are all taken as syntax errors by the new JimTcl. E.g.: openocd -c exit dumps wrong # args: should be "exit ..." Actually OpenOCD does not need the OpenOCD error code from the commands, with the exception of the codes: [a] ERROR_COMMAND_SYNTAX_ERROR, used internally by the command dispatcher, before returning to JimTcl; [b] ERROR_COMMAND_CLOSE_CONNECTION, to alert the telnet server that the current connection should be closed. With [a] already used internally, only [b] needs to be propagated through JimTcl and back to the OpenOCD caller. Map the OpenOCD error code ERROR_COMMAND_CLOSE_CONNECTION to the existing JimTcl error code JIM_EXIT, originally used only by JimTcl 'exit' command. Detect JIM_EXIT in command_run_line() and return to the caller the original ERROR_COMMAND_CLOSE_CONNECTION. Let exec_command(), and also its caller jim_command_dispatch(), to only return JimTcl error codes. Rename it to report the change. Modify the test suite as now a syntax error does not returns -601 anymore. While there, drop the association key "retval" as it's not used. Note: after this change there is no real need to replace the JimTcl command 'exit' with the OpenOCD version as both produce the same result. But I prefer keeping the code as is to mask any future change in the related JimTcl code. Link: https://github.com/msteveb/jimtcl/commit/5669e84aad22 [1] Change-Id: Ibd7aaeccdf4d7c9efe72aa71909aef83be5ecd27 Signed-off-by: Antonio Borneo <bor...@gm...> Reported-by: Andrzej SierżÄga <as...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9084 Tested-by: jenkins diff --git a/src/helper/command.c b/src/helper/command.c index d6993ab76..742eea1b1 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -417,7 +417,7 @@ static bool command_can_run(struct command_context *cmd_ctx, struct command *c, return false; } -static int exec_command(Jim_Interp *interp, struct command_context *context, +static int jim_exec_command(Jim_Interp *interp, struct command_context *context, struct command *c, int argc, Jim_Obj * const *argv) { /* use c->handler */ @@ -467,14 +467,14 @@ static int exec_command(Jim_Interp *interp, struct command_context *context, free(words); - int *return_retval = Jim_GetAssocData(interp, "retval"); - if (return_retval) - *return_retval = retval; - if (retval == ERROR_OK) return JIM_OK; - return retval; + // used by telnet server to close one connection + if (retval == ERROR_COMMAND_CLOSE_CONNECTION) + return JIM_EXIT; + + return JIM_ERR; } int command_run_line(struct command_context *context, char *line) @@ -484,7 +484,6 @@ int command_run_line(struct command_context *context, char *line) * results */ /* run the line thru a script engine */ - int retval = ERROR_FAIL; int retcode; /* Beware! This code needs to be reentrant. It is also possible * for OpenOCD commands to be invoked directly from Tcl. This would @@ -499,20 +498,17 @@ int command_run_line(struct command_context *context, char *line) Jim_DeleteAssocData(interp, "context"); retcode = Jim_SetAssocData(interp, "context", NULL, context); if (retcode == JIM_OK) { - /* associated the return value */ - Jim_DeleteAssocData(interp, "retval"); - retcode = Jim_SetAssocData(interp, "retval", NULL, &retval); - if (retcode == JIM_OK) { - retcode = Jim_Eval_Named(interp, line, NULL, 0); - - Jim_DeleteAssocData(interp, "retval"); - } + retcode = Jim_Eval_Named(interp, line, NULL, 0); Jim_DeleteAssocData(interp, "context"); int inner_retcode = Jim_SetAssocData(interp, "context", NULL, old_context); if (retcode == JIM_OK) retcode = inner_retcode; } context->current_target_override = saved_target_override; + + if (retcode == JIM_RETURN) + retcode = interp->returnCode; + if (retcode == JIM_OK) { const char *result; int reslen; @@ -522,25 +518,19 @@ int command_run_line(struct command_context *context, char *line) command_output_text(context, result); command_output_text(context, "\n"); } - retval = ERROR_OK; - } else if (retcode == JIM_EXIT) { - /* ignore. - * exit(Jim_GetExitCode(interp)); */ - } else if (retcode == ERROR_COMMAND_CLOSE_CONNECTION) { - return retcode; - } else { - Jim_MakeErrorMessage(interp); - /* error is broadcast */ - LOG_USER("%s", Jim_GetString(Jim_GetResult(interp), NULL)); + return ERROR_OK; + } - if (retval == ERROR_OK) { - /* It wasn't a low level OpenOCD command that failed */ - return ERROR_FAIL; - } - return retval; + if (retcode == JIM_EXIT) { + // used by telnet server to close one connection + return ERROR_COMMAND_CLOSE_CONNECTION; } - return retval; + Jim_MakeErrorMessage(interp); + /* error is broadcast */ + LOG_USER("%s", Jim_GetString(Jim_GetResult(interp), NULL)); + + return ERROR_FAIL; } int command_run_linef(struct command_context *context, const char *format, ...) @@ -867,7 +857,7 @@ static int jim_command_dispatch(Jim_Interp *interp, int argc, Jim_Obj * const *a if (c->jim_override_target) cmd_ctx->current_target_override = c->jim_override_target; - int retval = exec_command(interp, cmd_ctx, c, argc, argv); + int retval = jim_exec_command(interp, cmd_ctx, c, argc, argv); if (c->jim_override_target) cmd_ctx->current_target_override = saved_target_override; diff --git a/testing/tcl_commands/utils.tcl b/testing/tcl_commands/utils.tcl index dfc896661..65e52d2fe 100644 --- a/testing/tcl_commands/utils.tcl +++ b/testing/tcl_commands/utils.tcl @@ -32,7 +32,7 @@ namespace eval testing_helpers { } proc check_syntax_err script { - tailcall check_for_error -601 {} $script + tailcall check_for_error 1 {} $script } proc check_matches {pattern script} { ----------------------------------------------------------------------- Summary of changes: src/helper/command.c | 54 +++++++++++--------------- tcl/target/rk3588.cfg | 86 ++++++++++++++++++++++++++++++++++++++++++ testing/tcl_commands/utils.tcl | 2 +- 3 files changed, 109 insertions(+), 33 deletions(-) create mode 100644 tcl/target/rk3588.cfg hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-24 11:16:17
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 7effc6f825fe8aacfb15ea198994b212f55897cb (commit) via fe0080478b9e76a4b6b64186b7b705726ac55848 (commit) from 443139db002d597510bb744bece291c2703c13a3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 7effc6f825fe8aacfb15ea198994b212f55897cb Author: Antonio Borneo <bor...@gm...> Date: Thu Aug 14 22:18:56 2025 +0200 helper: command: inline command_retval_set() Inline the function command_retval_set(), called only once. No functional changes. Change-Id: I4478002adf92c2328e4879019020de5d1dfe89c8 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9083 Tested-by: jenkins diff --git a/src/helper/command.c b/src/helper/command.c index 04f4f9a54..d6993ab76 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -63,15 +63,6 @@ void *jimcmd_privdata(Jim_Cmd *cmd) return jimcmd_is_proc(cmd) ? NULL : cmd->u.native.privData; } -static int command_retval_set(Jim_Interp *interp, int retval) -{ - int *return_retval = Jim_GetAssocData(interp, "retval"); - if (return_retval) - *return_retval = retval; - - return (retval == ERROR_OK) ? JIM_OK : retval; -} - extern struct command_context *global_cmd_ctx; /* dump a single line to the log for the command. @@ -475,7 +466,15 @@ static int exec_command(Jim_Interp *interp, struct command_context *context, Jim_DecrRefCount(context->interp, cmd.output); free(words); - return command_retval_set(interp, retval); + + int *return_retval = Jim_GetAssocData(interp, "retval"); + if (return_retval) + *return_retval = retval; + + if (retval == ERROR_OK) + return JIM_OK; + + return retval; } int command_run_line(struct command_context *context, char *line) commit fe0080478b9e76a4b6b64186b7b705726ac55848 Author: Antonio Borneo <bor...@gm...> Date: Sat Sep 28 17:58:51 2024 +0200 jimtcl: fix build with jimtcl master branch Current jimtcl release 0.83 has been tagged on 2024-08-28 and the new 0.84 is on the way. The change [1] merged in jimtcl branch 'master' for 0.84 breaks the build of OpenOCD. OpenOCD releases are not frequent and jimtcl is now by default an external build dependency. The release of jimtcl 0.84 could force OpenOCD to deliver a fix release to support it. Anticipate the change [1] by detecting it at compile time, without relying on jimtcl version, and providing an alternative code. Link: https://github.com/msteveb/jimtcl/commit/5669e84aad22 [1] Change-Id: I61bf100d447083258aea222aaf15608b7cbe2e57 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8956 Tested-by: jenkins Reviewed-by: Andrzej SierżÄga <as...@gm...> diff --git a/src/helper/command.c b/src/helper/command.c index b70081a4d..04f4f9a54 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -45,17 +45,22 @@ static enum command_mode get_command_mode(Jim_Interp *interp, const char *cmd_na /* set of functions to wrap jimtcl internal data */ static inline bool jimcmd_is_proc(Jim_Cmd *cmd) { +#if defined(JIM_CMD_ISPROC) + // JIM_VERSION >= 84 + return cmd->flags & JIM_CMD_ISPROC; +#else return cmd->isproc; +#endif } bool jimcmd_is_oocd_command(Jim_Cmd *cmd) { - return !cmd->isproc && cmd->u.native.cmdProc == jim_command_dispatch; + return !jimcmd_is_proc(cmd) && cmd->u.native.cmdProc == jim_command_dispatch; } void *jimcmd_privdata(Jim_Cmd *cmd) { - return cmd->isproc ? NULL : cmd->u.native.privData; + return jimcmd_is_proc(cmd) ? NULL : cmd->u.native.privData; } static int command_retval_set(Jim_Interp *interp, int retval) ----------------------------------------------------------------------- Summary of changes: src/helper/command.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-24 05:05:35
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 443139db002d597510bb744bece291c2703c13a3 (commit) from 1879145bff1b4827f301eeb5039a6a722f3b2d2f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 443139db002d597510bb744bece291c2703c13a3 Author: Antonio Borneo <bor...@gm...> Date: Wed Aug 20 11:33:53 2025 +0200 jtag: keep the list of drivers in alphabetic order The introduction of the driver ch347 breaks the order. Fix it. Change-Id: I868fd3ec0b6694fb4bb7b28db0083ab1a9409b1c Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9089 Reviewed-by: Matthias Jentsch <in...@ea...> Reviewed-by: Tomas Vanek <va...@fb...> Reviewed-by: ZhiYuanNJ <871...@qq...> Tested-by: jenkins diff --git a/src/jtag/interfaces.c b/src/jtag/interfaces.c index 597196c0e..e29937b58 100644 --- a/src/jtag/interfaces.c +++ b/src/jtag/interfaces.c @@ -59,6 +59,9 @@ struct adapter_driver *adapter_drivers[] = { #if BUILD_BUS_PIRATE == 1 &buspirate_adapter_driver, #endif +#if BUILD_CH347 == 1 + &ch347_adapter_driver, +#endif #if BUILD_CMSIS_DAP_USB == 1 || BUILD_CMSIS_DAP_HID == 1 &cmsis_dap_adapter_driver, #endif @@ -159,8 +162,6 @@ struct adapter_driver *adapter_drivers[] = { &xlnx_pcie_xvc_adapter_driver, &xlnx_axi_xvc_adapter_driver, #endif -#if BUILD_CH347 == 1 - &ch347_adapter_driver, -#endif + NULL, }; ----------------------------------------------------------------------- Summary of changes: src/jtag/interfaces.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-24 05:05:11
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 1879145bff1b4827f301eeb5039a6a722f3b2d2f (commit) via b4a19768863825b5acddd6adc3ec44fd04acdea1 (commit) via fe50eceaff056d366a1f33bc21f59fc830e4ca83 (commit) from 0c575ced95219f11d554bdf5c34008362fb38f7b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 1879145bff1b4827f301eeb5039a6a722f3b2d2f Author: Tomas Vanek <va...@fb...> Date: Sat Feb 8 22:40:43 2025 +0100 drivers/ch347: limit SWD packet size by processing time CH347 chip firmware probably does not service USB poll/requests from the host during processing of SWD packet. If the processing takes longer than approx 8 ms, USB host disconnects the adapter from the bus as if it were dead. To avoid disconnect, compute approximate processing time of SWD transactions and flush the queue if the total time gets over the limit (use 7 ms to keep some safety margin). Allow ch347_swd_send_idle() to split the requested delay to more partial sequences. It prevents USB disconnect at beginning of target examine, when memaccess 255 clk is used. Also memaccess > 255 clk is now possible. Set the maximal divisor to fit the longest ADI sequence into 7 ms processing time. Tested on a linux x64 PC and RPi 5. Change-Id: Ibdcff4de52e3eb4d86ed83af81a1c64f1f9b5d24 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/8746 Tested-by: jenkins Reviewed-by: ZhiYuanNJ <871...@qq...> diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c index e420410f1..8f563acaf 100644 --- a/src/jtag/drivers/ch347.c +++ b/src/jtag/drivers/ch347.c @@ -115,13 +115,15 @@ #define CH347_CMD_SWD_REG_W 0xA0 // SWD Interface write reg #define CH347_CMD_SWD_SEQ_W 0xA1 // SWD Interface write spec seq #define CH347_CMD_SWD_REG_R 0xA2 // SWD Interface read reg -#define CH347_MAX_SEND_CMD 19 // max send cmd number -#define CH347_MAX_SEND_BUF 0X200 -#define CH347_MAX_RECV_BUF 0X200 +#define CH347_MAX_PROCESSING_US 7000 // max time in us for packet processing + // USB hosts disconnect the adapter if SWD processing takes more! +#define CH347_MAX_SEND_BUF USBC_PACKET_USBHS +#define CH347_MAX_RECV_BUF USBC_PACKET_USBHS #define CH347_MAX_CMD_BUF 128 #define CH347_SWD_CLOCK_MAX 5000 #define CH347_SWD_CLOCK_BASE 1000 -#define CH347_SWD_CLOCK_MAX_DIVISOR 8 +// limited by the longest sequence processing time +#define CH347_SWD_CLOCK_MAX_DIVISOR (CH347_MAX_PROCESSING_US / swd_seq_dormant_to_swd_len) #define CH347_EPOUT 0x06u // the usb endpoint number for writing #define CH347_EPIN 0x86u // the usb endpoint number for reading @@ -240,6 +242,8 @@ struct ch347_swd_context { int need_recv_len; int queued_retval; int sent_cmd_count; + unsigned int clk_divisor; + unsigned int total_swd_clk; struct list_head send_cmd_head; struct list_head free_cmd_head; struct ch347_swd_io ch347_cmd_buf[CH347_MAX_CMD_BUF]; @@ -1640,6 +1644,7 @@ static int ch347_swd_init_cmd(uint8_t clock_divisor) retval = ch347_single_read_get_byte(0, &init_result); LOG_DEBUG("SWD init clk div %" PRIu8 ", result %02" PRIx8, clock_divisor, init_result); + ch347_swd_context.clk_divisor = clock_divisor; return retval; } @@ -1734,7 +1739,7 @@ static int ch347_speed_get_index(int khz, int *speed_idx) // Don't allow too low clk speeds: packet processing is limited to ~8 msec // or triggers host USB disconnect *speed_idx = MIN(DIV_ROUND_UP(CH347_SWD_CLOCK_BASE, khz), - CH347_SWD_CLOCK_MAX_DIVISOR); + (int)CH347_SWD_CLOCK_MAX_DIVISOR); } return ERROR_OK; } @@ -1990,6 +1995,7 @@ static void ch347_write_swd_reg(uint8_t cmd, const uint32_t out) ch347_swd_context.send_buf[ch347_swd_context.send_len++] = parity_u32(out); // 0xA0 + 1 byte(3bit ACK) ch347_swd_context.need_recv_len += (1 + 1); + ch347_swd_context.total_swd_clk += 46; } static void ch347_write_spec_seq(const uint8_t *out, uint8_t out_len) @@ -2001,6 +2007,7 @@ static void ch347_write_spec_seq(const uint8_t *out, uint8_t out_len) for (uint8_t i = 0; i < DIV_ROUND_UP(out_len, 8); i++) ch347_swd_context.send_buf[ch347_swd_context.send_len++] = out ? out[i] : 0x00; ch347_swd_context.need_recv_len += 1; // 0xA1 + ch347_swd_context.total_swd_clk += out_len; } static void ch347_read_swd_reg(uint8_t cmd) @@ -2011,6 +2018,7 @@ static void ch347_read_swd_reg(uint8_t cmd) ch347_swd_context.send_buf[ch347_swd_context.send_len++] = cmd; // 0xA2 + 1 byte(3bit ACK) + 4 byte(data) + 1 byte(1bit parity+1bit trn) ch347_swd_context.need_recv_len += 1 + 1 + 4 + 1; + ch347_swd_context.total_swd_clk += 46; } static int ch347_swd_switch_out(enum swd_special_seq seq, const uint8_t *out, unsigned int out_len) @@ -2080,22 +2088,81 @@ static int ch347_swd_run_queue_inner(void); static int ch347_swd_send_idle(uint32_t ap_delay_clk) { - struct ch347_swd_io *pswd_io = ch347_get_one_swd_io(); - if (!pswd_io) { - int retval = ch347_swd_run_queue_inner(); - if (retval != ERROR_OK) - return retval; + bool run_q = false; + struct ch347_swd_io *pswd_io = NULL; + unsigned int max_processing_clk = ch347_swd_context.clk_divisor + ? CH347_MAX_PROCESSING_US / ch347_swd_context.clk_divisor + : CH347_MAX_PROCESSING_US * 5; + bool more_q_runs = + 1 + 1 + 1 + DIV_ROUND_UP(ap_delay_clk, 8) > CH347_MAX_SEND_BUF + && ap_delay_clk > max_processing_clk; + + if (ch347_swd_context.sent_cmd_count) { + unsigned int expected_total_clk = ch347_swd_context.total_swd_clk + ap_delay_clk; + unsigned int expected_send_len = ch347_swd_context.send_len + + 1 + 1 + 1 + DIV_ROUND_UP(ap_delay_clk, 8); + // 0xA1 + Len + rev + n byte(delay) + unsigned int expected_recv_len = ch347_swd_context.need_recv_len + 1; + // 0xA1 + unsigned int expected_time = ch347_swd_context.clk_divisor + ? expected_total_clk * ch347_swd_context.clk_divisor + : expected_total_clk / 5; + if (expected_time > CH347_MAX_PROCESSING_US + || expected_send_len > CH347_MAX_SEND_BUF + || expected_recv_len > CH347_MAX_RECV_BUF) { + int send_room = CH347_MAX_SEND_BUF - ch347_swd_context.send_len - 1 - 1 - 1; + if (more_q_runs + && send_room > 0 + && expected_recv_len <= CH347_MAX_RECV_BUF + && ch347_swd_context.total_swd_clk < max_processing_clk) { + pswd_io = ch347_get_one_swd_io(); + if (pswd_io) { + // fill the rest of queue/time by part of delay + unsigned int this_delay_clk = MIN(ap_delay_clk, 255); + if ((unsigned int)send_room * 8 < this_delay_clk) + this_delay_clk = send_room * 8; + if (max_processing_clk - ch347_swd_context.total_swd_clk < this_delay_clk) + this_delay_clk = max_processing_clk - ch347_swd_context.total_swd_clk; + LOG_DEBUG_IO("partial delay %u clk", this_delay_clk); + ch347_write_spec_seq(NULL, this_delay_clk); + list_add_tail(&pswd_io->list_entry, &ch347_swd_context.send_cmd_head); + ap_delay_clk -= this_delay_clk; + } + } + run_q = true; + } + } + + do { + if (!run_q) + pswd_io = ch347_get_one_swd_io(); - pswd_io = ch347_get_one_swd_io(); if (!pswd_io) { - LOG_ERROR("ch347 SWD queue not empty after ch347_swd_run_queue"); - ch347_swd_context.queued_retval = ERROR_FAIL; - return ERROR_FAIL; + int retval = ch347_swd_run_queue_inner(); + if (retval != ERROR_OK) + return retval; + + pswd_io = ch347_get_one_swd_io(); + if (!pswd_io) { + LOG_ERROR("ch347 SWD queue not empty after ch347_swd_run_queue"); + ch347_swd_context.queued_retval = ERROR_FAIL; + return ERROR_FAIL; + } } - } - ch347_write_spec_seq(NULL, ap_delay_clk); - list_add_tail(&pswd_io->list_entry, &ch347_swd_context.send_cmd_head); + unsigned int send_room = CH347_MAX_SEND_BUF - 1 - 1 - 1; + unsigned int this_delay_clk = MIN(ap_delay_clk, 255); + if (send_room * 8 < this_delay_clk) + this_delay_clk = send_room * 8; + if (max_processing_clk < this_delay_clk) + this_delay_clk = max_processing_clk; + LOG_DEBUG_IO("delay %u clk", this_delay_clk); + ch347_write_spec_seq(NULL, this_delay_clk); + list_add_tail(&pswd_io->list_entry, &ch347_swd_context.send_cmd_head); + ap_delay_clk -= this_delay_clk; + run_q = true; + pswd_io = NULL; + } while (ap_delay_clk); return ERROR_OK; } @@ -2236,6 +2303,7 @@ skip: ch347_swd_context.need_recv_len = CH347_CMD_HEADER; ch347_swd_context.recv_len = 0; ch347_swd_context.sent_cmd_count = 0; + ch347_swd_context.total_swd_clk = 0; retval = ch347_swd_context.queued_retval; ch347_swd_context.queued_retval = ERROR_OK; return retval; @@ -2255,22 +2323,28 @@ static int ch347_swd_run_queue(void) static int ch347_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data, uint32_t ap_delay_clk) { int retval = ERROR_OK; - if (ap_delay_clk > 255) - ap_delay_clk = 255; // limit imposed by spec. seq. size in one byte - - if (ch347_swd_context.sent_cmd_count >= CH347_MAX_SEND_CMD) { - retval = ch347_swd_run_queue_inner(); - if (retval != ERROR_OK) - return retval; + bool run_q = false; + if (ch347_swd_context.sent_cmd_count) { + unsigned int expected_total_clk = ch347_swd_context.total_swd_clk + + 46 // SWD transaction + + ap_delay_clk + + 8; // 8 idle cycles at the end of queue + unsigned int expected_time = ch347_swd_context.clk_divisor + ? expected_total_clk * ch347_swd_context.clk_divisor + : expected_total_clk / 5; + if (expected_time > CH347_MAX_PROCESSING_US) { + LOG_DEBUG_IO("Expected queue run %u cycles, with this cmd %u", + ch347_swd_context.total_swd_clk, expected_total_clk); + run_q = true; + } else if (!ch347_chk_buf_size(cmd, ap_delay_clk)) { + run_q = true; + } } - if (!ch347_chk_buf_size(cmd, ap_delay_clk)) { - retval = ch347_swd_run_queue_inner(); - if (retval != ERROR_OK) - return retval; - } + struct ch347_swd_io *pswd_io = NULL; + if (!run_q) + pswd_io = ch347_get_one_swd_io(); - struct ch347_swd_io *pswd_io = ch347_get_one_swd_io(); if (!pswd_io) { retval = ch347_swd_run_queue_inner(); if (retval != ERROR_OK) commit b4a19768863825b5acddd6adc3ec44fd04acdea1 Author: Tomas Vanek <va...@fb...> Date: Sun Feb 9 11:35:11 2025 +0100 drivers/ch347: fix SWD log messages Remove annoying and not too informative error message `ack != SWD_ACK_OK`. Fix copy&paste error in message `SWD Read data parity mismatch` logged in case of a write returning bad ack. Raise log level of read/write descriptive message to DEBUG when reg read/writes returns bad ack. Change-Id: Ic3433ae8bd02472756adf269658bfba0ba34dc26 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/8747 Reviewed-by: ZhiYuanNJ <871...@qq...> Tested-by: jenkins diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c index 57d1d0fdc..e420410f1 100644 --- a/src/jtag/drivers/ch347.c +++ b/src/jtag/drivers/ch347.c @@ -2153,13 +2153,25 @@ static int ch347_swd_run_queue_inner(void) /* Devices do not reply to DP_TARGETSEL write cmd, ignore received ack */ check_ack = swd_cmd_returns_ack(pswd_io->cmd); - if (ack != SWD_ACK_OK && check_ack) { - ch347_swd_context.queued_retval = swd_ack_to_error_code(ack); - LOG_ERROR("ack != SWD_ACK_OK"); - goto skip; - } if (pswd_io->cmd & SWD_CMD_RNW) { uint32_t data = buf_get_u32(&recv_buf[recv_len], 0, 32); + + LOG_CUSTOM_LEVEL((check_ack && ack != SWD_ACK_OK) + ? LOG_LVL_DEBUG : LOG_LVL_DEBUG_IO, + "%s%s %s read reg %X = %08" PRIx32, + check_ack ? "" : "ack ignored ", + ack == SWD_ACK_OK ? "OK" : + ack == SWD_ACK_WAIT ? "WAIT" : + ack == SWD_ACK_FAULT ? "FAULT" : "JUNK", + pswd_io->cmd & SWD_CMD_APNDP ? "AP" : "DP", + (pswd_io->cmd & SWD_CMD_A32) >> 1, + data); + + if (ack != SWD_ACK_OK && check_ack) { + ch347_swd_context.queued_retval = swd_ack_to_error_code(ack); + goto skip; + } + uint32_t parity = buf_get_u32(&recv_buf[recv_len], 32, 1); if (parity != (uint32_t)parity_u32(data)) { LOG_ERROR("SWD Read data parity mismatch"); @@ -2167,15 +2179,6 @@ static int ch347_swd_run_queue_inner(void) goto skip; } - LOG_DEBUG_IO("%s%s %s %s reg %X = %08X - " PRIx32, - check_ack ? "" : "ack ignored ", - ack == SWD_ACK_OK ? "OK" : ack == SWD_ACK_WAIT ? "WAIT" : - ack == SWD_ACK_FAULT ? "FAULT" : "JUNK", - pswd_io->cmd & SWD_CMD_APNDP ? "AP" : "DP", - pswd_io->cmd & SWD_CMD_RNW ? "read" : "write", - (pswd_io->cmd & SWD_CMD_A32) >> 1, - data); - if (pswd_io->dst) *pswd_io->dst = data; } else { @@ -2190,19 +2193,22 @@ static int ch347_swd_run_queue_inner(void) /* Devices do not reply to DP_TARGETSEL write cmd, ignore received ack */ check_ack = swd_cmd_returns_ack(pswd_io->cmd); + + LOG_CUSTOM_LEVEL((check_ack && ack != SWD_ACK_OK) + ? LOG_LVL_DEBUG : LOG_LVL_DEBUG_IO, + "%s%s %s write reg %X = %08" PRIx32, + check_ack ? "" : "ack ignored ", + ack == SWD_ACK_OK ? "OK" : + ack == SWD_ACK_WAIT ? "WAIT" : + ack == SWD_ACK_FAULT ? "FAULT" : "JUNK", + pswd_io->cmd & SWD_CMD_APNDP ? "AP" : "DP", + (pswd_io->cmd & SWD_CMD_A32) >> 1, + pswd_io->value); + if (ack != SWD_ACK_OK && check_ack) { ch347_swd_context.queued_retval = swd_ack_to_error_code(ack); - LOG_ERROR("SWD Read data parity mismatch"); goto skip; } - LOG_DEBUG_IO("%s%s %s %s reg %X = %08X - " PRIx32, - check_ack ? "" : "ack ignored ", - ack == SWD_ACK_OK ? "OK" : ack == SWD_ACK_WAIT ? "WAIT" : - ack == SWD_ACK_FAULT ? "FAULT" : "JUNK", - pswd_io->cmd & SWD_CMD_APNDP ? "AP" : "DP", - pswd_io->cmd & SWD_CMD_RNW ? "read" : "write", - (pswd_io->cmd & SWD_CMD_A32) >> 1, - pswd_io->value); } else { ch347_swd_context.queued_retval = ERROR_FAIL; LOG_ERROR("CH347 usb write/read failed recv_len = %d", recv_len); commit fe50eceaff056d366a1f33bc21f59fc830e4ca83 Author: Tomas Vanek <va...@fb...> Date: Sat Feb 8 22:00:40 2025 +0100 drivers/ch347: don't loose swd_read/write_reg errors SWD read_reg() and write_reg() methods are declared with void return. Save the error code to ch347_swd_context.queued_retval (will be returned later by SWD run method) instead of ignoring it. Change-Id: Ib95a1bc3398712ac2f8520c79d281633d75f0335 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/8745 Reviewed-by: ZhiYuanNJ <871...@qq...> Tested-by: jenkins diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c index 530ac5096..57d1d0fdc 100644 --- a/src/jtag/drivers/ch347.c +++ b/src/jtag/drivers/ch347.c @@ -2333,13 +2333,17 @@ static int ch347_swd_switch_seq(enum swd_special_seq seq) static void ch347_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk) { assert(cmd & SWD_CMD_RNW); - ch347_swd_queue_cmd(cmd, value, 0, ap_delay_clk); + int retval = ch347_swd_queue_cmd(cmd, value, 0, ap_delay_clk); + if (retval != ERROR_OK) + ch347_swd_context.queued_retval = retval; } static void ch347_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk) { assert(!(cmd & SWD_CMD_RNW)); - ch347_swd_queue_cmd(cmd, NULL, value, ap_delay_clk); + int retval = ch347_swd_queue_cmd(cmd, NULL, value, ap_delay_clk); + if (retval != ERROR_OK) + ch347_swd_context.queued_retval = retval; } static const struct swd_driver ch347_swd = { ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/ch347.c | 194 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 139 insertions(+), 55 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-08-24 05:04:58
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 0c575ced95219f11d554bdf5c34008362fb38f7b (commit) from 87f78286794f6d8fbf885715b01b685f98885d9d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit 0c575ced95219f11d554bdf5c34008362fb38f7b Author: Tomas Vanek <va...@fb...> Date: Sat Feb 8 21:36:15 2025 +0100 drivers/ch347: fix conditional sending of idle clock cycles ch347_swd_run_queue() fulfilled ADI requirement for idle cycles after the last transaction just if there was room in the buffer. A lazy programmer avoided this way the danger of recurrent call. Introduce ch347_swd_run_queue_inner() without sending idle cycles. They are useless when flushing the queue to get room for the next transaction. ch347_swd_run_queue() now can make room for idle cycles in the queue without recursion. While on it remove two useless debug logs showing ap_delay_clk value and prevent the overflow of ap_delay_clk forcing it to be <= 255. Change-Id: Ia7b7f0d373ff463e2f0742bdd068c3833c57f340 Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/8744 Reviewed-by: ZhiYuanNJ <871...@qq...> Tested-by: jenkins diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c index ecec155f7..530ac5096 100644 --- a/src/jtag/drivers/ch347.c +++ b/src/jtag/drivers/ch347.c @@ -2076,13 +2076,13 @@ static bool ch347_chk_buf_size(uint8_t cmd, uint32_t ap_delay_clk) return flush; } -static int ch347_swd_run_queue(void); +static int ch347_swd_run_queue_inner(void); static int ch347_swd_send_idle(uint32_t ap_delay_clk) { struct ch347_swd_io *pswd_io = ch347_get_one_swd_io(); if (!pswd_io) { - int retval = ch347_swd_run_queue(); + int retval = ch347_swd_run_queue_inner(); if (retval != ERROR_OK) return retval; @@ -2099,7 +2099,7 @@ static int ch347_swd_send_idle(uint32_t ap_delay_clk) return ERROR_OK; } -static int ch347_swd_run_queue(void) +static int ch347_swd_run_queue_inner(void) { LOG_DEBUG_IO("Executing %u queued transactions", ch347_swd_context.sent_cmd_count); if (ch347_swd_context.queued_retval != ERROR_OK) { @@ -2107,20 +2107,7 @@ static int ch347_swd_run_queue(void) goto skip; } - /* A transaction must be followed by another transaction or at least 8 - idle cycles to ensure that data is clocked through the AP. */ - if ((ch347_swd_context.send_len + (1 + 2 + 1)) > CH347_MAX_SEND_BUF) - goto skip_idle; - - if ((ch347_swd_context.need_recv_len + 1) > CH347_MAX_RECV_BUF) - goto skip_idle; - - int retval = ch347_swd_send_idle((uint32_t)8); - if (retval != ERROR_OK) - return retval; - -skip_idle: - retval = ch347_swd_queue_flush(); + int retval = ch347_swd_queue_flush(); if (retval != ERROR_OK) return retval; @@ -2248,27 +2235,38 @@ skip: return retval; } +static int ch347_swd_run_queue(void) +{ + /* A transaction must be followed by another transaction or at least 8 + idle cycles to ensure that data is clocked through the AP. */ + int retval = ch347_swd_send_idle(8); + if (retval != ERROR_OK) + return retval; + + return ch347_swd_run_queue_inner(); +} + static int ch347_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data, uint32_t ap_delay_clk) { + int retval = ERROR_OK; if (ap_delay_clk > 255) - LOG_DEBUG("ap_delay_clk = %d", ap_delay_clk); + ap_delay_clk = 255; // limit imposed by spec. seq. size in one byte - int retval = ERROR_OK; if (ch347_swd_context.sent_cmd_count >= CH347_MAX_SEND_CMD) { - retval = ch347_swd_run_queue(); + retval = ch347_swd_run_queue_inner(); if (retval != ERROR_OK) return retval; } if (!ch347_chk_buf_size(cmd, ap_delay_clk)) { - retval = ch347_swd_run_queue(); + retval = ch347_swd_run_queue_inner(); if (retval != ERROR_OK) return retval; } struct ch347_swd_io *pswd_io = ch347_get_one_swd_io(); if (!pswd_io) { - retval = ch347_swd_run_queue(); + retval = ch347_swd_run_queue_inner(); if (retval != ERROR_OK) return retval; @@ -2294,12 +2292,10 @@ static int ch347_swd_queue_cmd(uint8_t cmd, uint32_t *dst, uint32_t data, uint32 ch347_swd_context.sent_cmd_count++; list_add_tail(&pswd_io->list_entry, &ch347_swd_context.send_cmd_head); + // Insert idle cycles after AP accesses to avoid WAIT - if (cmd & SWD_CMD_APNDP) { - if (ap_delay_clk == 0) - LOG_DEBUG("ap_delay_clk == 0"); + if (ap_delay_clk) retval = ch347_swd_send_idle(ap_delay_clk); - } return retval; } ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/ch347.c | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) hooks/post-receive -- Main OpenOCD repository |