Skip to content
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

soc: add OpenHW Group CVA6 SoC #77732

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
5 changes: 5 additions & 0 deletions boards/openhwgroup/cv32a6_genesysII/Kconfig.cv32a6_genesysII
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
config BOARD_CV32A6_GENESYSII
select SOC_CV32A6
select SOC_FAMILY_CVA6_PROVIDE_FPGA_POWEROFF
8 changes: 8 additions & 0 deletions boards/openhwgroup/cv32a6_genesysII/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_genesysII/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_genesysII
vendor: openhwgroup

Check failure on line 5 in boards/openhwgroup/cv32a6_genesysII/board.yml

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

BoardYml

/home/runner/work/zephyr/zephyr/boards/openhwgroup/cv32a6_genesysII/board.yml:5 invalid vendor: openhwgroup
socs:
- name: cv32a6

Check warning on line 7 in boards/openhwgroup/cv32a6_genesysII/board.yml

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

YAMLLint (new-line-at-end-of-file)

boards/openhwgroup/cv32a6_genesysII/board.yml:7 no new line character at the end of file
58 changes: 58 additions & 0 deletions boards/openhwgroup/cv32a6_genesysII/cv32a6_genesysII.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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 II";
compatible = "ariane,cv32a6_genesysII";

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

&uart0 {
status = "okay";
// different interrupt than the CISPA version of the SoC
interrupts = <1 4>;
};

&spi0 {
status = "okay";
// different interrupt than the CISPA version of the SoC
interrupts = <2 2>;
};

&clint{
status = "okay";
};

&dma0 {
status = "disabled";
};


&mdio0{
status = "disabled";
};

&eth0 {
status = "disabled";
};

&eth {
status = "okay";
};

&xlnx_gpio {
status = "okay";
};


40 changes: 40 additions & 0 deletions boards/openhwgroup/cv32a6_genesysII/cv32a6_genesysII_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
CONFIG_BASE64=y
CONFIG_INCLUDE_RESET_VECTOR=y
CONFIG_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_NS16550=y
CONFIG_UART_NS16550_ACCESS_WORD_ONLY=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_XIP=n
CONFIG_INIT_STACKS=y
CONFIG_SYS_CLOCK_TICKS_PER_SEC=25000000
CONFIG_FPU=y
CONFIG_POWEROFF=y

# RNG
CONFIG_TIMER_RANDOM_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y

# IRQs
CONFIG_MULTI_LEVEL_INTERRUPTS=y
CONFIG_2ND_LEVEL_INTERRUPTS=y
# 1 PLIC
CONFIG_NUM_2ND_LEVEL_AGGREGATORS=1
CONFIG_PLIC=y
CONFIG_3RD_LEVEL_INTERRUPTS=n

# no networking support on this board

# logging
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_THREAD_NAME=y

# increased stack sizes
CONFIG_ISR_STACK_SIZE=524288
CONFIG_MAIN_STACK_SIZE=524288
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=524288
CONFIG_IDLE_STACK_SIZE=524288
49 changes: 49 additions & 0 deletions boards/openhwgroup/cv32a6_genesysII/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"
5 changes: 5 additions & 0 deletions boards/openhwgroup/cv64a6_genesysII/Kconfig.cv64a6_genesysII
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
config BOARD_CV64A6_GENESYSII
select SOC_CV64A6_IMAFDC
select SOC_FAMILY_CVA6_PROVIDE_FPGA_POWEROFF
8 changes: 8 additions & 0 deletions boards/openhwgroup/cv64a6_genesysII/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_genesysII/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_genesysII
vendor: openhwgroup

Check failure on line 5 in boards/openhwgroup/cv64a6_genesysII/board.yml

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

BoardYml

/home/runner/work/zephyr/zephyr/boards/openhwgroup/cv64a6_genesysII/board.yml:5 invalid vendor: openhwgroup
socs:
- name: cv64a6

Check warning on line 7 in boards/openhwgroup/cv64a6_genesysII/board.yml

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

YAMLLint (new-line-at-end-of-file)

boards/openhwgroup/cv64a6_genesysII/board.yml:7 no new line character at the end of file
58 changes: 58 additions & 0 deletions boards/openhwgroup/cv64a6_genesysII/cv64a6_genesysII.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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 II";
compatible = "ariane,cv64a6_genesysII";

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

&uart0 {
status = "okay";
// different interrupt than the CISPA version of the SoC
interrupts = <1 4>;
};

&spi0 {
status = "okay";
// different interrupt than the CISPA version of the SoC
interrupts = <2 2>;
};

&clint{
status = "okay";
};

&dma0 {
status = "disabled";
};


&mdio0{
status = "disabled";
};

&eth0 {
status = "disabled";
};

&eth {
status = "okay";
};

&xlnx_gpio {
status = "okay";
};


40 changes: 40 additions & 0 deletions boards/openhwgroup/cv64a6_genesysII/cv64a6_genesysII_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Copyright 2024 CISPA Helmholtz Center for Information Security gGmbH
# SPDX-License-Identifier: Apache-2.0
CONFIG_BASE64=y
CONFIG_INCLUDE_RESET_VECTOR=y
CONFIG_CONSOLE=y
CONFIG_SERIAL=y
CONFIG_UART_CONSOLE=y
CONFIG_UART_NS16550=y
CONFIG_UART_NS16550_ACCESS_WORD_ONLY=y
CONFIG_CONSOLE_HANDLER=y
CONFIG_XIP=n
CONFIG_INIT_STACKS=y
CONFIG_SYS_CLOCK_TICKS_PER_SEC=25000000
CONFIG_FPU=y
CONFIG_POWEROFF=y

# RNG
CONFIG_TIMER_RANDOM_GENERATOR=y
CONFIG_TEST_RANDOM_GENERATOR=y

# IRQs
CONFIG_MULTI_LEVEL_INTERRUPTS=y
CONFIG_2ND_LEVEL_INTERRUPTS=y
# 1 PLIC
CONFIG_NUM_2ND_LEVEL_AGGREGATORS=1
CONFIG_PLIC=y
CONFIG_3RD_LEVEL_INTERRUPTS=n

# no networking support on this board

# logging
CONFIG_LOG=y
CONFIG_LOG_DEFAULT_LEVEL=3
CONFIG_THREAD_NAME=y

# increased stack sizes
CONFIG_ISR_STACK_SIZE=524288
CONFIG_MAIN_STACK_SIZE=524288
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=524288
CONFIG_IDLE_STACK_SIZE=524288
49 changes: 49 additions & 0 deletions boards/openhwgroup/cv64a6_genesysII/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"
30 changes: 30 additions & 0 deletions dts/riscv/openhwgroup/cv32a6.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// SPDX-License-Identifier: Apache-2.0
Copy link
Collaborator

Choose a reason for hiding this comment

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

/* comment style

// Copyright 2024 CISPA Helmholtz Center for Information Security

#include "cva6.dtsi"

// minimal configuration of CVA6 32-bit CPUs: no instruction set extensions,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Capitalise first letter of comments i.e. English

// no MMU, no PMP
/ {
cpus_0: cpus {
timebase-frequency = <25000000>;

cpu_0: cpu {
clock-frequency = <50000000>;
device_type = "cpu";
status = "okay";
compatible = "riscv";
riscv,isa = "rv32ima";

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

status="okay";

hlic: interrupt-controller {
#interrupt-cells = <0x01>;
interrupt-controller;
compatible = "riscv,cpu-intc";
status="okay";
};
};
};

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

};
Loading
Loading