summaryrefslogtreecommitdiffstats
path: root/fpga/xilinx/programmer/dependencies/libxsvf/xsvftool-xpcu.src/reset-probe-impact.sh
blob: b5804a4767483c9eacdd7bc32b0ded2b0e100a2f (plain)
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
#!/bin/bash
#
# Reset probe to Xilinx Firmware using 'impact'
# (see README file for details)
#

ISEDIR="/opt/Xilinx/11.3/ISE"

finddev() {
	for id in 03fd:0009 03fd:000d 03fd:000f 04b4:8613; do lsusb -d $id; done | \
		head -n 1 | sed -r 's,^Bus ([0-9]+) Device ([0-9]+).*,/dev/bus/usb/\1/\2,'
}

v() {
	echo "+ $*"
	"$@"
}

batchfile=$( mktemp )
trap 'rm "$batchfile"' 0

cat << EOT > "$batchfile"
setMode -bs
setCable -port usb21
# identify
quit
EOT

v fxload -t fx2 -D $(finddev) -I "$ISEDIR"/bin/lin/xusb_emb.hex

for x in 0 1 2 3 4 5 6 7; do
	lsusb -d "03fd:0008" && break
	echo "Waiting for probe to re-enumerate.."
	sleep 1
done

echo -n "Waiting for probe to settle.."
for x in 1 2 3 4 5; do echo -n .; sleep 1; done; echo

v "$ISEDIR"/bin/lin/impact -batch "$batchfile"