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
(47) |
Oct
(15) |
Nov
|
Dec
|
From: openocd-gerrit <ope...@us...> - 2025-10-18 09:00: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 88b9bd396d5a1f83c49fa1b28745fd7feaca2b2e (commit) from 85542c1c5c65ea73beb6d52b3ea5c38601313a3b (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 88b9bd396d5a1f83c49fa1b28745fd7feaca2b2e Author: Antonio Borneo <bor...@gm...> Date: Sun Oct 12 12:10:46 2025 +0200 target: cortex-m: fix support for armv8m caches Scan-build is unable to correctly follow the deferred loading of queued read, finalized by the atomic write, thus it incorrectly claims that the arrays d_u_ccsidr[] and i_ccsidr[] could carry not initialized values: armv7m_cache.c:154:31: warning: 1st function call argument is an uninitialized value [core.CallAndMessage] cache->arch[cl].d_u_size = decode_ccsidr(d_u_ccsidr[cl]); armv7m_cache.c:172:29: warning: 1st function call argument is an uninitialized value [core.CallAndMessage] cache->arch[cl].i_size = decode_ccsidr(i_ccsidr[cl]); Initialize the arrays to zero to hide these false positive. Change-Id: I6d1e88093cb8807848643139647a571c1b566aa8 Signed-off-by: Antonio Borneo <bor...@gm...> Fixes: 04da6e2c6246 ("target: cortex-m: add support for armv8m caches") Reviewed-on: https://review.openocd.org/c/openocd/+/9167 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/target/armv7m_cache.c b/src/target/armv7m_cache.c index cb57c0e25..cc0c9d140 100644 --- a/src/target/armv7m_cache.c +++ b/src/target/armv7m_cache.c @@ -111,7 +111,7 @@ int armv7m_identify_cache(struct target *target) clidr, cache->loc); // retrieve all available inner caches - uint32_t d_u_ccsidr[8], i_ccsidr[8]; + uint32_t d_u_ccsidr[8] = {0}, i_ccsidr[8] = {0}; for (unsigned int cl = 0; cl < cache->loc; cl++) { unsigned int ctype = FIELD_GET(CLIDR_CTYPE_MASK(cl + 1), clidr); ----------------------------------------------------------------------- Summary of changes: src/target/armv7m_cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-18 08:59:26
|
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 85542c1c5c65ea73beb6d52b3ea5c38601313a3b (commit) from 557a2082b1b41b288a9acd0400a6f5c75a8f47b7 (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 85542c1c5c65ea73beb6d52b3ea5c38601313a3b Author: Antonio Borneo <bor...@gm...> Date: Sun Oct 12 11:30:00 2025 +0200 helper/log: mark 'fmt' argument of alloc_*printf() as not NULL Even after commit e12ceddd5ee4 ("helper/log: mark `fmt` argument of `alloc_vprintf()` as format string"), the GCC compiler still reports that alloc_vprintf() could call vsnprintf() with a NULL format parameter. Inform the compiler that alloc_vprintf() cannot accept NULL as format string. Add an assert() in alloc_vprintf() so even compilers that do not use the function attribute 'nonnull' will play safe. While there, extend the same fixes to alloc_printf() too. Change-Id: Idfa4fe9c6dfb2acfbf434c392237937ae03f0e8a Signed-off-by: Antonio Borneo <bor...@gm...> Reported-by: Parshintsev Anatoly <ana...@sy...> Reviewed-on: https://review.openocd.org/c/openocd/+/9166 Tested-by: jenkins Reviewed-by: Anatoly P <ana...@sy...> diff --git a/src/helper/log.c b/src/helper/log.c index 2dada3540..7acb154c6 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -354,6 +354,8 @@ char *alloc_vprintf(const char *fmt, va_list ap) int len; char *string; + assert(fmt); + /* determine the length of the buffer needed */ va_copy(ap_copy, ap); len = vsnprintf(NULL, 0, fmt, ap_copy); diff --git a/src/helper/log.h b/src/helper/log.h index 474d082ed..b8e3e339a 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -15,6 +15,7 @@ #define OPENOCD_HELPER_LOG_H #include <helper/command.h> +#include <helper/compiler.h> /* To achieve C99 printf compatibility in MinGW, gnu_printf should be * used for __attribute__((format( ... ))), with GCC v4.4 or later @@ -86,9 +87,9 @@ int log_add_callback(log_callback_fn fn, void *priv); int log_remove_callback(log_callback_fn fn, void *priv); char *alloc_vprintf(const char *fmt, va_list ap) - __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 0))); + __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 0))) __nonnull((1)); char *alloc_printf(const char *fmt, ...) - __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 2))); + __attribute__ ((format (PRINTF_ATTRIBUTE_FORMAT, 1, 2))) __nonnull((1)); const char *find_nonprint_char(const char *buf, unsigned int buf_len); ----------------------------------------------------------------------- Summary of changes: src/helper/log.c | 2 ++ src/helper/log.h | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-18 08:37:48
|
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 557a2082b1b41b288a9acd0400a6f5c75a8f47b7 (commit) from 3fd975941537346c7a3c37aecc944b30305a8e1e (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 557a2082b1b41b288a9acd0400a6f5c75a8f47b7 Author: Antonio Borneo <bor...@gm...> Date: Mon Aug 4 17:42:22 2025 +0200 openocd: don't test 'debug_level' directly Use the macro 'LOG_LEVEL_IS()' to test 'debug_level'. While there, use the macro 'LOG_LVL_*' in place of the numeric value. Skip all riscv code, as it is going to be updated soon from the external fork. Change-Id: Icad7e879e040d3b9cf1cc004c433f28725017493 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9070 Tested-by: jenkins diff --git a/src/helper/command.c b/src/helper/command.c index 9c29ceff8..4cce57f75 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -69,7 +69,7 @@ extern struct command_context *global_cmd_ctx; * Do nothing in case we are not at debug level 3 */ static void script_debug(Jim_Interp *interp, unsigned int argc, Jim_Obj * const *argv) { - if (debug_level < LOG_LVL_DEBUG) + if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) return; char *dbg = alloc_printf("command -"); diff --git a/src/helper/log.c b/src/helper/log.c index d8c4e09ac..2dada3540 100644 --- a/src/helper/log.c +++ b/src/helper/log.c @@ -113,7 +113,7 @@ static void log_puts(enum log_levels level, if (f) file = f + 1; - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { /* print with count and time information */ int64_t t = timeval_ms() - start; #ifdef _DEBUG_FREE_SPACE_ diff --git a/src/helper/log.h b/src/helper/log.h index ac24f8e83..474d082ed 100644 --- a/src/helper/log.h +++ b/src/helper/log.h @@ -101,7 +101,7 @@ extern int debug_level; #define LOG_DEBUG_IO(expr ...) \ do { \ - if (debug_level >= LOG_LVL_DEBUG_IO) \ + if (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO)) \ log_printf_lf(LOG_LVL_DEBUG, \ __FILE__, __LINE__, __func__, \ expr); \ @@ -109,7 +109,7 @@ extern int debug_level; #define LOG_DEBUG(expr ...) \ do { \ - if (debug_level >= LOG_LVL_DEBUG) \ + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) \ log_printf_lf(LOG_LVL_DEBUG, \ __FILE__, __LINE__, __func__, \ expr); \ @@ -118,7 +118,7 @@ extern int debug_level; #define LOG_CUSTOM_LEVEL(level, expr ...) \ do { \ enum log_levels _level = level; \ - if (debug_level >= _level) \ + if (LOG_LEVEL_IS(_level)) \ log_printf_lf(_level, \ __FILE__, __LINE__, __func__, \ expr); \ diff --git a/src/jtag/core.c b/src/jtag/core.c index 479d2efe5..3261e6079 100644 --- a/src/jtag/core.c +++ b/src/jtag/core.c @@ -967,7 +967,7 @@ int default_interface_jtag_execute_queue(void) struct jtag_command *cmd = jtag_command_queue_get(); int result = adapter_driver->jtag_ops->execute_queue(cmd); - while (debug_level >= LOG_LVL_DEBUG_IO && cmd) { + while (LOG_LEVEL_IS(LOG_LVL_DEBUG_IO) && cmd) { switch (cmd->type) { case JTAG_SCAN: LOG_DEBUG_IO("JTAG %s SCAN to %s", diff --git a/src/rtos/ecos.c b/src/rtos/ecos.c index 7b993c6f2..41159bf09 100644 --- a/src/rtos/ecos.c +++ b/src/rtos/ecos.c @@ -539,7 +539,7 @@ static int ecos_check_app_info(struct rtos *rtos, struct ecos_params *param) return -1; if (param->flush_common) { - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { for (unsigned int idx = 0; idx < ARRAY_SIZE(ecos_symbol_list); idx++) { LOG_DEBUG("eCos: %s 0x%016" PRIX64 " %s", rtos->symbols[idx].optional ? "OPTIONAL" : " ", diff --git a/src/svf/svf.c b/src/svf/svf.c index 001ffa263..7491ad651 100644 --- a/src/svf/svf.c +++ b/src/svf/svf.c @@ -1620,7 +1620,7 @@ static int svf_run_command(struct command_context *cmd_ctx, char *cmd_str) LOG_USER("(Above Padding command skipped, as per -tap argument)"); } - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { /* for convenient debugging, execute tap if possible */ if ((svf_buffer_index > 0) && (((command != STATE) && (command != RUNTEST)) || diff --git a/src/target/arc.c b/src/target/arc.c index 638e22099..629f79aa0 100644 --- a/src/target/arc.c +++ b/src/target/arc.c @@ -769,7 +769,7 @@ static int arc_exit_debug(struct target *target) target->state = TARGET_HALTED; CHECK_RETVAL(target_call_event_callbacks(target, TARGET_EVENT_HALTED)); - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { LOG_TARGET_DEBUG(target, "core stopped (halted) debug-reg: 0x%08" PRIx32, value); CHECK_RETVAL(arc_jtag_read_aux_reg_one(&arc->jtag_info, AUX_STATUS32_REG, &value)); LOG_TARGET_DEBUG(target, "core STATUS32: 0x%08" PRIx32, value); @@ -824,7 +824,7 @@ static int arc_halt(struct target *target) CHECK_RETVAL(target_call_event_callbacks(target, TARGET_EVENT_HALTED)); /* some more debug information */ - if (debug_level >= LOG_LVL_DEBUG) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { LOG_TARGET_DEBUG(target, "core stopped (halted) DEGUB-REG: 0x%08" PRIx32, value); CHECK_RETVAL(arc_get_register_value(target, "status32", &value)); LOG_TARGET_DEBUG(target, "core STATUS32: 0x%08" PRIx32, value); @@ -1148,7 +1148,7 @@ static int arc_arch_state(struct target *target) { uint32_t pc_value; - if (debug_level < LOG_LVL_DEBUG) + if (!LOG_LEVEL_IS(LOG_LVL_DEBUG)) return ERROR_OK; CHECK_RETVAL(arc_get_register_value(target, "pc", &pc_value)); diff --git a/src/target/arm720t.c b/src/target/arm720t.c index 7098aa472..3f7686fb7 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -323,7 +323,7 @@ static int arm720t_soft_reset_halt(struct target *target) return retval; } else break; - if (debug_level >= 3) + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) alive_sleep(100); else keep_alive(); diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c index c4bedcd85..06e76ac0d 100644 --- a/src/target/arm7_9_common.c +++ b/src/target/arm7_9_common.c @@ -637,7 +637,7 @@ int arm7_9_execute_sys_speed(struct target *target) if ((buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_DBGACK, 1)) && (buf_get_u32(dbg_stat->value, EICE_DBG_STATUS_SYSCOMP, 1))) break; - if (debug_level >= 3) + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) alive_sleep(100); else keep_alive(); @@ -1088,7 +1088,7 @@ int arm7_9_soft_reset_halt(struct target *target) retval = jtag_execute_queue(); if (retval != ERROR_OK) return retval; - if (debug_level >= 3) + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) alive_sleep(100); else keep_alive(); diff --git a/src/target/arm920t.c b/src/target/arm920t.c index 67c212e0b..441e42305 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -746,7 +746,7 @@ int arm920t_soft_reset_halt(struct target *target) return retval; } else break; - if (debug_level >= 3) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { /* do not eat all CPU, time out after 1 se*/ alive_sleep(100); } else diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index 0b77981ae..98fe6bf68 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -544,7 +544,7 @@ int arm926ejs_soft_reset_halt(struct target *target) return retval; } else break; - if (debug_level >= 1) { + if (LOG_LEVEL_IS(LOG_LVL_WARNING)) { /* do not eat all CPU, time out after 1 se*/ alive_sleep(100); } else diff --git a/src/target/xscale.c b/src/target/xscale.c index 613c8d20a..712db4ee2 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -400,7 +400,7 @@ static int xscale_read_tx(struct target *target, int consume) } if (!((!(field0_in & 1)) && consume)) goto done; - if (debug_level >= 3) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { LOG_DEBUG("waiting 100ms"); alive_sleep(100); /* avoid flooding the logs */ } else @@ -471,7 +471,7 @@ static int xscale_write_rx(struct target *target) } if (!(field0_in & 1)) goto done; - if (debug_level >= 3) { + if (LOG_LEVEL_IS(LOG_LVL_DEBUG)) { LOG_DEBUG("waiting 100ms"); alive_sleep(100); /* avoid flooding the logs */ } else ----------------------------------------------------------------------- Summary of changes: src/helper/command.c | 2 +- src/helper/log.c | 2 +- src/helper/log.h | 6 +++--- src/jtag/core.c | 2 +- src/rtos/ecos.c | 2 +- src/svf/svf.c | 2 +- src/target/arc.c | 6 +++--- src/target/arm720t.c | 2 +- src/target/arm7_9_common.c | 4 ++-- src/target/arm920t.c | 2 +- src/target/arm926ejs.c | 2 +- src/target/xscale.c | 4 ++-- 12 files changed, 18 insertions(+), 18 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-13 07:57: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 3fd975941537346c7a3c37aecc944b30305a8e1e (commit) from 1f5da25ed19f41499efdd482e522e016d0eb406c (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 3fd975941537346c7a3c37aecc944b30305a8e1e Author: Marc Schink <de...@za...> Date: Wed Oct 8 07:40:44 2025 +0200 adapters/cmsis-dap: Fix build without libusb The cmsis-dap core driver depends on libusb-related code which breaks the build when libusb is not available. Remove libusb dependency of the core driver to fix the build issue. For now, use an own timeout #define with the value of LIBUSB_TIMEOUT_MS but timeout handling should be better moved to the backends. However, this should be addressed in a dedicated patch. Change-Id: Ic5da392f8ab26b47466be199432432cdc08712ab Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9161 Reviewed-by: Tomas Vanek <va...@fb...> Reviewed-by: <nik...@gm...> Tested-by: jenkins diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index e5e82d13d..9f60a5ede 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -37,7 +37,8 @@ #include <target/cortex_m.h> #include "cmsis_dap.h" -#include "libusb_helper.h" + +#define TIMEOUT_MS 6000 /* Create a dummy backend for 'backend' command if real one does not build */ #if BUILD_CMSIS_DAP_USB == 0 @@ -363,12 +364,12 @@ static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen) } uint8_t current_cmd = dap->command[0]; - int retval = dap->backend->write(dap, txlen, LIBUSB_TIMEOUT_MS); + int retval = dap->backend->write(dap, txlen, TIMEOUT_MS); if (retval < 0) return retval; /* get reply */ - retval = dap->backend->read(dap, LIBUSB_TIMEOUT_MS, CMSIS_DAP_BLOCKING); + retval = dap->backend->read(dap, TIMEOUT_MS, CMSIS_DAP_BLOCKING); if (retval < 0) return retval; @@ -872,7 +873,7 @@ static void cmsis_dap_swd_write_from_queue(struct cmsis_dap *dap) } } - int retval = dap->backend->write(dap, idx, LIBUSB_TIMEOUT_MS); + int retval = dap->backend->write(dap, idx, TIMEOUT_MS); if (retval < 0) { queued_retval = retval; goto skip; @@ -913,7 +914,7 @@ static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, enum cmsis_dap_blo } /* get reply */ - retval = dap->backend->read(dap, LIBUSB_TIMEOUT_MS, blocking); + retval = dap->backend->read(dap, TIMEOUT_MS, blocking); bool timeout = (retval == ERROR_TIMEOUT_REACHED || retval == 0); if (timeout && blocking == CMSIS_DAP_NON_BLOCKING) return; ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/cmsis_dap.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 16:18:25
|
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 1f5da25ed19f41499efdd482e522e016d0eb406c (commit) from 7c16c38eda25da452945cd7148146e986efb6efe (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 1f5da25ed19f41499efdd482e522e016d0eb406c Author: Antonio Borneo <bor...@gm...> Date: Sun Oct 5 11:17:16 2025 +0200 configure.ac: rename 'adapterTuple' as 'adapter_driver' Commit ce3bf664c815 ("configure.ac: rename M4 macro 'adapter' to prevent accidental conflicts") renames the macro as 'adapterTuple' but since the macro name is printed in error messages, this creates cryptic errors like: configure: error: header sys/mman.h is required for adapterTuple "Bitbanging on EP93xx-based SBCs". Rename it as 'adapter_driver'. It keeps valid the purpose of the former renaming, while keeping readable the error message. Change-Id: Idd68270fbdf879153cd59f4cacf5036aa599b251 Signed-off-by: Antonio Borneo <bor...@gm...> Fixes: ce3bf664c815 ("configure.ac: rename M4 macro 'adapter' to prevent accidental conflicts") Reviewed-on: https://review.openocd.org/c/openocd/+/9160 Tested-by: jenkins diff --git a/configure.ac b/configure.ac index cc4ed4aa2..6efcf24f2 100644 --- a/configure.ac +++ b/configure.ac @@ -301,15 +301,15 @@ AS_IF([test "x$debug_malloc" = "xyes" -a "x$have_glibc" = "xyes"], [ ]) m4_define([AC_ARG_ADAPTERS], [ - m4_foreach([adapterTuple], [$1], - [AC_ARG_ENABLE(ADAPTER_OPT([adapterTuple]), - AS_HELP_STRING([--enable-ADAPTER_OPT([adapterTuple])[[[=yes/no/auto]]]], - [Enable building support for the ]ADAPTER_DESC([adapterTuple])[ (default is $2)]), + m4_foreach([adapter_driver], [$1], + [AC_ARG_ENABLE(ADAPTER_OPT([adapter_driver]), + AS_HELP_STRING([--enable-ADAPTER_OPT([adapter_driver])[[[=yes/no/auto]]]], + [Enable building support for the ]ADAPTER_DESC([adapter_driver])[ (default is $2)]), [case "${enableval}" in yes|no|auto) ;; - *) AC_MSG_ERROR([Option --enable-ADAPTER_OPT([adapterTuple]) has invalid value "${enableval}".]) ;; + *) AC_MSG_ERROR([Option --enable-ADAPTER_OPT([adapter_driver]) has invalid value "${enableval}".]) ;; esac], - [ADAPTER_VAR([adapterTuple])=$2]) + [ADAPTER_VAR([adapter_driver])=$2]) ]) ]) @@ -607,23 +607,24 @@ PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.2], # Arg $3: What prerequisites are missing, to be shown in an error message # if an adapter was requested but cannot be enabled. m4_define([PROCESS_ADAPTERS], [ - m4_foreach([adapterTuple], [$1], [ + m4_foreach([adapter_driver], [$1], [ AS_IF([test $2], [ - AS_IF([test "x$ADAPTER_VAR([adapterTuple])" != "xno"], [ - AC_DEFINE([BUILD_]ADAPTER_SYM([adapterTuple]), [1], - [1 if you want the ]ADAPTER_DESC([adapterTuple]).) + AS_IF([test "x$ADAPTER_VAR([adapter_driver])" != "xno"], [ + AC_DEFINE([BUILD_]ADAPTER_SYM([adapter_driver]), [1], + [1 if you want the ]ADAPTER_DESC([adapter_driver]).) ], [ - AC_DEFINE([BUILD_]ADAPTER_SYM([adapterTuple]), [0], - [0 if you do not want the ]ADAPTER_DESC([adapterTuple]).) + AC_DEFINE([BUILD_]ADAPTER_SYM([adapter_driver]), [0], + [0 if you do not want the ]ADAPTER_DESC([adapter_driver]).) ]) ], [ - AS_IF([test "x$ADAPTER_VAR([adapterTuple])" = "xyes"], [ - AC_MSG_ERROR([$3 is required for [adapterTuple] "ADAPTER_DESC([adapterTuple])".]) + AS_IF([test "x$ADAPTER_VAR([adapter_driver])" = "xyes"], [ + AC_MSG_ERROR([$3 is required for [adapter_driver] "ADAPTER_DESC([adapter_driver])".]) ]) - ADAPTER_VAR([adapterTuple])=no - AC_DEFINE([BUILD_]ADAPTER_SYM([adapterTuple]), [0], [0 if you do not want the ]ADAPTER_DESC([adapterTuple]).) + ADAPTER_VAR([adapter_driver])=no + AC_DEFINE([BUILD_]ADAPTER_SYM([adapter_driver]), [0], + [0 if you do not want the ]ADAPTER_DESC([adapter_driver]).) ]) - AM_CONDITIONAL(ADAPTER_SYM([adapterTuple]), [test "x$ADAPTER_VAR([adapterTuple])" != "xno"]) + AM_CONDITIONAL(ADAPTER_SYM([adapter_driver]), [test "x$ADAPTER_VAR([adapter_driver])" != "xno"]) ]) ]) @@ -838,7 +839,7 @@ echo echo echo OpenOCD configuration summary echo --------------------------------------------------- -m4_foreach([adapterTuple], [USB1_ADAPTERS, +m4_foreach([adapter_driver], [USB1_ADAPTERS, HIDAPI_ADAPTERS, HIDAPI_USB1_ADAPTERS, LIBFTDI_ADAPTERS, LIBFTDI_USB1_ADAPTERS, LIBGPIOD_ADAPTERS, @@ -860,8 +861,8 @@ m4_foreach([adapterTuple], [USB1_ADAPTERS, DUMMY_ADAPTER, OPTIONAL_LIBRARIES, COVERAGE], - [s=m4_format(["%-49s"], ADAPTER_DESC([adapterTuple])) - AS_CASE([$ADAPTER_VAR([adapterTuple])], + [s=m4_format(["%-49s"], ADAPTER_DESC([adapter_driver])) + AS_CASE([$ADAPTER_VAR([adapter_driver])], [auto], [ echo "$s"yes '(auto)' ], @@ -873,8 +874,8 @@ m4_foreach([adapterTuple], [USB1_ADAPTERS, ], [ AC_MSG_ERROR(m4_normalize([ - Error in [adapterTuple] "ADAPTER_ARG([adapterTuple])": Variable "ADAPTER_VAR([adapterTuple])" - has invalid value "$ADAPTER_VAR([adapterTuple])".])) + Error in [adapter_driver] "ADAPTER_ARG([adapter_driver])": Variable "ADAPTER_VAR([adapter_driver])" + has invalid value "$ADAPTER_VAR([adapter_driver])".])) ]) ]) echo ----------------------------------------------------------------------- Summary of changes: configure.ac | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 16:18:00
|
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 7c16c38eda25da452945cd7148146e986efb6efe (commit) from 910e6ba2f060d71506e4259ec2432e42242146ca (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 7c16c38eda25da452945cd7148146e986efb6efe Author: Antonio Borneo <bor...@gm...> Date: Sun Oct 5 11:13:44 2025 +0200 configure.ac: add adapter dependency from sys/mman.h The adapter's driver that require the header file sys/mman.h should check for it and don't compile if it is not present. Add the check for sys/mman.h in configure.ac and prevent the build of the adapter's driver that depend on it. Change-Id: If0a518069e8fef9b41a67b633ec20e2f142a8b14 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9159 Tested-by: jenkins diff --git a/configure.ac b/configure.ac index 84d9739b4..cc4ed4aa2 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,7 @@ AC_CHECK_HEADERS([netdb.h]) AC_CHECK_HEADERS([poll.h]) AC_CHECK_HEADERS([strings.h]) AC_CHECK_HEADERS([sys/ioctl.h]) +AC_CHECK_HEADERS([sys/mman.h]) AC_CHECK_HEADERS([sys/param.h]) AC_CHECK_HEADERS([sys/select.h]) AC_CHECK_HEADERS([sys/stat.h]) @@ -632,12 +633,14 @@ PROCESS_ADAPTERS([HIDAPI_USB1_ADAPTERS], ["x$use_hidapi" = "xyes" -a "x$use_libu PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi]) PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"], [libftdi and libusb-1.x]) PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [Linux libgpiod]) -PROCESS_ADAPTERS([DMEM_ADAPTER], ["x$is_linux" = "xyes"], [Linux /dev/mem]) +PROCESS_ADAPTERS([DMEM_ADAPTER], ["x$is_linux" = "xyes" -a "x$ac_cv_header_sys_mman_h" = "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([XVC_ADAPTERS], + ["x$is_linux" = "xyes" -a "x$ac_cv_header_linux_pci_h" = "xyes" -a "x$ac_cv_header_sys_mman_h" = "xyes"], + [Linux build with headers linux/pci.h and sys/mman.h]) PROCESS_ADAPTERS([SERIAL_PORT_ADAPTERS], ["x$can_build_buspirate" = "xyes"], [internal error: validation should happen beforehand]) PROCESS_ADAPTERS([PARALLEL_PORT_ADAPTER], [true], [unused]) @@ -649,8 +652,8 @@ PROCESS_ADAPTERS([JTAG_VPI_ADAPTER], [true], [unused]) PROCESS_ADAPTERS([RSHIM_ADAPTER], ["x$can_build_rshim" = "xyes"], [internal error: validation should happen beforehand]) PROCESS_ADAPTERS([AMTJTAGACCEL_ADAPTER], [true], [unused]) -PROCESS_ADAPTERS([HOST_ARM_BITBANG_ADAPTERS], [true], [unused]) -PROCESS_ADAPTERS([HOST_ARM_OR_AARCH64_BITBANG_ADAPTERS], [true], [unused]) +PROCESS_ADAPTERS([HOST_ARM_BITBANG_ADAPTERS], ["x$ac_cv_header_sys_mman_h" = "xyes"], [header sys/mman.h]) +PROCESS_ADAPTERS([HOST_ARM_OR_AARCH64_BITBANG_ADAPTERS], ["x$ac_cv_header_sys_mman_h" = "xyes"], [header sys/mman.h]) PROCESS_ADAPTERS([DUMMY_ADAPTER], [true], [unused]) AS_IF([test "x$enable_linuxgpiod" != "xno"], [ ----------------------------------------------------------------------- Summary of changes: configure.ac | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 16:16:28
|
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 910e6ba2f060d71506e4259ec2432e42242146ca (commit) from 39ed0b0bbaac63c88d1e4b9ffe85e209bdb6b059 (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 910e6ba2f060d71506e4259ec2432e42242146ca Author: Marc Schink <de...@za...> Date: Sun Aug 17 17:09:12 2025 +0000 adapter/parport: Add device file support Allow to specify the parallel port by its device file. Deprecate port number support but keep it for backward compatibility. This is one necessary step to remove direct I/O support for the parallel port driver. While at it, consistently return ERROR_JTAG_INIT_FAILED in case of a failure in parport_init(). Change-Id: Ie68087f05ece4b32ccab9d9bdfbf7e1a779e9031 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9152 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 4229f831b..9540e69f3 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -3217,11 +3217,12 @@ The pin direction is given in the following table. @tab 2 @end multitable -@deffn {Config Command} {parport port} port_number -Configure the number of the parallel port. +@deffn {Config Command} {parport port} file +Specify the device file of the parallel port device. +The parallel port device file is usually @file{/dev/parportX} on Linux and @file{/dev/ppiX} on FreeBSD. -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. +For legacy reason, the port number @var{X} can be specified instead of the device file. +@b{Note:} Using the port number is a deprecated feature and will be removed in the future. When using direct I/O, the number is the I/O port number. The default port number is 0x378 (LTP1). diff --git a/src/jtag/drivers/parport.c b/src/jtag/drivers/parport.c index b29562b84..794f8296e 100644 --- a/src/jtag/drivers/parport.c +++ b/src/jtag/drivers/parport.c @@ -47,8 +47,11 @@ static const struct adapter_gpio_config *adapter_gpio_config; +#if PARPORT_USE_PPDEV == 0 static uint16_t parport_port; +#endif static bool parport_write_exit_state; +static char *parport_device_file; static uint32_t parport_toggling_time_ns = 1000; static int wait_states; @@ -258,13 +261,13 @@ static int parport_init(void) 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; + goto init_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; + goto init_fail; } } } @@ -292,35 +295,37 @@ static int parport_init(void) #if PARPORT_USE_PPDEV == 1 if (device_handle > 0) { LOG_ERROR("Parallel port is already open"); - return ERROR_JTAG_INIT_FAILED; + goto init_fail; } - char device_path[256]; - + if (!parport_device_file) { #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) - snprintf(device_path, sizeof(device_path), "/dev/ppi%d", parport_port); + parport_device_file = strdup("/dev/ppi0"); #else - snprintf(device_path, sizeof(device_path), "/dev/parport%d", parport_port); -#endif /* __FreeBSD__, __FreeBSD_kernel__ */ + parport_device_file = strdup("/dev/parport0"); +#endif + LOG_WARNING("No parallel port specified, using %s", parport_device_file); + LOG_WARNING("DEPRECATED! The lack of a parallel port specification is deprecated and will no longer work in the future"); + } - LOG_DEBUG("Using parallel port %s", device_path); + LOG_DEBUG("Using parallel port %s", parport_device_file); - device_handle = open(device_path, O_WRONLY); + device_handle = open(parport_device_file, O_WRONLY); if (device_handle < 0) { int err = errno; - LOG_ERROR("Failed to open parallel port %s (errno = %d)", device_path, - err); + LOG_ERROR("Failed to open parallel port %s (errno = %d)", + parport_device_file, err); LOG_ERROR("Check whether the device exists and if you have the required access rights"); - return ERROR_JTAG_INIT_FAILED; + goto init_fail; } #if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) int retval = ioctl(device_handle, PPCLAIM); if (retval < 0) { - LOG_ERROR("Failed to claim parallel port %s", device_path); - return ERROR_JTAG_INIT_FAILED; + LOG_ERROR("Failed to claim parallel port %s", parport_device_file); + goto init_fail; } int value = PARPORT_MODE_COMPAT; @@ -328,7 +333,7 @@ static int parport_init(void) if (retval < 0) { LOG_ERROR("Cannot set compatible mode to device"); - return ERROR_JTAG_INIT_FAILED; + goto init_fail; } value = IEEE1284_MODE_COMPAT; @@ -336,7 +341,7 @@ static int parport_init(void) if (retval < 0) { LOG_ERROR("Cannot set compatible 1284 mode to device"); - return ERROR_JTAG_INIT_FAILED; + goto init_fail; } #endif /* not __FreeBSD__, __FreeBSD_kernel__ */ @@ -359,7 +364,7 @@ static int parport_init(void) if (ioperm(dataport, 3, 1) != 0) { #endif /* PARPORT_USE_GIVEIO */ LOG_ERROR("Missing privileges for direct I/O"); - return ERROR_JTAG_INIT_FAILED; + goto init_fail; } // Make sure parallel port is in right mode (clear tristate and interrupt). @@ -372,21 +377,27 @@ static int parport_init(void) #endif /* PARPORT_USE_PPDEV */ if (parport_reset(0, 0) != ERROR_OK) - return ERROR_FAIL; + goto init_fail; if (parport_write(0, 0, 0) != ERROR_OK) - return ERROR_FAIL; + goto init_fail; if (parport_led(true) != ERROR_OK) - return ERROR_FAIL; + goto init_fail; bitbang_interface = &parport_bitbang; return ERROR_OK; + +init_fail: + free(parport_device_file); + return ERROR_JTAG_INIT_FAILED; } static int parport_quit(void) { + free(parport_device_file); + // 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; @@ -421,13 +432,46 @@ COMMAND_HANDLER(parport_handle_port_command) if (CMD_ARGC != 1) return ERROR_COMMAND_SYNTAX_ERROR; - // Only if the port wasn't overwritten by command-line. +#if PARPORT_USE_PPDEV == 1 + if (parport_device_file) { + LOG_ERROR("The parallel port device file is already configured"); + return ERROR_FAIL; + } + + char *tmp; + + // We do not use the parse_xxx() or COMMAND_PARSE_xxx() functions here since + // they generate an error message if parsing fails. + char *endptr = NULL; + unsigned long port_number = strtoul(CMD_ARGV[0], &endptr, 0); + + if (*endptr == '\0' && endptr != CMD_ARGV[0]) { + LOG_WARNING("DEPRECATED! Using a port number is deprecated, use the device file instead"); + +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) + tmp = alloc_printf("/dev/ppi%lu", port_number); +#else + tmp = alloc_printf("/dev/parport%lu", port_number); +#endif + } else { + tmp = strdup(CMD_ARGV[0]); + } + + if (!tmp) { + LOG_ERROR("Failed to allocate memory"); + return ERROR_FAIL; + } + + free(parport_device_file); + parport_device_file = tmp; +#else if (parport_port > 0) { command_print(CMD, "The parallel port is already configured"); return ERROR_FAIL; } COMMAND_PARSE_NUMBER(u16, CMD_ARGV[0], parport_port); +#endif return ERROR_OK; } @@ -489,9 +533,8 @@ static const struct command_registration parport_subcommand_handlers[] = { .name = "port", .handler = parport_handle_port_command, .mode = COMMAND_CONFIG, - .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", + .help = "Specify the device file of the parallel port", + .usage = "file", }, { .name = "cable", ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 9 +++-- src/jtag/drivers/parport.c | 93 +++++++++++++++++++++++++++++++++------------- 2 files changed, 73 insertions(+), 29 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 16:14:37
|
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 39ed0b0bbaac63c88d1e4b9ffe85e209bdb6b059 (commit) from 6d51e6b900a1d2ec2446f042c8294109ecda7483 (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 39ed0b0bbaac63c88d1e4b9ffe85e209bdb6b059 Author: Marc Schink <de...@za...> Date: Sun Aug 17 14:11:39 2025 +0000 adapter/parport: Deprecate direct I/O support We deprecate direct I/O support in favor of ppdev for the following reasons: - Linux supports ppdev since ~2.4 (released ~24 years ago) and it is enabled by default on major distros (Ubuntu, Fedora). So it is effectively ubiquitous - FreeBSD provides no direct I/O support, so ppdev (ppi) is the only viable option - Direct I/O requires root/elevated privileges which is inadvisable - Removing direct I/O reduces build and driver complexity and yields a smaller, easier-to-maintain codebase - Supporting only ppdev allows us to simplify the codebase by using device files (e.g., /dev/parport0) instead of numeric identifiers Windows is the only rationale to keep direct I/O, but the user base appears minimal to nonexistent and no active contributors can test the Windows driver. Change-Id: Ia6d5ed6e8c5faa2a9b4919ca97c5cf9033372a64 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9151 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/configure.ac b/configure.ac index 128c565a0..84d9739b4 100644 --- a/configure.ac +++ b/configure.ac @@ -356,7 +356,7 @@ AC_ARG_ENABLE([parport_ppdev], AC_ARG_ENABLE([parport_giveio], AS_HELP_STRING([--enable-parport-giveio], - [Enable use of giveio for parport (for CygWin only)]), + [Enable use of giveio for parport (deprecated, for CygWin only)]), [parport_use_giveio=$enableval], [parport_use_giveio=]) AC_ARG_ENABLE([gw16012], @@ -825,6 +825,12 @@ AS_IF([test "x$build_gw16012" = "xyes"], [ AC_MSG_WARN([Gateworks GW16012 JTAG adapter is deprecated and support will be removed in the next release!]) ]) +AS_IF([test "x$parport_use_giveio" = "xyes" || test [ "x$enable_parport" != "xno" -a "x$parport_use_ppdev" = "xno"]], [ + echo + echo + AC_MSG_WARN([Parallel port access with direct I/O is deprecated and support will be removed in the next release!]) +]) + echo echo echo OpenOCD configuration summary diff --git a/doc/openocd.texi b/doc/openocd.texi index d6f9736b8..4229f831b 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -3225,6 +3225,7 @@ 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). +@b{Note:} Direct I/O support is deprecated and will be removed in the future. @end deffn @deffn {Config Command} {parport write_on_exit} (@option{on}|@option{off}) diff --git a/src/jtag/drivers/parport.c b/src/jtag/drivers/parport.c index 09e312ec2..b29562b84 100644 --- a/src/jtag/drivers/parport.c +++ b/src/jtag/drivers/parport.c @@ -341,6 +341,8 @@ static int parport_init(void) #endif /* not __FreeBSD__, __FreeBSD_kernel__ */ #else /* not PARPORT_USE_PPDEV */ + LOG_WARNING("DEPRECATED: Parallel port access with direct I/O is deprecated and support will be removed in the next release"); + if (!parport_port) { parport_port = 0x378; LOG_WARNING("No parallel port specified, using default 0x378 (LPT1)"); ----------------------------------------------------------------------- Summary of changes: configure.ac | 8 +++++++- doc/openocd.texi | 1 + src/jtag/drivers/parport.c | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 16:14: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 6d51e6b900a1d2ec2446f042c8294109ecda7483 (commit) via 4805ecad761d447f6fd6d5a243289e02f4251812 (commit) from 382f067b6ee51229d8b502362722fa22d36edcfe (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 6d51e6b900a1d2ec2446f042c8294109ecda7483 Author: Marc Schink <de...@za...> Date: Mon Aug 25 15:11:06 2025 +0000 tcl/interface: Remove flashlink config Remove the configuration file, a replacement is already available. Link the old filename to the new configuration file to ensure backwards compatibility. Change-Id: I77cbd62d805b1c9b9bb8f56a823c3f6476d1a5a9 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9150 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/tcl/file_renaming.cfg b/tcl/file_renaming.cfg index 9b5fedbb1..79932473e 100644 --- a/tcl/file_renaming.cfg +++ b/tcl/file_renaming.cfg @@ -21,4 +21,5 @@ set _file_renaming { board/stm32mp15x_dk2.cfg board/st/stm32mp157f-dk2.cfg board/sifive-hifive1-revb.cfg board/sifive/hifive1-rev-b.cfg interface/chameleon.cfg interface/parport/chameleon.cfg + interface/flashlink.cfg interface/parport/flashlink.cfg } diff --git a/tcl/interface/flashlink.cfg b/tcl/interface/flashlink.cfg deleted file mode 100644 index d552c50a6..000000000 --- a/tcl/interface/flashlink.cfg +++ /dev/null @@ -1,18 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later - -# -# ST FlashLINK JTAG parallel cable -# -# http://www.st.com/internet/evalboard/product/94023.jsp -# http://www.st.com/stonline/products/literature/um/7889.pdf -# - -if { [info exists PARPORTADDR] } { - set _PARPORTADDR $PARPORTADDR -} else { - set _PARPORTADDR 0 -} - -adapter driver parport -parport port $_PARPORTADDR -parport cable flashlink commit 4805ecad761d447f6fd6d5a243289e02f4251812 Author: Marc Schink <de...@za...> Date: Mon Aug 25 15:09:22 2025 +0000 tcl/interface: Remove chameleon config Remove the configuration file, a replacement is already available. Link the old filename to the new configuration file to ensure backwards compatibility. Change-Id: I11361e471bb7ec277a850f956e51cd7d0fab408d Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/9149 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/tcl/file_renaming.cfg b/tcl/file_renaming.cfg index 8950f6cd6..9b5fedbb1 100644 --- a/tcl/file_renaming.cfg +++ b/tcl/file_renaming.cfg @@ -20,4 +20,5 @@ 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 + interface/chameleon.cfg interface/parport/chameleon.cfg } diff --git a/tcl/interface/chameleon.cfg b/tcl/interface/chameleon.cfg deleted file mode 100644 index b73d129f0..000000000 --- a/tcl/interface/chameleon.cfg +++ /dev/null @@ -1,10 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-or-later - -# -# Amontec Chameleon POD -# -# http://www.amontec.com/chameleon.shtml -# - -adapter driver parport -parport cable chameleon ----------------------------------------------------------------------- Summary of changes: tcl/file_renaming.cfg | 2 ++ tcl/interface/chameleon.cfg | 10 ---------- tcl/interface/flashlink.cfg | 18 ------------------ 3 files changed, 2 insertions(+), 28 deletions(-) delete mode 100644 tcl/interface/chameleon.cfg delete mode 100644 tcl/interface/flashlink.cfg hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 16:07:57
|
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 382f067b6ee51229d8b502362722fa22d36edcfe (commit) from 34d76b805ef974825b5b69e036fcc0835679fc72 (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 382f067b6ee51229d8b502362722fa22d36edcfe Author: Marek Kraus <gam...@ou...> Date: Sat Mar 22 15:36:45 2025 +0100 tcl/target: add Bouffalo Lab BL616 chip series support Adds support for BL616 series of chips, BL616 and BL618. No flash bank support yet. BL616 in comparison with BL602-series have new architecture, using T-Head E907 RISC-V cores, instead of SiFive ones. As BL602-series, the ndmreset bit in RISC-V Debug Module does not reset the chip as it should, so we need to do it manually with registers almost the same way as in BL602. Additionally, JTAG Debug Transport Module in the chip have wrongly implemented Test-Logic-Reset state, causing automatic chain scan not working at all after initial JTAG usage. This is because Test-Logic-State do not set IR instruction to IDCODE, as it should by JTAG spec. We can fix this by getting state machine to known state and configure IR instruction manually to IDCODE. This bug was so far found in T-Head C906 and E907 IP cores. This patch was tested heavily and works reliably on BL616, BL618 and QCC74X. Change-Id: Idc80a702e817d78fc0ca925572c68d4d0c28ce4e Signed-off-by: Marek Kraus <gam...@ou...> Reviewed-on: https://review.openocd.org/c/openocd/+/9145 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/tcl/target/bl616.cfg b/tcl/target/bl616.cfg new file mode 100644 index 000000000..ee59f1850 --- /dev/null +++ b/tcl/target/bl616.cfg @@ -0,0 +1,145 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Author: Marek Kraus <gam...@ga...> + +# +# Bouffalo Labs BL616 and BL618 target +# +# Default JTAG pins: (if not changed by eFuse configuration) +# TMS - GPIO0 +# TCK - GPIO1 +# TDO - GPIO2 +# TDI - GPIO3 +# + +source [find mem_helper.tcl] + +transport select jtag + +if { [info exists CHIPNAME] } { + set _CHIPNAME $CHIPNAME +} else { + set _CHIPNAME bl616 +} + +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x10000b6f + +set _TARGETNAME $_CHIPNAME.cpu +target create $_TARGETNAME riscv -chain-position $_TARGETNAME + +riscv set_mem_access progbuf +riscv set_enable_virt2phys off + +$_TARGETNAME configure -work-area-phys 0x40000000 -work-area-size 0x10000 -work-area-backup 1 + +adapter speed 4000 + +# Useful functions +set dmcontrol 0x10 +set dmcontrol_dmactive [expr {1 << 0}] +set dmcontrol_haltreq [expr {1 << 31}] + +# By spec, ndmreset should reset whole chip. This implementation resets only few parts of the chip. +# CTRL_PWRON_RESET register in GLB core triggers full "power-on like" reset, so we use it instead +# for full software reset. +$_TARGETNAME configure -event reset-assert { + halt + + # To stay in BootROM until JTAG re-attaches, we are using BootROM functionality + # to force ISP mode, so BootROM looks out for external ISP communication. + + # In HBN_RSV2, set HBN_RELEASE_CORE to HBN_RELEASE_CORE_FLAG (4) + # and HBN_USER_BOOT_SEL to 1 (ISP) + mww 0x2000f108 0x44000000 + + # Switch clock to internal RC32M + # In HBN_GLB, set ROOT_CLK_SEL = 0 + mmw 0x2000f030 0x0 0x00000002 + + # In GLB_SYS_CFG0, set REG_BCLK_DIV and REG_HCLK_DIV = 0 + mmw 0x20000090 0x0 0x00FFFF00 + + # Trigger BCLK ACT pulse + # In GLB_SYS_CFG1, set BCLK_DIV_ACT_PULSE = 1 + mmw 0x20000094 0x1 0x00000001 + # In GLB_SYS_CFG1, wait for GLB_STS_BCLK_PROT_DONE to become 1 + while { [expr {[mrw 0x20000094] & 4}] == 0 } { sleep 1 } + + # In GLB_SWRST_CFG2, clear CTRL_PWRON_RESET + mmw 0x20000548 0x0 0x00000001 + + # This Software reset method resets everything, so CPU as well. + # It does that in not much good way, resulting in Debug Module being reset as well. + # This also means, that right after CPU and Debug Module are turned on, we need to + # enable Debug Module and halt CPU if needed. Additionally, we trigger this SW reset + # through program buffer access directly with DMI commands, to avoid errors printed by + # OpenOCD about unsuccessful register write. + + # In GLB_SWRST_CFG2, set CTRL_PWRON_RESET to 1 + set_reg {fp 0x20000548 s1 0x01} + riscv dmi_write 0x20 0x00942023 + riscv dmi_write 0x17 0x40000 + + # We need to wait for chip to finish reset and execute BootROM + sleep 10 + + # JTAG Debug Transport Module is reset as well, so we need to get into RUN/IDLE state + runtest 10 + + # We need to enable Debug Module and halt the CPU, so we can reset Program Counter + # and to do additional clean-ups. If reset was called without halt, resume is handled + # by reset-deassert-post event handler. + + # In Debug Module Control (dmcontrol), set dmactive to 1 and then haltreq to 1 + riscv dmi_write $::dmcontrol $::dmcontrol_dmactive + riscv dmi_write $::dmcontrol [ expr {$::dmcontrol_dmactive | $::dmcontrol_haltreq} ] +} + +$_TARGETNAME configure -event reset-deassert-post { + # Set Program Counter to start of BootROM and execute one instruction + step 0x90000000 + + # When using default JTAG pinout, BOOT pin is the same as JTAG TDO pin. + # Since after reset we set PC to start of the BootROM, + # BootROM will execute also check of BOOT pin, which will disable TDO pin, + # to check the BOOT pin state. This leads to temporary loss of JTAG access + # and causes (recoverable) errors in OpenOCD. We can bypass the BOOT pin check + # function, by forcing booting from Media/SPI Flash. + + # In HBN_RSV2, set HBN_RELEASE_CORE to HBN_RELEASE_CORE_FLAG (4) + # and HBN_USER_BOOT_SEL to 2 (Media/SPI Flash) + mww 0x2000f108 0x48000000 + + # Resume the processor if reset was triggered without halt request + if {$halt == 0} { + resume + } +} + +# According to JTAG spec (IEEE 1149.1), when chip enters "Test-Logic-Reset" state, +# the IR instruction should be set to "IDCODE" or "BYPASS" (when chip does not have IDCODE). +# This is done so automatic chain scan can detect all the chips within JTAG chain without knowing IDCODE. +# JTAG Debug Transport Module (DTM) used in this chip, developed by T-Head (formerly C-Sky) +# does not implement this, so OpenOCD can't detect the chip anymore after the IR instruction is changed. +# This workaround gets chip into known state, and manually set IR instruction to IDCODE, +# which is 0x01, standardized by RISC-V Debug Specification. +proc init_reset { mode } { + if {[using_jtag]} { + # Get JTAG SM to known state + runtest 10 + # Set IR to IDCODE + irscan $::_CHIPNAME.cpu 0x01 + jtag arp_init-reset + } +} + +proc jtag_init {} { + # Get JTAG SM to known state + runtest 10 + # Set IR to IDCODE + irscan $::_CHIPNAME.cpu 0x01 + + if {[catch {jtag arp_init} err]!=0} { + # try resetting additionally + init_reset startup + } +} ----------------------------------------------------------------------- Summary of changes: tcl/target/bl616.cfg | 145 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) create mode 100644 tcl/target/bl616.cfg hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 16:03:10
|
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 34d76b805ef974825b5b69e036fcc0835679fc72 (commit) from 5fa74d4ee8739ef15d529ce0d4a49d129ce6f517 (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 34d76b805ef974825b5b69e036fcc0835679fc72 Author: Antonio Borneo <bor...@gm...> Date: Sat Sep 13 10:15:21 2025 +0200 README: add instructions for missing INSTALL file The file INSTALL has been dropped in 2009 with [1] and it has been replaced by the INSTALL file generated by automake. The file INSTALL is only present in official releases of OpenOCD and not in the code cloned from git. Add a note in README to report this inconsistency. Change-Id: I881b4282550a80bd5a6c61baff05543714a2e9c5 Reported-by: Mats <ma...@us...> Signed-off-by: Antonio Borneo <bor...@gm...> Fixes: https://sourceforge.net/p/openocd/tickets/451/ Link: [1] commit ef733b48e9f8 ("Switch automake handling to use --gnu mode, not --foreign. Remove INSTALL file; automake generates a copy of the latest version.") Reviewed-on: https://review.openocd.org/c/openocd/+/9121 Tested-by: jenkins diff --git a/README b/README index 875c85de3..73aa3a630 100644 --- a/README +++ b/README @@ -191,6 +191,11 @@ and compiling the OpenOCD source code. That file is provided by default for all GNU autotools packages. If you are not familiar with the GNU autotools, then you should read those instructions first. +Note: if the INSTALL file is not present, it means you are using the +source code from a development branch, not from an OpenOCD release. +In this case, follow the instructions 'Compiling OpenOCD' below and +the file will be created by the first command './bootstrap'. + The remainder of this document tries to provide some instructions for those looking for a quick-install. ----------------------------------------------------------------------- Summary of changes: README | 5 +++++ 1 file changed, 5 insertions(+) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 16:02: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 5fa74d4ee8739ef15d529ce0d4a49d129ce6f517 (commit) from 8b43a967e59de4eacb65627ea0ff6665dcdb0ac4 (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 5fa74d4ee8739ef15d529ce0d4a49d129ce6f517 Author: EasyDevKits <in...@ea...> Date: Wed Sep 3 22:21:21 2025 +0200 jtag/ch347: Refine driver and configs for EasyDevKits adapters This commit improves support for CH347-based JTAG adapters: - configure.ac: removed "Mode3" restriction (CH347F does not require mode). - configs: added board config for ESP32-WROVER-E WCH JTAG DevKit and ESP32-WROVER-E FTDI JTAG DevKit - ch347 driver: removed `ch347 activity_led` command; activity LED is now controlled via the generic `adapter gpio led` command. - doc/openocd.texi: updated documentation accordingly. Change-Id: I5524290297adcc004e00af919181868d2b6303af Signed-off-by: EasyDevKits <in...@ea...> Reviewed-on: https://review.openocd.org/c/openocd/+/9015 Reviewed-by: zapb <de...@za...> Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/configure.ac b/configure.ac index ed26d45e1..128c565a0 100644 --- a/configure.ac +++ b/configure.ac @@ -129,7 +129,7 @@ m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])]) m4_define([USB1_ADAPTERS], [[[ftdi], [MPSSE mode of FTDI based devices], [FTDI]], - [[ch347], [Mode 3 of CH347 based devices], [CH347]], + [[ch347], [CH347 based devices], [CH347]], [[stlink], [ST-Link Programmer], [HLADAPTER_STLINK]], [[ti_icdi], [TI ICDI JTAG Programmer], [HLADAPTER_ICDI]], [[ulink], [Keil ULINK JTAG Programmer], [ULINK]], diff --git a/doc/openocd.texi b/doc/openocd.texi index 6301077fc..d6f9736b8 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -2590,6 +2590,9 @@ mitigates the problem. @end itemize @end itemize +The driver supports activity LED through the generic +command @ref{adapter gpio, @command{adapter gpio led}}. + This driver has these driver-specific command: @deffn {Config Command} {ch347 vid_pid} [vid pid]+ @@ -2609,17 +2612,6 @@ and product ID will be connected. ch347 device_desc "EasyDevKit" @end example @end deffn - -@deffn {Config Command} {ch347 activity_led} [n]gpio_number -If specified the drive let an activity LED blink during JTAG operations. -The number is the GPIO number of the CH347T chip. If prefixed with "n", -then this GPIO should be low active. The example configures GPIO4 as -low active activity LED. For the CH347T chip only GPIO3 (Pin11 / SCL), -GPIO4 (Pin15 / ACT), GPIO5 (Pin9 / TRST) and GPIO6 (Pin2 / CTS1) are possible. -@example -ch347 activity_led n4 -@end example -@end deffn @end deffn @deffn {Interface Driver} {cmsis-dap} diff --git a/src/jtag/drivers/ch347.c b/src/jtag/drivers/ch347.c index 6a848ba7c..c031ceece 100644 --- a/src/jtag/drivers/ch347.c +++ b/src/jtag/drivers/ch347.c @@ -48,6 +48,7 @@ #include <jtag/interface.h> #include <jtag/commands.h> #include <jtag/swd.h> +#include <jtag/adapter.h> #include <helper/time_support.h> #include <helper/replacements.h> #include <helper/list.h> @@ -1805,32 +1806,6 @@ COMMAND_HANDLER(ch347_handle_device_desc_command) return ERROR_OK; } -/** - * @brief The command handler for configuring which GPIO pin is used as activity LED - * - * @return ERROR_OK at success; ERROR_COMMAND_SYNTAX_ERROR otherwise - */ -COMMAND_HANDLER(ch347_handle_activity_led_command) -{ - if (CMD_ARGC != 1) - return ERROR_COMMAND_SYNTAX_ERROR; - - uint8_t gpio; - if (CMD_ARGV[0][0] == 'n') { - COMMAND_PARSE_NUMBER(u8, &CMD_ARGV[0][1], gpio); - ch347_activity_led_active_high = false; - } else { - COMMAND_PARSE_NUMBER(u8, CMD_ARGV[0], gpio); - ch347_activity_led_active_high = true; - } - - if (gpio >= GPIO_CNT || (BIT(gpio) & USEABLE_GPIOS) == 0) - return ERROR_COMMAND_ARGUMENT_INVALID; - - ch347_activity_led_gpio_pin = gpio; - return ERROR_OK; -} - static const struct command_registration ch347_subcommand_handlers[] = { { .name = "vid_pid", @@ -1846,13 +1821,6 @@ static const struct command_registration ch347_subcommand_handlers[] = { .help = "set the USB device description of the CH347 device", .usage = "description_string", }, - { - .name = "activity_led", - .handler = &ch347_handle_activity_led_command, - .mode = COMMAND_CONFIG, - .help = "if set this CH347 GPIO pin is the JTAG activity LED; start with n for active low output", - .usage = "[n]gpio_number", - }, COMMAND_REGISTRATION_DONE }; @@ -1867,6 +1835,25 @@ static const struct command_registration ch347_command_handlers[] = { COMMAND_REGISTRATION_DONE }; +/** + * @brief Configure which GPIO pin is used as the activity LED. + * + * Updates the global activity LED GPIO pin and polarity settings + * based on the provided configuration. If the given GPIO is not + * usable, the function returns without making changes. + * + * @param led_config Pointer to the GPIO configuration structure for the LED pin + */ +static void ch347_configure_activity_led(const struct adapter_gpio_config *led_config) +{ + uint8_t gpio = led_config->gpio_num; + if (gpio >= GPIO_CNT || (BIT(gpio) & USEABLE_GPIOS) == 0) + return; + + ch347_activity_led_gpio_pin = gpio; + ch347_activity_led_active_high = !led_config->active_low; +} + /** * @brief CH347 Initialization function * @@ -1893,6 +1880,8 @@ static int ch347_init(void) ch347.pack_size = UNSET; + ch347_configure_activity_led(&adapter_gpio_get_config()[ADAPTER_GPIO_IDX_LED]); + if (!swd_mode) { tap_set_state(TAP_RESET); } else { diff --git a/tcl/board/easydevkits/esp32-wrover-e-ftdi-jtag-devkit.cfg b/tcl/board/easydevkits/esp32-wrover-e-ftdi-jtag-devkit.cfg new file mode 100644 index 000000000..30cfb5797 --- /dev/null +++ b/tcl/board/easydevkits/esp32-wrover-e-ftdi-jtag-devkit.cfg @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Example OpenOCD configuration file for the EasyDevKits ESP32-WROVER-E FTDI JTAG DevKit. +# +# For example, OpenOCD can be started for ESP32 debugging on +# +# openocd -f board/esp32-wrover-e-ftdi-jtag-devkit.cfg +# + +# Select the FTDI JTAG driver +adapter driver ftdi + +# Identify the device +ftdi device_desc "EasyDevKit" +ftdi vid_pid 0x0403 0x6010 +# interface 0 is JTAG; interface 1 is the uart +ftdi channel 0 + +# TCK, TDI, TDO, TMS: ADBUS0-3 +# activity LED: ADBUS4 +ftdi layout_init 0x0008 0x001b +ftdi layout_signal LED -data 0x0010 + +# Source the ESP32 configuration file +source [find target/esp32.cfg] + +# --------------------------------------------------------------------------- +# JTAG speed (in kHz) +# +# If you encounter DSR/DIR errors that are not caused by OpenOCD +# attempting to read unmapped memory regions, try lowering this value. +# +# Recommended settings for EasyDevKits: +# - Do not exceed 20 MHz. +# - Best results are typically achieved at 20 MHz. +# --------------------------------------------------------------------------- +adapter speed 20000 diff --git a/tcl/board/easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg b/tcl/board/easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg new file mode 100644 index 000000000..76f1435be --- /dev/null +++ b/tcl/board/easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg @@ -0,0 +1,37 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# +# Example OpenOCD configuration file for the EasyDevKits ESP32-WROVER-E WCH JTAG DevKit. +# +# For example, OpenOCD can be started for ESP32 debugging on +# +# openocd -f board/esp32-wrover-e-wch-jtag-devkit.cfg +# + +# Select the CH347 JTAG driver +adapter driver ch347 + +# Identify the device +ch347 device_desc "EasyDevKit" +ch347 vid_pid 0x1a86 0x55dd + +# Configure activity LED +# Note: The LED is active-low on GPIO4. +adapter gpio led 4 -active-low + +# Source the ESP32 configuration file +source [find target/esp32.cfg] + +# --------------------------------------------------------------------------- +# JTAG speed (in kHz) +# +# If you encounter DSR/DIR errors that are not caused by OpenOCD +# attempting to read unmapped memory regions, try lowering this value. +# +# Recommended settings for EasyDevKits: +# - Do not exceed 30 MHz. +# - Best results are typically achieved at 15 MHz. +# +# Supported frequencies (kHz): +# 469, 938, 1875, 3750, 7500, 15000, 30000, 60000 +# --------------------------------------------------------------------------- +adapter speed 15000 ----------------------------------------------------------------------- Summary of changes: configure.ac | 2 +- doc/openocd.texi | 14 ++---- src/jtag/drivers/ch347.c | 55 +++++++++------------- .../esp32-wrover-e-ftdi-jtag-devkit.cfg | 37 +++++++++++++++ .../easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg | 37 +++++++++++++++ 5 files changed, 100 insertions(+), 45 deletions(-) create mode 100644 tcl/board/easydevkits/esp32-wrover-e-ftdi-jtag-devkit.cfg create mode 100644 tcl/board/easydevkits/esp32-wrover-e-wch-jtag-devkit.cfg hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 15:57: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 8b43a967e59de4eacb65627ea0ff6665dcdb0ac4 (commit) from 04da6e2c624658d2c2c5c81f49be2e396bd30490 (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 8b43a967e59de4eacb65627ea0ff6665dcdb0ac4 Author: Antonio Borneo <bor...@gm...> Date: Mon Sep 22 09:53:43 2025 +0200 target: cortex_m: add comment for breakpoint of length 3 Add a comment in the breakpoint code to clarify the check for the odd breakpoint length of 3 bytes, introduced by [1]. [1]: commit 0a5e03c12aff ("cortex_m.c: Use two byte breakpoint for 32bit Thumb-2 request"). Change-Id: I024863d10078b5d9062c876aa59ccf70a81bf641 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9139 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index bfcbbc289..42e957260 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -2041,6 +2041,15 @@ int cortex_m_unset_breakpoint(struct target *target, struct breakpoint *breakpoi int cortex_m_add_breakpoint(struct target *target, struct breakpoint *breakpoint) { + /* + * GDB packets Z0 and z0 provide the 'kind' parameter that is target-specific + * and typically indicates the size in bytes of the breakpoint. + * But for 32-bit Thumb mode (Thumb-2) breakpoint, GDB provides 'kind = 3' to + * be used to derive the length information. See: + * https://sourceware.org/gdb/current/onlinedocs/gdb.html/ARM-Breakpoint-Kinds.html + * Since there isn't a four byte Thumb-2 breakpoint instruction, always use + * the two bytes breakpoint instruction. + */ if (breakpoint->length == 3) { LOG_TARGET_DEBUG(target, "Using a two byte breakpoint for 32bit Thumb-2 request"); breakpoint->length = 2; ----------------------------------------------------------------------- Summary of changes: src/target/cortex_m.c | 9 +++++++++ 1 file changed, 9 insertions(+) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 15:57:20
|
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 04da6e2c624658d2c2c5c81f49be2e396bd30490 (commit) from 2abf8daa80d31dc78877943ad580af7a6fbbbe3f (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 04da6e2c624658d2c2c5c81f49be2e396bd30490 Author: Antonio Borneo <bor...@gm...> Date: Tue Aug 5 12:06:22 2025 +0200 target: cortex-m: add support for armv8m caches Cores like Cortex-M7, Cortex-M55 and Cortex-M85 can have either D-Cache and/or I-Cache. Using SW breakpoints in RAM requires handling these caches. Detect the presence of cache at examine. Detect cache state (enable/disable) at debug entry. Take care of caches synchronization through the PoC (usually the SRAM) while setting and removing SW breakpoints. Add command 'cache_info' to check cache presence and size. Change-Id: Ice637c215fe3042c8fff57edefbab1b86515ef4b Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9077 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/doc/openocd.texi b/doc/openocd.texi index 7f7c8892f..6301077fc 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -11120,6 +11120,10 @@ Enable or disable trace output for all ITM stimulus ports. @subsection Cortex-M specific commands @cindex Cortex-M +@deffn {Command} {cortex_m cache_info} +Report information about the type and size of the cache, if present. +@end deffn + @deffn {Command} {cortex_m maskisr} (@option{auto}|@option{on}|@option{off}|@option{steponly}) Control masking (disabling) interrupts during target step/resume. diff --git a/src/target/Makefile.am b/src/target/Makefile.am index 1a7686418..0b5a85704 100644 --- a/src/target/Makefile.am +++ b/src/target/Makefile.am @@ -75,6 +75,7 @@ ARMV6_SRC = \ ARMV7_SRC = \ %D%/armv7m.c \ + %D%/armv7m_cache.c \ %D%/armv7m_trace.c \ %D%/cortex_m.c \ %D%/armv7a.c \ @@ -183,6 +184,7 @@ ARC_SRC = \ %D%/armv4_5_cache.h \ %D%/armv7a.h \ %D%/armv7m.h \ + %D%/armv7m_cache.h \ %D%/armv7m_trace.h \ %D%/armv8.h \ %D%/armv8_dpm.h \ diff --git a/src/target/armv7m.h b/src/target/armv7m.h index 86c45f7f2..942e22584 100644 --- a/src/target/armv7m.h +++ b/src/target/armv7m.h @@ -15,6 +15,7 @@ #define OPENOCD_TARGET_ARMV7M_H #include "arm.h" +#include "armv7m_cache.h" #include "armv7m_trace.h" struct adiv5_ap; @@ -239,6 +240,8 @@ struct armv7m_common { /* hla_target uses a high level adapter that does not support all functions */ bool is_hla_target; + struct armv7m_cache_common armv7m_cache; + struct armv7m_trace_config trace_config; /* Direct processor core register read and writes */ diff --git a/src/target/armv7m_cache.c b/src/target/armv7m_cache.c new file mode 100644 index 000000000..cb57c0e25 --- /dev/null +++ b/src/target/armv7m_cache.c @@ -0,0 +1,284 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +/* + * Copyright (C) 2025 by STMicroelectronics + * Copyright (C) 2025 by Antonio Borneo <bor...@gm...> + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <stdint.h> + +#include <helper/align.h> +#include <helper/bitfield.h> +#include <helper/bits.h> +#include <helper/command.h> +#include <helper/log.h> +#include <helper/types.h> +#include <target/arm_adi_v5.h> +#include <target/armv7m_cache.h> +#include <target/cortex_m.h> + +static int get_cache_info(struct adiv5_ap *ap, unsigned int cl, + unsigned int ind, uint32_t *ccsidr) +{ + uint32_t csselr = FIELD_PREP(CSSELR_LEVEL_MASK, cl) + | FIELD_PREP(CSSELR_IND_MASK, ind); + + int retval = mem_ap_write_u32(ap, CSSELR, csselr); + if (retval != ERROR_OK) + return retval; + + return mem_ap_read_u32(ap, CCSIDR, ccsidr); +} + +static int get_d_u_cache_info(struct adiv5_ap *ap, unsigned int cl, + uint32_t *ccsidr) +{ + return get_cache_info(ap, cl, CSSELR_IND_DATA_OR_UNIFIED_CACHE, ccsidr); +} + +static int get_i_cache_info(struct adiv5_ap *ap, unsigned int cl, + uint32_t *ccsidr) +{ + return get_cache_info(ap, cl, CSSELR_IND_INSTRUCTION_CACHE, ccsidr); +} + +static struct armv7m_cache_size decode_ccsidr(uint32_t ccsidr) +{ + struct armv7m_cache_size size; + + size.line_len = 16 << FIELD_GET(CCSIDR_LINESIZE_MASK, ccsidr); + size.associativity = FIELD_GET(CCSIDR_ASSOCIATIVITY_MASK, ccsidr) + 1; + size.num_sets = FIELD_GET(CCSIDR_NUMSETS_MASK, ccsidr) + 1; + size.cache_size = size.line_len * size.associativity * size.num_sets / 1024; + + // compute info for set way operation on cache + size.index_shift = FIELD_GET(CCSIDR_LINESIZE_MASK, ccsidr) + 2; + size.index = FIELD_GET(CCSIDR_NUMSETS_MASK, ccsidr); + size.way = FIELD_GET(CCSIDR_ASSOCIATIVITY_MASK, ccsidr); + + unsigned int i = 0; + while (((size.way << i) & 0x80000000) == 0) + i++; + size.way_shift = i; + + return size; +} + +int armv7m_identify_cache(struct target *target) +{ + struct armv7m_common *armv7m = target_to_armv7m(target); + struct armv7m_cache_common *cache = &armv7m->armv7m_cache; + + uint32_t clidr; + int retval = mem_ap_read_u32(armv7m->debug_ap, CLIDR, &clidr); + if (retval != ERROR_OK) + return retval; + + uint32_t ctr; + retval = mem_ap_read_u32(armv7m->debug_ap, CTR, &ctr); + if (retval != ERROR_OK) + return retval; + + // retrieve selected cache for later restore + uint32_t csselr; + retval = mem_ap_read_atomic_u32(armv7m->debug_ap, CSSELR, &csselr); + if (retval != ERROR_OK) + return retval; + + if (clidr == 0) { + LOG_TARGET_DEBUG(target, "No cache detected"); + return ERROR_OK; + } + + if (FIELD_GET(CTR_FORMAT_MASK, ctr) != CTR_FORMAT_PROVIDED) { + LOG_ERROR("Wrong value in CTR register"); + return ERROR_FAIL; + } + + cache->i_min_line_len = 4UL << FIELD_GET(CTR_IMINLINE_MASK, ctr); + cache->d_min_line_len = 4UL << FIELD_GET(CTR_DMINLINE_MASK, ctr); + LOG_TARGET_DEBUG(target, + "ctr=0x%" PRIx32 " ctr.i_min_line_len=%" PRIu32 " ctr.d_min_line_len=%" PRIu32, + ctr, cache->i_min_line_len, cache->d_min_line_len); + + cache->loc = FIELD_GET(CLIDR_LOC_MASK, clidr); + LOG_TARGET_DEBUG(target, + "clidr=0x%" PRIx32 " Number of cache levels to PoC=%" PRIu32, + clidr, cache->loc); + + // retrieve all available inner caches + uint32_t d_u_ccsidr[8], i_ccsidr[8]; + for (unsigned int cl = 0; cl < cache->loc; cl++) { + unsigned int ctype = FIELD_GET(CLIDR_CTYPE_MASK(cl + 1), clidr); + + // skip reserved values + if (ctype > CLIDR_CTYPE_UNIFIED_CACHE) + continue; + + cache->arch[cl].ctype = ctype; + + // separate d or unified d/i cache at this level ? + if (ctype & (CLIDR_CTYPE_UNIFIED_CACHE | CLIDR_CTYPE_D_CACHE)) { + // retrieve d-cache info + retval = get_d_u_cache_info(armv7m->debug_ap, cl, &d_u_ccsidr[cl]); + if (retval != ERROR_OK) + break; + } + + if (ctype & CLIDR_CTYPE_I_CACHE) { + // retrieve i-cache info + retval = get_i_cache_info(armv7m->debug_ap, cl, &i_ccsidr[cl]); + if (retval != ERROR_OK) + break; + } + } + + // restore selected cache + int retval1 = mem_ap_write_atomic_u32(armv7m->debug_ap, CSSELR, csselr); + + if (retval != ERROR_OK) + return retval; + if (retval1 != ERROR_OK) + return retval1; + + for (unsigned int cl = 0; cl < cache->loc; cl++) { + unsigned int ctype = cache->arch[cl].ctype; + + // separate d or unified d/i cache at this level ? + if (ctype & (CLIDR_CTYPE_UNIFIED_CACHE | CLIDR_CTYPE_D_CACHE)) { + cache->has_d_u_cache = true; + cache->arch[cl].d_u_size = decode_ccsidr(d_u_ccsidr[cl]); + + LOG_TARGET_DEBUG(target, + "data/unified cache index %" PRIu32 " << %" PRIu32 ", way %" PRIu32 " << %" PRIu32, + cache->arch[cl].d_u_size.index, + cache->arch[cl].d_u_size.index_shift, + cache->arch[cl].d_u_size.way, + cache->arch[cl].d_u_size.way_shift); + + LOG_TARGET_DEBUG(target, + "cache line %" PRIu32 " bytes %" PRIu32 " KBytes asso %" PRIu32 " ways", + cache->arch[cl].d_u_size.line_len, + cache->arch[cl].d_u_size.cache_size, + cache->arch[cl].d_u_size.associativity); + } + + if (ctype & CLIDR_CTYPE_I_CACHE) { + cache->has_i_cache = true; + cache->arch[cl].i_size = decode_ccsidr(i_ccsidr[cl]); + + LOG_TARGET_DEBUG(target, + "instruction cache index %" PRIu32 " << %" PRIu32 ", way %" PRIu32 " << %" PRIu32, + cache->arch[cl].i_size.index, + cache->arch[cl].i_size.index_shift, + cache->arch[cl].i_size.way, + cache->arch[cl].i_size.way_shift); + + LOG_TARGET_DEBUG(target, + "cache line %" PRIu32 " bytes %" PRIu32 " KBytes asso %" PRIu32 " ways", + cache->arch[cl].i_size.line_len, + cache->arch[cl].i_size.cache_size, + cache->arch[cl].i_size.associativity); + } + } + + cache->info_valid = true; + + return ERROR_OK; +} + +int armv7m_d_cache_flush(struct target *target, uint32_t address, + unsigned int length) +{ + struct armv7m_common *armv7m = target_to_armv7m(target); + struct armv7m_cache_common *cache = &armv7m->armv7m_cache; + + if (!cache->info_valid || !cache->has_d_u_cache) + return ERROR_OK; + + uint32_t line_len = cache->d_min_line_len; + uint32_t addr_line = ALIGN_DOWN(address, line_len); + uint32_t addr_end = address + length; + + while (addr_line < addr_end) { + int retval = mem_ap_write_u32(armv7m->debug_ap, DCCIMVAC, addr_line); + if (retval != ERROR_OK) + return retval; + addr_line += line_len; + keep_alive(); + } + + return dap_run(armv7m->debug_ap->dap); +} + +int armv7m_i_cache_inval(struct target *target, uint32_t address, + unsigned int length) +{ + struct armv7m_common *armv7m = target_to_armv7m(target); + struct armv7m_cache_common *cache = &armv7m->armv7m_cache; + + if (!cache->info_valid || !cache->has_i_cache) + return ERROR_OK; + + uint32_t line_len = cache->i_min_line_len; + uint32_t addr_line = ALIGN_DOWN(address, line_len); + uint32_t addr_end = address + length; + + while (addr_line < addr_end) { + int retval = mem_ap_write_u32(armv7m->debug_ap, ICIMVAU, addr_line); + if (retval != ERROR_OK) + return retval; + addr_line += line_len; + keep_alive(); + } + + return dap_run(armv7m->debug_ap->dap); +} + +int armv7m_handle_cache_info_command(struct command_invocation *cmd, + struct target *target) +{ + struct armv7m_common *armv7m = target_to_armv7m(target); + struct armv7m_cache_common *cache = &armv7m->armv7m_cache; + + if (!target_was_examined(target)) { + command_print(cmd, "Target not examined yet"); + return ERROR_FAIL; + } + + if (!cache->info_valid) { + command_print(cmd, "No cache detected"); + return ERROR_OK; + } + + for (unsigned int cl = 0; cl < cache->loc; cl++) { + struct armv7m_arch_cache *arch = &cache->arch[cl]; + + if (arch->ctype & CLIDR_CTYPE_I_CACHE) + command_print(cmd, + "L%d I-Cache: line length %" PRIu32 ", associativity %" PRIu32 + ", num sets %" PRIu32 ", cache size %" PRIu32 " KBytes", + cl + 1, + arch->i_size.line_len, + arch->i_size.associativity, + arch->i_size.num_sets, + arch->i_size.cache_size); + + if (arch->ctype & (CLIDR_CTYPE_UNIFIED_CACHE | CLIDR_CTYPE_D_CACHE)) + command_print(cmd, + "L%d %c-Cache: line length %" PRIu32 ", associativity %" PRIu32 + ", num sets %" PRIu32 ", cache size %" PRIu32 " KBytes", + cl + 1, + (arch->ctype & CLIDR_CTYPE_D_CACHE) ? 'D' : 'U', + arch->d_u_size.line_len, + arch->d_u_size.associativity, + arch->d_u_size.num_sets, + arch->d_u_size.cache_size); + } + + return ERROR_OK; +} diff --git a/src/target/armv7m_cache.h b/src/target/armv7m_cache.h new file mode 100644 index 000000000..576bff8d6 --- /dev/null +++ b/src/target/armv7m_cache.h @@ -0,0 +1,57 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/* + * Copyright (C) 2025 by STMicroelectronics + * Copyright (C) 2025 by Antonio Borneo <bor...@gm...> + */ + +#ifndef OPENOCD_TARGET_ARMV7M_CACHE_H +#define OPENOCD_TARGET_ARMV7M_CACHE_H + +#include <stdbool.h> +#include <stdint.h> + +#include <helper/types.h> + +struct target; + +struct armv7m_cache_size { + // cache dimensioning + uint32_t line_len; + uint32_t associativity; + uint32_t num_sets; + uint32_t cache_size; + // info for set way operation on cache + uint32_t index; + uint32_t index_shift; + uint32_t way; + uint32_t way_shift; +}; + +// information about one architecture cache at any level +struct armv7m_arch_cache { + unsigned int ctype; // cache type, CLIDR encoding + struct armv7m_cache_size d_u_size; // data cache + struct armv7m_cache_size i_size; // instruction cache +}; + +// common cache information +struct armv7m_cache_common { + bool info_valid; + bool has_i_cache; + bool has_d_u_cache; + unsigned int loc; // level of coherency + uint32_t d_min_line_len; // minimum d-cache line_len + uint32_t i_min_line_len; // minimum i-cache line_len + struct armv7m_arch_cache arch[6]; // cache info, L1 - L7 +}; + +int armv7m_identify_cache(struct target *target); +int armv7m_d_cache_flush(struct target *target, uint32_t address, + unsigned int length); +int armv7m_i_cache_inval(struct target *target, uint32_t address, + unsigned int length); +int armv7m_handle_cache_info_command(struct command_invocation *cmd, + struct target *target); + +#endif /* OPENOCD_TARGET_ARMV7M_CACHE_H */ diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 047a1d38e..bfcbbc289 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -21,6 +21,7 @@ #include "jtag/interface.h" #include "breakpoints.h" #include "cortex_m.h" +#include "armv7m_cache.h" #include "target_request.h" #include "target_type.h" #include "arm_adi_v5.h" @@ -30,6 +31,7 @@ #include "arm_semihosting.h" #include "smp.h" #include <helper/nvp.h> +#include <helper/string_choices.h> #include <helper/time_support.h> #include <rtt/rtt.h> @@ -873,6 +875,14 @@ static int cortex_m_debug_entry(struct target *target) return retval; } + // read caches state + uint32_t ccr = 0; + if (armv7m->armv7m_cache.info_valid) { + retval = mem_ap_read_u32(armv7m->debug_ap, CCR, &ccr); + if (retval != ERROR_OK) + return retval; + } + /* Load all registers to arm.core_cache */ if (!cortex_m->slow_register_read) { retval = cortex_m_fast_read_all_regs(target); @@ -926,6 +936,11 @@ static int cortex_m_debug_entry(struct target *target) secure_state ? "Secure" : "Non-Secure", target_state_name(target)); + if (armv7m->armv7m_cache.info_valid) + LOG_TARGET_DEBUG(target, "D-Cache %s, I-Cache %s", + str_enabled_disabled(ccr & CCR_DC_MASK), + str_enabled_disabled(ccr & CCR_IC_MASK)); + /* Errata 3092511 workaround * Cortex-M7 can halt in an incorrect address when breakpoint * and exception occurs simultaneously */ @@ -1938,12 +1953,25 @@ int cortex_m_set_breakpoint(struct target *target, struct breakpoint *breakpoint breakpoint->orig_instr); if (retval != ERROR_OK) return retval; + // make sure data cache is cleaned & invalidated down to PoC + retval = armv7m_d_cache_flush(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; + retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, code); if (retval != ERROR_OK) return retval; + // update i-cache at breakpoint location + retval = armv7m_d_cache_flush(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; + retval = armv7m_i_cache_inval(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; + breakpoint->is_set = true; } @@ -1986,12 +2014,25 @@ int cortex_m_unset_breakpoint(struct target *target, struct breakpoint *breakpoi target_write_u32(target, comparator_list[fp_num].fpcr_address, comparator_list[fp_num].fpcr_value); } else { + // make sure data cache is cleaned & invalidated down to PoC + retval = armv7m_d_cache_flush(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; + /* restore original instruction (kept in target endianness) */ retval = target_write_memory(target, breakpoint->address & 0xFFFFFFFE, breakpoint->length, 1, breakpoint->orig_instr); if (retval != ERROR_OK) return retval; + + // update i-cache at breakpoint location + retval = armv7m_d_cache_flush(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; + retval = armv7m_i_cache_inval(target, breakpoint->address, breakpoint->length); + if (retval != ERROR_OK) + return retval; } breakpoint->is_set = false; @@ -2906,6 +2947,12 @@ int cortex_m_examine(struct target *target) LOG_TARGET_INFO(target, "target has %d breakpoints, %d watchpoints", cortex_m->fp_num_code, cortex_m->dwt_num_comp); + + retval = armv7m_identify_cache(target); + if (retval != ERROR_OK) { + LOG_ERROR("Cannot detect cache"); + return retval; + } } return ERROR_OK; @@ -3238,6 +3285,16 @@ COMMAND_HANDLER(handle_cortex_m_reset_config_command) return ERROR_OK; } +COMMAND_HANDLER(handle_cortex_m_cache_info_command) +{ + if (CMD_ARGC) + return ERROR_COMMAND_SYNTAX_ERROR; + + struct target *target = get_current_target(CMD_CTX); + + return armv7m_handle_cache_info_command(CMD, target); +} + static const struct command_registration cortex_m_exec_command_handlers[] = { { .name = "maskisr", @@ -3260,6 +3317,13 @@ static const struct command_registration cortex_m_exec_command_handlers[] = { .help = "configure software reset handling", .usage = "['sysresetreq'|'vectreset']", }, + { + .name = "cache_info", + .handler = handle_cortex_m_cache_info_command, + .mode = COMMAND_EXEC, + .help = "display information about target caches", + .usage = "", + }, { .chain = smp_command_handlers, }, diff --git a/src/target/cortex_m.h b/src/target/cortex_m.h index 82b2c1ecd..e0a4e8552 100644 --- a/src/target/cortex_m.h +++ b/src/target/cortex_m.h @@ -15,6 +15,7 @@ #define OPENOCD_TARGET_CORTEX_M_H #include "armv7m.h" +#include "helper/bitfield.h" #include "helper/bits.h" #define CORTEX_M_COMMON_MAGIC 0x1A451A45U @@ -114,6 +115,45 @@ struct cortex_m_part_info { #define FPU_FPCAR 0xE000EF38 #define FPU_FPDSCR 0xE000EF3C +// Cache +#define CCR 0xE000ED14 +#define CLIDR 0xE000ED78 +#define CTR 0xE000ED7C +#define CCSIDR 0xE000ED80 +#define CSSELR 0xE000ED84 +#define ICIMVAU 0xE000EF58 +#define DCCIMVAC 0xE000EF70 + +#define CCR_IC_MASK BIT(17) +#define CCR_DC_MASK BIT(16) + +#define CLIDR_ICB_MASK GENMASK(31, 30) +#define CLIDR_LOUU_MASK GENMASK(29, 27) +#define CLIDR_LOC_MASK GENMASK(26, 24) +#define CLIDR_LOUIS_MASK GENMASK(23, 21) +#define CLIDR_CTYPE_MASK(i) (GENMASK(2, 0) << (3 * (i) - 3)) + +#define CLIDR_CTYPE_I_CACHE BIT(0) +#define CLIDR_CTYPE_D_CACHE BIT(1) +#define CLIDR_CTYPE_UNIFIED_CACHE BIT(2) + +#define CTR_FORMAT_MASK GENMASK(31, 29) +#define CTR_CWG_MASK GENMASK(27, 24) +#define CTR_ERG_MASK GENMASK(23, 20) +#define CTR_DMINLINE_MASK GENMASK(19, 16) +#define CTR_IMINLINE_MASK GENMASK(3, 0) + +#define CTR_FORMAT_PROVIDED 0x04 + +#define CCSIDR_NUMSETS_MASK GENMASK(27, 13) +#define CCSIDR_ASSOCIATIVITY_MASK GENMASK(12, 3) +#define CCSIDR_LINESIZE_MASK GENMASK(2, 0) + +#define CSSELR_LEVEL_MASK GENMASK(3, 1) +#define CSSELR_IND_MASK BIT(0) +#define CSSELR_IND_DATA_OR_UNIFIED_CACHE 0 +#define CSSELR_IND_INSTRUCTION_CACHE 1 + #define TPIU_SSPSR 0xE0040000 #define TPIU_CSPSR 0xE0040004 #define TPIU_ACPR 0xE0040010 ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 4 + src/target/Makefile.am | 2 + src/target/armv7m.h | 3 + src/target/armv7m_cache.c | 284 ++++++++++++++++++++++++++++++++++++++++++++++ src/target/armv7m_cache.h | 57 ++++++++++ src/target/cortex_m.c | 64 +++++++++++ src/target/cortex_m.h | 40 +++++++ 7 files changed, 454 insertions(+) create mode 100644 src/target/armv7m_cache.c create mode 100644 src/target/armv7m_cache.h hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-10-11 15:52:37
|
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 2abf8daa80d31dc78877943ad580af7a6fbbbe3f (commit) from e5888bda38f4952e2ae92f7dc5b25fc9a2d1c2b3 (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 2abf8daa80d31dc78877943ad580af7a6fbbbe3f Author: Marc Schink <de...@za...> Date: Mon Apr 15 07:48:31 2024 +0200 target/cortex_m: Remove echo of 'reset_config' command Do not echo the selected reset config. This is one of many changes to make the behavior of Tcl commands more consistent. This also avoids stray and confusing messages in the output of OpenOCD. For example, the "reset_config" line here: Open On-Chip Debugger 0.12.0+dev-00802-gb7f0145fc-dirty Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html cortex_m reset_config sysresetreq Info : Listening on port 6666 for tcl connections Info : Listening on port 4444 for telnet connections While at it, fix some coding style and command handling issues. Change-Id: I3b3d8687af1d23a2dc1764f29b52dc607b80cb59 Signed-off-by: Marc Schink <de...@za...> Reviewed-on: https://review.openocd.org/c/openocd/+/8638 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index c5d668a4d..047a1d38e 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -3194,43 +3194,46 @@ COMMAND_HANDLER(handle_cortex_m_reset_config_command) { struct target *target = get_current_target(CMD_CTX); struct cortex_m_common *cortex_m = target_to_cm(target); - int retval; - char *reset_config; - retval = cortex_m_verify_pointer(CMD, cortex_m); + int retval = cortex_m_verify_pointer(CMD, cortex_m); if (retval != ERROR_OK) return retval; - if (CMD_ARGC > 0) { - if (strcmp(*CMD_ARGV, "sysresetreq") == 0) - cortex_m->soft_reset_config = CORTEX_M_RESET_SYSRESETREQ; - - else if (strcmp(*CMD_ARGV, "vectreset") == 0) { - if (target_was_examined(target) - && !cortex_m->vectreset_supported) - LOG_TARGET_WARNING(target, "VECTRESET is not supported on your Cortex-M core!"); - else - cortex_m->soft_reset_config = CORTEX_M_RESET_VECTRESET; + if (!CMD_ARGC) { + char *reset_config; - } else - return ERROR_COMMAND_SYNTAX_ERROR; - } + switch (cortex_m->soft_reset_config) { + case CORTEX_M_RESET_SYSRESETREQ: + reset_config = "sysresetreq"; + break; - switch (cortex_m->soft_reset_config) { - case CORTEX_M_RESET_SYSRESETREQ: - reset_config = "sysresetreq"; - break; + case CORTEX_M_RESET_VECTRESET: + reset_config = "vectreset"; + break; - case CORTEX_M_RESET_VECTRESET: - reset_config = "vectreset"; - break; + default: + reset_config = "unknown"; + break; + } - default: - reset_config = "unknown"; - break; + command_print(CMD, "%s", reset_config); + return ERROR_OK; + } else if (CMD_ARGC != 1) { + return ERROR_COMMAND_SYNTAX_ERROR; } - command_print(CMD, "cortex_m reset_config %s", reset_config); + if (!strcmp(CMD_ARGV[0], "sysresetreq")) { + cortex_m->soft_reset_config = CORTEX_M_RESET_SYSRESETREQ; + } else if (!strcmp(CMD_ARGV[0], "vectreset")) { + if (target_was_examined(target) + && !cortex_m->vectreset_supported) + LOG_TARGET_WARNING(target, "VECTRESET is not supported on your Cortex-M core"); + else + cortex_m->soft_reset_config = CORTEX_M_RESET_VECTRESET; + } else { + command_print(CMD, "invalid reset config '%s'", CMD_ARGV[0]); + return ERROR_COMMAND_ARGUMENT_INVALID; + } return ERROR_OK; } ----------------------------------------------------------------------- Summary of changes: src/target/cortex_m.c | 57 +++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 27 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-30 07:23: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 e5888bda38f4952e2ae92f7dc5b25fc9a2d1c2b3 (commit) from 896738264e92b74a17250dab639999a2743d0b7c (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 e5888bda38f4952e2ae92f7dc5b25fc9a2d1c2b3 Author: Samuel Obuch <sam...@es...> Date: Mon Aug 18 22:05:55 2025 +0200 target/breakpoints: drop duplicate breakpoint/watchpoint "clear_target" functions We need to cleanup watchpoints on all targets in SMP group when GDB connects. Otherwise, the targets will not be consistent. Once thats fixed, both *_clear_target functions clearly duplicate the corresponding *_remove_all functions. Change-Id: I8e85dbc66fd3e596990d631ed2aed22959a8ca60 Signed-off-by: Samuel Obuch <sam...@es...> Reviewed-on: https://review.openocd.org/c/openocd/+/9086 Reviewed-by: Evgeniy Naydanov <evg...@sy...> Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/server/gdb_server.c b/src/server/gdb_server.c index 356dd6ec4..080e3360a 100644 --- a/src/server/gdb_server.c +++ b/src/server/gdb_server.c @@ -1041,8 +1041,8 @@ static int gdb_new_connection(struct connection *connection) * GDB session could leave dangling breakpoints if e.g. communication * timed out. */ - breakpoint_clear_target(target); - watchpoint_clear_target(target); + breakpoint_remove_all(target); + watchpoint_remove_all(target); /* Since version 3.95 (gdb-19990504), with the exclusion of 6.5~6.8, GDB * sends an ACK at connection with the following comment in its source code: @@ -3219,8 +3219,8 @@ static void gdb_restart_inferior(struct connection *connection, const char *pack struct gdb_connection *gdb_con = connection->priv; struct target *target = get_target_from_connection(connection); - breakpoint_clear_target(target); - watchpoint_clear_target(target); + breakpoint_remove_all(target); + watchpoint_remove_all(target); command_run_linef(connection->cmd_ctx, "ocd_gdb_restart %s", target_name(target)); /* set connection as attached after reset */ diff --git a/src/target/breakpoints.c b/src/target/breakpoints.c index 54a6145ca..7254eac7d 100644 --- a/src/target/breakpoints.c +++ b/src/target/breakpoints.c @@ -412,6 +412,8 @@ static int watchpoint_free(struct target *target, struct watchpoint *watchpoint_ static int watchpoint_remove_all_internal(struct target *target) { + LOG_TARGET_DEBUG(target, "Delete all watchpoints"); + struct watchpoint *watchpoint = target->watchpoints; int retval = ERROR_OK; @@ -465,27 +467,6 @@ int watchpoint_remove_all(struct target *target) return breakpoint_watchpoint_remove_all(target, WATCHPOINT); } -int breakpoint_clear_target(struct target *target) -{ - int retval = ERROR_OK; - - if (target->smp) { - struct target_list *head; - - foreach_smp_target(head, target->smp_targets) { - struct target *curr = head->target; - int status = breakpoint_remove_all_internal(curr); - - if (status != ERROR_OK) - retval = status; - } - } else { - retval = breakpoint_remove_all_internal(target); - } - - return retval; -} - struct breakpoint *breakpoint_find(struct target *target, target_addr_t address) { struct breakpoint *breakpoint = target->breakpoints; @@ -641,23 +622,6 @@ int watchpoint_remove(struct target *target, target_addr_t address) return retval; } -int watchpoint_clear_target(struct target *target) -{ - LOG_TARGET_DEBUG(target, "Delete all watchpoints"); - - struct watchpoint *watchpoint = target->watchpoints; - int retval = ERROR_OK; - - while (watchpoint) { - struct watchpoint *tmp = watchpoint; - watchpoint = watchpoint->next; - int status = watchpoint_free(target, tmp); - if (status != ERROR_OK) - retval = status; - } - return retval; -} - int watchpoint_hit(struct target *target, enum watchpoint_rw *rw, target_addr_t *address) { diff --git a/src/target/breakpoints.h b/src/target/breakpoints.h index 0789267c7..d547a687f 100644 --- a/src/target/breakpoints.h +++ b/src/target/breakpoints.h @@ -50,7 +50,6 @@ struct watchpoint { int unique_id; }; -int breakpoint_clear_target(struct target *target); int breakpoint_add(struct target *target, target_addr_t address, unsigned int length, enum breakpoint_type type); int context_breakpoint_add(struct target *target, @@ -69,7 +68,6 @@ static inline void breakpoint_hw_set(struct breakpoint *breakpoint, unsigned int breakpoint->number = hw_number; } -int watchpoint_clear_target(struct target *target); int watchpoint_add(struct target *target, target_addr_t address, unsigned int length, enum watchpoint_rw rw, uint64_t value, uint64_t mask); ----------------------------------------------------------------------- Summary of changes: src/server/gdb_server.c | 8 ++++---- src/target/breakpoints.c | 40 ++-------------------------------------- src/target/breakpoints.h | 2 -- 3 files changed, 6 insertions(+), 44 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 15:22:55
|
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 896738264e92b74a17250dab639999a2743d0b7c (commit) from 5bf63333138896120349cbcd48af815aeab5e185 (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 896738264e92b74a17250dab639999a2743d0b7c Author: Brian Kuschak <bku...@gm...> Date: Thu Sep 18 13:41:24 2025 +0800 jtag/drivers/cmsis_dap_tcp: fix socket handling for Windows Windows does not support socket recv() with a combination of MSG_PEEK and MSG_WAITALL flags. Work around this limitation in a way that works for both Windows and other platforms. Change-Id: Ib77e2cc872e5fe3d1fc41034010b86390131fff3 Fixes: https://sourceforge.net/p/openocd/tickets/457/ Signed-off-by: Brian Kuschak <bku...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9136 Reviewed-by: IRON ALEKS <8ir...@gm...> Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/src/jtag/drivers/cmsis_dap_tcp.c b/src/jtag/drivers/cmsis_dap_tcp.c index 8a96cd624..7894550fe 100644 --- a/src/jtag/drivers/cmsis_dap_tcp.c +++ b/src/jtag/drivers/cmsis_dap_tcp.c @@ -20,6 +20,10 @@ #include "config.h" #endif +#ifdef HAVE_ARPA_INET_H +#include <arpa/inet.h> +#endif +#include <errno.h> #ifdef HAVE_NETDB_H #include <netdb.h> #endif @@ -28,10 +32,21 @@ #endif #include <stdbool.h> #include <string.h> +#ifdef HAVE_SYS_IOCTL_H +#include <sys/ioctl.h> +#endif #ifdef HAVE_SYS_SOCKET_H #include <sys/socket.h> #endif #include <sys/types.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#ifdef _WIN32 +#include <winsock2.h> +#include <ws2tcpip.h> +#endif #include "helper/command.h" #include "helper/log.h" @@ -193,19 +208,107 @@ static void cmsis_dap_tcp_close(struct cmsis_dap *dap) cmsis_dap_tcp_free(dap); } +static int socket_bytes_available(int sock, unsigned int *out_avail) +{ +#ifdef _WIN32 + u_long avail = 0; + if (ioctlsocket((SOCKET)sock, FIONREAD, &avail) == SOCKET_ERROR) + return -1; +#else + int avail = 0; + if (ioctl(sock, FIONREAD, &avail) < 0) + return -1; +#endif + *out_avail = avail; + return 0; +} + 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) +static int peekall_socket(int handle, void *buffer, unsigned int count, + enum cmsis_dap_blocking blocking, unsigned int timeout_ms) { - /* Data remains unread on the socket until recv() is called later without + /* Windows doesn't support MSG_PEEK in combination with MSG_WAITALL: + * return recv(handle, buffer, count, MSG_PEEK | MSG_WAITALL); + * + * So, use this method instead which should work for Windows and others. + * + * 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); + + if (count == 0) + return 0; + + while (true) { + int ret; + unsigned int avail; + if (socket_bytes_available(handle, &avail) < 0) + return -1; + + if (avail >= count) { + ret = recv(handle, (char *)buffer, (int)count, MSG_PEEK); + if (ret < 0) { +#ifdef _WIN32 + int err = WSAGetLastError(); + if (err == WSAEINTR) + continue; + if (err == WSAEWOULDBLOCK) + return -1; +#else + if (errno == EINTR) + continue; + if (errno == EAGAIN || errno == EWOULDBLOCK) + return -1; // Timeout or nonblocking. +#endif + } + return ret; // 0: Closed, <0: Other error, >0 Success. + } + + // Not enough data available. + if (blocking == CMSIS_DAP_NON_BLOCKING) { +#ifdef _WIN32 + WSASetLastError(WSAEWOULDBLOCK); +#else + errno = EAGAIN; +#endif + return -1; + } + + // Blocking wait. + fd_set rfds; + FD_ZERO(&rfds); + FD_SET(handle, &rfds); + + struct timeval tv; + tv.tv_sec = timeout_ms / 1000; + tv.tv_usec = (timeout_ms % 1000) * 1000; + + ret = select(handle + 1, &rfds, NULL, NULL, &tv); + if (ret > 0) + continue; // Readable + + if (ret == 0) { // Timeout +#ifdef _WIN32 + WSASetLastError(WSAEWOULDBLOCK); +#else + errno = EAGAIN; +#endif + return -1; + } + + // Error +#ifndef _WIN32 + if (errno == EINTR) + continue; +#endif + return ret; + } } static int cmsis_dap_tcp_read(struct cmsis_dap *dap, int transfer_timeout_ms, @@ -232,7 +335,7 @@ static int cmsis_dap_tcp_read(struct cmsis_dap *dap, int transfer_timeout_ms, // Peek at the header first to find the length. int retval = peekall_socket(dap->bdata->sockfd, dap->packet_buffer, - HEADER_SIZE); + HEADER_SIZE, blocking, wait_ms); LOG_DEBUG_IO("Reading header returned %d", retval); if (retval == 0) { LOG_DEBUG_IO("CMSIS-DAP: tcp timeout reached 1"); ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/cmsis_dap_tcp.c | 111 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 107 insertions(+), 4 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 15:22: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 5bf63333138896120349cbcd48af815aeab5e185 (commit) from 32afb0ab04e773edd57bb64e428a24708c127c82 (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 5bf63333138896120349cbcd48af815aeab5e185 Author: Brian Kuschak <bku...@gm...> Date: Thu Sep 18 16:19:40 2025 +0800 tools/scripts: symbol added to camelcase.txt This Windows symbol is camelcase. Change-Id: I2427de43e070592cf0c36c160c53c2bdfe96e524 Signed-off-by: Brian Kuschak <bku...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9137 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/tools/scripts/camelcase.txt b/tools/scripts/camelcase.txt index 058df4d80..1c782ee35 100644 --- a/tools/scripts/camelcase.txt +++ b/tools/scripts/camelcase.txt @@ -172,6 +172,7 @@ Sleep WaitForSingleObject WSACleanup WSAGetLastError +WSASetLastError WSAStartup dwHighDateTime dwLowDateTime ----------------------------------------------------------------------- Summary of changes: tools/scripts/camelcase.txt | 1 + 1 file changed, 1 insertion(+) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:56: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 32afb0ab04e773edd57bb64e428a24708c127c82 (commit) via 9e2a11c2f22792400077e81950f8ff7ef5fae874 (commit) via c92cc6b5703cd85497011d2221f008372921b192 (commit) via f64421d07e09bc6addc15ab363db250c5ba5a228 (commit) from 4b311d3b8f4221938eabccda23f99c4d64ca8dcb (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 32afb0ab04e773edd57bb64e428a24708c127c82 Author: Tomas Vanek <va...@fb...> Date: Thu Sep 11 22:12:05 2025 +0200 jtag: linuxgpiod: log memory allocation errors Log error in case of NULL calloc() return. Change-Id: I40c5cba5b92cd39e9a8f7e6d420e11afc8747b3e Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/9119 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 323160b1a..cc738e9a3 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -52,8 +52,10 @@ static struct gpiod_line_settings *gpiod_line_settings_new(void) struct gpiod_line_settings *rv; rv = calloc(sizeof(struct gpiod_line_settings), 1); - if (!rv) + if (!rv) { + LOG_ERROR("No memory for gpiod line settings"); return NULL; + } return rv; } @@ -128,8 +130,10 @@ static struct gpiod_line_config *gpiod_line_config_new(void) struct gpiod_line_config *rv; rv = calloc(sizeof(struct gpiod_line_config), 1); - if (!rv) + if (!rv) { + LOG_ERROR("No memory for gpiod line config"); return NULL; + } return rv; } @@ -159,8 +163,10 @@ static struct gpiod_request_config *gpiod_request_config_new(void) struct gpiod_request_config *rv; rv = calloc(sizeof(struct gpiod_request_config), 1); - if (!rv) + if (!rv) { + LOG_ERROR("No memory for gpiod request config"); return NULL; + } return rv; } @@ -194,8 +200,10 @@ static struct gpiod_line_request *gpiod_chip_request_lines(struct gpiod_chip *ch assert(req_cfg); line_req = calloc(sizeof(struct gpiod_line_request), 1); - if (!line_req) + if (!line_req) { + LOG_ERROR("No memory for gpiod line request"); return NULL; + } line_req->gpio_line = gpiod_chip_get_line(chip, line_cfg->gpio_num); if (!line_req->gpio_line) { commit 9e2a11c2f22792400077e81950f8ff7ef5fae874 Author: Michael Heimpold <mh...@he...> Date: Sat Apr 20 19:01:30 2024 +0200 jtag: linuxgpiod: finalize emulation of libgpiod v2 API for older versions This finalizes the work that has begun to emulate v2 API for older libgpiod versions. It also add the required autotools/pkg-config stuff to detect the available libgpiod version. Change-Id: I2c3a60ce607ed9601b01d22d5d9b8af953944941 Signed-off-by: Michael Heimpold <mh...@he...> Signed-off-by: Tomas Vanek <va...@fb...> Reviewed-on: https://review.openocd.org/c/openocd/+/8226 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/configure.ac b/configure.ac index 3060940ed..ed26d45e1 100644 --- a/configure.ac +++ b/configure.ac @@ -583,12 +583,19 @@ PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [ PKG_CHECK_MODULES([LIBFTDI], [libftdi], [use_libftdi=yes], [use_libftdi=no]) ]) -PKG_CHECK_MODULES([LIBGPIOD], [libgpiod < 2.0], [ +PKG_CHECK_MODULES([LIBGPIOD], [libgpiod >= 2.0] , [ use_libgpiod=yes - AC_DEFINE([HAVE_LIBGPIOD_V1], [1], [define if libgpiod is version v1.x]) - PKG_CHECK_EXISTS([libgpiod >= 1.5], - [AC_DEFINE([HAVE_LIBGPIOD1_FLAGS_BIAS], [1], [define if libgpiod v1 has line request flags bias])]) -], [use_libgpiod=no]) +], [ + PKG_CHECK_MODULES([LIBGPIOD], [libgpiod], [ + use_libgpiod=yes + AC_DEFINE([HAVE_LIBGPIOD_V1], [1], [define if libgpiod is version v1.x]) + + PKG_CHECK_EXISTS([libgpiod >= 1.5], + [AC_DEFINE([HAVE_LIBGPIOD1_FLAGS_BIAS], [1], [define if libgpiod v1 has line request flags bias])]) + ], [ + use_libgpiod=no + ]) +]) PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.2], [use_libjaylink=yes], [use_libjaylink=no]) diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index f5d2cf457..323160b1a 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -39,8 +39,6 @@ #define GPIOD_LINE_BIAS_PULL_UP GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP #define GPIOD_LINE_BIAS_PULL_DOWN GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN -#define gpiod_request_config gpiod_line_request_config - struct gpiod_line_settings { int direction; int value; @@ -49,48 +47,20 @@ struct gpiod_line_settings { int active_low; }; -struct gpiod_line_config { - unsigned int gpio_num; - struct gpiod_line_settings *line_settings; -}; - static struct gpiod_line_settings *gpiod_line_settings_new(void) { - static struct gpiod_line_settings my; - - my = (struct gpiod_line_settings) { 0 }; - - return &my; -} - -static struct gpiod_line_config *gpiod_line_config_new(void) -{ - static struct gpiod_line_config my; - - my = (struct gpiod_line_config) { 0 }; - - return &my; -} - -static struct gpiod_request_config *gpiod_request_config_new(void) -{ - static struct gpiod_request_config my; + struct gpiod_line_settings *rv; - my = (struct gpiod_request_config) { NULL, 0, 0 }; + rv = calloc(sizeof(struct gpiod_line_settings), 1); + if (!rv) + return NULL; - return &my; + return rv; } static void gpiod_line_settings_free(struct gpiod_line_settings *settings) { -} - -static void gpiod_line_config_free(struct gpiod_line_config *config) -{ -} - -static void gpiod_request_config_free(struct gpiod_request_config *config) -{ + free(settings); } static int gpiod_line_settings_set_direction(struct gpiod_line_settings *settings, @@ -123,12 +93,6 @@ static void gpiod_line_settings_set_active_low(struct gpiod_line_settings *setti settings->active_low = GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; } -static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, - const char *consumer) -{ - config->consumer = consumer; -} - #ifdef HAVE_LIBGPIOD1_FLAGS_BIAS static int gpiod_line_settings_set_bias(struct gpiod_line_settings *settings, int bias) @@ -145,18 +109,180 @@ static int gpiod_line_settings_set_bias(struct gpiod_line_settings *settings, in if (bias == GPIOD_LINE_BIAS_DISABLED) return 0; - LOG_WARNING("linuxgpiod: ignoring request for pull-%s: not supported by gpiod v%s", + LOG_WARNING("linuxgpiod: ignoring request for pull-%s: not supported by libgpiod v%s", (bias == GPIOD_LINE_BIAS_PULL_UP) ? "up" : "down", gpiod_version_string()); - return -1; + return 0; } #endif /* HAVE_LIBGPIOD1_FLAGS_BIAS */ + +struct gpiod_line_config { + unsigned int gpio_num; + struct gpiod_line_settings *line_settings; +}; + +static struct gpiod_line_config *gpiod_line_config_new(void) +{ + struct gpiod_line_config *rv; + + rv = calloc(sizeof(struct gpiod_line_config), 1); + if (!rv) + return NULL; + + return rv; +} + +static void gpiod_line_config_free(struct gpiod_line_config *config) +{ + free(config); +} + +static int gpiod_line_config_add_line_settings(struct gpiod_line_config *config, + const unsigned int *offsets, size_t num_offsets, struct gpiod_line_settings *settings) +{ + assert(num_offsets == 1); + + config->gpio_num = *offsets; + config->line_settings = settings; + + return 0; +} + +struct gpiod_request_config { + const char *consumer; +}; + +static struct gpiod_request_config *gpiod_request_config_new(void) +{ + struct gpiod_request_config *rv; + + rv = calloc(sizeof(struct gpiod_request_config), 1); + if (!rv) + return NULL; + + return rv; +} + +static void gpiod_request_config_free(struct gpiod_request_config *config) +{ + free(config); +} + +static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, + const char *consumer) +{ + config->consumer = consumer; +} + +struct gpiod_line_request { + struct gpiod_line *gpio_line; + struct gpiod_chip *chip; + struct gpiod_request_config *req_cfg; + struct gpiod_line_config *line_cfg; +}; + +static void gpiod_line_request_release(struct gpiod_line_request *request); + +static struct gpiod_line_request *gpiod_chip_request_lines(struct gpiod_chip *chip, + struct gpiod_request_config *req_cfg, struct gpiod_line_config *line_cfg) +{ + struct gpiod_line_request *line_req; + int rv, flags = 0; + + assert(req_cfg); + + line_req = calloc(sizeof(struct gpiod_line_request), 1); + if (!line_req) + return NULL; + + line_req->gpio_line = gpiod_chip_get_line(chip, line_cfg->gpio_num); + if (!line_req->gpio_line) { + free(line_req); + return NULL; + } + + /* remember stuff in case we need to reconfigure later */ + line_req->chip = chip; + line_req->req_cfg = gpiod_request_config_new(); + *line_req->req_cfg = *req_cfg; + line_req->line_cfg = line_cfg; + + flags |= line_cfg->line_settings->drive; + flags |= line_cfg->line_settings->bias; + flags |= line_cfg->line_settings->active_low; + + struct gpiod_line_request_config config = { + .consumer = line_req->req_cfg->consumer, + .request_type = line_cfg->line_settings->direction, + .flags = flags, + }; + + rv = gpiod_line_request(line_req->gpio_line, &config, line_cfg->line_settings->value); + if (rv < 0) { + gpiod_line_request_release(line_req); + return NULL; + } + + return line_req; +} + +static int gpiod_line_request_get_value(struct gpiod_line_request *request, + __attribute__((unused)) unsigned int offset) +{ + return gpiod_line_get_value(request->gpio_line); +} + +static int gpiod_line_request_set_value(struct gpiod_line_request *request, + __attribute__((unused)) unsigned int offset, int value) +{ + return gpiod_line_set_value(request->gpio_line, value); +} + +static void gpiod_line_request_release(struct gpiod_line_request *request) +{ + gpiod_request_config_free(request->req_cfg); + gpiod_line_release(request->gpio_line); + free(request); +} + +static int gpiod_line_request_reconfigure_lines(struct gpiod_line_request *request, + struct gpiod_line_config *line_cfg) +{ + int rv, flags = 0; + + /* in libgpiod v1 we have to release the line and re-aquire it */ + gpiod_line_release(request->gpio_line); + request->gpio_line = gpiod_chip_get_line(request->chip, request->line_cfg->gpio_num); + if (!request->gpio_line) + return -1; + + flags |= line_cfg->line_settings->drive; + flags |= line_cfg->line_settings->bias; + flags |= line_cfg->line_settings->active_low; + + struct gpiod_line_request_config config = { + .consumer = request->req_cfg->consumer, + .request_type = line_cfg->line_settings->direction, + .flags = flags, + }; + + rv = gpiod_line_request(request->gpio_line, &config, line_cfg->line_settings->value); + if (rv < 0) + return -1; + + /* remember updated line_cfg */ + request->line_cfg = line_cfg; + return 0; +} + #endif /* HAVE_LIBGPIOD_V1 */ static struct gpiod_chip *gpiod_chip[ADAPTER_GPIO_IDX_NUM] = {}; -static struct gpiod_line *gpiod_line[ADAPTER_GPIO_IDX_NUM] = {}; +static struct gpiod_line_settings *gpiod_line_settings[ADAPTER_GPIO_IDX_NUM] = {}; +static struct gpiod_line_config *gpiod_line_config[ADAPTER_GPIO_IDX_NUM] = {}; +static struct gpiod_line_request *gpiod_line_req[ADAPTER_GPIO_IDX_NUM] = {}; static int last_swclk; static int last_swdio; @@ -165,6 +291,20 @@ static bool swdio_input; static const struct adapter_gpio_config *adapter_gpio_config; +/* Helper to get/set a single line */ +static int linuxgpiod_line_get_value(enum adapter_gpio_config_index idx) +{ + return gpiod_line_request_get_value(gpiod_line_req[idx], + adapter_gpio_config[idx].gpio_num); +} + +static int linuxgpiod_line_set_value(enum adapter_gpio_config_index idx, int value) +{ + return gpiod_line_request_set_value(gpiod_line_req[idx], + adapter_gpio_config[idx].gpio_num, + value); +} + /* * Helper function to determine if gpio config is valid * @@ -182,7 +322,7 @@ static enum bb_value linuxgpiod_read(void) { int retval; - retval = gpiod_line_get_value(gpiod_line[ADAPTER_GPIO_IDX_TDO]); + retval = linuxgpiod_line_get_value(ADAPTER_GPIO_IDX_TDO); if (retval < 0) { LOG_WARNING("reading tdo failed"); return 0; @@ -215,20 +355,20 @@ static int linuxgpiod_write(int tck, int tms, int tdi) } if (tdi != last_tdi) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_TDI], tdi); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_TDI, tdi); if (retval < 0) LOG_WARNING("writing tdi failed"); } if (tms != last_tms) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_TMS], tms); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_TMS, tms); if (retval < 0) LOG_WARNING("writing tms failed"); } /* write clk last */ if (tck != last_tck) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_TCK], tck); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_TCK, tck); if (retval < 0) LOG_WARNING("writing tck failed"); } @@ -244,7 +384,7 @@ static int linuxgpiod_swdio_read(void) { int retval; - retval = gpiod_line_get_value(gpiod_line[ADAPTER_GPIO_IDX_SWDIO]); + retval = linuxgpiod_line_get_value(ADAPTER_GPIO_IDX_SWDIO); if (retval < 0) { LOG_WARNING("Fail read swdio"); return 0; @@ -257,30 +397,54 @@ static void linuxgpiod_swdio_drive(bool is_output) { int retval; - /* - * FIXME: change direction requires release and re-require the line - * https://stackoverflow.com/questions/58735140/ - * this would change in future libgpiod - */ - gpiod_line_release(gpiod_line[ADAPTER_GPIO_IDX_SWDIO]); - if (is_output) { - if (gpiod_line[ADAPTER_GPIO_IDX_SWDIO_DIR]) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_SWDIO_DIR], 1); + if (gpiod_line_req[ADAPTER_GPIO_IDX_SWDIO_DIR]) { + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_SWDIO_DIR, 1); if (retval < 0) - LOG_WARNING("Fail set swdio_dir"); + LOG_WARNING("Failed to set swdio_dir=1"); } - retval = gpiod_line_request_output(gpiod_line[ADAPTER_GPIO_IDX_SWDIO], "OpenOCD", 1); + + retval = gpiod_line_settings_set_direction(gpiod_line_settings[ADAPTER_GPIO_IDX_SWDIO], + GPIOD_LINE_DIRECTION_OUTPUT); + if (retval < 0) + LOG_WARNING("Failed to set new direction of swdio"); + + retval = gpiod_line_settings_set_output_value(gpiod_line_settings[ADAPTER_GPIO_IDX_SWDIO], + GPIOD_LINE_VALUE_ACTIVE); + if (retval < 0) + LOG_WARNING("Failed to set output value of swdio"); + + retval = gpiod_line_config_add_line_settings(gpiod_line_config[ADAPTER_GPIO_IDX_SWDIO], + &adapter_gpio_config[ADAPTER_GPIO_IDX_SWDIO].gpio_num, 1, + gpiod_line_settings[ADAPTER_GPIO_IDX_SWDIO]); if (retval < 0) - LOG_WARNING("Fail request_output line swdio"); + LOG_WARNING("Failed to apply output configuration to swdio"); + + retval = gpiod_line_request_reconfigure_lines(gpiod_line_req[ADAPTER_GPIO_IDX_SWDIO], + gpiod_line_config[ADAPTER_GPIO_IDX_SWDIO]); + if (retval < 0) + LOG_WARNING("Failed to switch swdio to output"); } else { - retval = gpiod_line_request_input(gpiod_line[ADAPTER_GPIO_IDX_SWDIO], "OpenOCD"); + retval = gpiod_line_settings_set_direction(gpiod_line_settings[ADAPTER_GPIO_IDX_SWDIO], + GPIOD_LINE_DIRECTION_INPUT); + if (retval < 0) + LOG_WARNING("Failed to switch swdio to output"); + + retval = gpiod_line_config_add_line_settings(gpiod_line_config[ADAPTER_GPIO_IDX_SWDIO], + &adapter_gpio_config[ADAPTER_GPIO_IDX_SWDIO].gpio_num, 1, + gpiod_line_settings[ADAPTER_GPIO_IDX_SWDIO]); if (retval < 0) - LOG_WARNING("Fail request_input line swdio"); - if (gpiod_line[ADAPTER_GPIO_IDX_SWDIO_DIR]) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_SWDIO_DIR], 0); + LOG_WARNING("Failed to apply input configuration to swdio"); + + retval = gpiod_line_request_reconfigure_lines(gpiod_line_req[ADAPTER_GPIO_IDX_SWDIO], + gpiod_line_config[ADAPTER_GPIO_IDX_SWDIO]); + if (retval < 0) + LOG_WARNING("Failed to switch swdio to input"); + + if (gpiod_line_req[ADAPTER_GPIO_IDX_SWDIO_DIR]) { + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_SWDIO_DIR, 0); if (retval < 0) - LOG_WARNING("Fail set swdio_dir"); + LOG_WARNING("Failed to set swdio_dir=0"); } } @@ -294,7 +458,7 @@ static int linuxgpiod_swd_write(int swclk, int swdio) if (!swdio_input) { if (!last_stored || swdio != last_swdio) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_SWDIO], swdio); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_SWDIO, swdio); if (retval < 0) LOG_WARNING("Fail set swdio"); } @@ -302,7 +466,7 @@ static int linuxgpiod_swd_write(int swclk, int swdio) /* write swclk last */ if (!last_stored || swclk != last_swclk) { - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_SWCLK], swclk); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_SWCLK, swclk); if (retval < 0) LOG_WARNING("Fail set swclk"); } @@ -321,7 +485,7 @@ static int linuxgpiod_blink(bool on) if (!is_gpio_config_valid(ADAPTER_GPIO_IDX_LED)) return ERROR_OK; - retval = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_LED], on ? 1 : 0); + retval = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_LED, on); if (retval < 0) LOG_WARNING("Fail set led"); return retval; @@ -348,17 +512,17 @@ static int linuxgpiod_reset(int trst, int srst) LOG_DEBUG("linuxgpiod_reset"); /* - * active low behaviour handled by "adaptor gpio" command and + * active low behavior handled by "adaptor gpio" command and * GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW flag when requesting the line. */ - if (gpiod_line[ADAPTER_GPIO_IDX_SRST]) { - retval1 = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_SRST], srst); + if (gpiod_line_req[ADAPTER_GPIO_IDX_SRST]) { + retval1 = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_SRST, srst); if (retval1 < 0) LOG_WARNING("set srst value failed"); } - if (gpiod_line[ADAPTER_GPIO_IDX_TRST]) { - retval2 = gpiod_line_set_value(gpiod_line[ADAPTER_GPIO_IDX_TRST], trst); + if (gpiod_line_req[ADAPTER_GPIO_IDX_TRST]) { + retval2 = linuxgpiod_line_set_value(ADAPTER_GPIO_IDX_TRST, trst); if (retval2 < 0) LOG_WARNING("set trst value failed"); } @@ -390,9 +554,17 @@ static bool linuxgpiod_swd_mode_possible(void) static inline void helper_release(enum adapter_gpio_config_index idx) { - if (gpiod_line[idx]) { - gpiod_line_release(gpiod_line[idx]); - gpiod_line[idx] = NULL; + if (gpiod_line_req[idx]) { + gpiod_line_request_release(gpiod_line_req[idx]); + gpiod_line_req[idx] = NULL; + } + if (gpiod_line_config[idx]) { + gpiod_line_config_free(gpiod_line_config[idx]); + gpiod_line_config[idx] = NULL; + } + if (gpiod_line_settings[idx]) { + gpiod_line_settings_free(gpiod_line_settings[idx]); + gpiod_line_settings[idx] = NULL; } if (gpiod_chip[idx]) { gpiod_chip_close(gpiod_chip[idx]); @@ -411,97 +583,108 @@ static int linuxgpiod_quit(void) static int helper_get_line(enum adapter_gpio_config_index idx) { + struct gpiod_request_config *req_cfg = NULL; char chip_path[24]; + int rv = 0; if (!is_gpio_config_valid(idx)) return ERROR_OK; - int flags = 0, retval; - snprintf(chip_path, sizeof(chip_path), "/dev/gpiochip%u", adapter_gpio_config[idx].chip_num); gpiod_chip[idx] = gpiod_chip_open(chip_path); + if (!gpiod_chip[idx]) { LOG_ERROR("Cannot open LinuxGPIOD chip %d for %s", adapter_gpio_config[idx].chip_num, adapter_gpio_get_name(idx)); return ERROR_JTAG_INIT_FAILED; } - gpiod_line[idx] = gpiod_chip_get_line(gpiod_chip[idx], adapter_gpio_config[idx].gpio_num); - if (!gpiod_line[idx]) { - LOG_ERROR("Error get line %s", adapter_gpio_get_name(idx)); - return ERROR_JTAG_INIT_FAILED; - } - - struct gpiod_line_settings *line_settings = gpiod_line_settings_new(); - struct gpiod_line_config *line_config = gpiod_line_config_new(); - struct gpiod_request_config *req_cfg = gpiod_request_config_new(); + gpiod_line_settings[idx] = gpiod_line_settings_new(); + gpiod_line_config[idx] = gpiod_line_config_new(); + req_cfg = gpiod_request_config_new(); - if (!line_settings || !line_config || !req_cfg) { + if (!gpiod_line_settings[idx] || !gpiod_line_config[idx] || !req_cfg) { LOG_ERROR("Cannot configure LinuxGPIOD line for %s", adapter_gpio_get_name(idx)); - retval = ERROR_JTAG_INIT_FAILED; - goto err_out; + gpiod_request_config_free(req_cfg); + return ERROR_JTAG_INIT_FAILED; } gpiod_request_config_set_consumer(req_cfg, "OpenOCD"); switch (adapter_gpio_config[idx].init_state) { case ADAPTER_GPIO_INIT_STATE_INPUT: - gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_INPUT); + rv = gpiod_line_settings_set_direction(gpiod_line_settings[idx], GPIOD_LINE_DIRECTION_INPUT); break; case ADAPTER_GPIO_INIT_STATE_INACTIVE: - gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT); - gpiod_line_settings_set_output_value(line_settings, GPIOD_LINE_VALUE_INACTIVE); + rv = gpiod_line_settings_set_direction(gpiod_line_settings[idx], GPIOD_LINE_DIRECTION_OUTPUT); + rv |= gpiod_line_settings_set_output_value(gpiod_line_settings[idx], GPIOD_LINE_VALUE_INACTIVE); break; case ADAPTER_GPIO_INIT_STATE_ACTIVE: - gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT); - gpiod_line_settings_set_output_value(line_settings, GPIOD_LINE_VALUE_ACTIVE); + rv = gpiod_line_settings_set_direction(gpiod_line_settings[idx], GPIOD_LINE_DIRECTION_OUTPUT); + rv |= gpiod_line_settings_set_output_value(gpiod_line_settings[idx], GPIOD_LINE_VALUE_ACTIVE); break; } + if (rv < 0) { + LOG_ERROR("Error while configuring LinuxGPIOD line init state for %s", adapter_gpio_get_name(idx)); + gpiod_request_config_free(req_cfg); + return ERROR_JTAG_INIT_FAILED; + } switch (adapter_gpio_config[idx].drive) { case ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL: - gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_PUSH_PULL); + rv = gpiod_line_settings_set_drive(gpiod_line_settings[idx], GPIOD_LINE_DRIVE_PUSH_PULL); break; case ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN: - gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_OPEN_DRAIN); + rv = gpiod_line_settings_set_drive(gpiod_line_settings[idx], GPIOD_LINE_DRIVE_OPEN_DRAIN); break; case ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE: - gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_OPEN_SOURCE); + rv = gpiod_line_settings_set_drive(gpiod_line_settings[idx], GPIOD_LINE_DRIVE_OPEN_SOURCE); break; } + if (rv < 0) { + LOG_ERROR("Error while configuring LinuxGPIOD line driving for %s", adapter_gpio_get_name(idx)); + gpiod_request_config_free(req_cfg); + return ERROR_JTAG_INIT_FAILED; + } switch (adapter_gpio_config[idx].pull) { case ADAPTER_GPIO_PULL_NONE: - gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_DISABLED); + rv = gpiod_line_settings_set_bias(gpiod_line_settings[idx], GPIOD_LINE_BIAS_DISABLED); break; case ADAPTER_GPIO_PULL_UP: - gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_PULL_UP); + rv = gpiod_line_settings_set_bias(gpiod_line_settings[idx], GPIOD_LINE_BIAS_PULL_UP); break; case ADAPTER_GPIO_PULL_DOWN: - gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_PULL_DOWN); + rv = gpiod_line_settings_set_bias(gpiod_line_settings[idx], GPIOD_LINE_BIAS_PULL_DOWN); break; } + if (rv < 0) { + LOG_ERROR("Error while configuring LinuxGPIOD line biasing for %s", adapter_gpio_get_name(idx)); + gpiod_request_config_free(req_cfg); + return ERROR_JTAG_INIT_FAILED; + } - gpiod_line_settings_set_active_low(line_settings, adapter_gpio_config[idx].active_low); - - req_cfg->request_type = line_settings->direction; - req_cfg->flags = flags | line_settings->drive | line_settings->bias | line_settings->active_low; + gpiod_line_settings_set_active_low(gpiod_line_settings[idx], adapter_gpio_config[idx].active_low); - retval = gpiod_line_request(gpiod_line[idx], req_cfg, line_settings->value); - if (retval < 0) { - LOG_ERROR("Error requesting gpio line %s", adapter_gpio_get_name(idx)); - retval = ERROR_JTAG_INIT_FAILED; - goto err_out; + rv = gpiod_line_config_add_line_settings(gpiod_line_config[idx], + &adapter_gpio_config[idx].gpio_num, 1, + gpiod_line_settings[idx]); + if (rv < 0) { + LOG_ERROR("Error configuring gpio line %s", adapter_gpio_get_name(idx)); + gpiod_request_config_free(req_cfg); + return ERROR_JTAG_INIT_FAILED; } - retval = ERROR_OK; + gpiod_line_req[idx] = gpiod_chip_request_lines(gpiod_chip[idx], req_cfg, gpiod_line_config[idx]); -err_out: - gpiod_line_settings_free(line_settings); - gpiod_line_config_free(line_config); gpiod_request_config_free(req_cfg); - return retval; + if (!gpiod_line_req[idx]) { + LOG_ERROR("Error requesting gpio line %s", adapter_gpio_get_name(idx)); + return ERROR_JTAG_INIT_FAILED; + } + + return ERROR_OK; } static int linuxgpiod_init(void) commit c92cc6b5703cd85497011d2221f008372921b192 Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 21:15:48 2024 +0200 jtag: linuxgpiod: use libgpiod v2 API for gpiod_line_request() Work in progress. Target is to replace v1 gpiod_line_request() Define and use dummy functions from v2 for v1: - gpiod_line_config_new(), - gpiod_line_config_free(), Not yet used: - gpiod_line_config_add_line_settings(), - gpiod_chip_request_lines(). Change-Id: I9e2d3013845c5d12942f5e07c9721fcd151d6840 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8207 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 4369175f7..f5d2cf457 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -49,6 +49,11 @@ struct gpiod_line_settings { int active_low; }; +struct gpiod_line_config { + unsigned int gpio_num; + struct gpiod_line_settings *line_settings; +}; + static struct gpiod_line_settings *gpiod_line_settings_new(void) { static struct gpiod_line_settings my; @@ -58,6 +63,15 @@ static struct gpiod_line_settings *gpiod_line_settings_new(void) return &my; } +static struct gpiod_line_config *gpiod_line_config_new(void) +{ + static struct gpiod_line_config my; + + my = (struct gpiod_line_config) { 0 }; + + return &my; +} + static struct gpiod_request_config *gpiod_request_config_new(void) { static struct gpiod_request_config my; @@ -71,6 +85,10 @@ static void gpiod_line_settings_free(struct gpiod_line_settings *settings) { } +static void gpiod_line_config_free(struct gpiod_line_config *config) +{ +} + static void gpiod_request_config_free(struct gpiod_request_config *config) { } @@ -415,9 +433,10 @@ static int helper_get_line(enum adapter_gpio_config_index idx) } struct gpiod_line_settings *line_settings = gpiod_line_settings_new(); + struct gpiod_line_config *line_config = gpiod_line_config_new(); struct gpiod_request_config *req_cfg = gpiod_request_config_new(); - if (!line_settings || !req_cfg) { + if (!line_settings || !line_config || !req_cfg) { LOG_ERROR("Cannot configure LinuxGPIOD line for %s", adapter_gpio_get_name(idx)); retval = ERROR_JTAG_INIT_FAILED; goto err_out; @@ -479,6 +498,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx) err_out: gpiod_line_settings_free(line_settings); + gpiod_line_config_free(line_config); gpiod_request_config_free(req_cfg); return retval; commit f64421d07e09bc6addc15ab363db250c5ba5a228 Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 18:32:45 2024 +0200 jtag: linuxgpiod: use libgpiod v2 API to set gpio active_low Define and use dummy functions from v2 for v1: - gpiod_line_settings_set_active_low(). Change-Id: I2c00e1a71950215c47dc07d71af4f319434a266a Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8206 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index dc9b9f5d5..4369175f7 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -46,6 +46,7 @@ struct gpiod_line_settings { int value; int drive; int bias; + int active_low; }; static struct gpiod_line_settings *gpiod_line_settings_new(void) @@ -97,6 +98,13 @@ static int gpiod_line_settings_set_drive(struct gpiod_line_settings *settings, i return 0; } +static void gpiod_line_settings_set_active_low(struct gpiod_line_settings *settings, + bool active_low) +{ + if (active_low) + settings->active_low = GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; +} + static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, const char *consumer) { @@ -455,11 +463,10 @@ static int helper_get_line(enum adapter_gpio_config_index idx) break; } - if (adapter_gpio_config[idx].active_low) - flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; + gpiod_line_settings_set_active_low(line_settings, adapter_gpio_config[idx].active_low); req_cfg->request_type = line_settings->direction; - req_cfg->flags = flags | line_settings->drive | line_settings->bias; + req_cfg->flags = flags | line_settings->drive | line_settings->bias | line_settings->active_low; retval = gpiod_line_request(gpiod_line[idx], req_cfg, line_settings->value); if (retval < 0) { ----------------------------------------------------------------------- Summary of changes: configure.ac | 17 +- src/jtag/drivers/linuxgpiod.c | 408 ++++++++++++++++++++++++++++++++---------- 2 files changed, 325 insertions(+), 100 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:56:43
|
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 4b311d3b8f4221938eabccda23f99c4d64ca8dcb (commit) via 78ea8c7fb4755089d4190c580dbf6bb60c7721e1 (commit) from 981ae530fc4fcca57a5e66b0459783b92ccbc29f (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 4b311d3b8f4221938eabccda23f99c4d64ca8dcb Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 18:25:49 2024 +0200 jtag: linuxgpiod: use libgpiod v2 API to set gpio bias Define and use dummy functions from v2 for v1: - gpiod_line_settings_set_bias(). Change-Id: I96d32b6200d3bb6ca7c16e7a18e3860f367b5008 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8205 Reviewed-by: Tomas Vanek <va...@fb...> Tested-by: jenkins diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 6afb1dcc9..dc9b9f5d5 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -35,12 +35,17 @@ #define GPIOD_LINE_DRIVE_OPEN_DRAIN GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN #define GPIOD_LINE_DRIVE_OPEN_SOURCE GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE +#define GPIOD_LINE_BIAS_DISABLED GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE +#define GPIOD_LINE_BIAS_PULL_UP GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP +#define GPIOD_LINE_BIAS_PULL_DOWN GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN + #define gpiod_request_config gpiod_line_request_config struct gpiod_line_settings { int direction; int value; int drive; + int bias; }; static struct gpiod_line_settings *gpiod_line_settings_new(void) @@ -98,6 +103,30 @@ static void gpiod_request_config_set_consumer(struct gpiod_request_config *confi config->consumer = consumer; } +#ifdef HAVE_LIBGPIOD1_FLAGS_BIAS + +static int gpiod_line_settings_set_bias(struct gpiod_line_settings *settings, int bias) +{ + settings->bias = bias; + + return 0; +} + +#else /* HAVE_LIBGPIOD1_FLAGS_BIAS */ + +static int gpiod_line_settings_set_bias(struct gpiod_line_settings *settings, int bias) +{ + if (bias == GPIOD_LINE_BIAS_DISABLED) + return 0; + + LOG_WARNING("linuxgpiod: ignoring request for pull-%s: not supported by gpiod v%s", + (bias == GPIOD_LINE_BIAS_PULL_UP) ? "up" : "down", + gpiod_version_string()); + + return -1; +} + +#endif /* HAVE_LIBGPIOD1_FLAGS_BIAS */ #endif /* HAVE_LIBGPIOD_V1 */ static struct gpiod_chip *gpiod_chip[ADAPTER_GPIO_IDX_NUM] = {}; @@ -416,25 +445,13 @@ static int helper_get_line(enum adapter_gpio_config_index idx) switch (adapter_gpio_config[idx].pull) { case ADAPTER_GPIO_PULL_NONE: -#ifdef HAVE_LIBGPIOD1_FLAGS_BIAS - flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_DISABLE; -#endif + gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_DISABLED); break; case ADAPTER_GPIO_PULL_UP: -#ifdef HAVE_LIBGPIOD1_FLAGS_BIAS - flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_UP; -#else - LOG_WARNING("linuxgpiod: ignoring request for pull-up on %s: not supported by gpiod v%s", - adapter_gpio_get_name(idx), gpiod_version_string()); -#endif + gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_PULL_UP); break; case ADAPTER_GPIO_PULL_DOWN: -#ifdef HAVE_LIBGPIOD1_FLAGS_BIAS - flags |= GPIOD_LINE_REQUEST_FLAG_BIAS_PULL_DOWN; -#else - LOG_WARNING("linuxgpiod: ignoring request for pull-down on %s: not supported by gpiod v%s", - adapter_gpio_get_name(idx), gpiod_version_string()); -#endif + gpiod_line_settings_set_bias(line_settings, GPIOD_LINE_BIAS_PULL_DOWN); break; } @@ -442,7 +459,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx) flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; req_cfg->request_type = line_settings->direction; - req_cfg->flags = flags | line_settings->drive; + req_cfg->flags = flags | line_settings->drive | line_settings->bias; retval = gpiod_line_request(gpiod_line[idx], req_cfg, line_settings->value); if (retval < 0) { commit 78ea8c7fb4755089d4190c580dbf6bb60c7721e1 Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 18:15:48 2024 +0200 jtag: linuxgpiod: use libgpiod v2 API to set gpio drive Define and use dummy functions from v2 for v1: - gpiod_line_settings_set_drive(). Change-Id: Ic058e85c441c9f8db63919be5166172be5b72221 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8204 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index fa0b38ebb..6afb1dcc9 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -31,11 +31,16 @@ #define GPIOD_LINE_VALUE_INACTIVE 0 #define GPIOD_LINE_VALUE_ACTIVE 1 +#define GPIOD_LINE_DRIVE_PUSH_PULL 0 +#define GPIOD_LINE_DRIVE_OPEN_DRAIN GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN +#define GPIOD_LINE_DRIVE_OPEN_SOURCE GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE + #define gpiod_request_config gpiod_line_request_config struct gpiod_line_settings { int direction; int value; + int drive; }; static struct gpiod_line_settings *gpiod_line_settings_new(void) @@ -80,6 +85,13 @@ static int gpiod_line_settings_set_output_value(struct gpiod_line_settings *sett return 0; } +static int gpiod_line_settings_set_drive(struct gpiod_line_settings *settings, int drive) +{ + settings->drive = drive; + + return 0; +} + static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, const char *consumer) { @@ -392,12 +404,13 @@ static int helper_get_line(enum adapter_gpio_config_index idx) switch (adapter_gpio_config[idx].drive) { case ADAPTER_GPIO_DRIVE_MODE_PUSH_PULL: + gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_PUSH_PULL); break; case ADAPTER_GPIO_DRIVE_MODE_OPEN_DRAIN: - flags |= GPIOD_LINE_REQUEST_FLAG_OPEN_DRAIN; + gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_OPEN_DRAIN); break; case ADAPTER_GPIO_DRIVE_MODE_OPEN_SOURCE: - flags |= GPIOD_LINE_REQUEST_FLAG_OPEN_SOURCE; + gpiod_line_settings_set_drive(line_settings, GPIOD_LINE_DRIVE_OPEN_SOURCE); break; } @@ -429,7 +442,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx) flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; req_cfg->request_type = line_settings->direction; - req_cfg->flags = flags; + req_cfg->flags = flags | line_settings->drive; retval = gpiod_line_request(gpiod_line[idx], req_cfg, line_settings->value); if (retval < 0) { ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/linuxgpiod.c | 66 +++++++++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 18 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:55:46
|
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 981ae530fc4fcca57a5e66b0459783b92ccbc29f (commit) via fcbdab78c918f6dc014d953836ef66e03e07c336 (commit) from 82d0aac95b7440f62ee29e1888809c52503a3220 (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 981ae530fc4fcca57a5e66b0459783b92ccbc29f Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 17:45:07 2024 +0200 jtag: linuxgpiod: use libgpiod v2 to set gpio state Define and use dummy functions from v2 for v1: - gpiod_line_settings_new(), - gpiod_line_settings_free(), - gpiod_line_settings_set_direction(), - gpiod_line_settings_set_output_value(). Change-Id: I7d147fa49daf1d008744fab5bf0001c570ea43d6 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8203 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 6336a56d0..fa0b38ebb 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -25,8 +25,28 @@ */ #ifdef HAVE_LIBGPIOD_V1 +#define GPIOD_LINE_DIRECTION_INPUT GPIOD_LINE_REQUEST_DIRECTION_INPUT +#define GPIOD_LINE_DIRECTION_OUTPUT GPIOD_LINE_REQUEST_DIRECTION_OUTPUT + +#define GPIOD_LINE_VALUE_INACTIVE 0 +#define GPIOD_LINE_VALUE_ACTIVE 1 + #define gpiod_request_config gpiod_line_request_config +struct gpiod_line_settings { + int direction; + int value; +}; + +static struct gpiod_line_settings *gpiod_line_settings_new(void) +{ + static struct gpiod_line_settings my; + + my = (struct gpiod_line_settings) { 0 }; + + return &my; +} + static struct gpiod_request_config *gpiod_request_config_new(void) { static struct gpiod_request_config my; @@ -36,10 +56,30 @@ static struct gpiod_request_config *gpiod_request_config_new(void) return &my; } +static void gpiod_line_settings_free(struct gpiod_line_settings *settings) +{ +} + static void gpiod_request_config_free(struct gpiod_request_config *config) { } +static int gpiod_line_settings_set_direction(struct gpiod_line_settings *settings, + int direction) +{ + settings->direction = direction; + + return 0; +} + +static int gpiod_line_settings_set_output_value(struct gpiod_line_settings *settings, + int value) +{ + settings->value = value; + + return 0; +} + static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, const char *consumer) { @@ -309,7 +349,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx) if (!is_gpio_config_valid(idx)) return ERROR_OK; - int dir = GPIOD_LINE_REQUEST_DIRECTION_INPUT, flags = 0, val = 0, retval; + int flags = 0, retval; snprintf(chip_path, sizeof(chip_path), "/dev/gpiochip%u", adapter_gpio_config[idx].chip_num); gpiod_chip[idx] = gpiod_chip_open(chip_path); @@ -325,8 +365,10 @@ static int helper_get_line(enum adapter_gpio_config_index idx) return ERROR_JTAG_INIT_FAILED; } + struct gpiod_line_settings *line_settings = gpiod_line_settings_new(); struct gpiod_request_config *req_cfg = gpiod_request_config_new(); - if (!req_cfg) { + + if (!line_settings || !req_cfg) { LOG_ERROR("Cannot configure LinuxGPIOD line for %s", adapter_gpio_get_name(idx)); retval = ERROR_JTAG_INIT_FAILED; goto err_out; @@ -336,15 +378,15 @@ static int helper_get_line(enum adapter_gpio_config_index idx) switch (adapter_gpio_config[idx].init_state) { case ADAPTER_GPIO_INIT_STATE_INPUT: - dir = GPIOD_LINE_REQUEST_DIRECTION_INPUT; + gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_INPUT); break; case ADAPTER_GPIO_INIT_STATE_INACTIVE: - dir = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT; - val = 0; + gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT); + gpiod_line_settings_set_output_value(line_settings, GPIOD_LINE_VALUE_INACTIVE); break; case ADAPTER_GPIO_INIT_STATE_ACTIVE: - dir = GPIOD_LINE_REQUEST_DIRECTION_OUTPUT; - val = 1; + gpiod_line_settings_set_direction(line_settings, GPIOD_LINE_DIRECTION_OUTPUT); + gpiod_line_settings_set_output_value(line_settings, GPIOD_LINE_VALUE_ACTIVE); break; } @@ -386,10 +428,10 @@ static int helper_get_line(enum adapter_gpio_config_index idx) if (adapter_gpio_config[idx].active_low) flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; - req_cfg->request_type = dir; + req_cfg->request_type = line_settings->direction; req_cfg->flags = flags; - retval = gpiod_line_request(gpiod_line[idx], req_cfg, val); + retval = gpiod_line_request(gpiod_line[idx], req_cfg, line_settings->value); if (retval < 0) { LOG_ERROR("Error requesting gpio line %s", adapter_gpio_get_name(idx)); retval = ERROR_JTAG_INIT_FAILED; @@ -399,6 +441,7 @@ static int helper_get_line(enum adapter_gpio_config_index idx) retval = ERROR_OK; err_out: + gpiod_line_settings_free(line_settings); gpiod_request_config_free(req_cfg); return retval; commit fcbdab78c918f6dc014d953836ef66e03e07c336 Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 17:18:40 2024 +0200 jtag: linuxgpiod: wrap gpiod_request_config from libgpiod v2 Reorganize the code of helper_get_line() for label err_out. Define and use dummy functions from v2 for v1: - gpiod_request_config_new(), - gpiod_request_config_free(), - gpiod_request_config_set_consumer(). Change-Id: Ide7cd8459941a5a863c425a2b5abf1fb4a075874 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8202 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 6f71205ca..6336a56d0 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -19,6 +19,35 @@ #include <transport/transport.h> #include "bitbang.h" +/* + * In case of libgpiod v1, use as much as possible API from v2 plus + * the dummy wrappers below. + */ +#ifdef HAVE_LIBGPIOD_V1 + +#define gpiod_request_config gpiod_line_request_config + +static struct gpiod_request_config *gpiod_request_config_new(void) +{ + static struct gpiod_request_config my; + + my = (struct gpiod_request_config) { NULL, 0, 0 }; + + return &my; +} + +static void gpiod_request_config_free(struct gpiod_request_config *config) +{ +} + +static void gpiod_request_config_set_consumer(struct gpiod_request_config *config, + const char *consumer) +{ + config->consumer = consumer; +} + +#endif /* HAVE_LIBGPIOD_V1 */ + static struct gpiod_chip *gpiod_chip[ADAPTER_GPIO_IDX_NUM] = {}; static struct gpiod_line *gpiod_line[ADAPTER_GPIO_IDX_NUM] = {}; @@ -296,6 +325,15 @@ static int helper_get_line(enum adapter_gpio_config_index idx) return ERROR_JTAG_INIT_FAILED; } + struct gpiod_request_config *req_cfg = gpiod_request_config_new(); + if (!req_cfg) { + LOG_ERROR("Cannot configure LinuxGPIOD line for %s", adapter_gpio_get_name(idx)); + retval = ERROR_JTAG_INIT_FAILED; + goto err_out; + } + + gpiod_request_config_set_consumer(req_cfg, "OpenOCD"); + switch (adapter_gpio_config[idx].init_state) { case ADAPTER_GPIO_INIT_STATE_INPUT: dir = GPIOD_LINE_REQUEST_DIRECTION_INPUT; @@ -348,19 +386,22 @@ static int helper_get_line(enum adapter_gpio_config_index idx) if (adapter_gpio_config[idx].active_low) flags |= GPIOD_LINE_REQUEST_FLAG_ACTIVE_LOW; - struct gpiod_line_request_config config = { - .consumer = "OpenOCD", - .request_type = dir, - .flags = flags, - }; + req_cfg->request_type = dir; + req_cfg->flags = flags; - retval = gpiod_line_request(gpiod_line[idx], &config, val); + retval = gpiod_line_request(gpiod_line[idx], req_cfg, val); if (retval < 0) { LOG_ERROR("Error requesting gpio line %s", adapter_gpio_get_name(idx)); - return ERROR_JTAG_INIT_FAILED; + retval = ERROR_JTAG_INIT_FAILED; + goto err_out; } - return ERROR_OK; + retval = ERROR_OK; + +err_out: + gpiod_request_config_free(req_cfg); + + return retval; } static int linuxgpiod_init(void) ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/linuxgpiod.c | 112 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 98 insertions(+), 14 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:55:28
|
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 82d0aac95b7440f62ee29e1888809c52503a3220 (commit) from 601d478015dcbd96ce9dcde57f8004b9a13fd311 (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 82d0aac95b7440f62ee29e1888809c52503a3220 Author: Michael Heimpold <mh...@he...> Date: Sun Sep 14 11:47:10 2025 +0200 jtag: linuxgpiod: add macro HAVE_LIBGPIOD_V1 To prepare the support for libgpiod v2, add a macro to report the old version v1 of the library. Extracted part of 8226: jtag: linuxgpiod: finalize emulation of libgpiod v2 API for older versions Link: https://review.openocd.org/c/openocd/+/8226 Change-Id: Ib9c4e495b326770fabadbc752df8aa0a920b1831 Signed-off-by: Michael Heimpold <mh...@he...> Signed-off-by: Tomas Vanek <va...@fb...> Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9118 Tested-by: jenkins diff --git a/configure.ac b/configure.ac index 01077847b..3060940ed 100644 --- a/configure.ac +++ b/configure.ac @@ -585,6 +585,7 @@ PKG_CHECK_MODULES([LIBFTDI], [libftdi1], [ PKG_CHECK_MODULES([LIBGPIOD], [libgpiod < 2.0], [ use_libgpiod=yes + AC_DEFINE([HAVE_LIBGPIOD_V1], [1], [define if libgpiod is version v1.x]) PKG_CHECK_EXISTS([libgpiod >= 1.5], [AC_DEFINE([HAVE_LIBGPIOD1_FLAGS_BIAS], [1], [define if libgpiod v1 has line request flags bias])]) ], [use_libgpiod=no]) ----------------------------------------------------------------------- Summary of changes: configure.ac | 1 + 1 file changed, 1 insertion(+) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:54: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 601d478015dcbd96ce9dcde57f8004b9a13fd311 (commit) from 27ab12dd82de8154724db96b921d6b0ed650eb2d (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 601d478015dcbd96ce9dcde57f8004b9a13fd311 Author: Antonio Borneo <bor...@gm...> Date: Sun Apr 7 16:00:14 2024 +0200 jtag: linuxgpiod: replace gpiod_chip_open_by_number() Preparing for libgpiod v2, replace v1 specific function gpiod_chip_open_by_number() with the common v1 & v2 function gpiod_chip_open(). Change-Id: I5f0f9bef739f4097fb74f78b5b6e2fe823c1ab87 Signed-off-by: Antonio Borneo <bor...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8201 Tested-by: jenkins Reviewed-by: Tomas Vanek <va...@fb...> diff --git a/src/jtag/drivers/linuxgpiod.c b/src/jtag/drivers/linuxgpiod.c index 36c7e0493..6f71205ca 100644 --- a/src/jtag/drivers/linuxgpiod.c +++ b/src/jtag/drivers/linuxgpiod.c @@ -275,12 +275,15 @@ static int linuxgpiod_quit(void) static int helper_get_line(enum adapter_gpio_config_index idx) { + char chip_path[24]; + if (!is_gpio_config_valid(idx)) return ERROR_OK; int dir = GPIOD_LINE_REQUEST_DIRECTION_INPUT, flags = 0, val = 0, retval; - gpiod_chip[idx] = gpiod_chip_open_by_number(adapter_gpio_config[idx].chip_num); + snprintf(chip_path, sizeof(chip_path), "/dev/gpiochip%u", adapter_gpio_config[idx].chip_num); + gpiod_chip[idx] = gpiod_chip_open(chip_path); if (!gpiod_chip[idx]) { LOG_ERROR("Cannot open LinuxGPIOD chip %d for %s", adapter_gpio_config[idx].chip_num, adapter_gpio_get_name(idx)); ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/linuxgpiod.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:53: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 27ab12dd82de8154724db96b921d6b0ed650eb2d (commit) from 3b03e439dee2f1b3959f38246fa44a51210e7108 (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 27ab12dd82de8154724db96b921d6b0ed650eb2d Author: Antonio Borneo <bor...@gm...> Date: Sat Sep 13 20:41:31 2025 +0200 target: extend registers match on 'get_reg' and 'set_reg' Some target, like aarch64, has more than one bank of registers. Let the commands 'get_reg' and 'set_reg' to search the register name in all banks, as is already done in command 'reg'. Change-Id: Iae350a52f993790c5546925a2f7f81fbdb3f49b8 Signed-off-by: Antonio Borneo <bor...@gm...> Fixes: e8e62c5aca49 ("target/tcl: Add get_reg function") Fixes: da7328010165 ("target/tcl: Add set_reg function") Reviewed-on: https://review.openocd.org/c/openocd/+/9122 Tested-by: jenkins Reviewed-by: zapb <de...@za...> diff --git a/src/target/target.c b/src/target/target.c index 1bdbee19a..bdf0ff244 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -4745,7 +4745,7 @@ COMMAND_HANDLER(handle_target_get_reg) const char *reg_name = Jim_String(elem); - struct reg *reg = register_get_by_name(target->reg_cache, reg_name, false); + struct reg *reg = register_get_by_name(target->reg_cache, reg_name, true); if (!reg || !reg->exist) { command_print(CMD, "unknown register '%s'", reg_name); @@ -4803,7 +4803,7 @@ COMMAND_HANDLER(handle_set_reg_command) for (unsigned int i = 0; i < length; i += 2) { const char *reg_name = Jim_String(dict[i]); const char *reg_value = Jim_String(dict[i + 1]); - struct reg *reg = register_get_by_name(target->reg_cache, reg_name, false); + struct reg *reg = register_get_by_name(target->reg_cache, reg_name, true); if (!reg || !reg->exist) { command_print(CMD, "unknown register '%s'", reg_name); ----------------------------------------------------------------------- Summary of changes: src/target/target.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) hooks/post-receive -- Main OpenOCD repository |
From: openocd-gerrit <ope...@us...> - 2025-09-27 14:53: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 3b03e439dee2f1b3959f38246fa44a51210e7108 (commit) from 4ae92ee3b9c8c2eaa07dc22262cdc2c1eec6412d (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 3b03e439dee2f1b3959f38246fa44a51210e7108 Author: Daniel Anselmi <dan...@gm...> Date: Fri Sep 12 23:42:21 2025 +0200 tcl/board/digilent_zybo: clarify supported/tested hardware Clarify that this config has been tested with the Zybo board but not with the Zybo Z7 board. Change-Id: Id826480444364e5916f25c1c219c5ddaa3ec827d Signed-off-by: Daniel Anselmi <dan...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/9019 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/tcl/board/digilent_zybo.cfg b/tcl/board/digilent_zybo.cfg index 97d54302a..8573399f8 100644 --- a/tcl/board/digilent_zybo.cfg +++ b/tcl/board/digilent_zybo.cfg @@ -1,8 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-or-later -# digilent zybo +# Digilent Zybo # https://digilent.com/reference/programmable-logic/zybo/start +# Tested with the Zybo board from Digilent (older). +# Not tested with the Zybo Z7 board from Digilent (newer). + adapter driver ftdi ftdi channel 0 ----------------------------------------------------------------------- Summary of changes: tcl/board/digilent_zybo.cfg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) hooks/post-receive -- Main OpenOCD repository |