-
Notifications
You must be signed in to change notification settings - Fork 1
/
dependencies.sh
executable file
·182 lines (147 loc) · 5.62 KB
/
dependencies.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
#!/bin/bash
## Install dependancies:
## + libedgetpu
## + Vulkan
## + OpenNI2
##
## TODO size estimate
# Check root
if [ "$EUID" -ne 0 ]; then # TODO remove
echo "Please run as root."
exit 1
fi
# upgrade
echo "Updating packages..."; sudo apt-get update -y
echo "Upgrading packages..."; sudo apt-get full-upgrade -y
if [[ $GITHUB_ACTIONS ]]; then
CROSSTC="."
else
CROSSTC="arm-linux-gnueabihf"
fi
# edgetpu dependencies
# + Test lib: https://github.com/google-coral/pycoral.git
# + Procedure: hard reboot without coral then hard reboot with coral
# + website: https://coral.ai/docs/accelerator/get-started/#3-run-a-model-on-the-edge-tpu
echo "Installing clang ..."; sudo apt-get install -y clang
echo "Installing curl ..."; sudo apt install -y curl
sudo apt-get update
sudo apt-get full-upgrade
echo "deb https://packages.cloud.google.com/apt coral-edgetpu-stable main" | sudo tee /etc/apt/sources.list.d/coral-edgetpu.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
sudo apt update
sudo apt full-upgrade
sudo apt update
echo "Installing edgetpu library and header files ..."
if [[ $GITHUB_ACTIONS ]]; then
# For now I don't have the time to sink into finding out why other solutions don't work
apt install -y libedgetpu1-std
apt install -y libedgetpu-dev
git clone https://coral.googlesource.com/edgetpu
cd edgetpu
git checkout release-chef
# TODO clean
cp libedgetpu/libedgetpu_arm64_throttled.so /usr/lib/$CROSSTC/libedgetpu.so >> /dev/null
cp libedgetpu/edgetpu.h /usr/include/edgetpu.h >> /dev/null
cd ..
apt remove -y libedgetpu1-std
apt remove -y libedgetpu-dev
apt update
apt full-upgrade
apt update
apt install -y libedgetpu1-std
apt install -y libedgetpu-dev
else
# WARNING: Not theroughly tested!
# You may need to do a manual install of the https://github.com/google-coral/edgetpu library
# Do not forget to link edgetpu.so to edgetpu.so.1.0 in the cross toolchain lib folder.
# compile for edgetpu with --min_runtime_version 13
$(
sudo rm /usr/lib/$CROSSTC/libedgetpu.so
sudo rm /usr/lib/$CROSSTC/libedgetpu.so.1
sudo rm /usr/lib/$CROSSTC/libedgetpu.so.1.0
git clone https://github.com/google-coral/edgetpu
cd edgetpu
sudo cp libedgetpu/edgetpu.h /usr/include/edgetpu.h
sudo cp libedgetpu/edgetpu_c.h /usr/include/edgetpu_c.h
sudo cp libedgetpu/direct/armv7a/libedgetpu.so.* /usr/lib/$CROSSTC
cd /usr/lib/$CROSSTC
sudo ln libedgetpu.so.1.0 libedgetpu.so
)
fi
# Vulkan Dependencies
echo "Installing Vulkan Dependencies ..."
sudo apt-get install -y libxcb-randr0-dev libxrandr-dev
sudo apt-get install -y libxcb-xinerama0-dev libxinerama-dev libxcursor-dev
sudo apt-get install -y libxcb-cursor-dev libxkbcommon-dev xutils-dev
sudo apt-get install -y xutils-dev libpthread-stubs0-dev libpciaccess-dev
sudo apt-get install -y libffi-dev x11proto-xext-dev libxcb1-dev libxcb-*dev
sudo apt-get install -y libssl-dev libgnutls28-dev x11proto-dri2-dev
sudo apt-get install -y x11proto-dri3-dev libx11-dev libxcb-glx0-dev
sudo apt-get install -y libx11-xcb-dev libxext-dev libxdamage-dev libxfixes-dev
sudo apt-get install -y libva-dev x11proto-randr-dev x11proto-present-dev
sudo apt-get install -y libclc-dev libelf-dev mesa-utils
sudo apt-get install -y libvulkan-dev libvulkan1 libassimp-dev
sudo apt-get install -y libdrm-dev libxshmfence-dev libxxf86vm-dev libunwind-dev
sudo apt-get install -y libwayland-dev wayland-protocols
sudo apt-get install -y libwayland-egl-backend-dev
sudo apt-get install -y valgrind libzstd-dev vulkan-tools
sudo apt-get install -y git build-essential bison flex ninja-build
VERSION_CODENAME=$(cat /etc/os-release | grep -o 'VERSION_CODENAME.*' | cut -f2- -d=)
if [[ $VERSION_CODENAME == 'buster' ]]; then
sudo apt-get install -y python-mako vulkan-utils
elif [[ $VERSION_CODENAME == 'bullseye' ]]; then
sudo apt-get install -y python3-mako
fi
echo "Installing Vulkan ..."
# remove old versions first
sudo rm -rf /home/pi/mesa_vulkan
# install meson
sudo apt purge meson -y
sudo pip3 install meson
# install mako
sudo pip3 install mako
# install v3dv
cd ~
git clone -b 20.3 https://gitlab.freedesktop.org/mesa/mesa.git mesa_vulkan
# build v3dv (± 30 min)
cd mesa_vulkan
CFLAGS="-mcpu=cortex-a72 -mfpu=neon-fp-armv8" \
CXXFLAGS="-mcpu=cortex-a72 -mfpu=neon-fp-armv8" \
meson --prefix /usr \
-D platforms=x11 \
-D vulkan-drivers=broadcom \
-D dri-drivers= \
-D gallium-drivers=kmsro,v3d,vc4 \
-D buildtype=release build
sudo ninja -C build -j4
ninja -C build install
echo "TIP: Check your driver using \"glxinfo -B\""
# OpenNI2 dependencies
sudo apt-get install -y libusb-1.0-0-dev
sudo apt-get install -y libudev-dev
sudo apt-get install -y freeglut3-dev
sudo apt-get install -y doxygen
sudo apt-get install -y graphviz
# install Java
sudo apt install -y openjdk-8-jdk
# install cmake
sudo apt install cmake
# Build for Arm
git clone https://github.com/occipital/OpenNI2
cd OpenNI2
if ! [[ $GITHUB_ACTIONS ]]; then
find . -name Makefile -exec sed -i 's/CFLAGS += -Wall/CFLAGS += -Wall -mfloat-abi=hard/g' {} \;
fi
make
sudo ./Packaging/Linux/install.sh
cp ./Bin/*-Release/libOpenNI2.so /usr/lib/$CROSSTC/
cp -r ./Bin/*-Release/OpenNI2 /usr/lib/$CROSSTC/
# Adding current user to video group
echo "Add user to video group so they may access the camera (requires reboot)"
sudo usermod -a -G video pi
# Save env variables
sudo mkdir /lib/libOpenNI2
echo 'export OPENNI2_REDIST="/lib/libOpenNI2"' >> ~/.bashrc
echo 'export OPENNI2_REDIST64="/lib/libOpenNI2"' >> ~/.bashrc
echo "A reboot is required for some changes to take effect."
exit 0