forked from Xilinx/PYNQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·165 lines (142 loc) · 4.87 KB
/
build.sh
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
set -e
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [[ -z "$PYNQ_OVERLAYS_REMOTE_PREFIX" ]]; then
PYNQ_OVERLAYS_REMOTE_PREFIX="https://www.xilinx.com/bin/public/openDownload?filename=pynq."
fi
usage () {
echo "$0" >&2
echo "" >&2
echo "Script for building default overlays, microblaze bsp's and binaries." >&2
echo "" >&2
}
checkdeps () {
for f in vivado vitis curl; do
if ! which $f > /dev/null; then
echo "Could not find command $f, please ensure it is installed" 2>&1
exit 1
fi
done
}
# bitstream building will be skipped only if bit and hwh are both available
build_bitstreams () {
local root=$1
local board=$2
local orig_dir=$(pwd)
cd $root/$board
local overlays=`find . -maxdepth 2 -iname 'makefile' | cut -f2 -d"/"`
for ol in $overlays ; do
cd $root/$board/$ol
if [[ -e $ol.bit && -e $ol.hwh ]]; then
echo "skipping bitstream $ol.bit for $board"
else
echo "building bitstream $ol.bit for $board"
make clean && make
fi
done
cd $orig_dir
}
get_opendownloads_file() {
local remote_file=$1
local local_file=$2
curl -L -s $remote_file --output $local_file 2>/dev/null
ftype=$(file $local_file | awk '{print $2}')
# if opendownloads returns an HTML type, then most likely a 404 page...
# TODO: something cleaner, but for now, remove the file like it never arrived
if [ "$ftype" = "HTML" ]; then
rm $local_file
fi
}
get_bitstreams () {
local root=$1
local board=$2
local orig_dir=$(pwd)
cd $root/$board
local overlays=`find . -maxdepth 2 -iname 'makefile' | cut -f2 -d"/"`
for ol in $overlays ; do
cd $root/$board/$ol
tcl_md5=$(md5sum $ol.tcl | awk '{print $1}')
if [ ! -e $ol.bit ] || [ ! -e $ol.hwh ]; then
rm -f $ol.bit $ol.hwh
set +e
get_opendownloads_file ${PYNQ_OVERLAYS_REMOTE_PREFIX}$board.$ol.$tcl_md5.bit $ol.bit
get_opendownloads_file ${PYNQ_OVERLAYS_REMOTE_PREFIX}$board.$ol.$tcl_md5.hwh $ol.hwh
set -e
if [ ! -s $ol.bit ] || [ ! -s $ol.hwh ] || [ ! -e $ol.bit ] || [ ! -e $ol.hwh ]; then
# download failed for .bit, .hwh, or both.
# Cleanup to avoid potential issues later
rm -f $ol.bit
rm -f $ol.hwh
fi
fi
if [ ! -e $ol.xsa ]; then
set +e
get_opendownloads_file ${PYNQ_OVERLAYS_REMOTE_PREFIX}$board.$ol.$tcl_md5.xsa $ol.xsa
set -e
if [ ! -s $ol.xsa ] || [ ! -e $ol.xsa ]; then
rm -f $ol.xsa
fi
fi
done
cd $orig_dir
}
usage
checkdeps
cd $script_dir/boards
boards=`find . -maxdepth 2 -name '*.spec' -printf '%h\n' | cut -f2 -d"/"`
for b in $boards ; do
get_bitstreams "$script_dir/boards" "$b"
done
# enforce Pynq-Z2 projects to be rebuilt in case of missing XSA files
if [[ ! -e $script_dir/boards/Pynq-Z2/base/base.xsa ]]; then
rm -f $script_dir/boards/Pynq-Z2/base/base.bit
rm -f $script_dir/boards/Pynq-Z2/base/base.hwh
fi
if [[ ! -e $script_dir/boards/Pynq-Z2/logictools/logictools.xsa ]]; then
rm -f $script_dir/boards/Pynq-Z2/logictools/logictools.bit
rm -f $script_dir/boards/Pynq-Z2/logictools/logictools.hwh
fi
# build all bitstreams for all the boards
for b in $boards ; do
build_bitstreams "$script_dir/boards" "$b"
done
common_path="standalone_domain/bsp"
# build IO Processor (IOP) binaries
if [ ! -d $script_dir/pynq/lib/arduino/bsp_iop_arduino ] || \
[ ! -d $script_dir/pynq/lib/pmod/bsp_iop_pmod ] || \
[ ! -d $script_dir/pynq/lib/rpi/bsp_iop_rpi ]; then
cd $script_dir/boards/sw_repo
make clean && make XSA=../Pynq-Z2/base/base.xsa
cd $script_dir/boards/sw_repo
rm -rf bsp_iop_arduino_mb/iop_arduino_mb/$common_path/iop_arduino_mb/code
rm -rf bsp_iop_arduino_mb/iop_arduino_mb/$common_path/iop_arduino_mb/libsrc
cp -rf bsp_iop_arduino_mb/iop_arduino_mb/$common_path \
$script_dir/pynq/lib/arduino/bsp_iop_arduino
cd $script_dir/pynq/lib/arduino && make && make clean
cd $script_dir/boards/sw_repo
rm -rf bsp_iop_pmoda_mb/iop_pmoda_mb/$common_path/iop_pmoda_mb/code
rm -rf bsp_iop_pmoda_mb/iop_pmoda_mb/$common_path/iop_pmoda_mb/libsrc
cp -rf bsp_iop_pmoda_mb/iop_pmoda_mb/$common_path \
$script_dir/pynq/lib/pmod/bsp_iop_pmod
cd $script_dir/pynq/lib/pmod && make && make clean
cd $script_dir/boards/sw_repo
rm -rf bsp_iop_rpi_mb/iop_rpi_mb/$common_path/iop_rpi_mb/code
rm -rf bsp_iop_rpi_mb/iop_rpi_mb/$common_path/iop_rpi_mb/libsrc
cp -rf bsp_iop_rpi_mb/iop_rpi_mb/$common_path \
$script_dir/pynq/lib/rpi/bsp_iop_rpi
cd $script_dir/boards/sw_repo
make clean
fi
# build Logictools Controller Processor (LCP) binaries
if [ ! -d $script_dir/pynq/lib/logictools/bsp_lcp_ar_mb ]; then
cd $script_dir/boards/sw_repo
make clean && make XSA=../Pynq-Z2/logictools/logictools.xsa
cd $script_dir/boards/sw_repo
rm -rf bsp_lcp_ar_mb/lcp_ar_mb/$common_path/lcp_ar_mb/code
rm -rf bsp_lcp_ar_mb/lcp_ar_mb/$common_path/lcp_ar_mb/libsrc
cp -rf bsp_lcp_ar_mb/lcp_ar_mb/$common_path \
$script_dir/pynq/lib/logictools/bsp_lcp_ar_mb
cd $script_dir/pynq/lib/logictools && make && make clean
cd $script_dir/boards/sw_repo
make clean
fi