-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathpost-boot.sh
executable file
·211 lines (188 loc) · 6.63 KB
/
post-boot.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
#!/usr/bin/env bash
install_xrt() {
echo "Install XRT"
if [[ "$OSVERSION" == "ubuntu-20.04" ]] || [[ "$OSVERSION" == "ubuntu-22.04" ]]; then
echo "Ubuntu XRT install"
echo "Installing XRT dependencies..."
apt update
echo "Installing XRT package..."
apt install -y $XRT_BASE_PATH/$TOOLVERSION/$OSVERSION/$XRT_PACKAGE
fi
sudo bash -c "echo 'source /opt/xilinx/xrt/setup.sh' >> /etc/profile"
sudo bash -c "echo 'source $VITIS_BASE_PATH/$VITISVERSION/settings64.sh' >> /etc/profile"
}
install_shellpkg() {
if [[ "$U280" == 0 ]]; then
echo "[WARNING] No FPGA Board Detected."
exit 1;
fi
for PF in U280; do
if [[ "$(($PF))" != 0 ]]; then
echo "You have $(($PF)) $PF card(s). "
PLATFORM=`echo "alveo-$PF" | awk '{print tolower($0)}'`
install_u280_shell
fi
done
}
check_shellpkg() {
if [[ "$OSVERSION" == "ubuntu-20.04" ]] || [[ "$OSVERSION" == "ubuntu-22.04" ]]; then
PACKAGE_INSTALL_INFO=`apt list --installed 2>/dev/null | grep "$PACKAGE_NAME" | grep "$PACKAGE_VERSION"`
else
echo "Unsupported OS: $OSVERSION"
exit 1
fi
}
check_xrt() {
if [[ "$OSVERSION" == "ubuntu-20.04" ]] || [[ "$OSVERSION" == "ubuntu-22.04" ]]; then
XRT_INSTALL_INFO=`apt list --installed 2>/dev/null | grep "xrt" | grep "$XRT_VERSION"`
else
echo "Unsupported OS: $OSVERSION"
exit 1
fi
}
install_xbflash() {
cp -r $XBFLASH_BASE_PATH/${OSVERSION} /tmp
echo "Installing xbflash."
if [[ "$OSVERSION" == "ubuntu-20.04" ]] || [[ "$OSVERSION" == "ubuntu-22.04" ]]; then
apt install /tmp/${OSVERSION}/*.deb
else
echo "Unsupported OS: $OSVERSION"
exit 1
fi
}
check_requested_shell() {
SHELL_INSTALL_INFO=`/opt/xilinx/xrt/bin/xbmgmt examine | grep "$DSA"`
}
check_factory_shell() {
SHELL_INSTALL_INFO=`/opt/xilinx/xrt/bin/xbmgmt examine | grep "$FACTORY_SHELL"`
}
install_u280_shell() {
check_shellpkg
if [[ $? != 0 ]]; then
# echo "Download Shell package"
# wget -cO - "https://www.xilinx.com/bin/public/openDownload?filename=$SHELL_PACKAGE" > /tmp/$SHELL_PACKAGE
if [[ $SHELL_PACKAGE == *.tar.gz ]]; then
echo "Untar the package. "
tar xzvf $SHELL_BASE_PATH/$TOOLVERSION/$OSVERSION/$SHELL_PACKAGE -C /tmp/
rm /tmp/$SHELL_PACKAGE
fi
echo "Install Shell"
if [[ "$OSVERSION" == "ubuntu-20.04" ]] || [[ "$OSVERSION" == "ubuntu-22.04" ]]; then
echo "Install Ubuntu shell package"
apt-get install -y /tmp/xilinx*
elif [[ "$OSVERSION" == "centos-8" ]]; then
echo "Install CentOS shell package"
yum install -y /tmp/xilinx*
fi
rm /tmp/xilinx*
else
echo "The package is already installed. "
fi
}
flash_card() {
echo "Flash Card(s). "
/opt/xilinx/xrt/bin/xbmgmt program --base --device $PCI_ADDR
}
detect_cards() {
lspci > /dev/null
if [ $? != 0 ] ; then
if [[ "$OSVERSION" == "ubuntu-20.04" ]] || [[ "$OSVERSION" == "ubuntu-22.04" ]]; then
apt-get install -y pciutils
elif [[ "$OSVERSION" == "centos-7" ]] || [[ "$OSVERSION" == "centos-8" ]]; then
yum install -y pciutils
fi
fi
if [[ "$OSVERSION" == "ubuntu-20.04" ]] || [[ "$OSVERSION" == "ubuntu-22.04" ]]; then
PCI_ADDR=$(lspci -d 10ee: | awk '{print $1}' | head -n 1)
if [ -n "$PCI_ADDR" ]; then
U280=$((U280 + 1))
else
echo "Error: No card detected."
exit 1
fi
fi
}
install_config_fpga() {
echo "Installing config-fpga."
cp $CONFIG_FPGA_PATH/* /usr/local/bin
}
install_libs() {
echo "Installing libs."
sudo $VITIS_BASE_PATH/$VITISVERSION/scripts/installLibs.sh
}
disable_pcie_fatal_error() {
echo "Disabling PCIe fatal error reporting for node: $NODE_ID"
sudo /proj/octfpga-PG0/tools/pcie_disable_fatal.sh $PCI_ADDR
}
XRT_BASE_PATH="/proj/octfpga-PG0/tools/deployment/xrt"
SHELL_BASE_PATH="/proj/octfpga-PG0/tools/deployment/shell"
XBFLASH_BASE_PATH="/proj/octfpga-PG0/tools/xbflash"
VITIS_BASE_PATH="/proj/octfpga-PG0/tools/Xilinx/Vitis"
CONFIG_FPGA_PATH="/proj/octfpga-PG0/tools/post-boot"
OSVERSION=`grep '^ID=' /etc/os-release | awk -F= '{print $2}'`
OSVERSION=`echo $OSVERSION | tr -d '"'`
VERSION_ID=`grep '^VERSION_ID=' /etc/os-release | awk -F= '{print $2}'`
VERSION_ID=`echo $VERSION_ID | tr -d '"'`
OSVERSION="$OSVERSION-$VERSION_ID"
WORKFLOW=$1
TOOLVERSION=$2
VITISVERSION="2023.1"
SCRIPT_PATH=/local/repository
COMB="${TOOLVERSION}_${OSVERSION}"
XRT_PACKAGE=`grep ^$COMB: $SCRIPT_PATH/spec.txt | awk -F':' '{print $2}' | awk -F';' '{print $1}' | awk -F= '{print $2}'`
SHELL_PACKAGE=`grep ^$COMB: $SCRIPT_PATH/spec.txt | awk -F':' '{print $2}' | awk -F';' '{print $2}' | awk -F= '{print $2}'`
DSA=`grep ^$COMB: $SCRIPT_PATH/spec.txt | awk -F':' '{print $2}' | awk -F';' '{print $3}' | awk -F= '{print $2}'`
PACKAGE_NAME=`grep ^$COMB: $SCRIPT_PATH/spec.txt | awk -F':' '{print $2}' | awk -F';' '{print $5}' | awk -F= '{print $2}'`
PACKAGE_VERSION=`grep ^$COMB: $SCRIPT_PATH/spec.txt | awk -F':' '{print $2}' | awk -F';' '{print $6}' | awk -F= '{print $2}'`
XRT_VERSION=`grep ^$COMB: $SCRIPT_PATH/spec.txt | awk -F':' '{print $2}' | awk -F';' '{print $7}' | awk -F= '{print $2}'`
FACTORY_SHELL="xilinx_u280_GOLDEN_8"
NODE_ID=$(hostname | cut -d'.' -f1)
#PCI_ADDR=$(lspci -d 10ee: | awk '{print $1}' | head -n 1)
detect_cards
check_xrt
if [ $? == 0 ]; then
echo "XRT is already installed."
else
echo "XRT is not installed. Attempting to install XRT..."
install_xrt
check_xrt
if [ $? == 0 ]; then
echo "XRT was successfully installed."
else
echo "Error: XRT installation failed."
exit 1
fi
fi
install_libs
# Disable PCIe fatal error reporting
disable_pcie_fatal_error
install_config_fpga
if [ "$WORKFLOW" = "Vitis" ] ; then
check_shellpkg
if [ $? == 0 ]; then
echo "Shell is already installed."
else
echo "Shell is not installed. Installing shell..."
install_shellpkg
check_shellpkg
if [ $? == 0 ]; then
echo "Shell was successfully installed. Flashing..."
flash_card
/usr/local/bin/post-boot-fpga
#echo "Cold rebooting..."
#sudo -u geniuser perl /local/repository/cold-reboot.pl
else
echo "Error: Shell installation failed."
exit 1
fi
fi
if check_requested_shell ; then
echo "FPGA shell verified."
else
echo "Error: FPGA shell couldn't be verified."
exit 1
fi
else
echo "Custom flow selected."
install_xbflash
fi