# NEORV32 on-chip debugger openOCD configuration file

# ----------------------------------------------
# Physical interface configuration
# -> ADJUST THIS FOR YOUR ADAPTER / SETUP
# ----------------------------------------------

# Default: FT2232H breakout board
# TCK:  D0
# TDI:  D1
# TDO:  D2
# TMS:  D3
# TRST: D4 (low-active, optional - pull input pin high if not used)

adapter driver ftdi
ftdi vid_pid 0x0403 0x6010
ftdi channel 0
ftdi layout_init 0x0038 0x003b
ftdi layout_signal nTRST -ndata 0x0010 -noe 0x0040

adapter speed 4000
transport select jtag

# ----------------------------------------------
# Target configuration
# ----------------------------------------------
set _CHIPNAME neorv32
jtag newtap $_CHIPNAME cpu -irlen 5
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME.0 riscv -chain-position $_TARGETNAME

# expose NEORV32-specific CSRs
riscv expose_csrs 2048=cfureg0
riscv expose_csrs 2049=cfureg1
riscv expose_csrs 2050=cfureg2
riscv expose_csrs 2051=cfureg3
riscv expose_csrs 4032=mxisa

# enable memory access error reports
gdb_report_data_abort enable

# ----------------------------------------------
# Start session
# ----------------------------------------------
init
halt

echo "Target HALTED. Ready for remote connections."
