Skip to content

Commit

Permalink
fpga: Configurable remote boot
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilKoe committed Mar 17, 2024
1 parent df6afda commit ffd7855
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 29 deletions.
11 changes: 5 additions & 6 deletions target/fpga/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
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 :=
HW_SERVER :=
FPGA_PATH := $(XILINX_FPGA_PATH)
HW_SERVER := $(XILINX_HOST):$(XILINX_PORT)
BENDER ?= bender
VIVADO ?= vitis-2020.2 vivado
# Do not proceed with implem (CI)
Expand Down Expand Up @@ -54,12 +53,12 @@ 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
4 changes: 2 additions & 2 deletions target/fpga/bootrom/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,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 Down
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 ];
4 changes: 2 additions & 2 deletions target/fpga/bootrom/occamy.dts
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +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 07 D5 DD ]; // hero-vcu128-03
mac-address = [ 00 0A 35 07 D5 DD ]; // hero-vcu128-03
/include/ "mac_address.dtsi"
/include/ "remote_boot.dtsi"
device_type = "network";
axistream-connected = <&eth_dma0>;
axistream-control-connected = <&eth_dma0>;
Expand Down
8 changes: 5 additions & 3 deletions target/fpga/bootrom/occamy_pcie.dts
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,11 @@
reg-names = "quadrant-control";
reg = <0x0 0x0b000000 0x0 0x10000>;
};
scratchpad-narrow@70000000 {
compatible = "eth,scratchpad-narrow";
reg = <0x0 0x70000000 0x0 0x80000>;
// 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 {
Expand Down
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
10 changes: 5 additions & 5 deletions target/fpga/occamy_vcu128_flash.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
# Programs the SPI Flash of the VCU128 board with with two partitions
#
# HW_SERVER host:port URL to the server where the FPGA board is connected to
# FPGA_ID Serial of the FPGA to target
# FPGA_PATH Serial of the FPGA to target
# MCS Output flash configuration file
# OFFSET0 Address offset of partition 0
# FILE0 File to program to partition 0

# Parse arguments
if {$argc < 5} {
error "usage: occamy_vcu_138_flash.tcl HW_SERVER FPGA_ID MCS OFFSET0 FILE0"
error "usage: occamy_vcu_138_flash.tcl HW_SERVER FPGA_PATH MCS OFFSET0 FILE0"
}
set HW_SERVER [lindex $argv 0]
set FPGA_ID [lindex $argv 1]
set FPGA_PATH [lindex $argv 1]
set MCS [lindex $argv 2]
set OFFSET0 [lindex $argv 3]
set FILE0 [lindex $argv 4]
Expand All @@ -38,8 +38,8 @@ write_cfgmem -force -format mcs -size 256 -interface SPIx4 \
# Open and connect HW manager
open_hw_manager
connect_hw_server -url ${HW_SERVER} -allow_non_jtag
current_hw_target [get_hw_targets */xilinx_tcf/Xilinx/${FPGA_ID}]
set_property PARAM.FREQUENCY 15000000 [get_hw_targets */xilinx_tcf/Xilinx/${FPGA_ID}]
current_hw_target [get_hw_targets ${FPGA_PATH}]
set_property PARAM.FREQUENCY 15000000 [get_hw_targets ${FPGA_PATH}]
open_hw_target
current_hw_device [get_hw_devices xcvu37p_0]

Expand Down
15 changes: 8 additions & 7 deletions target/fpga/occamy_vcu128_flashrun.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Afterwards programs the real bitstream and runs the bootrom
#
# HW_SERVER host:port URL to the server where the FPGA board is connected to
# FPGA_ID Serial of the FPGA to target
# FPGA_PATH Serial of the FPGA to target
# MCS Output flash configuration file
# OFFSET0 Address offset of partition 0
# FILE0 File to program to partition 0
Expand All @@ -18,10 +18,10 @@ source occamy_vcu128_procs.tcl

# Parse arguments
if {$argc < 5} {
error "usage: occamy_vcu_138_flash.tcl HW_SERVER FPGA_ID MCS OFFSET0 FILE0"
error "usage: occamy_vcu_138_flash.tcl HW_SERVER FPGA_PATH MCS OFFSET0 FILE0"
}
set HW_SERVER [lindex $argv 0]
set FPGA_ID [lindex $argv 1]
set FPGA_PATH [lindex $argv 1]
set MCS [lindex $argv 2]
set OFFSET0 [lindex $argv 3]
set FILE0 [lindex $argv 4]
Expand All @@ -37,8 +37,9 @@ write_cfgmem -force -format mcs -size 256 -interface SPIx4 \
# Open and connect HW manager
open_hw_manager
connect_hw_server -url ${HW_SERVER} -allow_non_jtag
current_hw_target [get_hw_targets */xilinx_tcf/Xilinx/${FPGA_ID}]
set_property PARAM.FREQUENCY 15000000 [get_hw_targets */xilinx_tcf/Xilinx/${FPGA_ID}]

current_hw_target [get_hw_targets *${FPGA_PATH}]
set_property PARAM.FREQUENCY 15000000 [get_hw_targets *${FPGA_PATH}]
open_hw_target
current_hw_device [get_hw_devices xcvu37p_0]

Expand Down Expand Up @@ -66,11 +67,11 @@ program_hw_cfgmem -hw_cfgmem $hw_cfgmem

# Program BIT
global occ_hw_server
global occ_target_serial
global occ_target_path
global occ_hw_device
global occ_bit_stem
set occ_hw_server $HW_SERVER
set occ_target_serial $FPGA_ID
set occ_target_path $FPGA_PATH
set occ_hw_device xcvu37p_0
set occ_bit_stem occamy_vcu128/occamy_vcu128.runs/impl_1/occamy_vcu128_wrapper

Expand Down
6 changes: 3 additions & 3 deletions target/fpga/occamy_vcu128_procs.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ proc target_03 {} {

proc occ_connect { } {
global occ_hw_server
global occ_target_serial
global occ_target_path
global occ_hw_device
open_hw_manager
connect_hw_server -url ${occ_hw_server} -allow_non_jtag
current_hw_target [get_hw_targets */xilinx_tcf/Xilinx/${occ_target_serial}]
set_property PARAM.FREQUENCY 15000000 [get_hw_targets */xilinx_tcf/Xilinx/${occ_target_serial}]
current_hw_target [get_hw_targets ${occ_target_path}]
set_property PARAM.FREQUENCY 15000000 [get_hw_targets ${occ_target_path}]
open_hw_target
current_hw_device [get_hw_devices ${occ_hw_device}]
refresh_hw_device -update_hw_probes false [lindex [get_hw_devices ${occ_hw_device}] 0]
Expand Down

0 comments on commit ffd7855

Please sign in to comment.