|
| 1 | +# Amazon FPGA Hardware Development Kit |
| 2 | +# |
| 3 | +# Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 4 | +# |
| 5 | +# Licensed under the Amazon Software License (the "License"). You may not use |
| 6 | +# this file except in compliance with the License. A copy of the License is |
| 7 | +# located at |
| 8 | +# |
| 9 | +# http://aws.amazon.com/asl/ |
| 10 | +# |
| 11 | +# or in the "license" file accompanying this file. This file is distributed on |
| 12 | +# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or |
| 13 | +# implied. See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +# Script must be sourced from a bash shell or it will not work |
| 17 | +# When being sourced $0 will be the interactive shell and $BASH_SOURCE_ will contain the script being sourced |
| 18 | +# When being run $0 and $_ will be the same. |
| 19 | +script=${BASH_SOURCE[0]} |
| 20 | +if [ $script == $0 ]; then |
| 21 | + echo "ERROR: You must source this script" |
| 22 | + exit 2 |
| 23 | +fi |
| 24 | + |
| 25 | +full_script=$(readlink -f $script) |
| 26 | +script_name=$(basename $full_script) |
| 27 | +script_dir=$(dirname $full_script) |
| 28 | +current_dir=$(pwd) |
| 29 | + |
| 30 | +source $script_dir/shared/bin/set_common_functions.sh |
| 31 | +source $script_dir/shared/bin/set_common_env_vars.sh |
| 32 | + |
| 33 | +# Source sdk_setup.sh |
| 34 | +info_msg "Sourcing sdk_setup.sh" |
| 35 | +if ! source $AWS_FPGA_REPO_DIR/sdk_setup.sh; then |
| 36 | + return 1 |
| 37 | +fi |
| 38 | + |
| 39 | +if [ -z "$SDK_DIR" ]; then |
| 40 | + err_msg "SDK_DIR environment variable is not set. Please use 'source sdk_setup.sh' from the aws-fpga directory." |
| 41 | + return 1 |
| 42 | +fi |
| 43 | + |
| 44 | +debug=0 |
| 45 | +override=0 |
| 46 | +function usage { |
| 47 | + echo -e "USAGE: source [\$AWS_FPGA_REPO_DIR/]$script_name [-d|-debug] [-h|-help] [-o|-override]" |
| 48 | +} |
| 49 | + |
| 50 | +function help { |
| 51 | + info_msg "$script_name" |
| 52 | + info_msg " " |
| 53 | + info_msg "Checks & Sets up the runtime environment for AWS FPGA SDAccel Application usage." |
| 54 | + info_msg " " |
| 55 | + info_msg "sdaccel_runtime_check.sh script will:" |
| 56 | + info_msg " (1) install FPGA Management Tools," |
| 57 | + info_msg " (2) check if Xilinx Runtime (XRT) is installed" |
| 58 | + info_msg " (3) check if correct version of Xilinx Runtime (XRT) is installed," |
| 59 | + info_msg " (4) check if the required XOCL driver is running " |
| 60 | + info_msg " (5) source runtime setup script " |
| 61 | + echo " " |
| 62 | + usage |
| 63 | +} |
| 64 | + |
| 65 | +function xrt_install_instructions_2018_2 { |
| 66 | + err_msg "AWS recommended XRT version release: https://github.com/Xilinx/XRT/releases/tag/2018.2_XDF.RC4" |
| 67 | + err_msg "refer to following link for instructions to install XRT" |
| 68 | + err_msg "https://www.xilinx.com/html_docs/xilinx2018_2_xdf/sdaccel_doc/ejy1538090924727.html" |
| 69 | + err_msg "use following command to download and install latest validated XRT rpms for centos distributions" |
| 70 | + err_msg "curl -s https://s3.amazonaws.com/aws-fpga-developer-ami/1.5.0/Patches/xrt_201802.2.1.0_7.5.1804-xrt.rpm -o xrt_201802.2.1.0_7.5.1804-xrt.rpm" |
| 71 | + err_msg "curl -s https://s3.amazonaws.com/aws-fpga-developer-ami/1.5.0/Patches/xrt_201802.2.1.0_7.5.1804-aws.rpm -o xrt_201802.2.1.0_7.5.1804-aws.rpm" |
| 72 | + err_msg "sudo yum reinstall -y xrt_*-xrt.rpm" |
| 73 | + err_msg "sudo yum reinstall -y xrt_*-aws.rpm" |
| 74 | +} |
| 75 | + |
| 76 | +function check_xdma_driver { |
| 77 | + |
| 78 | + if lsmod | grep -q 'xdma' ; then |
| 79 | + err_msg "Found XDMA Driver running. Please remove xdma driver using below command" |
| 80 | + err_msg " rmmod xdma" |
| 81 | + return 1 |
| 82 | + fi |
| 83 | +} |
| 84 | + |
| 85 | +function check_edma_driver { |
| 86 | + |
| 87 | + if lsmod | grep -q 'edma' ; then |
| 88 | + err_msg "Found EDMA Driver running. Please remove edma driver using below command" |
| 89 | + err_msg " rmmod edma" |
| 90 | + return 1 |
| 91 | + fi |
| 92 | +} |
| 93 | + |
| 94 | +function check_xocl_driver { |
| 95 | + if lsmod | grep -q 'xocl' ; then |
| 96 | + info_msg "Found 'xocl Driver is installed and running. ' " |
| 97 | + else |
| 98 | + err_msg " XOCL Driver not installed. Please install xocl driver using below instructions" |
| 99 | + err_msg " If using 2017.4 Vivado toolset please source $AWS_FPGA_REPO_DIR/sdaccel_setup.sh " |
| 100 | + err_msg " if using 2018.2 Vivado toolset please reinstall rpm using instructions below " |
| 101 | + xrt_install_instructions_2018_2 |
| 102 | + return 1 |
| 103 | + fi |
| 104 | +} |
| 105 | + |
| 106 | +# Process command line args |
| 107 | +args=( "$@" ) |
| 108 | +for (( i = 0; i < ${#args[@]}; i++ )); do |
| 109 | + arg=${args[$i]} |
| 110 | + case $arg in |
| 111 | + -d|-debug) |
| 112 | + debug=1 |
| 113 | + ;; |
| 114 | + -h|-help) |
| 115 | + help |
| 116 | + return 0 |
| 117 | + ;; |
| 118 | + -o|-override) |
| 119 | + override=1 |
| 120 | + ;; |
| 121 | + *) |
| 122 | + err_msg "Invalid option: $arg\n" |
| 123 | + usage |
| 124 | + return 1 |
| 125 | + esac |
| 126 | +done |
| 127 | + |
| 128 | + |
| 129 | +if ! is_vivado_available; then |
| 130 | + if [[ -z "${VIVADO_TOOL_VERSION}" ]]; then |
| 131 | + err_msg " You are not using FPGA Developer AMI and VIVADO_TOOL_VERSION ENV variable is Empty. " |
| 132 | + err_msg " ENV Variable VIVADO_TOOL_VERSION is required to be set for runtime " |
| 133 | + err_msg " If AFI was generated using V2018.2 tools use the command : export VIVADO_TOOL_VERSION=2018.2 " |
| 134 | + err_msg " If AFI was generated using V2017.4 tools use the command : export VIVADO_TOOL_VERSION=2017.4 " |
| 135 | + err_msg " If you are using the FPGA Developer AMI then please request support on AWS FPGA Developers Forum." |
| 136 | + return 1 |
| 137 | + else |
| 138 | + info_msg " VIVADO tools not found. Reading VIVADO_TOOL_VERSION ENV variable to determine runtime version... " |
| 139 | + VIVADO_TOOL_VERSION="${VIVADO_TOOL_VERSION}" |
| 140 | + export VIVADO_TOOL_VERSION=${VIVADO_TOOL_VERSION:0:6} |
| 141 | + fi |
| 142 | +else |
| 143 | + info_msg "You are using instance with installed vivado tools. determining VIVADO version for runtime setup..." |
| 144 | + VIVADO_TOOL_VERSION=`vivado -version | grep Vivado | head -1 | sed 's:Vivado *::' | sed 's: .*$::' | sed 's:v::'` |
| 145 | + export VIVADO_TOOL_VERSION=${VIVADO_TOOL_VERSION:0:6} |
| 146 | +fi |
| 147 | +info_msg "VIVADO_TOOL_VERSION is $VIVADO_TOOL_VERSION" |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | +check_xdma_driver |
| 152 | +check_edma_driver |
| 153 | + |
| 154 | +if [[ "$VIVADO_TOOL_VERSION" =~ .*2018\.2.* ]]; then |
| 155 | + info_msg "Xilinx Vivado version is 2018.2" |
| 156 | + |
| 157 | + if override; then |
| 158 | + info_msg "XRT check overide selected." |
| 159 | + source /opt/xilinx/xrt/setup.sh |
| 160 | + return 0 |
| 161 | + fi |
| 162 | + |
| 163 | + if [ -f "/opt/xilinx/xrt/include/version.h" ]; then |
| 164 | + info_msg "XRT installed. proceeding to check version compatibility" |
| 165 | + xrt_build_ver=$(grep 'xrt_build_version_hash\[\]' /opt/xilinx/xrt/include/version.h | sed 's/";//' | sed 's/^.*"//') |
| 166 | + info_msg "Installed XRT version : $xrt_build_ver" |
| 167 | + if grep -Fxq "$xrt_build_ver" $AWS_FPGA_REPO_DIR/SDAccel/sdaccel_xrt_version.txt |
| 168 | + then |
| 169 | + info_msg "XRT version $xrt_build_ver is supported." |
| 170 | + info_msg " Now checking XOCL driver..." |
| 171 | + check_xocl_driver |
| 172 | + if [ -f "/opt/xilinx/xrt/setup.sh" ]; then |
| 173 | + source /opt/xilinx/xrt/setup.sh |
| 174 | + else |
| 175 | + err_msg " Cannot find /opt/xilinx/xrt/setup.sh " |
| 176 | + err_msg " Please check XRT is installed correctly " |
| 177 | + return 1 |
| 178 | + fi |
| 179 | + info_msg " XRT Runtime setup Done " |
| 180 | + else |
| 181 | + err_msg "$xrt_build_ver does not match recommended version" |
| 182 | + cat $AWS_FPGA_REPO_DIR/SDAccel/sdaccel_xrt_version.txt |
| 183 | + xrt_install_instructions_2018_2 |
| 184 | + return 1 |
| 185 | + fi |
| 186 | + else |
| 187 | + err_msg "XRT not installed. Please install XRT" |
| 188 | + xrt_install_instructions_2018_2 |
| 189 | + return 1 |
| 190 | + fi |
| 191 | +else |
| 192 | + info_msg "Xilinx Vivado version is $VIVADO_TOOL_VERSION " |
| 193 | + #info_msg " checking for file: /opt/Xilinx/SDx/${VIVADO_TOOL_VERSION}.rte.dyn/setup.sh" |
| 194 | + info_msg " Now checking XOCL driver..." |
| 195 | + check_xocl_driver |
| 196 | + if [ -f "/opt/Xilinx/SDx/${VIVADO_TOOL_VERSION}.rte.dyn/setup.sh" ]; then |
| 197 | + info_msg " Sourcing /opt/Xilinx/SDx/${VIVADO_TOOL_VERSION}.rte.dyn/setup.sh" |
| 198 | + source /opt/Xilinx/SDx/${VIVADO_TOOL_VERSION}.rte.dyn/setup.sh |
| 199 | + info_msg "$VIVADO_TOOL_VERSION Runtime setup Done" |
| 200 | + else |
| 201 | + err_msg " /opt/Xilinx/SDx/${VIVADO_TOOL_VERSION}.rte.dyn/setup.sh Not found. " |
| 202 | + err_msg "$VIVADO_TOOL_VERSION runtime environment not installed. Please source $AWS_FPGA_REPO_DIR/sdaccel_setup.sh" |
| 203 | + return 1 |
| 204 | + fi |
| 205 | +fi |
| 206 | + |
| 207 | +info_msg "SDAccel runtime check PASSED" |
0 commit comments