From: openocd-gerrit <ope...@us...> - 2025-06-07 10:05:34
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via 2065bac3805102a37a2d10d374298b875d750392 (commit) from db8db903338d1f99eda6ad533168885c9e21178f (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 2065bac3805102a37a2d10d374298b875d750392 Author: Jacek Wuwer <jac...@gm...> Date: Wed Apr 24 10:15:38 2024 +0200 jtag/vdebug: implement a polling mechanism This change adds a polling mechanism to the driver. When not busy the driver issues a wait, allowing the target to advance time. The wait period gets adjusted to match the polling setting. Change-Id: I67f481d05d7c5ce5352b5cb97de78dbaa97d82ae Signed-off-by: Jacek Wuwer <jac...@gm...> Reviewed-on: https://review.openocd.org/c/openocd/+/8221 Reviewed-by: Antonio Borneo <bor...@gm...> Tested-by: jenkins diff --git a/src/jtag/drivers/vdebug.c b/src/jtag/drivers/vdebug.c index 38685950a..29bfa8360 100644 --- a/src/jtag/drivers/vdebug.c +++ b/src/jtag/drivers/vdebug.c @@ -47,19 +47,20 @@ #include "jtag/interface.h" #include "jtag/commands.h" #include "transport/transport.h" +#include "target/target.h" #include "target/arm_adi_v5.h" #include "helper/time_support.h" #include "helper/replacements.h" #include "helper/log.h" #include "helper/list.h" -#define VD_VERSION 48 +#define VD_VERSION 50 #define VD_BUFFER_LEN 4024 #define VD_CHEADER_LEN 24 #define VD_SHEADER_LEN 16 #define VD_MAX_MEMORIES 20 -#define VD_POLL_INTERVAL 500 +#define VD_POLL_INTERVAL 1000 #define VD_SCALE_PSTOMS 1000000000 /** @@ -205,6 +206,7 @@ struct vd_client { uint32_t poll_max; uint32_t targ_time; int hsocket; + int64_t poll_ts; char server_name[32]; char bfm_path[128]; char mem_path[VD_MAX_MEMORIES][128]; @@ -839,6 +841,35 @@ static void vdebug_mem_close(int hsock, struct vd_shm *pm, uint8_t ndx) } +/* function gets invoked through a callback every VD_POLL_INTERVAL ms + * if the idle time, measured by VD_POLL_INTERVAL - targ_time is more than poll_min + * the wait function is called and its time measured and wait cycles adjusted. + * The wait allows hardware to advance, when no data activity from the vdebug occurs + */ +static int vdebug_poll(void *priv) +{ + int64_t ts, te; + + ts = timeval_ms(); + if (ts - vdc.poll_ts - vdc.targ_time >= vdc.poll_min) { + vdebug_wait(vdc.hsocket, pbuf, vdc.poll_cycles); + te = timeval_ms(); + LOG_DEBUG("poll after %" PRId64 "ms, busy %" PRIu32 "ms; wait %" PRIu32 " %" PRId64 "ms", + ts - vdc.poll_ts, vdc.targ_time, vdc.poll_cycles, te - ts); + + if (te - ts + vdc.targ_time < vdc.poll_max / 2) + vdc.poll_cycles *= 2; + else if (te - ts + vdc.targ_time > vdc.poll_max) + vdc.poll_cycles /= 2; + } else { + LOG_DEBUG("poll after %" PRId64 "ms, busy %" PRIu32 "ms", ts - vdc.poll_ts, vdc.targ_time); + } + vdc.poll_ts = ts; + vdc.targ_time = 0; /* reset target time counter */ + + return ERROR_OK; +} + static int vdebug_init(void) { vdc.hsocket = vdebug_socket_open(vdc.server_name, vdc.server_port); @@ -858,6 +889,7 @@ static int vdebug_init(void) } vdc.trans_first = 1; vdc.poll_cycles = vdc.poll_max; + vdc.poll_ts = timeval_ms(); uint32_t sig_mask = VD_SIG_RESET; if (transport_is_jtag()) sig_mask |= VD_SIG_TRST | VD_SIG_TCKDIV; @@ -876,6 +908,8 @@ static int vdebug_init(void) LOG_ERROR("0x%x cannot connect to %s", rc, vdc.mem_path[i]); } + target_register_timer_callback(vdebug_poll, VD_POLL_INTERVAL, + TARGET_TIMER_TYPE_PERIODIC, &vdc); LOG_INFO("vdebug %d connected to %s through %s:%" PRIu16, VD_VERSION, vdc.bfm_path, vdc.server_name, vdc.server_port); } @@ -885,6 +919,8 @@ static int vdebug_init(void) static int vdebug_quit(void) { + target_unregister_timer_callback(vdebug_poll, &vdc); + for (uint8_t i = 0; i < vdc.mem_ndx; i++) if (vdc.mem_width[i]) vdebug_mem_close(vdc.hsocket, pbuf, i); @@ -1299,16 +1335,16 @@ static const struct command_registration vdebug_command_handlers[] = { { .name = "batching", .handler = &vdebug_set_batching, - .mode = COMMAND_CONFIG, + .mode = COMMAND_ANY, .help = "set the transaction batching no|wr|rd [0|1|2]", .usage = "<level>", }, { .name = "polling", .handler = &vdebug_set_polling, - .mode = COMMAND_CONFIG, - .help = "set the polling pause, executing hardware cycles between min and max", - .usage = "<min cycles> <max cycles>", + .mode = COMMAND_ANY, + .help = "set the min idle time and max wait time in ms", + .usage = "<min_idle> <max_wait>", }, COMMAND_REGISTRATION_DONE }; diff --git a/tcl/board/vd_a75x4_jtag.cfg b/tcl/board/vd_a75x4_jtag.cfg index c94a71972..a91f8b8cf 100644 --- a/tcl/board/vd_a75x4_jtag.cfg +++ b/tcl/board/vd_a75x4_jtag.cfg @@ -17,7 +17,7 @@ set CPUTAPID 0x4ba06477 transport select jtag # JTAG reset config, frequency and reset delay -reset_config trst_and_srst +reset_config trst_only adapter speed 1500000 adapter srst delay 5 diff --git a/tcl/board/vd_pulpissimo_jtag.cfg b/tcl/board/vd_pulpissimo_jtag.cfg index a3f5a8488..5a6725fd6 100644 --- a/tcl/board/vd_pulpissimo_jtag.cfg +++ b/tcl/board/vd_pulpissimo_jtag.cfg @@ -4,9 +4,9 @@ source [find interface/vdebug.cfg] -set _CHIPNAME ibex -set _HARTID 0x20 -set _CPUTAPID 0x249511c3 +set CHIPNAME ibex +set HARTID 0x20 +set CPUTAPID 0x249511c3 # vdebug select transport transport select jtag @@ -25,7 +25,7 @@ vdebug mem_path tbench.soc_domain_i.pulp_soc_i.gen_mem_l2_pri\[1\].sram_i.mem_ar vdebug mem_path tbench.soc_domain_i.pulp_soc_i.gen_mem_l2\[0\].sram_i.mem_array 0x1c010000 0x80000 # need to explicitly define riscv tap, autoprobing does not work for icapture != 0x01 -jtag newtap $_CHIPNAME cpu -irlen 5 -ircapture 0x05 -irmask 0x1f -expected-id $_CPUTAPID +jtag newtap $CHIPNAME cpu -irlen 5 -ircapture 0x05 -irmask 0x1f -expected-id $CPUTAPID jtag arp_init-reset diff --git a/tcl/interface/vdebug.cfg b/tcl/interface/vdebug.cfg index 63a595506..27a8aafd7 100644 --- a/tcl/interface/vdebug.cfg +++ b/tcl/interface/vdebug.cfg @@ -30,4 +30,4 @@ tcl port disabled vdebug batching 1 # Polling values -vdebug polling 100 1000 +vdebug polling 100 500 diff --git a/tcl/target/vd_riscv.cfg b/tcl/target/vd_riscv.cfg index f08cb1ac8..44a80524a 100644 --- a/tcl/target/vd_riscv.cfg +++ b/tcl/target/vd_riscv.cfg @@ -2,15 +2,15 @@ # Cadence virtual debug interface # RISCV core -if {![info exists _HARTID]} { - set _HARTID 0x00 +if {![info exists HARTID]} { + set HARTID 0x00 } -if {![info exists _CHIPNAME]} { - set _CHIPNAME riscv +if {![info exists CHIPNAME]} { + set CHIPNAME riscv } -set _TARGETNAME $_CHIPNAME.cpu +set _TARGETNAME $CHIPNAME.cpu -target create $_TARGETNAME riscv -chain-position $_TARGETNAME -coreid $_HARTID +target create $_TARGETNAME riscv -chain-position $_TARGETNAME -coreid $HARTID riscv set_reset_timeout_sec 120 riscv set_command_timeout_sec 120 ----------------------------------------------------------------------- Summary of changes: src/jtag/drivers/vdebug.c | 48 +++++++++++++++++++++++++++++++++++----- tcl/board/vd_a75x4_jtag.cfg | 2 +- tcl/board/vd_pulpissimo_jtag.cfg | 8 +++---- tcl/interface/vdebug.cfg | 2 +- tcl/target/vd_riscv.cfg | 12 +++++----- 5 files changed, 54 insertions(+), 18 deletions(-) hooks/post-receive -- Main OpenOCD repository |