Cadence virtual debug interface (vdebug) integration

Change-Id: I1bc105b3addc3f34161c2356c482ff3011e3f2cc
Signed-off-by: Jacek Wuwer <jacekmw8@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6097
Tested-by: jenkins
Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
Reviewed-by: zapb <dev@zapb.de>
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Jacek Wuwer 2021-04-06 20:08:11 +02:00 committed by Antonio Borneo
parent 2a2636f138
commit f998a2aaf1
13 changed files with 1364 additions and 2 deletions

View File

@ -274,6 +274,10 @@ AC_ARG_ENABLE([jtag_vpi],
AS_HELP_STRING([--enable-jtag_vpi], [Enable building support for JTAG VPI]),
[build_jtag_vpi=$enableval], [build_jtag_vpi=no])
AC_ARG_ENABLE([vdebug],
AS_HELP_STRING([--enable-vdebug], [Enable building support for Cadence Virtual Debug Interface]),
[build_vdebug=$enableval], [build_vdebug=no])
AC_ARG_ENABLE([jtag_dpi],
AS_HELP_STRING([--enable-jtag_dpi], [Enable building support for JTAG DPI]),
[build_jtag_dpi=$enableval], [build_jtag_dpi=no])
@ -513,6 +517,12 @@ AS_IF([test "x$build_jtag_vpi" = "xyes"], [
AC_DEFINE([BUILD_JTAG_VPI], [0], [0 if you don't want JTAG VPI.])
])
AS_IF([test "x$build_vdebug" = "xyes"], [
AC_DEFINE([BUILD_VDEBUG], [1], [1 if you want Cadence vdebug interface.])
], [
AC_DEFINE([BUILD_VDEBUG], [0], [0 if you don't want Cadence vdebug interface.])
])
AS_IF([test "x$build_jtag_dpi" = "xyes"], [
AC_DEFINE([BUILD_JTAG_DPI], [1], [1 if you want JTAG DPI.])
], [
@ -688,8 +698,9 @@ AM_CONDITIONAL([AT91RM9200], [test "x$build_at91rm9200" = "xyes"])
AM_CONDITIONAL([BCM2835GPIO], [test "x$build_bcm2835gpio" = "xyes"])
AM_CONDITIONAL([IMX_GPIO], [test "x$build_imx_gpio" = "xyes"])
AM_CONDITIONAL([BITBANG], [test "x$build_bitbang" = "xyes"])
AM_CONDITIONAL([JTAG_VPI], [test "x$build_jtag_vpi" = "xyes" -o "x$build_jtag_vpi" = "xyes"])
AM_CONDITIONAL([JTAG_DPI], [test "x$build_jtag_dpi" = "xyes" -o "x$build_jtag_dpi" = "xyes"])
AM_CONDITIONAL([JTAG_VPI], [test "x$build_jtag_vpi" = "xyes"])
AM_CONDITIONAL([VDEBUG], [test "x$build_vdebug" = "xyes"])
AM_CONDITIONAL([JTAG_DPI], [test "x$build_jtag_dpi" = "xyes"])
AM_CONDITIONAL([USB_BLASTER_DRIVER], [test "x$enable_usb_blaster" != "xno" -o "x$enable_usb_blaster_2" != "xno"])
AM_CONDITIONAL([AMTJTAGACCEL], [test "x$build_amtjtagaccel" = "xyes"])
AM_CONDITIONAL([GW16012], [test "x$build_gw16012" = "xyes"])

View File

@ -588,6 +588,12 @@ produced, PDF schematics are easily found and it is easy to make.
@* A JTAG driver acting as a client for the JTAG VPI server interface.
@* Link: @url{http://github.com/fjullien/jtag_vpi}
@item @b{vdebug}
@* A driver for Cadence virtual Debug Interface to emulated or simulated targets.
It implements a client connecting to the vdebug server, which in turn communicates
with the emulated or simulated RTL model through a transactor. The current version
supports only JTAG as a transport, but other virtual transports, like DAP are planned.
@item @b{jtag_dpi}
@* A JTAG driver acting as a client for the SystemVerilog Direct Programming
Interface (DPI) for JTAG devices. DPI allows OpenOCD to connect to the JTAG
@ -3345,6 +3351,41 @@ This value is only used with the standard variant.
@end deffn
@deffn {Interface Driver} {vdebug}
Cadence Virtual Debug Interface driver.
@deffn {Config Command} {vdebug server} host:port
Specifies the host and TCP port number where the vdebug server runs.
@end deffn
@deffn {Config Command} {vdebug batching} value
Specifies the batching method for the vdebug request. Possible values are
0 for no batching
1 or wr to batch write transactions together (default)
2 or rw to batch both read and write transactions
@end deffn
@deffn {Config Command} {vdebug polling} min max
Takes two values, representing the polling interval in ms. Lower values mean faster
debugger responsiveness, but lower emulation performance. The minimum should be
around 10, maximum should not exceed 1000, which is the default gdb and keepalive
timeout value.
@end deffn
@deffn {Config Command} {vdebug bfm_path} path clk_period
Specifies the hierarchical path and input clk period of the vdebug BFM in the design.
The hierarchical path uses Verilog notation top.inst.inst
The clock period must include the unit, for instance 40ns.
@end deffn
@deffn {Config Command} {vdebug mem_path} path base size
Specifies the hierarchical path to the design memory instance for backdoor access.
Up to 4 memories can be specified. The hierarchical path uses Verilog notation.
The base specifies start address in the design address space, size its size in bytes.
Both values can use hexadecimal notation with prefix 0x.
@end deffn
@end deffn
@deffn {Interface Driver} {jtag_dpi}
SystemVerilog Direct Programming Interface (DPI) compatible driver for
JTAG devices in emulation. The driver acts as a client for the SystemVerilog

View File

@ -75,6 +75,9 @@ endif
if JTAG_VPI
DRIVERFILES += %D%/jtag_vpi.c
endif
if VDEBUG
DRIVERFILES += %D%/vdebug.c
endif
if JTAG_DPI
DRIVERFILES += %D%/jtag_dpi.c
endif

1076
src/jtag/drivers/vdebug.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -57,6 +57,9 @@ extern struct adapter_driver usb_blaster_adapter_driver;
#if BUILD_JTAG_VPI == 1
extern struct adapter_driver jtag_vpi_adapter_driver;
#endif
#if BUILD_VDEBUG == 1
extern struct adapter_driver vdebug_adapter_driver;
#endif
#if BUILD_JTAG_DPI == 1
extern struct adapter_driver jtag_dpi_adapter_driver;
#endif
@ -168,6 +171,9 @@ struct adapter_driver *adapter_drivers[] = {
#if BUILD_JTAG_VPI == 1
&jtag_vpi_adapter_driver,
#endif
#if BUILD_VDEBUG == 1
&vdebug_adapter_driver,
#endif
#if BUILD_JTAG_DPI == 1
&jtag_dpi_adapter_driver,
#endif

View File

@ -0,0 +1,31 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Cadence virtual debug interface
# Arm Cortex A53x2 through JTAG
source [find interface/vdebug.cfg]
set _CORES 2
set _CHIPNAME a53
set _MEMSTART 0x00000000
set _MEMSIZE 0x1000000
set _CPUTAPID 0x5ba00477
# vdebug select transport
#transport select jtag
# JTAG reset config, frequency and reset delay
reset_config trst_and_srst
adapter speed 50000
adapter srst delay 5
# BFM hierarchical path and input clk period
vdebug bfm_path tbench.u_vd_jtag_bfm 10ns
# DMA Memories to access backdoor (up to 4)
vdebug mem_path tbench.u_memory.mem_array $_MEMSTART $_MEMSIZE
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
jtag arp_init-reset
source [find target/vd_aarch64.cfg]

30
tcl/board/vd_m4_jtag.cfg Normal file
View File

@ -0,0 +1,30 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Cadence virtual debug interface
# Arm Cortex m4 through JTAG
source [find interface/vdebug.cfg]
set _CHIPNAME m4
set _MEMSTART 0x00000000
set _MEMSIZE 0x10000
set _CPUTAPID 0x4ba00477
# vdebug select transport
#transport select jtag
# JTAG reset config, frequency and reset delay
reset_config trst_and_srst
adapter speed 25000
adapter srst delay 5
# BFM hierarchical path and input clk period
vdebug bfm_path tbench.u_vd_jtag_bfm 20ns
# DMA Memories to access backdoor (up to 4)
vdebug mem_path tbench.u_mcu.u_sys.u_rom.rom $_MEMSTART $_MEMSIZE
jtag newtap $_CHIPNAME cpu -irlen 4 -ircapture 0x1 -irmask 0xf -expected-id $_CPUTAPID
jtag arp_init-reset
source [find target/vd_cortex_m.cfg]

View File

@ -0,0 +1,32 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Cadence virtual debug interface
# RISCV Ibex core with Pulpissimo through JTAG
source [find interface/vdebug.cfg]
set _CHIPNAME ibex
set _HARTID 0x20
set _CPUTAPID 0x249511c3
# vdebug select transport
#transport select jtag
# JTAG reset config, frequency and reset delay
reset_config trst_and_srst
adapter speed 12500
adapter srst delay 10
# BFM hierarchical path and input clk period
vdebug bfm_path tbench.u_vd_jtag_bfm 40ns
# DMA Memories to access backdoor (up to 4)
vdebug mem_path tbench.soc_domain_i.pulp_soc_i.gen_mem_l2_pri\[0\].sram_i.mem_array 0x1c000000 0x8000
vdebug mem_path tbench.soc_domain_i.pulp_soc_i.gen_mem_l2_pri\[1\].sram_i.mem_array 0x1c008000 0x8000
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 arp_init-reset
source [find target/vd_riscv.cfg]

View File

@ -0,0 +1,32 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Cadence virtual debug interface
# RISCV swerv core with Swerv through JTAG
source [find interface/vdebug.cfg]
set _CHIPNAME rv32
set _HARTID 0x00
set _CPUTAPID 0x1000008b
set _MEMSTART 0x00000000
set _MEMSIZE 0x10000
# vdebug select transport
#transport select jtag
# JTAG reset config, frequency and reset delay
reset_config trst_and_srst
adapter speed 50000
adapter srst delay 5
# BFM hierarchical path and input clk period
vdebug bfm_path tbench.u_vd_jtag_bfm 10ns
# DMA Memories to access backdoor (up to 4)
vdebug mem_path tbench.i_ahb_ic.mem $_MEMSTART $_MEMSIZE
# need to explicitly define riscv tap, autoprobing does not work for icapture != 0x01
jtag newtap $_CHIPNAME cpu -irlen 5 -ircapture 0x01 -irmask 0x1f -expected-id $_CPUTAPID
jtag arp_init-reset
source [find target/vd_riscv.cfg]

33
tcl/interface/vdebug.cfg Normal file
View File

@ -0,0 +1,33 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Cadence virtual debug interface
if { [info exists VDEBUGHOST] } {
set _VDEBUGHOST $VDEBUGHOST
} else {
set _VDEBUGHOST localhost
}
if { [info exists VDEBUGPORT] } {
set _VDEBUGPORT $VDEBUGPORT
} else {
set _VDEBUGPORT 8192
}
adapter driver vdebug
# vdebug server:port
vdebug server $_VDEBUGHOST:$_VDEBUGPORT
# example config debug level and log
#debug_level 3
#log_output vd_ocd.log
# example config listen on all interfaces, disable tcl/telnet server
bindto 0.0.0.0
#gdb_port 3333
#telnet_port disabled
tcl_port disabled
# transaction batching: 0 - no batching, 1 - (default) wr, 2 - rw
vdebug batching 1
# Polling values
vdebug polling 100 1000

37
tcl/target/vd_aarch64.cfg Normal file
View File

@ -0,0 +1,37 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Cadence virtual debug interface
# Arm v8 64b Cortex A
if {![info exists _CORES]} {
set _CORES 1
}
if {![info exists _CHIPNAME]} {
set _CHIPNAME aarch64
}
set _TARGETNAME $_CHIPNAME.cpu
set _CTINAME $_CHIPNAME.cti
set DBGBASE {0x80810000 0x80910000}
set CTIBASE {0x80820000 0x80920000}
dap create $_CHIPNAME.dap -chain-position $_TARGETNAME
$_CHIPNAME.dap apsel 1
for { set _core 0 } { $_core < $_CORES } { incr _core } \
{
cti create $_CTINAME.$_core -dap $_CHIPNAME.dap -ap-num 1 -baseaddr [lindex $CTIBASE $_core]
set _command "target create $_TARGETNAME.$_core aarch64 -dap $_CHIPNAME.dap \
-dbgbase [lindex $DBGBASE $_core] -cti $_CTINAME.$_core -coreid $_core"
if { $_core != 0 } {
# non-boot core examination may fail
set _command "$_command -defer-examine"
set _smp_command "$_smp_command $_TARGETNAME.$_core"
} else {
set _smp_command "target smp $_TARGETNAME.$_core"
}
eval $_command
}
eval $_smp_command
# default target is core 0
targets $_TARGETNAME.0

View File

@ -0,0 +1,12 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Cadence virtual debug interface
# ARM Cortex M
if {![info exists _CHIPNAME]} {
set _CHIPNAME cortex_m
}
set _TARGETNAME $_CHIPNAME.cpu
dap create $_CHIPNAME.dap -chain-position $_TARGETNAME
target create $_TARGETNAME cortex_m -dap $_CHIPNAME.dap

18
tcl/target/vd_riscv.cfg Normal file
View File

@ -0,0 +1,18 @@
# SPDX-License-Identifier: GPL-2.0-or-later
# Cadence virtual debug interface
# RISCV core
if {![info exists _HARTID]} {
set _HARTID 0x00
}
if {![info exists _CHIPNAME]} {
set _CHIPNAME riscv
}
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME -coreid $_HARTID
riscv set_reset_timeout_sec 120
riscv set_command_timeout_sec 120
# prefer to use sba for system bus access
riscv set_prefer_sba on