Skip to content

Commit

Permalink
[openocd] split configuration files
Browse files Browse the repository at this point in the history
  • Loading branch information
stnolting committed Feb 2, 2025
1 parent 31e4535 commit 7e3583e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 124 deletions.
66 changes: 6 additions & 60 deletions sw/openocd/openocd_neorv32.cfg
Original file line number Diff line number Diff line change
@@ -1,64 +1,10 @@
# The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32
# OpenOCD on-chip debugger configuration file for SINGLE-CORE configuration

echo "NEORV32 single-core openOCD configuration."
echo "*****************************************"
echo "NEORV32 single-core openOCD configuration"
echo "*****************************************"

# -------------------------------------------------------------------
# Physical interface configuration; ADJUST THIS FOR YOUR ADAPTER
# -------------------------------------------------------------------
adapter driver ftdi
ftdi vid_pid 0x0403 0x6010
ftdi channel 0
ftdi layout_init 0x0038 0x003b
adapter speed 4000
transport select jtag

# -------------------------------------------------------------------
# Target configuration
# -------------------------------------------------------------------
set _CHIPNAME neorv32
jtag newtap $_CHIPNAME cpu -irlen 5

set _TARGETNAME $_CHIPNAME.cpu

target create $_TARGETNAME 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

# -------------------------------------------------------------------
# Server configuration
# -------------------------------------------------------------------
gdb report_data_abort enable

# -------------------------------------------------------------------
# Initialize target
# -------------------------------------------------------------------
init

# -------------------------------------------------------------------
# Authenticate; ADJUST THIS FOR YOUR AUTHENTICATOR
# -------------------------------------------------------------------
set challenge [riscv authdata_read]
riscv authdata_write [expr {$challenge | 1}]

# -------------------------------------------------------------------
# Check if device is authenticated (bit 7 in dmstatus)
# -------------------------------------------------------------------
set dmstatus [riscv dmi_read 0x11]
if { [expr {$dmstatus & (1<<7)}] } {
echo "Authentication passed."
} else {
echo "AUTHENTICATION FAILED!"
exit
}

# -------------------------------------------------------------------
# Target should be halted and ready now
# -------------------------------------------------------------------
halt
echo "Target HALTED. Ready for remote connections."
set PATH [ file dirname [ file normalize [ info script ] ] ]
source [file join $PATH target.cfg]
target_setup 1
71 changes: 7 additions & 64 deletions sw/openocd/openocd_neorv32.dual_core.cfg
Original file line number Diff line number Diff line change
@@ -1,67 +1,10 @@
# The NEORV32 RISC-V Processor - https://github.com/stnolting/neorv32
# OpenOCD on-chip debugger configuration file for DUAL-CORE configuration
# OpenOCD on-chip debugger configuration file for DUAL-CORE SMP configuration

echo "NEORV32 dual-core openOCD configuration."
echo "*******************************************"
echo "NEORV32 SMP dual-core openOCD configuration"
echo "*******************************************"

# -------------------------------------------------------------------
# Physical interface configuration; ADJUST THIS FOR YOUR ADAPTER
# -------------------------------------------------------------------
adapter driver ftdi
ftdi vid_pid 0x0403 0x6010
ftdi channel 0
ftdi layout_init 0x0038 0x003b
adapter speed 4000
transport select jtag

# -------------------------------------------------------------------
# Target configuration
# -------------------------------------------------------------------
set _CHIPNAME neorv32
jtag newtap $_CHIPNAME cpu -irlen 5

set _TARGETNAME_0 $_CHIPNAME.cpu0
set _TARGETNAME_1 $_CHIPNAME.cpu1

target create $_TARGETNAME_0 riscv -chain-position $_CHIPNAME.cpu -rtos hwthread
target create $_TARGETNAME_1 riscv -chain-position $_CHIPNAME.cpu -coreid 1
target smp $_TARGETNAME_0 $_TARGETNAME_1

# expose NEORV32-specific CSRs to debugger
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

# -------------------------------------------------------------------
# Server configuration
# -------------------------------------------------------------------
gdb report_data_abort enable

# -------------------------------------------------------------------
# Initialize target
# -------------------------------------------------------------------
init

# -------------------------------------------------------------------
# Authenticate; ADJUST THIS FOR YOUR AUTHENTICATOR
# -------------------------------------------------------------------
set challenge [riscv authdata_read]
riscv authdata_write [expr {$challenge | 1}]

# -------------------------------------------------------------------
# Check if device is authenticated (bit 7 in dmstatus)
# -------------------------------------------------------------------
set dmstatus [riscv dmi_read 0x11]
if { [expr {$dmstatus & (1<<7)}] } {
echo "Authentication passed."
} else {
echo "AUTHENTICATION FAILED!"
exit
}

# -------------------------------------------------------------------
# Target should be halted and ready now
# -------------------------------------------------------------------
halt
echo "Target HALTED. Ready for remote connections."
set PATH [ file dirname [ file normalize [ info script ] ] ]
source [file join $PATH target.cfg]
target_setup 2

0 comments on commit 7e3583e

Please sign in to comment.