Update fpgactl tool

This commit is contained in:
Rodrigo Arias Mallo 2024-03-04 16:31:07 +01:00
parent 409d2caecc
commit bd2b8b1bc5

View File

@ -101,27 +101,59 @@ function create_qdma_queue() # {{{
function do_system_reset() # {{{
{
# UartBootEn (bit2) + system reset (bit0)
dma-ctl qdma08000 reg write bar 2 0x0 0x0
dma-ctl qdma08000 reg write bar 2 0x0 0x0 > /dev/null
sleep 0.2
# Release system reset, we must wait until the memory is filled with 0s
dma-ctl qdma08000 reg write bar 2 0x0 0x1
dma-ctl qdma08000 reg write bar 2 0x0 0x1 > /dev/null
#sleep 5
} # }}}
function do_system_release() # {{{
{
# Release Ariane's reset
dma-ctl qdma08000 reg write bar 2 0x0 0x3
dma-ctl qdma08000 reg write bar 2 0x0 0x3 > /dev/null
} # }}}
function copy_by_dma() # {{{
{
ifile="$1"
address="$2"
ofile="/dev/qdma08000-MM-1"
bs=$((8*1024*1024)) # 8 MiB
total_size=$(stat --format "%s" "$ifile")
nblocks=$(( ($total_size + $bs - 1) / $bs ))
skip=0
# Using just a single dd command doesn't seem to work. My hypothesis is that
# the driver doesn't allow multiple writes without setting the fseek position.
# So we keep copying blocks until the end of the file, one at a time.
while [ "$skip" -lt "$nblocks" ]; do
dst=$(($address + $skip * $bs))
dd if="$ifile" skip=$skip count=1 bs=$bs of="$ofile" seek=$dst oflag=seek_bytes
let skip=$skip+1
done
} # }}}
function load_file_in_memory() # {{{
{
file="$1"
address="$2"
# Previous tests...
#strace -f dma-to-device -d /dev/qdma08000-MM-1 -a "$address" -s $((8*1024*1024)) -f "$file"
#strace -f dd if="$file" bs=16M seek="${address}" oflag=seek_bytes of=/dev/qdma08000-MM-1 status=progress conv=sync
#strace -f fpgakit/fpgadd -i "$file" -a "$address" -d /dev/qdma08000-MM-1 -c 1024 -s 1024
ID=08 ./load_image.sh "$file" "$address"
#ID=08 ./load_image.sh "$file" "$address"
# Now dd seems to work fine, but I will leave this as fallback:
#copy_by_dma "$file" "$address"
dd if="$file" bs=8M seek="${address}" oflag=seek_bytes of=/dev/qdma08000-MM-1 status=none
} # }}}
function do_boot_only() # {{{
@ -190,9 +222,22 @@ function upload_bitstream_file() # {{{
exit 1
fi
vivado -nolog -nojournal -mode batch -source load-bitstream.tcl -tclargs "$bitfile" "$fpgajtag"
script=$(mktemp vivado-XXXXXXXXXX.tcl)
cat > "$script" <<EOF
open_hw_manager
connect_hw_server -url localhost:3121
current_hw_target "localhost:3121/xilinx_tcf/Xilinx/${fpgajtag}A"
open_hw_target
set dev [lindex [get_hw_devices] 0]
current_hw_device \$dev
set_property PROGRAM.FILE ${bitfile} \$dev
program_hw_devices \$dev
exit
EOF
vivado -nolog -nojournal -mode batch -source "$script"
rm "$script"
echo "Bitstream $bitfile loaded."
killall hw_server
} # }}}
@ -256,25 +301,25 @@ function load_bitstream() # {{{
create_qdma_queue
} # }}}
slotid="8"
bitstream=
bootloader=
kernelfile=
reloadfs=
resetcpu=
verbose=
while getopts "s:w:k:r:b:" opt; do
while getopts "s:w:k:r:b:v" opt; do
case "${opt}" in
s) slotid="${OPTARG}" ;;
w) bitstream="${OPTARG}" ;;
b) bootloader="${OPTARG}"; resetcpu=1 ;;
k) kernelfile="${OPTARG}"; resetcpu=1 ;;
r) rootfs="${OPTARG}"; resetcpu=1 ;;
v) verbose=1 ;;
*) usage ;;
esac
done
set -x
test "$verbose" && set -x
check_environment