-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.sh
More file actions
executable file
·51 lines (42 loc) · 1.18 KB
/
program.sh
File metadata and controls
executable file
·51 lines (42 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
# FPGA programming script for ICE40
# Usage: ./program.sh <bitstream_bin> [device]
set -e
if [ $# -lt 1 ]; then
echo "Usage: $0 <bitstream_bin> [device]"
echo " bitstream_bin: Binary bitstream file (.bin)"
echo " device: Device path (optional, e.g., /dev/ttyUSB0)"
echo ""
echo "Note: If device is not specified, iceprog will attempt to auto-detect"
exit 1
fi
BITSTREAM_BIN="$1"
DEVICE="${2:-}"
if [ ! -f "$BITSTREAM_BIN" ]; then
echo "Error: Bitstream file '$BITSTREAM_BIN' not found"
exit 1
fi
echo "Programming FPGA"
echo "Bitstream: $BITSTREAM_BIN"
if [ -n "$DEVICE" ]; then
echo "Device: $DEVICE"
fi
echo ""
echo "Make sure your ICE40 board is connected via USB"
echo ""
if [ -n "$DEVICE" ]; then
iceprog -d "$DEVICE" "$BITSTREAM_BIN"
else
iceprog "$BITSTREAM_BIN"
fi
if [ $? -eq 0 ]; then
echo ""
echo "✓ Programming successful"
else
echo ""
echo "✗ Programming failed"
echo " - Check that the board is connected"
echo " - Check USB permissions (you may need to be in the 'dialout' group)"
echo " - Try specifying the device explicitly: $0 $BITSTREAM_BIN /dev/ttyUSB0"
exit 1
fi