Skip to content

Commit

Permalink
[cheshire] Add LINUX + SW flow for cheshire
Browse files Browse the repository at this point in the history
Co-authored-by: Vincenzo Maisto <[email protected]>
  • Loading branch information
mp-17 and MaistoV committed Oct 15, 2024
1 parent dc3fc54 commit 9ea9e56
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 17 deletions.
20 changes: 13 additions & 7 deletions cheshire/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ BOARD := vcu128
VLOG_ARGS ?= -suppress 2583 -suppress 13314
COMMON_CUSTOM_TARGETS := -t cv64a6_imafdcv_sv39 -t cva6 --define ARA --define NR_LANES=$(nr_lanes) --define VLEN=$(vlen)
CUSTOM_SIM_BENDER_TARGETS := $(COMMON_CUSTOM_TARGETS) -t sim -t test -t rtl --vlog-arg="$(VLOG_ARGS)"
CUSTOM_XIL_BENDER_TARGETS := $(COMMON_CUSTOM_TARGETS) -t fpga -t $(BOARD)
CUSTOM_XIL_BENDER_TARGETS := $(COMMON_CUSTOM_TARGETS) -t fpga -t $(BOARD)

.PHONY: ara-chs-xilinx-$(BOARD) ara-chs-flash-$(BOARD) apply-patches update_xilinx_src clean
# Define XILINX FPGA URL and PATH for programming
CHS_XILINX_HWS_URL ?=
CHS_XILINX_HWS_PATH ?=

.PHONY: ara-chs-xilinx-$(BOARD) ara-chs-flash-$(BOARD) ara-chs-xilinx-program-$(BOARD) update_xilinx_src update_vsim_src clean

ara-chs-xilinx-$(BOARD): update_xilinx_src
make -C $(BACKREF_CHS_ROOT) chs-xilinx-$(BOARD)

ara-chs-flash-$(BOARD):
make -C $(BACKREF_CHS_ROOT) chs-xilinx-flash-$(BOARD) VIVADO=$(VIVADO)
ara-chs-image-$(BOARD):
make -C $(BACKREF_CHS_ROOT) $(BACKREF_CHS_ROOT)/sw/boot/linux.$(BOARD).gpt.bin -B

apply-patches:
cd $(BACKREF_CHS_ROOT) && \
git apply $(ARA_ROOT)/cheshire/patches/device_tree.patch
ara-chs-xilinx-flash-$(BOARD):
make -C $(BACKREF_CHS_ROOT) chs-xilinx-flash-$(BOARD) VIVADO=$(VIVADO) CHS_XILINX_HWS_URL=$(CHS_XILINX_HWS_URL) CHS_XILINX_HWS_PATH_$(BOARD)=$(CHS_XILINX_HWS_PATH)

ara-chs-xilinx-program-$(BOARD):
make -C $(BACKREF_CHS_ROOT) chs-xilinx-program-$(BOARD) VIVADO=$(VIVADO) CHS_XILINX_HWS_URL=$(CHS_XILINX_HWS_URL) CHS_XILINX_HWS_PATH_$(BOARD)=$(CHS_XILINX_HWS_PATH)

update_xilinx_src:
cd $(BACKREF_CHS_ROOT) && \
Expand Down
66 changes: 56 additions & 10 deletions cheshire/sw/cva6-sdk.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,65 @@
#
# Build an RVV-ready Linux image

# CVA6-SDK subpath
CVA6_SDK_ROOT = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))/cva6-sdk

# Linux should be RVV-ready?
RVV_LINUX := 1
# Suffix for host toolchain (to build buildroot toolchain)
TOOLCHAIN_SUFFIX :=
# For IIS users: HOST_TOOLCHAIN_SUFFIX=-11.2.0
HOST_TOOLCHAIN_SUFFIX ?=
# Buildroot toolchain
TARGET_OS_TOOLCHAIN := $(CVA6_SDK_ROOT)/buildroot/output/host/bin/riscv64-buildroot-linux-gnu-gcc
# Github submodule update tokens
CVA6_SDK_UPDATED := $(ARA_ROOT)/cheshire/sw/.cva6-sdk.updated

.PHONY: %-linux linux-img

################
## Build deps ##
################

.PRECIOUS: $(CVA6_SDK_UPDATED)
$(CVA6_SDK_UPDATED):
git submodule update --init --recursive -- $(CVA6_SDK_ROOT)
touch $@

$(TARGET_OS_TOOLCHAIN): $(CVA6_SDK_UPDATED)
@echo "Building the RISC-V CVA6-SDK Linux TOOLCHAIN"
@echo "Your gcc version is: $$(gcc -dumpfullversion). This build worked with gcc and g++ version 11.2.0. Please adjust this if needed."
make -C $(CVA6_SDK_ROOT) $@ \
HOSTCC=gcc$(HOST_TOOLCHAIN_SUFFIX) \
HOSTCXX=g++$(HOST_TOOLCHAIN_SUFFIX) \
HOSTCPP=cpp$(HOST_TOOLCHAIN_SUFFIX) \
RVV=$(RVV_LINUX)
touch $@

########################
## Build RVV Software ##
########################

$(ARA_APPS)/bin/%-linux: $(shell find $(ARA_APPS)/$* -name "*.c" -o -name "*.S") $(TARGET_OS_TOOLCHAIN)
make -C $(ARA_APPS) bin/$*-linux LINUX=1

.PRECIOUS: $(CVA6_SDK_ROOT)/rootfs/%
$(CVA6_SDK_ROOT)/rootfs/%: $(ARA_APPS)/bin/%-linux
cp $< $@

%-linux: $(CVA6_SDK_ROOT)/rootfs/%
@echo "$@ built and copied."

.PHONY: cva6-sdk linux_img
#####################
## Build Linux IMG ##
#####################

cva6-sdk:
git submodule update --init --recursive -- $(ARA_SW)/$@
$(CVA6_SDK_ROOT)/install64/vmlinux: $(CVA6_SDK_UPDATED) $(TARGET_OS_TOOLCHAIN) $(TARGET_KERNELS)
make -C $(ARA_SW)/cva6-sdk images RVV=$(RVV_LINUX)

linux_img: cva6-sdk
echo "Your gcc version is: $(gcc -dumpfullversion). This build worked with gcc and g++ version 11.2.0"
make -C $(ARA_SW)/cva6-sdk images RVV=$(RVV_LINUX) \
HOSTCC=gcc$(TOOLCHAIN_SUFFIX) \
HOSTCXX=g++$(TOOLCHAIN_SUFFIX) \
HOSTCPP=cpp$(TOOLCHAIN_SUFFIX)
# Softlink the linux image and create a bootable Cheshire image
linux-img: $(CVA6_SDK_ROOT)/install64/vmlinux
if [ -d "$(CHS_SW)/deps/cva6-sdk/install64" ]; then \
echo "$(CHS_SW)/deps/cva6-sdk/install64 already exists, creating a backup..."; \
mv $(CHS_SW)/deps/cva6-sdk/install64 $(CHS_SW)/deps/cva6-sdk/install64.bak_$(shell date +%Y%m%d_%H%M%S); \
fi
cd $(CHS_SW)/deps/cva6-sdk && ln -s $(CVA6_SDK_ROOT)/install64

0 comments on commit 9ea9e56

Please sign in to comment.