Add scripts to load FPGA system

This commit is contained in:
2024-03-04 18:32:25 +01:00
parent ef29bb0681
commit 730e342bfe
6 changed files with 97 additions and 4 deletions

9
fpga/boot.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/bash
set -x
set -e
source ./env.sh
./fpgactl -b opensbi.bin -k kernel.bin -i initrd.bin
picocom -b 115200 /dev/ttyUSB2

View File

@@ -1,4 +1,3 @@
#!/bin/false
# Source this file to setup the environment

45
fpga/load_image.sh Executable file
View File

@@ -0,0 +1,45 @@
#!/bin/bash
source /home/tools/ACME-EA-v1/setup.sh
if [ $# -ne 2 ]; then
>&2 echo "usage: load-fs.sh <file> <address>"
exit 1
fi
input=$1
#startaddr=$((0x00000000))
startaddr=$2
filesize=$(du -L -b $input | cut -f1)
#chunksize=$((0x10000000))
#chunksize=$((0x08000000))
chunksize=$((0x00800000))
nrchunk=$((filesize/chunksize + ((filesize%chunksize) != 0) ))
lastchunk=$((nrchunk - 1))
total=0
myid=$$
rm -f /tmp/sect.tmp.$myid
for i in `seq 0 $lastchunk`; do
echo "extracting section $i... "
dd if=$input of=/tmp/sect.tmp.$myid bs=$chunksize skip=$i count=1 status=none
from=$((i * chunksize))
to=$((startaddr + i * chunksize))
#copysize=$((i != lastchunk ? chunksize : (filesize - i * chunksize) ))
copysize=$(du -L -b /tmp/sect.tmp.$myid | cut -f1)
echo "copying section $i: from=$from to=$to size=$copysize ($((copysize/1024/1024)) MiB)"
dma-to-device -d /dev/qdma${ID}000-MM-1 -a $to -s $copysize -f /tmp/sect.tmp.$myid
#sleep 0.2
rm -f /tmp/sect.tmp.$myid
echo -e "done\n"
total=$((total + copysize))
done
if [ $filesize -ne $total ]; then
>&2 echo "Error: Copy failed"
exit 1
fi

15
fpga/upload.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
set -e
set -x
dst=femu:nixos/
rsync -a fpga/fpgactl "$dst"
rsync -a fpga/boot.sh "$dst"
rsync -a fpga/env.sh "$dst"
rsync "$OPENSBI/share/opensbi/lp64/fpga/openpiton/firmware/fw_payload.bin" "$dst/opensbi.bin"
rsync "$KERNEL/Image" "$dst/kernel.bin"
rsync "$INITRD/initrd" "$dst/initrd.bin"
echo "Now go to $dst and run ./boot.sh"