From 18bf234a5b3e5cafed535fd8116557b0396aef25 Mon Sep 17 00:00:00 2001 From: Brian Woods Date: Wed, 8 Sep 2021 18:29:22 -0700 Subject: Add support for loading bitstreams Signed-off-by: Brian Woods Reviewed-by: Stefano Stabellini Signed-off-by: Stefano Stabellini --- README.md | 6 ++++++ scripts/disk_image | 8 ++++++++ scripts/uboot-script-gen | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/README.md b/README.md index 8854469..9549fff 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,8 @@ DOMU_RAMDISK[1]="zynqmp-dom2/domU-ramdisk.cpio" DOMU_MEM[1]=512 DOMU_VCPUS[1]=1 +BITSTREAM=download.bit + NUM_BOOT_AUX_FILE=2 BOOT_AUX_FILE[0]="BOOT.BIN" BOOT_AUX_FILE[1]="uboot.cfg" @@ -127,6 +129,10 @@ Where: - LINUX_RAMDISK is optional but specifies the ramdisk to use when booting baremetal Linux. +- BITSTREAM is optional but specifies the bitstream to program the FPGA + with in u-boot when booting. Currently only a single bitstream is + supported. + - NUM_BOOT_AUX_FILE: is optional but if specified tell how many extra files to include in the first partition with disk_image. Useful for things like uboot config files, firmware files or other such files. diff --git a/scripts/disk_image b/scripts/disk_image index fc64386..1d71863 100755 --- a/scripts/disk_image +++ b/scripts/disk_image @@ -327,6 +327,10 @@ then i=$(( $i + 1 )) done fi +if test "${BITSTREAM}" +then + _part1_size=$(( $_part1_size + `stat -L --printf="%s" $UBOOT_OUT/$BITSTREAM` )) +fi i=0 while test $i -lt $NUM_DOMUS @@ -462,6 +466,10 @@ then i=$(( $i + 1 )) done fi +if test "${BITSTREAM}" +then + cp --parents "$BITSTREAM" "${DESTDIR_ABS}/part/disk1/" +fi i=0 while test $i -lt $NUM_DOMUS diff --git a/scripts/uboot-script-gen b/scripts/uboot-script-gen index abcc0cd..974fc5f 100755 --- a/scripts/uboot-script-gen +++ b/scripts/uboot-script-gen @@ -446,6 +446,22 @@ linux_file_loading() fi } +bitstream_load_and_config() +{ + if test "$BITSTREAM" + then + check_file_type "$BITSTREAM" "BIT data" + bitstream_addr=$memaddr + load_file $BITSTREAM "fpga_bitstream" + bitstream_size=$filesize + if test "$UBOOT_SOURCE" + then + # we assume the FPGA device is 0 here + echo "fpga load 0 $bitstream_addr $bitstream_size" >> "$UBOOT_SOURCE" + fi + fi +} + create_its_file_xen() { if test "$ramdisk_addr" != "-" @@ -608,6 +624,23 @@ create_its_file() fdt_line+=";" fi + if test "$BITSTREAM" + then + local fpga_line="fpga = \"fpga_bitstream\";" + cat >> "$its_file" <<- EOF + fpga_bitstream { + description = "FPGA bit stream"; + data = /incbin/("$BITSTREAM"); + type = "fpga"; + arch = "arm64"; + compression = "none"; + compatible = "u-boot,fpga-legacy"; + load = <$bitstream_addr>; + $fit_algo + }; + EOF + fi + # script for fit cat >> "$its_file" <<- EOF boot_scr { @@ -640,6 +673,7 @@ create_its_file() kernel = "host_kernel"; $fdt_line $ramdisk_line + $fpga_line $loadables_line }; }; @@ -903,6 +937,7 @@ fi check_file_type $DEVICE_TREE "Device Tree Blob" device_tree_addr=$memaddr load_file $DEVICE_TREE "host_fdt" +bitstream_load_and_config # bitstream is loaded last but used first device_tree_editing $device_tree_addr # disable device tree reloation -- cgit v1.2.3