Skip to content

Commit

Permalink
fpga: Adapted flow to new directory
Browse files Browse the repository at this point in the history
sw: Replaced host related flag names for easier cross compilation

sw: Adding placeholder for hero libomptarget-device library

fpga: build bootrom in ci

fpga: adding bin2jtag util

fpga: Replace XDMA DMA by PCIe bridge

hero: Working on runtime

fpga: Configurable remote boot

sw: Adding dma count for hero

sw: Remove duplicate csleep

occamy: Added mailbox based printf
  • Loading branch information
CyrilKoe committed Nov 7, 2024
1 parent d5d0d83 commit 2dc0c36
Show file tree
Hide file tree
Showing 31 changed files with 1,232 additions and 70 deletions.
35 changes: 18 additions & 17 deletions target/fpga/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,18 @@
MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(dir $(MKFILE_PATH))
ROOT := ${MKFILE_DIR}../../../..
CVA6_SDK ?= ${ROOT}/../cva6-sdk
CVA6_SDK ?=
DEBUG ?= 0
EXT_JTAG ?= 0
VCU ?= 01
FPGA_ID := 091847100576A
HW_SERVER := bordcomputer:3231

# Select VCU128-02
ifeq ($(VCU),02)
FPGA_ID := 091847100638A
HW_SERVER := bordcomputer:3232
endif
FPGA_PATH := $(XILINX_FPGA_PATH)
HW_SERVER := $(XILINX_HOST):$(XILINX_PORT)
BENDER ?= bender
VIVADO ?= vitis-2020.2 vivado
# Do not proceed with implem (CI)
XILINX_SYNTHESIS_ONLY ?= 0

VIVADO ?= vivado
VIVADO_ARGS := XILINX_SYNTHESIS_ONLY=$(XILINX_SYNTHESIS_ONLY)
MKIMAGE ?= $(CURDIR)/br2_external/install/bin/mkimage
NPROC ?= $(shell nproc)

Expand All @@ -31,33 +29,36 @@ LINUX_UIMAGE ?= ${CVA6_SDK}/uImage

DTB = bootrom/occamy.dtb

BENDER_TARGETS += -t cv64a6_imafdc_sv39 -t occamy
ifeq ($(EXT_JTAG), 0)
BENDER_TARGETS += -t bscane
endif

default: all
all: occamy_vcu128

include $(ROOT)/util/Makefrag

vivado_ips/occamy_xilinx:
${MAKE} -C vivado_ips occamy_xilinx
${MAKE} -C vivado_ips occamy_xilinx DEBUG=$(DEBUG) EXT_JTAG=$(EXT_JTAG)

bootrom/bootrom-spl.coe:
${MAKE} -C bootrom

occamy_vcu128: vivado_ips/occamy_xilinx bootrom/bootrom-spl.coe define_defines_includes_no_simset.tcl
${VIVADO} -mode batch -source occamy_vcu128.tcl -tclargs $(DEBUG) $(EXT_JTAG) $(NPROC) ${MKFILE_DIR}/bootrom/bootrom-spl.coe
$(VIVADO_ARGS) ${VIVADO} -mode gui -source occamy_vcu128.tcl -tclargs $(DEBUG) $(EXT_JTAG) $(NPROC) ${MKFILE_DIR}/bootrom/bootrom-spl.coe

define_defines_includes_no_simset.tcl: $(BENDER_FILES)
${BENDER} script vivado -t cv64a6_imafdc_sv39 --only-defines --only-includes --no-simset > $@
${BENDER} script vivado $(BENDER_TARGETS) --only-defines --only-includes --no-simset > $@

program:
${VIVADO} -mode batch -source occamy_vcu128_program.tcl -tclargs ${VCU}

flash: ${FILE}
${VIVADO} -mode batch -source occamy_vcu128_flash.tcl -tclargs ${HW_SERVER} ${FPGA_ID} flash.mcs ${OFFSET} ${FILE}
${VIVADO} -mode batch -source occamy_vcu128_flash.tcl -tclargs ${HW_SERVER} ${FPGA_PATH} flash.mcs ${OFFSET} ${FILE}
rm flash.mcs

# Flash only uboot (made for TFTP bootmode), overwrite the bootrom, and reset the board
flashrun: ${UBOOT_ITB}
${VIVADO} -mode batch -source occamy_vcu128_flashrun.tcl -tclargs ${HW_SERVER} ${FPGA_ID} flash.mcs 6000000 ${UBOOT_ITB}
${VIVADO} -mode batch -source occamy_vcu128_flashrun.tcl -tclargs ${HW_SERVER} ${FPGA_PATH} flash.mcs 6000000 ${UBOOT_ITB}
rm flash.mcs

flash-u-boot:
Expand Down
13 changes: 6 additions & 7 deletions target/fpga/bootrom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@

MKFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
MKFILE_DIR := $(dir $(MKFILE_PATH))
ROOT := ${MKFILE_DIR}../../../../..

include $(ROOT)/util/Makefrag
ROOT := ${MKFILE_DIR}../../..

CVA6_SDK ?= $(ROOT)/../cva6-sdk
UBOOT_SPL_BIN ?= $(CVA6_SDK)/u-boot/spl/u-boot-spl.bin
Expand All @@ -28,7 +26,7 @@ CFLAGS = -Os -g -Werror -ffreestanding -fno-strict-aliasing
CFLAGS += -static -nostartfiles -nostartfiles
CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-stack-protector
CFLAGS += -mno-save-restore -mstrict-align
CFLAGS += -mabi=lp64d -march=rv64imafd
CFLAGS += -mabi=lp64d -march=rv64imafd_zifencei
CFLAGS += -mcmodel=medany

GIT_SHA := $(shell git describe --match=NeVeRmAtCh --always --abbrev=10 --dirty)
Expand All @@ -40,8 +38,8 @@ all: bootrom-spl.coe bootrom.tcl bootrom-spl.tcl
$(CC) $(CFLAGS) -DGIT_SHA=\"$(GIT_SHA)\" $(INCLUDES) -c $< -o $@
@echo "CC <= $<"

%.dtb: %.dts
dtc -I dts $< -O dtb -o $@
%.dtb: %.dts $(wildcard *.dtsi)
dtc -@ -I dts $< -O dtb -o $@

bootrom.elf bootrom.dump bootrom.bin: bootrom.S $(OBJS_C) bootrom.ld occamy.dtb
$(CC) $(CFLAGS) $(INCLUDES) -Tbootrom.ld $< $(OBJS_C) -o bootrom.elf
Expand All @@ -67,4 +65,5 @@ clean:
%.tcl: %.bin
@echo "TCL <= $<"
@$(call BINRAY_SIZE_CHECK,$<,1000000)
@$(BIN2JTAG) -c32 -b 0 -d hw_axi_1 $< > $@
python3 $(ROOT)/util/bin2jtag.py -c32 -b 0 -d hw_axi_1 $< > $@

2 changes: 2 additions & 0 deletions target/fpga/bootrom/mac_address.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
local-mac-address = [ 00 00 00 00 00 00 ];
mac-address = [ 00 00 00 00 00 00 ];
15 changes: 10 additions & 5 deletions target/fpga/bootrom/occamy.dts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#address-cells = <2>;
#size-cells = <2>;
ranges;
snitch_mem: buffer@c0000000 {
snitch_mem: l3_mem@c0000000 {
reg = <0x0 0xc0000000 0x0 0x10000000>;
};
};
Expand Down Expand Up @@ -63,7 +63,7 @@
soc: soc {
#address-cells = <2>;
#size-cells = <2>;
compatible = "simple-bus";
compatible = "eth,occamy-soc", "simple-bus";
ranges;
debug@0 {
compatible = "riscv,debug-013";
Expand Down Expand Up @@ -191,9 +191,8 @@
clock-names = "s_axi_lite_clk", "axis_clk";
// interrupt and mac_irq
interrupts-extended = <&PLIC0 1 &PLIC0 6>;
// local-mac-address = [ 00 0A 35 04 E1 60 ]; // hero-vcu128-01
local-mac-address = [ 00 0A 35 04 E1 52 ]; // hero-vcu128-02
mac-address = [ 00 0A 35 04 E1 52 ];
/include/ "mac_address.dtsi"
/include/ "remote_boot.dtsi"
device_type = "network";
axistream-connected = <&eth_dma0>;
axistream-control-connected = <&eth_dma0>;
Expand Down Expand Up @@ -238,6 +237,12 @@
reg-names = "quadrant-control";
reg = <0x0 0x0b000000 0x0 0x10000>;
};
// We do not use the spm-narrow (contains OpenSBI code)
spm_wide: spm-wide@71000000 {
compatible = "eth,occamy-spm-wide";
reg-names = "spm-wide";
reg = <0x0 0x71000000 0x0 0x100000>;
};
// Instantiate a snitch cluster
snitch-cluster@10000000 {
compatible = "eth,snitch-cluster";
Expand Down
151 changes: 151 additions & 0 deletions target/fpga/bootrom/occamy_pcie.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
// Copyright 2021 ETH Zurich and University of Bologna.
// Licensed under the Apache License, Version 2.0, see LICENSE for details.
// SPDX-License-Identifier: Apache-2.0


// TODO(niwis) auto generate
/dts-v1/;
/plugin/;
&{/dev@0,0} {
axi-bus {
#address-cells = <1>;
#size-cells = <2>;
compatible = "simple-bus";
ranges;
// Create a reserved memory region for Snitch program memory
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
snitch_mem: buffer@c0000000 {
reg = <0x0 0xc0000000 0x0 0x10000000>;
};
};
cpus {
#address-cells = <1>;
#size-cells = <0>;
timebase-frequency = <12500000>;
CPU0: cpu@0 {
device_type = "cpu";
status = "okay";
compatible = "eth,ariane", "riscv";
clock-frequency = <25000000>;
riscv,isa = "rv64fimafd";
mmu-type = "riscv,sv39";
tlb-split;
reg = <0>;
// represents the destination of the mcause bits
// ariane has 3 interrupt inputs:
// - software (ipi_i[0], IRQ_M_SOFT)
// - timer (time_irq_i[0], IRQ_M_TIMER)
// - external (irq_i[1:0], {IRQ_S_EXT, IRQ_M_EXT})
CPU0_intc: interrupt-controller {
#interrupt-cells = <1>;
#address-cells = <1>;
interrupt-controller;
compatible = "riscv,cpu-intc";
};
};
};
sysclk: virt_25mhz {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <25000000>;
};
soc: soc {
#address-cells = <2>;
#size-cells = <2>;
compatible = "eth,occamy-soc", "simple-bus";
ranges;
debug@0 {
compatible = "riscv,debug-013";
// interrupts-extended = <&CPU0_intc 65535>;
reg-names = "control";
reg = <0x0 0x0 0x0 0x1000>;
};
serial@2002000 {
compatible = "ns16550a";
reg = <0x0 0x2002000 0x0 0x1000>;
clock-frequency = <25000000>;
current-speed = <115200>;
interrupt-parent = <&PLIC0>;
interrupts = <36>;
reg-offset = <0>;
reg-shift = <2>; // regs are spaced on 32 bit boundary
reg-io-width = <4>; // only 32-bit access are supported
// fifo-size = <64>;
};
timer@2006000 {
compatible = "pulp,apb_timer";
interrupt-parent = <&PLIC0>;
interrupts = <0x00000068 0x00000069 0x00000070 0x00000071>;
reg = <0x00000000 0x2006000 0x00000000 0x00001000>;
reg-names = "control";
};
clint0: clint@4000000 {
clock-frequency = <12500000>;
compatible = "riscv,clint0";
// clint generates software and timer interrupts to the core. Attach them
// to the CPU
// bits in mip and exception code in mcause:
// - IRQ_M_SOFT = 3: Machine software interrupt
// - IRQ_M_TIMER = 7: Machine timer interrupt
interrupts-extended = <&CPU0_intc 3 &CPU0_intc 7>;
reg-names = "clint";
reg = <0x0 0x4000000 0x0 0x100000>;
};
PLIC0: interrupt-controller@c000000 {
compatible = "riscv,plic0";
#address-cells = <0>;
#interrupt-cells = <1>;
interrupt-controller;
// PLIC generates external interrupts to the core, M and S mode
// - IRQ_M_EXT = 11: Machine external interrupt
// - IRQ_S_EXT = 9: Supervisor external interrupt
interrupts-extended = <&CPU0_intc 11 &CPU0_intc 9>;
riscv,max-priority = <6>;
riscv,ndev = <72>;
reg = <0x0 0xc000000 0x0 0x4000000>;
};
soc_ctl0: soc-control@2000000 {
compatible = "eth,occamy-soc-control";
reg-names = "soc-control";
reg = <0x0 0x02000000 0x0 0x1000>;
};
quadrant_ctrl0: quadrant-control@b000000 {
compatible = "eth,occamy-quadrant-control";
reg-names = "quadrant-control";
reg = <0x0 0x0b000000 0x0 0x10000>;
};
// We do not use the spm-narrow (contains OpenSBI code)
spm_wide: spm-wide@71000000 {
compatible = "eth,occamy-spm-wide";
reg-names = "spm-wide";
reg = <0x0 0x71000000 0x0 0x100000>;
};
pcie_axi_bar_mem: pcie-axi-bar-mem@20000000 {
compatible = "eth,pcie-axi-bar-mem";
reg = <0x0 0x20000000 0x0 0x40000000>;
};
// Instantiate a snitch cluster
snitch-cluster@10000000 {
compatible = "eth,snitch-cluster";
// TCDM and Peripheral spaces
reg = <0x0 0x10000000 0x0 0x40000>;
// points to a memory region reserved for use by the cluster
memory-region = <&snitch_mem>;
// cluster specific properties
eth,compute-cores = <8>;
eth,dm-cores = <1>;
eth,quadrant-idx = <0>;
eth,cluster-idx = <0>; // Used to calculate offsets in clint, soc-ctrl etc..
// A handle to the soc-control register where isolates etc are located
eth,soc-ctl = <&soc_ctl0>;
// Handle to the associated quadrant controller
eth,quadrant-ctrl = <&quadrant_ctrl0>;
// handle to the clint where IPI interrupts are attached
eth,clint = <&clint0>;
};
};
};
};
Empty file.
2 changes: 1 addition & 1 deletion target/fpga/bootrom/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int main() {
// Copy the DBT at (SPM+4)

print_uart("\r\nCopying DTB at ");
print_uart_addr(SPL_DEST + 1);
print_uart_addr(SPL_DEST + 4);
for (int i = 0; i < totalsize; i++)
*(uint8_t *)(SPL_DEST + 4 + i) =
*(((uint8_t *)__dtb_start) + i);
Expand Down
6 changes: 6 additions & 0 deletions target/fpga/occamy_vcu128.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ if {[get_property PROGRESS [get_run $run]] != "100%"} {
puts "Skipping 100% complete run: $run"
}

if {[info exists ::env(XILINX_SYNTHESIS_ONLY)] && $::env(XILINX_SYNTHESIS_ONLY)==1} {
puts "XILINX_SYNTHESIS_ONLY is set, stopping now..."
exit
}


# Create ILA. Attach all signals that were previously marked debug.
# For occamy-internal signals: Add "(* mark_debug = "true" *)" before signal definition in HDL code.
# For blockdesign-level signals: Use "set_property HDL_ATTRIBUTE.DEBUG $DEBUG [get_bd_nets ...]" in occamy_vcu128_bd.tcl
Expand Down
Loading

0 comments on commit 2dc0c36

Please sign in to comment.