forked from aws/aws-fpga
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdaccel_setup.sh
358 lines (323 loc) · 12.5 KB
/
sdaccel_setup.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
#
# Copyright 2015-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Script must be sourced from a bash shell or it will not work
# When being sourced $0 will be the interactive shell and $BASH_SOURCE_ will contain the script being sourced
# When being run $0 and $_ will be the same.
script=${BASH_SOURCE[0]}
if [ $script == $0 ]; then
echo "ERROR: You must source this script"
exit 2
fi
full_script=$(readlink -f $script)
script_name=$(basename $full_script)
script_dir=$(dirname $full_script)
current_dir=$(pwd)
source $script_dir/shared/bin/message_functions.sh
source $script_dir/shared/bin/set_AWS_FPGA_REPO_DIR.sh
# Source sdk_setup.sh
info_msg "source sdk_setup.sh"
if ! source $AWS_FPGA_REPO_DIR/sdk_setup.sh; then
return 1
fi
if [ -z "$SDK_DIR" ]; then
err_msg "SDK_DIR environment variable is not set. Please use 'source sdk_setup.sh' from the aws-fpga directory."
return 1
fi
# Setup Location of SDACCEL_DIR
export SDACCEL_DIR=$AWS_FPGA_REPO_DIR/SDAccel
# Update Xilinx SDAccel Examples from GitHub
echo "Updating Xilinx SDAccel Examples"
git submodule update --init -- SDAccel/examples/xilinx
debug=0
function usage {
echo -e "USAGE: source [\$AWS_FPGA_REPO_DIR/]$script_name [-d|-debug] [-h|-help]"
}
function help {
info_msg "$script_name"
info_msg " "
info_msg "Sets up the environment for AWS FPGA SDAccel tools."
info_msg " "
info_msg "sdaccel_setup.sh script will:"
info_msg " (1) install FPGA Management Tools,"
info_msg " (2) check if Xilinx tools are available,"
info_msg " (3) check if required packages are installed,"
info_msg " (4) Download lastest AWS Platform,"
info_msg " (5) Install Runtime drivers "
echo " "
usage
}
function check_set_xilinx_sdx {
if [[ ":$XILINX_SDX" == ':' ]]; then
debug_msg "XILINX_SDX is not set"
which sdx
RET=$?
if [ $RET != 0 ]; then
debug_msg "sdx not found in path."
err_msg "XILINX_SDX variable not set and sdx not in the path"
err_msg "Please set XILINX_SDX variable to point to your location of your Xilinx installation or add location of sdx exectuable to your PATH variable"
return $RET
else
export XILINX_SDX=`which sdx | sed 's:/bin/sdx::'`
info_msg "Setting XILINX_SDX to $XILINX_SDX"
fi
else
info_msg "XILINX_SDX is already set to $XILINX_SDX"
fi
}
function check_install_packages {
#TODO: Check required packages are installed or install them
#TODO: Check version of gcc is above 4.8.5 (4.6.3 does not work)
for pkg in `cat $SDACCEL_DIR/packages.txt`; do
if yum list installed "$pkg" >/dev/null 2>&1; then
true
else
warn_msg " $pkg not installed - please run: sudo yum install $pkg "
fi
done
}
function check_internet {
curl --silent --head -m 30 http://www.amazon.com
RET=$?
if [ $RET != 0 ]; then
err_msg "curl cannot connect to the internet using please check your internet connection or proxy settings"
err_msg "To check your connection run: curl --silent --head -m 30 http://www.amazon.com "
return $RET
else
info_msg "Internet Access OK"
fi
}
function check_icd {
info_msg "Checking ICD is installed"
if grep -q 'libxilinxopencl.so' /etc/OpenCL/vendors/xilinx.icd; then
info_msg "Found 'libxilinxopencl.so"
else
info_msg "/etc/OpenCL/vendors/xilinx.icd does not exist or does not contain lbixilinxopencl.so creating and adding libxilinxopencl.so to it"
sudo sh -c "echo libxilinxopencl.so > /etc/OpenCL/vendors/xilinx.icd"
RET=$?
if [ $RET != 0 ]; then
err_msg "/etc/OpenCL/vendors/xilinx.icd does not exist and cannot be created, sudo permissions needed to update it."
err_msg "Run the following with sudo permissions: sudo sh -c \"echo libxilinxopencl.so > /etc/OpenCL/vendors/xilinx.icd\" "
return $RET
else
echo "Done with ICD installation"
fi
fi
}
# Process command line args
args=( "$@" )
for (( i = 0; i < ${#args[@]}; i++ )); do
arg=${args[$i]}
case $arg in
-d|-debug)
debug=1
;;
-h|-help)
help
return 0
;;
*)
err_msg "Invalid option: $arg\n"
usage
return 1
esac
done
# Check XILINX_SDX is set
if ! check_set_xilinx_sdx; then
return 1
fi
# Check if internet connection is available
if ! check_internet; then
return 1
fi
# Check ICD is installed
if ! check_icd; then
return 1
fi
# Check correct packages are installed
if ! check_install_packages; then
return 1
fi
# Download correct DSA
#-------------------4 DDR--------------------
#TODO DSA Version: info_msg "Using HDK shell version $hdk_shell_version"
#TODO DSA Version: debug_msg "Checking HDK shell's checkpoint version"
DSA=xilinx_aws-vu9p-f1_4ddr-xpr-2pr_4_0
dsa_dir=$SDACCEL_DIR/aws_platform/$DSA/hw/
sdk_dsa=$dsa_dir/$DSA.dsa
sdk_dsa_s3_bucket=aws-fpga-hdk-resources
s3_sdk_dsa=$sdk_dsa_s3_bucket/SDAccel/dsa_v0911_shell_v071417d3/$DSA/$DSA.dsa
# set a variable to point to the platfom for build and emulation runs
export AWS_PLATFORM=$SDACCEL_DIR/aws_platform/$DSA/$DSA.xpfm
# Download the sha256
if [ ! -e $dsa_dir ]; then
mkdir -p $dsa_dir || { err_msg "Failed to create $dsa_dir"; return 2; }
fi
# Use curl instead of AWS CLI so that credentials aren't required.
curl -s https://s3.amazonaws.com/$s3_sdk_dsa.sha256 -o $sdk_dsa.sha256 || { err_msg "Failed to download DSA checkpoint version from $s3_sdk_dsa.sha256 -o $sdk_dsa.sha256"; return 2; }
if grep -q '<?xml version' $sdk_dsa.sha256; then
err_msg "Failed to downlonad SDK DSA checkpoint version from $s3_sdk_dsa.sha256"
cat sdk_dsa.sha256
return 2
fi
exp_sha256=$(cat $sdk_dsa.sha256)
debug_msg " latest version=$exp_sha256"
# If DSA already downloaded check its sha256
if [ -e $sdk_dsa ]; then
act_sha256=$( sha256sum $sdk_dsa | awk '{ print $1 }' )
debug_msg " existing version=$act_sha256"
if [[ $act_sha256 != $exp_sha256 ]]; then
info_msg "SDK dsa checkpoint version is incorrect"
info_msg " Saving old checkpoint to $sdk_dsa.back"
mv $sdk_dsa $sdk_dsa.back
fi
else
info_msg "SDK dsa hasn't been downloaded yet."
fi
if [ ! -e $sdk_dsa ]; then
info_msg "Downloading latest SDK dsa checkpoint from $s3_sdk_dsa"
# Use curl instead of AWS CLI so that credentials aren't required.
curl -s https://s3.amazonaws.com/$s3_sdk_dsa -o $sdk_dsa || { err_msg "SDK dsa checkpoint download failed"; return 2; }
fi
# Check sha256
act_sha256=$( sha256sum $sdk_dsa | awk '{ print $1 }' )
if [[ $act_sha256 != $exp_sha256 ]]; then
err_msg "Incorrect SDK dsa checkpoint version:"
err_msg " expected version=$exp_sha256"
err_msg " actual version=$act_sha256"
err_msg " There may be an issue with the uploaded checkpoint or the download failed."
return 2
fi
info_msg "AWS Platform: 4DDR is up-to-date"
#-------------------4 DDR--------------------
#-------------------1 DDR--------------------
#TODO DSA Version: info_msg "Using HDK shell version $hdk_shell_version"
#TODO DSA Version: debug_msg "Checking HDK shell's checkpoint version"
DSA=xilinx_aws-vu9p-f1_1ddr-xpr-2pr_4_0
dsa_dir=$SDACCEL_DIR/aws_platform/$DSA/hw/
sdk_dsa=$dsa_dir/$DSA.dsa
sdk_dsa_s3_bucket=aws-fpga-hdk-resources
s3_sdk_dsa=$sdk_dsa_s3_bucket/SDAccel/dsa_v11517_shell_v071417d3/$DSA/$DSA.dsa
# set a variable to point to the platfom for build and emulation runs
export AWS_PLATFORM=$SDACCEL_DIR/aws_platform/$DSA/$DSA.xpfm
# Download the sha256
if [ ! -e $dsa_dir ]; then
mkdir -p $dsa_dir || { err_msg "Failed to create $dsa_dir"; return 2; }
fi
# Use curl instead of AWS CLI so that credentials aren't required.
curl -s https://s3.amazonaws.com/$s3_sdk_dsa.sha256 -o $sdk_dsa.sha256 || { err_msg "Failed to download DSA checkpoint version from $s3_sdk_dsa.sha256 -o $sdk_dsa.sha256"; return 2; }
if grep -q '<?xml version' $sdk_dsa.sha256; then
err_msg "Failed to downlonad SDK DSA checkpoint version from $s3_sdk_dsa.sha256"
cat sdk_dsa.sha256
return 2
fi
exp_sha256=$(cat $sdk_dsa.sha256)
debug_msg " latest version=$exp_sha256"
# If DSA already downloaded check its sha256
if [ -e $sdk_dsa ]; then
act_sha256=$( sha256sum $sdk_dsa | awk '{ print $1 }' )
debug_msg " existing version=$act_sha256"
if [[ $act_sha256 != $exp_sha256 ]]; then
info_msg "SDK dsa checkpoint version is incorrect"
info_msg " Saving old checkpoint to $sdk_dsa.back"
mv $sdk_dsa $sdk_dsa.back
fi
else
info_msg "SDK dsa hasn't been downloaded yet."
fi
if [ ! -e $sdk_dsa ]; then
info_msg "Downloading latest SDK dsa checkpoint from $s3_sdk_dsa"
# Use curl instead of AWS CLI so that credentials aren't required.
curl -s https://s3.amazonaws.com/$s3_sdk_dsa -o $sdk_dsa || { err_msg "SDK dsa checkpoint download failed"; return 2; }
fi
# Check sha256
act_sha256=$( sha256sum $sdk_dsa | awk '{ print $1 }' )
if [[ $act_sha256 != $exp_sha256 ]]; then
err_msg "Incorrect SDK dsa checkpoint version:"
err_msg " expected version=$exp_sha256"
err_msg " actual version=$act_sha256"
err_msg " There may be an issue with the uploaded checkpoint or the download failed."
return 2
fi
info_msg "AWS Platform: 1DDR is up-to-date"
#-------------------1 DDR--------------------
#-------------------4 DDR RTL Kernel Debug--------------------
#TODO DSA Version: info_msg "Using HDK shell version $hdk_shell_version"
#TODO DSA Version: debug_msg "Checking HDK shell's checkpoint version"
DSA=xilinx_aws-vu9p-f1_4ddr-xpr-2pr-debug_4_0
dsa_dir=$SDACCEL_DIR/aws_platform/$DSA/hw/
sdk_dsa=$dsa_dir/$DSA.dsa
sdk_dsa_s3_bucket=aws-fpga-hdk-resources
s3_sdk_dsa=$sdk_dsa_s3_bucket/SDAccel/dsa_v11517_shell_v071417d3/$DSA/$DSA.dsa
# set a variable to point to the platfom for build and emulation runs
export AWS_PLATFORM=$SDACCEL_DIR/aws_platform/$DSA/$DSA.xpfm
# Download the sha256
if [ ! -e $dsa_dir ]; then
mkdir -p $dsa_dir || { err_msg "Failed to create $dsa_dir"; return 2; }
fi
# Use curl instead of AWS CLI so that credentials aren't required.
curl -s https://s3.amazonaws.com/$s3_sdk_dsa.sha256 -o $sdk_dsa.sha256 || { err_msg "Failed to download DSA checkpoint version from $s3_sdk_dsa.sha256 -o $sdk_dsa.sha256"; return 2; }
if grep -q '<?xml version' $sdk_dsa.sha256; then
err_msg "Failed to downlonad SDK DSA checkpoint version from $s3_sdk_dsa.sha256"
cat sdk_dsa.sha256
return 2
fi
exp_sha256=$(cat $sdk_dsa.sha256)
debug_msg " latest version=$exp_sha256"
# If DSA already downloaded check its sha256
if [ -e $sdk_dsa ]; then
act_sha256=$( sha256sum $sdk_dsa | awk '{ print $1 }' )
debug_msg " existing version=$act_sha256"
if [[ $act_sha256 != $exp_sha256 ]]; then
info_msg "SDK dsa checkpoint version is incorrect"
info_msg " Saving old checkpoint to $sdk_dsa.back"
mv $sdk_dsa $sdk_dsa.back
fi
else
info_msg "SDK dsa hasn't been downloaded yet."
fi
if [ ! -e $sdk_dsa ]; then
info_msg "Downloading latest SDK dsa checkpoint from $s3_sdk_dsa"
# Use curl instead of AWS CLI so that credentials aren't required.
curl -s https://s3.amazonaws.com/$s3_sdk_dsa -o $sdk_dsa || { err_msg "SDK dsa checkpoint download failed"; return 2; }
fi
# Check sha256
act_sha256=$( sha256sum $sdk_dsa | awk '{ print $1 }' )
if [[ $act_sha256 != $exp_sha256 ]]; then
err_msg "Incorrect SDK dsa checkpoint version:"
err_msg " expected version=$exp_sha256"
err_msg " actual version=$act_sha256"
err_msg " There may be an issue with the uploaded checkpoint or the download failed."
return 2
fi
info_msg "AWS Platform: 4DDR RTL Kernel is up-to-date"
#-------------------4 DDR RTL Kernel Debug--------------------
# Start of runtime xdma driver install
cd $SDACCEL_DIR
info_msg "Building SDAccel runtime"
if ! make ec2=1 debug=1 ; then
err_msg "Build of SDAccel runtime FAILED"
return 1
fi
info_msg "Installing SDAccel runtime"
if ! sudo make ec2=1 debug=1 INSTALL_ROOT=/opt/Xilinx/SDx/2017.1.rte SDK_DIR=$SDK_DIR DSA=$DSA XILINX_SDX=$XILINX_SDX SDACCEL_DIR=$SDACCEL_DIR install ; then
err_msg "Install of SDAccel runtime FAILED"
return 1
fi
info_msg "SDAccel runtime installed"
DSA=xilinx_aws-vu9p-f1_4ddr-xpr-2pr_4_0
export AWS_PLATFORM=$SDACCEL_DIR/aws_platform/$DSA/$DSA.xpfm
info_msg "The default AWS Platform has been set to: 4DDR - $AWS_PLATFORM"
cd $current_dir
info_msg "$script_name PASSED"