-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
## NEORV32 OpenOCD Scripts | ||
|
||
* `openocd_neorv32.cfg` For the default **single-core** processor configuration | ||
* `openocd_neorv32.dual_core.cfg` For the **SMP dual-core** processor configuration | ||
|
||
### Helper Scripts | ||
|
||
The _helper scripts_ are called by the main OpenOCD configuration files. | ||
Hence, these scripts are not meant for stand-alone operation. | ||
|
||
* `authentication.cfg` Authenticate debug access via the RISC-V DM authentication commands. | ||
Modify this file (but not the helper procedures) if you are using a | ||
**custom/non-default authenticator** processor hardware module. | ||
* `interface.cfg` Physical adapter configuration. Adjust this file to match your specific adapter board. | ||
* `target.cfg` CPU core(s) and GDB configuration. This file should not be altered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# ------------------------------------------------------------------- | ||
# Authenticator helper functions. Do not edit. | ||
# ------------------------------------------------------------------- | ||
|
||
# write 32-bit data word to authenticator data input | ||
proc authenticator_write {WDATA} { | ||
riscv authdata_write $WDATA | ||
} | ||
|
||
# read 32-bit data word from authenticator data output | ||
proc authenticator_read {} { | ||
return [riscv authdata_read] | ||
} | ||
|
||
# check if authentication was successful (bit 7 in dmstatus) | ||
proc authenticator_check {} { | ||
set DMSTATUS [riscv dmi_read 0x11] | ||
if { [expr {$DMSTATUS & (1<<7)}] } { | ||
echo "Authentication passed." | ||
} else { | ||
echo "AUTHENTICATION FAILED!" | ||
exit | ||
} | ||
} | ||
|
||
# --------------------------------------------------------- | ||
# Authentication process. | ||
# Adjust this for your custom/non-default authenticator. | ||
# --------------------------------------------------------- | ||
# read challenge | ||
set CHALLENGE [authenticator_read] | ||
# compute response (default authenticator module) | ||
set RESPONSE [expr {$CHALLENGE | 1}] | ||
# send response | ||
authenticator_write $RESPONSE | ||
# success? | ||
authenticator_check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# ------------------------------------------------------------------- | ||
# Physical interface configuration. | ||
# Adjust this file for your specific debug adapter. | ||
# ------------------------------------------------------------------- | ||
adapter driver ftdi | ||
ftdi vid_pid 0x0403 0x6010 | ||
ftdi channel 0 | ||
ftdi layout_init 0x0038 0x003b | ||
adapter speed 4000 | ||
transport select jtag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# ------------------------------------------------------------------- | ||
# Target configuration and (session) initialization | ||
# Do not edits this file. | ||
# ------------------------------------------------------------------- | ||
proc target_setup { {NUM_CORES 1} } { | ||
|
||
# path of this file | ||
set PATH [ file dirname [ file normalize [ info script ] ] ] | ||
|
||
# configure physical interface | ||
source [file join $PATH interface.cfg] | ||
|
||
set CORENAME neorv32 | ||
|
||
# configures JTAG tap | ||
jtag newtap $CORENAME cpu -irlen 5 | ||
|
||
# attach core(s) | ||
if { $NUM_CORES == 1 } { | ||
set TARGETNAME $CORENAME.cpu | ||
target create $TARGETNAME riscv -chain-position $TARGETNAME | ||
} elseif { $NUM_CORES == 2 } { | ||
set TARGETNAME_0 $CORENAME.cpu0 | ||
set TARGETNAME_1 $CORENAME.cpu1 | ||
target create $TARGETNAME_0 riscv -chain-position $CORENAME.cpu -rtos hwthread | ||
target create $TARGETNAME_1 riscv -chain-position $CORENAME.cpu -coreid 1 | ||
target smp $TARGETNAME_0 $TARGETNAME_1 | ||
} else { | ||
echo "ERROR: Invalid NUM_CORE configuration!" | ||
} | ||
|
||
# GDB server configuration | ||
gdb report_data_abort enable | ||
gdb report_register_access_error enable | ||
|
||
# expose additional / 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 | ||
|
||
# initialize target | ||
init | ||
|
||
# authenticate | ||
source [file join $PATH authentication.cfg] | ||
|
||
# halt | ||
halt | ||
echo "Target HALTED. Ready for remote connections." | ||
} |