Add helper script for programming FPGA

This commit is contained in:
Madeline Busig 2025-11-09 19:13:06 -08:00
parent 843012cd40
commit 0c9fb498e9
2 changed files with 54 additions and 0 deletions

15
scripts/program_device.sh Executable file
View File

@ -0,0 +1,15 @@
#!/usr/bin/bash
THISSCRIPT=$(realpath $0)
PROJECT_ROOT=$(dirname $(dirname $THISSCRIPT))
TCLSCRIPT="$PROJECT_ROOT/tcl/program_device.tcl"
if [ $# -lt 1 ]; then
echo "Usage: $0 BITFILE"
exit -1
fi
BITFILE=$1
$VIVADO_ROOT/bin/vivado -mode batch -source "$TCLSCRIPT" -tclargs "$BITFILE"

39
tcl/program_device.tcl Normal file
View File

@ -0,0 +1,39 @@
if { $argc < 1 } {
puts "Usage: program_device.sh BITFILE"
exit -1
}
set bitfile [lindex $argv 0]
set hwserver "localhost:3121"
set hwtarget "$hwserver/*"
puts "Opening hardware server at $hwserver"
open_hw_manager
connect_hw_server -url $hwserver
puts "Opening target $hwtarget"
set targetlist [get_hw_targets $hwtarget]
if { [llength $targetlist] != 1 } {
puts "Failed to get hw target. Number of matching targets is not 1."
exit -2
}
set target $targetlist
current_hw_target $target
open_hw_target
puts "Refreshing device"
refresh_hw_device [current_hw_device]
puts "Programming device using bitfile $bitfile"
set_property PROGRAM.file "$bitfile" [current_hw_device]
program_hw_devices [current_hw_device]
refresh_hw_device [current_hw_device]
puts "Successfully programmed device"
exit 0