Skip to content

soc: add OpenHW Group CVA6 SoC #77732

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions boards/openhwgroup/cv32a6_genesys_2/Kconfig.cv32a6_genesys_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
config BOARD_CV32A6_GENESYS_2
select SOC_CV32A6
8 changes: 8 additions & 0 deletions boards/openhwgroup/cv32a6_genesys_2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
board_runner_args(openocd "--config=${BOARD_DIR}/support/ariane.cfg")
board_runner_args(openocd "--use-elf")
board_runner_args(openocd "--verify")
board_runner_args(openocd "--cmd-pre-init=riscv.cpu configure -work-area-phys 0x90000000 -work-area-size 16780000")

include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
7 changes: 7 additions & 0 deletions boards/openhwgroup/cv32a6_genesys_2/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
board:
name: cv32a6_genesys_2
vendor: openhwgroup
socs:
- name: cv32a6
40 changes: 40 additions & 0 deletions boards/openhwgroup/cv32a6_genesys_2/cv32a6_genesys_2.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2024 CISPA Helmholtz Center for Information Security gGmbH
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;

#include <openhwgroup/cv32a6.dtsi>

/ {
model = "Openhardwaregroup CV32A6 on Genesys 2";
compatible = "openhwgroup,cv32a6_genesys_2";

chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,sram = &memory0;
};
};

&uart0 {
status = "okay";
};

&spi0 {
status = "okay";
};

&clint {
status = "okay";
};

&eth {
local-mac-address = [00 18 3e 02 e3 7f];
status = "okay";
};

&xlnx_gpio {
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
CONFIG_INCLUDE_RESET_VECTOR=y
CONFIG_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_NS16550_ACCESS_WORD_ONLY=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_XIP=n
Binary file not shown.
81 changes: 81 additions & 0 deletions boards/openhwgroup/cv32a6_genesys_2/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
.. zephyr:board:: cv32a6_genesys_2

Overview
********

The Digilent Genesys 2 board features a Xilinx Kintex-7 FPGA which can run various softcore CPUs.
In this configuration, the Genesys 2 is configured with a 32-bit version of the CVA6 RISC-V CPU.
The SoC is configured with a memory controller interfacing with the Genesys' DRAM, PLIC and CLINT
interrupt controllers, a UART device interfacing with the Genesys' USB UART, a RISC-V compatible
debug module that interfaces with the Genesys' FTDI (USB JTAG) chip, a Xilinx SPI interface
interfacing with the Genesys' SD card slot and a Xilinx GPIO interfacing with the Genesys' LEDs
and switches.
The complete hardware sources (see first reference) in conjunction with
instructions for compiling and loading the configuration onto the Genesys 2 are available.

See the following references for more information:

- `CVA6 documentation`_
- `Genesys 2 Reference Manual`_
- `Genesys 2 Schematic`_

Hardware
********

- CVA6 CPU with RV32imac instruction sets with PLIC, CLINT interrupt controllers.
- 1 GB DDR3 DRAM
- 10/100/1000 Ethernet with copper interface, lowRISC Ethernet MAC
- ns16550a-compatible USB UART, 115200 baud
- RISCV debug module, connected via on-board FTDI (USB JTAG)
- Xilinx SPI controller, connected to microSD slot
- Xilinx GPIO, connected to 7 switches and LEDs

Supported Features
==================

.. zephyr:board-supported-hw::

Programming and Debugging
*************************

Loading the FPGA configuration
==============================

You need to build a bitstream with Xilinx Vivado and load it into the FPGA
before you can load zephyr onto the board.
Please refer to the CVA6 documentation for the required steps.
This configuration is compatible with the following build targets:
cv32a6_imac_sv0, cv32a6_imac_sv32, cv32a6_imafc_sv32, cv32a6_ima_sv32_fpga.

Flashing
========
west flash is supported via the openocd runner.
Here is an example for the :zephyr:code-sample:`hello_world` application.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: cv32a6_genesys_2
:goals: build flash

Debugging
=========

west debug, attach and debugserver commands are supported via the openocd runner.
Here is an example for the :zephyr:code-sample:`hello_world` application.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: cv32a6_genesys_2
:goals: build debug

References
**********

.. _CVA6 documentation:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.. _CVA6 documentation:
.. target-notes::
.. _CVA6 documentation:

https://github.com/openhwgroup/cva6

.. _Genesys 2 Reference Manual:
https://digilent.com/reference/programmable-logic/genesys-2/reference-manual

.. _Genesys 2 Schematic:
https://digilent.com/reference/_media/reference/programmable-logic/genesys-2/genesys-2_sch.pdf
49 changes: 49 additions & 0 deletions boards/openhwgroup/cv32a6_genesys_2/support/ariane.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0

# Based on the ariane.cfg from the cva6 project:
# https://github.com/openhwgroup/cva6/blob/master/corev_apu/fpga/ariane.cfg
adapter_khz 1000

interface ftdi
ftdi_vid_pid 0x0403 0x6010

# Channel 1 is taken by Xilinx JTAG
ftdi_channel 0

# links:
# http://openocd.org/doc-release/html/Debug-Adapter-Configuration.html
#
# Bit MPSSE FT2232 JTAG Type Description
# Bit0 TCK ADBUS0 TCK Out Clock Signal Output
# Bit1 TDI ADBUS1 TDI Out Serial Data Out
# Bit2 TDO ADBUS2 TDO In Serial Data In
# Bit3 TMS ADBUS3 TMS Out Select Signal Out
# Bit4 GPIOL0 ADBUS4 nTRST In/Out General Purpose I/O
# this corresponds to the following in/out layout, with TMS initially set to 1
ftdi_layout_init 0x0018 0x001b
# we only have to specify nTRST, the others are assigned correctly by default
ftdi_layout_signal nTRST -ndata 0x0010

set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5

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

# prefer to use sba for system bus access
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"
4 changes: 4 additions & 0 deletions boards/openhwgroup/cv64a6_genesys_2/Kconfig.cv64a6_genesys_2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
config BOARD_CV64A6_GENESYS_2
select SOC_CV64A6_IMAFDC
8 changes: 8 additions & 0 deletions boards/openhwgroup/cv64a6_genesys_2/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
board_runner_args(openocd "--config=${BOARD_DIR}/support/ariane.cfg")
board_runner_args(openocd "--use-elf")
board_runner_args(openocd "--verify")
board_runner_args(openocd "--cmd-pre-init=riscv.cpu configure -work-area-phys 0x90000000 -work-area-size 16780000")

include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
7 changes: 7 additions & 0 deletions boards/openhwgroup/cv64a6_genesys_2/board.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
board:
name: cv64a6_genesys_2
vendor: openhwgroup
socs:
- name: cv64a6_imafdc
44 changes: 44 additions & 0 deletions boards/openhwgroup/cv64a6_genesys_2/cv64a6_genesys_2.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2024 CISPA Helmholtz Center for Information Security gGmbH
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;

#include <openhwgroup/cv64a6.dtsi>

/ {
model = "Openhardwaregroup CV64A6 on Genesys 2";
compatible = "openhwgroup,cv64a6_genesys_2";

chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,sram = &memory0;
};
};

&uart0 {
status = "okay";
};

&spi0 {
status = "okay";
};

&clint{
status = "okay";
};

&dma0 {
status = "disabled";
};

&eth {
local-mac-address = [00 18 3e 02 e3 7f];
status = "okay";
};

&xlnx_gpio {
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
CONFIG_INCLUDE_RESET_VECTOR=y
CONFIG_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_NS16550_ACCESS_WORD_ONLY=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_XIP=n
Binary file not shown.
80 changes: 80 additions & 0 deletions boards/openhwgroup/cv64a6_genesys_2/doc/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.. zephyr:board:: cv64a6_genesys_2

Overview
********

The Digilent Genesys 2 board features a Xilinx Kintex-7 FPGA which can run various softcore CPUs.
In this configuration, the Genesys 2 is configured with a 64-bit version of the CVA6 RISC-V CPU.
The SoC is configured with a memory controller interfacing with the Genesys' DRAM, PLIC and CLINT
interrupt controllers, a UART device interfacing with the Genesys' USB UART, a RISC-V compatible
debug module that interfaces with the Genesys' FTDI (USB JTAG) chip, a Xilinx SPI interface
interfacing with the Genesys' SD card slot and a Xilinx GPIO interfacing with the Genesys' LEDs
and switches.
The complete hardware sources (see first reference) in conjunction with
instructions for compiling and loading the configuration onto the Genesys 2 are available.

See the following references for more information:

- `CVA6 documentation`_
- `Genesys 2 Reference Manual`_
- `Genesys 2 Schematic`_

Hardware
********

- CVA6 CPU with RV64imafdc instruction sets and an SV39 MMU
- 1 GB DDR3 DRAM
- 10/100/1000 Ethernet with copper interface, lowRISC Ethernet MAC
- ns16550a-compatible USB UART, 115200 baud
- RISCV debug module, connected via on-board FTDI (USB JTAG)
- Xilinx SPI controller, connected to microSD slot
- Xilinx GPIO, connected to 7 switches and LEDs

Supported Features
==================

.. zephyr:board-supported-hw::

Programming and Debugging
*************************

Loading the FPGA configuration
==============================

You need to build a bitstream with Xilinx Vivado and load it into the FPGA
before you can load zephyr onto the board.
Please refer to the CVA6 documentation for the required steps.
This configuration is compatible with the following build target: cv64a6_imafdc_sv39

Flashing
========
west flash is supported via the openocd runner.
Here is an example for the :zephyr:code-sample:`hello_world` application.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: cv64a6_genesys_2
:goals: build flash
Comment on lines +54 to +57
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WorldofJARcraft have you actually tested this? It doesn't seem like it's possible to build a hello world at the moment?
Also, you will want to add twister files so that this board is tested in CI, this will allow to catch such issues in the future. Somehow this was missed during the review of this PR.

I tried to kick things off here but you're probably better positioned to take it it from here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kartben I have tested the configuration, but against an outdated main branch, sorry.
Apparently, at some point during when I initially composed the PR and now, the device tree requirements for the RISC-V machine timer changed.
I have force-pushed a corrected version to the branch I have been using for this PR. I am also making the necessary changes for integrating the board into twister.
Should I make a new PR with the necessary changes or can I somehow overwrite the commits that have already been merged?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@WorldofJARcraft Thanks for the quick feedback, really appreciated! It needs to be a new branch/PR based off of current main. FWIW what you now have in your branch looks in a much better shape but I encourage you to actually run Twister to check where things are at (for example I don't think you want "simulation: qemu" in there)

west twister -p cv32a6_genesys_2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kartben I have made a new PR for this: #88511
I have successfully tested the new PR in hardware against cv64a6.
I will set up and test on cv32a6 next week.
Until then, I will leave the PR in draft mode.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thanks for the update!


Debugging
=========

west debug, attach and debugserver commands are supported via the openocd runner.
Here is an example for the :zephyr:code-sample:`hello_world` application.

.. zephyr-app-commands::
:zephyr-app: samples/hello_world
:board: cv64a6_genesys_2
:goals: build debug

References
**********

.. _CVA6 documentation:
https://github.com/openhwgroup/cva6

.. _Genesys 2 Reference Manual:
https://digilent.com/reference/programmable-logic/genesys-2/reference-manual

.. _Genesys 2 Schematic:
https://digilent.com/reference/_media/reference/programmable-logic/genesys-2/genesys-2_sch.pdf
Loading