From 569f96adcebe07964ee8c9456f9258202177a08b Mon Sep 17 00:00:00 2001 From: IveanEx Date: Mon, 2 Sep 2024 14:27:56 +0200 Subject: [PATCH 1/3] Fix OpenOCD debugger --- target/fpga/openocd_configs/vcu128-2.cfg | 33 ------------------- .../jtag/openocd_configs/hemaia_vcu128.cfg} | 16 ++++----- .../jtag/openocd_configs/hemaia_vpk180.cfg} | 18 +++++----- 3 files changed, 15 insertions(+), 52 deletions(-) delete mode 100644 target/fpga/openocd_configs/vcu128-2.cfg rename target/{fpga/openocd_configs/vcu128-1.cfg => fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg} (74%) rename target/{fpga/openocd_configs/digilent-HS2.cfg => fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg} (76%) diff --git a/target/fpga/openocd_configs/vcu128-2.cfg b/target/fpga/openocd_configs/vcu128-2.cfg deleted file mode 100644 index b5c566fd5..000000000 --- a/target/fpga/openocd_configs/vcu128-2.cfg +++ /dev/null @@ -1,33 +0,0 @@ -# Copyright 2021 ETH Zurich and University of Bologna. -# Solderpad Hardware License, Version 0.51, see LICENSE for details. -# SPDX-License-Identifier: SHL-0.51 - -adapter driver ftdi -adapter speed 2000 -transport select jtag - -# FTF232 -ftdi_vid_pid 0x0403 0x6011 -# If more than one FTDI is connected we -# can use the serial to differentiate. -ftdi_serial 091847100638 -ftdi_layout_init 0x0008 0x05eb - - -set _CHIPNAME riscv -jtag newtap $_CHIPNAME cpu -irlen 18 -expected-id 0x14B79093 - -set _TARGETNAME $_CHIPNAME.cpu -target create $_TARGETNAME riscv -chain-position $_TARGETNAME - -riscv set_ir idcode 0x9249 -riscv set_ir dtmcs 0x22924 -riscv set_ir dmi 0x23924 - -# 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." } - -telnet_port disabled -tcl_port disabled -gdb_port 3334 \ No newline at end of file diff --git a/target/fpga/openocd_configs/vcu128-1.cfg b/target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg similarity index 74% rename from target/fpga/openocd_configs/vcu128-1.cfg rename to target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg index fcd01dbcd..ab8060996 100644 --- a/target/fpga/openocd_configs/vcu128-1.cfg +++ b/target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg @@ -6,16 +6,14 @@ adapter driver ftdi adapter speed 2000 transport select jtag -# FTF232 -ftdi_vid_pid 0x0403 0x6011 -# If more than one FTDI is connected we -# can use the serial to differentiate. -ftdi_serial 091847100576 -ftdi_layout_init 0x0008 0x05eb - +# FT4232 +ftdi vid_pid 0x0403 0x6011 +adapter serial FT80Z5JA +ftdi layout_init 0x0808 0x0b0b +ftdi_channel 1 set _CHIPNAME riscv -jtag newtap $_CHIPNAME cpu -irlen 18 -expected-id 0x14B79093 +jtag newtap $_CHIPNAME cpu -irlen 18 -expected-id 0x20002001 set _TARGETNAME $_CHIPNAME.cpu target create $_TARGETNAME riscv -chain-position $_TARGETNAME @@ -30,4 +28,4 @@ riscv set_ir dmi 0x23924 telnet_port disabled tcl_port disabled -gdb_port 3334 \ No newline at end of file +gdb_port 3334 diff --git a/target/fpga/openocd_configs/digilent-HS2.cfg b/target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg similarity index 76% rename from target/fpga/openocd_configs/digilent-HS2.cfg rename to target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg index 6eb33ca35..3484459f7 100644 --- a/target/fpga/openocd_configs/digilent-HS2.cfg +++ b/target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg @@ -3,16 +3,14 @@ # SPDX-License-Identifier: SHL-0.51 adapter driver ftdi -adapter speed 2000 +adapter speed 5000 transport select jtag -# FTF232 -ftdi_vid_pid 0x0403 0x6014 -# If more than one FTDI is connected we -# can use the serial to differentiate. -ftdi_channel 0 -ftdi_serial 210249AEC334 -ftdi_layout_init 0x00e8 0x60eb +# FT4232 +ftdi vid_pid 0x0403 0x6011 +adapter serial FT80Z5JA +ftdi layout_init 0x0808 0x0b0b +ftdi channel 0 set _CHIPNAME riscv jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20002001 @@ -28,6 +26,6 @@ riscv set_ir dmi 0x23924 #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." } +tcl port disabled +gdb port 3334 telnet_port disabled -tcl_port disabled -gdb_port 3334 \ No newline at end of file From baafc2c5bd1d2f4e4a4431612f82064d76095c95 Mon Sep 17 00:00:00 2001 From: IveanEx Date: Mon, 2 Sep 2024 16:01:37 +0200 Subject: [PATCH 2/3] Bug Fix --- Makefile | 2 +- target/fpga/sw/Makefile | 8 ++++++- target/fpga_chip/jtag/app/Makefile | 23 +++++++++++++++++++ .../jtag/openocd_configs/download_bin.cfg | 1 + .../jtag/openocd_configs/hemaia_vcu128.cfg | 2 +- .../jtag/openocd_configs/hemaia_vpk180.cfg | 2 +- 6 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 target/fpga_chip/jtag/app/Makefile create mode 100644 target/fpga_chip/jtag/openocd_configs/download_bin.cfg diff --git a/Makefile b/Makefile index 85c26f4dd..442d9fe50 100644 --- a/Makefile +++ b/Makefile @@ -83,7 +83,7 @@ occamy_system_download_sw: # In ESAT Server; this procedure will only inject the make -C ./target/fpga/sw download_sw open_terminal: # It opens ttyUSB1 without locking it, and set baudrate at 1Mbps - $(shell minicom -D /dev/ttyUSB1 -b 1000000 -o) + $(info "shell minicom -D /dev/ttyUSB1 -b 1000000 -o") # FPGA Workflow (with no Xilinx IP - tapeout configuration) # Please be attention that in this configuration, injecting any binary files by Xilinx Vivado are not possible anymore; please use JTAG or embedded bootrom to load the binary diff --git a/target/fpga/sw/Makefile b/target/fpga/sw/Makefile index a95484f95..9be869d94 100644 --- a/target/fpga/sw/Makefile +++ b/target/fpga/sw/Makefile @@ -10,6 +10,12 @@ APP ?= $(TARGET)/sim/sw/host/apps/hello_world/build/hello_world.elf BIN2JTAG ?= $(ROOT)/util/bin2jtag.py BIN_VERIFY ?= $(ROOT)/util/bin2jtag_only_verify.py +CVA6_GCC_ROOT = /tools/riscv/bin +RISCV_CC = $(CVA6_GCC_ROOT)/riscv64-unknown-elf-gcc +RISCV_OBJCOPY = $(CVA6_GCC_ROOT)/riscv64-unknown-elf-objcopy +RISCV_OBJDUMP = $(CVA6_GCC_ROOT)/riscv64-unknown-elf-objdump +RISCV_READELF = $(CVA6_GCC_ROOT)/riscv64-unknown-elf-readelf + .PHONY: sw download_sw clean verify_sw sw: bootrom.tcl app.tcl app_verify.tcl @@ -21,7 +27,7 @@ bootrom.tcl: $(BOOTROM) $(BIN2JTAG) -c32 -b 0 -d hw_axi_1 $< > $@ app.bin: - riscv64-unknown-elf-objcopy -O binary $(APP) $@ + $(RISCV_OBJCOPY) -O binary $(APP) $@ app.tcl: app.bin $(BIN2JTAG) -c32 -b 80000000 -d hw_axi_2 $< > $@ diff --git a/target/fpga_chip/jtag/app/Makefile b/target/fpga_chip/jtag/app/Makefile new file mode 100644 index 000000000..90db14fab --- /dev/null +++ b/target/fpga_chip/jtag/app/Makefile @@ -0,0 +1,23 @@ +MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) +MKFILE_DIR := $(dir $(MKFILE_PATH)) +TARGET := $(MKFILE_DIR)../../.. +ROOT := ${MKFILE_DIR}../../../.. + +APP ?= $(TARGET)/sim/sw/host/apps/hello_world/build/hello_world.elf + +CVA6_GCC_ROOT = /tools/riscv/bin +RISCV_CC = $(CVA6_GCC_ROOT)/riscv64-unknown-elf-gcc +RISCV_OBJCOPY = $(CVA6_GCC_ROOT)/riscv64-unknown-elf-objcopy +RISCV_OBJDUMP = $(CVA6_GCC_ROOT)/riscv64-unknown-elf-objdump +RISCV_READELF = $(CVA6_GCC_ROOT)/riscv64-unknown-elf-readelf + +.PHONY: download_sw + +app.bin: + $(RISCV_OBJCOPY) -O binary $(APP) $@ + +download_sw: + ${VIVADO} -mode batch -source download_sw.tcl + +clean: + @rm -f app.bin diff --git a/target/fpga_chip/jtag/openocd_configs/download_bin.cfg b/target/fpga_chip/jtag/openocd_configs/download_bin.cfg new file mode 100644 index 000000000..6db87d737 --- /dev/null +++ b/target/fpga_chip/jtag/openocd_configs/download_bin.cfg @@ -0,0 +1 @@ +load_image ../app.bin 0x80000000 diff --git a/target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg b/target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg index ab8060996..ae0066165 100644 --- a/target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg +++ b/target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg @@ -26,6 +26,6 @@ riscv set_ir dmi 0x23924 #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." } -telnet_port disabled tcl_port disabled gdb_port 3334 +telnet_port 4444 diff --git a/target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg b/target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg index 3484459f7..a0533dfa9 100644 --- a/target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg +++ b/target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg @@ -28,4 +28,4 @@ riscv set_ir dmi 0x23924 tcl port disabled gdb port 3334 -telnet_port disabled +telnet_port 4444 From f8355b13b80662bd0c047505358a8b4bf1a814d6 Mon Sep 17 00:00:00 2001 From: IveanEx Date: Thu, 5 Sep 2024 20:07:25 +0200 Subject: [PATCH 3/3] Bug Fix --- target/fpga/sw/send_uart.sh | 6 +++--- .../jtag/openocd_configs/download_bin.cfg | 2 +- .../jtag/openocd_configs/hemaia_vcu128.cfg | 18 +++++++----------- .../jtag/openocd_configs/hemaia_vpk180.cfg | 12 ++++-------- 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/target/fpga/sw/send_uart.sh b/target/fpga/sw/send_uart.sh index 902660cb6..1e88a21a7 100755 --- a/target/fpga/sw/send_uart.sh +++ b/target/fpga/sw/send_uart.sh @@ -11,10 +11,10 @@ else FILE=$1 fi - stty -F /dev/ttyUSB1 cs8 1000000 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon crtscts + stty -F /dev/ttyUSB3 cs8 1000000 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon crtscts - echo -n 2 > /dev/ttyUSB1 + echo -n 2 > /dev/ttyUSB3 - sx -k "$FILE" < /dev/ttyUSB1 > /dev/ttyUSB1 + sx -k "$FILE" < /dev/ttyUSB3 > /dev/ttyUSB3 fi diff --git a/target/fpga_chip/jtag/openocd_configs/download_bin.cfg b/target/fpga_chip/jtag/openocd_configs/download_bin.cfg index 6db87d737..d29c1f567 100644 --- a/target/fpga_chip/jtag/openocd_configs/download_bin.cfg +++ b/target/fpga_chip/jtag/openocd_configs/download_bin.cfg @@ -1 +1 @@ -load_image ../app.bin 0x80000000 +load_image /users/micas/ydeng/Desktop/SNAX/HeMAiA/target/fpga_chip/jtag/app/app.bin 0x80000000 diff --git a/target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg b/target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg index ae0066165..c9cf6945b 100644 --- a/target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg +++ b/target/fpga_chip/jtag/openocd_configs/hemaia_vcu128.cfg @@ -10,22 +10,18 @@ transport select jtag ftdi vid_pid 0x0403 0x6011 adapter serial FT80Z5JA ftdi layout_init 0x0808 0x0b0b -ftdi_channel 1 +ftdi channel 1 set _CHIPNAME riscv -jtag newtap $_CHIPNAME cpu -irlen 18 -expected-id 0x20002001 +jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20002001 set _TARGETNAME $_CHIPNAME.cpu target create $_TARGETNAME riscv -chain-position $_TARGETNAME -riscv set_ir idcode 0x9249 -riscv set_ir dtmcs 0x22924 -riscv set_ir dmi 0x23924 +riscv.cpu riscv set_ir idcode 0x9249 +# riscv.cpu riscv set_ir dtmcs 0x22924 +# riscv.cpu riscv set_ir dmi 0x23924 -# 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." } - -tcl_port disabled -gdb_port 3334 +tcl port disabled +gdb port 3334 telnet_port 4444 diff --git a/target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg b/target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg index a0533dfa9..5238f0f39 100644 --- a/target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg +++ b/target/fpga_chip/jtag/openocd_configs/hemaia_vpk180.cfg @@ -3,7 +3,7 @@ # SPDX-License-Identifier: SHL-0.51 adapter driver ftdi -adapter speed 5000 +adapter speed 2000 transport select jtag # FT4232 @@ -18,13 +18,9 @@ jtag newtap $_CHIPNAME cpu -irlen 5 -expected-id 0x20002001 set _TARGETNAME $_CHIPNAME.cpu target create $_TARGETNAME riscv -chain-position $_TARGETNAME -riscv set_ir idcode 0x9249 -riscv set_ir dtmcs 0x22924 -riscv set_ir dmi 0x23924 - -# 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." } +riscv.cpu riscv set_ir idcode 0x9249 +# riscv.cpu riscv set_ir dtmcs 0x22924 +# riscv.cpu riscv set_ir dmi 0x23924 tcl port disabled gdb port 3334