Skip to content

Commit

Permalink
fpga: Add openocd util scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilKoe committed May 22, 2024
1 parent df80ad6 commit 2433ea2
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
44 changes: 44 additions & 0 deletions utils/openocd.host.hs2.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2024 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Use this OpenOCD script to connect to debug Carfield via a Digilent
# HS2 USB-JTAG Dongle connected to your FPGA
# Attention: This config requires
# Safety-Island : Disabled
# OpenTitan : Disabled

adapter_khz 2000
interface ftdi
ftdi_vid_pid 0x0403 0x6014
ftdi_layout_init 0x00e8 0x60eb
ftdi_channel 0
set irlen 5

transport select jtag
telnet_port disabled
tcl_port disabled
reset_config none

set _CHIPNAME carfield
jtag newtap $_CHIPNAME cheshire -irlen ${irlen} -expected-id 0xed9c5e51

set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME -coreid 0

gdb_report_data_abort enable
gdb_report_register_access_error enable

riscv set_reset_timeout_sec 120
riscv set_command_timeout_sec 120

riscv set_prefer_sba off

# Try enabling address translation (only works for newer versions)
if { [catch {riscv set_enable_virtual on} ] } {
echo "Warning: This version of OpenOCD does not support address translation. To debug on virtual addresses, please update to the latest version." }

init
halt
echo "Ready for Remote Connections"

45 changes: 45 additions & 0 deletions utils/openocd.host_safety.hs2.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright 2024 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
#
# Use this OpenOCD script to connect to debug Carfield via a Digilent
# HS2 USB-JTAG Dongle connected to your FPGA
# Attention: This config requires
# Safety-Island : Enabled
# OpenTitan : Disabled

adapter_khz 2000
interface ftdi
ftdi_vid_pid 0x0403 0x6014
ftdi_layout_init 0x00e8 0x60eb
ftdi_channel 0
set irlen 5

transport select jtag
telnet_port disabled
tcl_port disabled
reset_config none

set _CHIPNAME carfield
jtag newtap $_CHIPNAME.safety cpu -irlen ${irlen} -expected-id 0x10000db3
jtag newtap $_CHIPNAME.cheshire cpu -irlen ${irlen} -expected-id 0xed9c5e51

target create $_CHIPNAME.cheshire riscv -chain-position $_CHIPNAME.cheshire -coreid 0
target create $_CHIPNAME.safety riscv -chain-position $_CHIPNAME.safety -coreid 0x8

gdb_report_data_abort enable
gdb_report_register_access_error enable

riscv set_reset_timeout_sec 120
riscv set_command_timeout_sec 120

riscv set_prefer_sba off

# Try enabling address translation (only works for newer versions)
if { [catch {riscv set_enable_virtual on} ] } {
echo "Warning: This version of OpenOCD does not support address translation. To debug on virtual addresses, please update to the latest version." }

init
halt
echo "Ready for Remote Connections"

0 comments on commit 2433ea2

Please sign in to comment.