Add scripts to load FPGA system
This commit is contained in:
parent
ef29bb0681
commit
730e342bfe
20
README.md
20
README.md
@ -22,9 +22,23 @@ To prevent the GC from erasing the system:
|
||||
$ nix build .#devShells.x86_64-linux.default --out-link result-env
|
||||
```
|
||||
|
||||
## FPGA
|
||||
## Lagarto Hun on FPGA Alveo U55C
|
||||
|
||||
First build required dependencies:
|
||||
|
||||
```
|
||||
. fpga/env.sh
|
||||
fpga/fpgactl -w /path/to/bitstream -b openpiton2.bin -k kernel-nixos -r initrd-nixos
|
||||
$ nix develop '.#lagarto-hun'
|
||||
```
|
||||
|
||||
Then upload to destination:
|
||||
|
||||
```
|
||||
$ fpga/upload.sh
|
||||
```
|
||||
|
||||
And then boot the system there:
|
||||
|
||||
```
|
||||
cucu$ ./boot.sh
|
||||
...
|
||||
```
|
||||
|
11
flake.nix
11
flake.nix
@ -54,5 +54,16 @@
|
||||
NIXOS_SYSTEM_TOPLEVEL = toplevel;
|
||||
OPENSBI = syspkgs.opensbi-uboot;
|
||||
};
|
||||
devShells.x86_64-linux.lagarto-hun =
|
||||
let
|
||||
nixosconf = self.nixosConfigurations.lagarto-hun;
|
||||
syspkgs = nixosconf.pkgs;
|
||||
build = nixosconf.config.system.build;
|
||||
in pkgs.mkShell {
|
||||
pname = "lagarto-hun-shell";
|
||||
OPENSBI = syspkgs.opensbi;
|
||||
KERNEL = build.kernel;
|
||||
INITRD = build.initialRamdisk;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
9
fpga/boot.sh
Executable file
9
fpga/boot.sh
Executable 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
|
@ -1,4 +1,3 @@
|
||||
#!/bin/false
|
||||
|
||||
# Source this file to setup the environment
|
||||
|
||||
|
45
fpga/load_image.sh
Executable file
45
fpga/load_image.sh
Executable 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
15
fpga/upload.sh
Executable 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"
|
Loading…
Reference in New Issue
Block a user