/
build-gpu-deb
209 lines (174 loc) · 7 KB
/
build-gpu-deb
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
# Functions:
# build_gpu_deb
build_gpu_deb() {
if [ -z "$GPU_MODEL" ]; then
return
fi
info_msg "Build gpu deb..."
local pkgname="linux-gpu-${VENDER,,}-${CHIP,,}-${GPU_MODEL,,}-${GPU_VER,,}-${GPU_PLATFORM}"
local pkgdir="$BUILD_IMAGES/.tmp/${pkgname}_${VERSION}_${DISTRIB_ARCH}"
if [ "$KHADAS_BOARD" == "VIM1" ]; then
cd $ROOT
rm -rf $pkgdir
mkdir -p $pkgdir/DEBIAN
# set up control file
cat <<-END > $pkgdir/DEBIAN/control
Package: $pkgname
Version: $VERSION
Architecture: $DISTRIB_ARCH
Maintainer: Khadas <hello@khadas.com>
Installed-Size: 1
Replaces: libegl1-mesa, libegl1, libgles2
Provides: aml-mali-905
Conflicts: aml-mali-905
Section: kernel
Priority: optional
Description: lib mali S905
END
if [ "$GPU_PLATFORM" == "fbdev" ]; then
### fbdev
local gpu_lib_dir="$ROOT/archives/hwpacks/mali/${VENDER}/r7p0/lib/$DISTRIB_ARCH/$GPU_VER/m450"
elif [ "$GPU_PLATFORM" == "x11" ]; then
### x11
local gpu_lib_dir="$ROOT/archives/hwpacks/mali/${VENDER}/r7p0/lib/$DISTRIB_ARCH/$GPU_VER/m450-X"
elif [ "$GPU_PLATFORM" == "wayland" ]; then
### wayland
local gpu_lib_dir="$ROOT/archives/hwpacks/mali/${VENDER}/r7p0/lib/$DISTRIB_ARCH/$GPU_VER/m450/wayland"
fi
# GPU user space binary drivers
## Headers
mkdir -p $pkgdir/usr/include/
cp -arf archives/hwpacks/mali/${VENDER}/r7p0/include/EGL $pkgdir/usr/include/
cp -arf archives/hwpacks/mali/${VENDER}/r7p0/include/GLES $pkgdir/usr/include/
cp -arf archives/hwpacks/mali/${VENDER}/r7p0/include/GLES2 $pkgdir/usr/include/
cp -arf archives/hwpacks/mali/${VENDER}/r7p0/include/KHR $pkgdir/usr/include/
cp -arf archives/hwpacks/mali/${VENDER}/r7p0/include/EGL_platform/platform_${GPU_PLATFORM}/*.h $pkgdir/usr/include/EGL/
## libMali.so
mkdir -p $pkgdir/usr/lib/
cp -arf $gpu_lib_dir/libMali.so $pkgdir/usr/lib/
if [ "$DISTRIB_ARCH" == "arm64" ]; then
mkdir -p $pkgdir/usr/lib/aarch64-linux-gnu
cp -arf $gpu_lib_dir $pkgdir/usr/lib/aarch64-linux-gnu
elif [ "$DISTRIB_ARCH" == "armhf" ]; then
mkdir -p $pkgdir/usr/lib/arm-linux-gnueabihf
cp -arf $gpu_lib_dir $pkgdir/usr/lib/arm-linux-gnueabihf
fi
### links
cp -arf archives/hwpacks/mali/${VENDER}/r7p0/lib/*.so* $pkgdir/usr/lib/
if [ "$DISTRIB_ARCH" == "arm64" ]; then
cp -arf archives/hwpacks/mali/${VENDER}/r7p0/lib/*.so* $pkgdir/usr/lib/aarch64-linux-gnu
elif [ "$DISTRIB_ARCH" == "armhf" ]; then
cp -arf archives/hwpacks/mali/${VENDER}/r7p0/lib/*.so* $pkgdir/usr/lib/arm-linux-gnueabihf
fi
mkdir -p $pkgdir/usr/lib/pkgconfig/
cp -arf archives/hwpacks/mali/${VENDER}/r7p0/lib/pkgconfig/*.pc $pkgdir/usr/lib/pkgconfig/
# Mali m450 framebuffer mode examples
if [ "$DISTRIB_ARCH" == "arm64" ] && [ "$LINUX" != "mainline" ]; then
mkdir -p $pkgdir/usr/share/arm/
cp -arf archives/hwpacks/mali/${VENDER}/fbdev_examples/$LINUX/lib/* $pkgdir/usr/lib/
cp -arf archives/hwpacks/mali/${VENDER}/fbdev_examples/$LINUX/opengles_20 $pkgdir/usr/share/arm/
fi
mkdir -p $pkgdir/usr/lib/udev/rules.d
cat <<-EOF > $pkgdir/usr/lib/udev/rules.d/99-mali.rules
KERNEL=="mali",SUBSYSTEM=="misc",MODE="0777"
KERNEL=="ump",SUBSYSTEM=="ump",MODE="0777"
EOF
# Create board deb file
echo "Building package: $pkgname"
fakeroot dpkg-deb -b $pkgdir ${pkgdir}.deb
mkdir -p $BUILD_DEBS
# Remove old debs
rm -rf $BUILD_DEBS/linux-gpu-*.deb
cp ${pkgdir}.deb $BUILD_DEBS
# Cleanup
rm -rf ${pkgdir}.deb
rm -rf $pkgdir
elif [ "$KHADAS_BOARD" == "Edge" ] || [ "$KHADAS_BOARD" == "Firefly_RK3399" ]; then
cd $ROOT
rm -rf $pkgdir
mkdir -p $pkgdir/DEBIAN
# set up control file
cat <<-EOF > $pkgdir/DEBIAN/control
Package: $pkgname
Source: libmali-rk
Version: $VERSION
Architecture: $DISTRIB_ARCH
Maintainer: Khadas <hello@khadas.com>
Installed-Size: 17199
Depends: libc6 (>= 2.15), libdrm2 (>= 2.3.1), libgcc1 (>= 1:3.5), libstdc++6 (>= 4.8), libx11-6, libx11-xcb1, libxcb-dri2-0 (>= 1.8), libxcb1
Replaces: libegl1-mesa, libegl1-x11, libgbm1, libgles2-mesa, libegl1-mesa-dev, libgbm-dev, libgles2-mesa-dev, opencl-c-headers, libegl1, libgles2
Provides: libegl1, libegl1-mesa, libgbm1, libgles2-mesa, libwayland-egl1-mesa, libegl1-mesa-dev, libgbm-dev, libgles2-mesa-dev, opencl-c-headers
Section: libs
Priority: optional
Multi-Arch: same
Homepage: http://www.rock-chips.com/
Description: The mali library for Rockchip RK3399 (64bit).
EOF
cat <<-EOF > $pkgdir/DEBIAN/conffiles
/etc/OpenCL/vendors/mali.icd
EOF
cat <<-EOF > $pkgdir/DEBIAN/preinst
#!/bin/sh
rm -rf /usr/lib/arm-linux-gnueabihf/mesa-egl
rm -rf /usr/lib/aarch64-linux-gnu/mesa-egl
EOF
chmod 755 "$pkgdir/DEBIAN/preinst"
if [ "$GPU_PLATFORM" == "fbdev" ]; then
### fbdev
local gpu_lib="$ROOT/archives/hwpacks/mali/${VENDER}/lib/$DISTRIB_ARCH/libmali-midgard-t86x-${GPU_VER}-fbdev.so"
elif [ "$GPU_PLATFORM" == "gbm" ]; then
### gbm
local gpu_lib="$ROOT/archives/hwpacks/mali/${VENDER}/lib/$DISTRIB_ARCH/libmali-midgard-t86x-${GPU_VER}-gbm.so"
elif [ "$GPU_PLATFORM" == "x11" ]; then
### x11
local gpu_lib="$ROOT/archives/hwpacks/mali/${VENDER}/lib/$DISTRIB_ARCH/libmali-midgard-t86x-${GPU_VER}.so"
elif [ "$GPU_PLATFORM" == "wayland" ]; then
### wayland
local gpu_lib="$ROOT/archives/hwpacks/mali/${VENDER}/lib/$DISTRIB_ARCH/libmali-midgard-t86x-${GPU_VER}-wayland.so"
fi
# GPU user space binary drivers
## Headers
mkdir -p $pkgdir/usr/include/
cp -arf archives/hwpacks/mali/${VENDER}/include/* $pkgdir/usr/include/
rm $pkgdir/usr/include/mali.icd
mkdir -p $pkgdir/etc/OpenCL/vendors/
cp archives/hwpacks/mali/${VENDER}/include/mali.icd $pkgdir/etc/OpenCL/vendors/
## libMali.so
if [ "$DISTRIB_ARCH" == "arm64" ]; then
local gpu_lib_install_dir="$pkgdir/usr/lib/aarch64-linux-gnu"
elif [ "$DISTRIB_ARCH" == "armhf" ]; then
local gpu_lib_install_dir="$pkgdir/usr/lib/arm-linux-gnueabihf"
fi
mkdir -p $gpu_lib_install_dir
cp -arf $gpu_lib $gpu_lib_install_dir/libMali.so
## pkgconfig
cp -r archives/hwpacks/mali/${VENDER}/lib/pkgconfig_${DISTRIB_ARCH} $gpu_lib_install_dir/pkgconfig
### links
cp -arf archives/hwpacks/mali/${VENDER}/lib/*.so* $gpu_lib_install_dir
mkdir -p $pkgdir/usr/lib/udev/rules.d
cat <<-EOF > $pkgdir/usr/lib/udev/rules.d/50-mail.rules
KERNEL=="mali0", MODE="0666", GROUP="video"
EOF
# Create board deb file
echo "Building package: $pkgname"
fakeroot dpkg-deb -b $pkgdir ${pkgdir}.deb
mkdir -p $BUILD_DEBS
# Remove old debs
rm -rf $BUILD_DEBS/linux-gpu-*.deb
cp ${pkgdir}.deb $BUILD_DEBS
# Cleanup
rm -rf ${pkgdir}.deb
rm -rf $pkgdir
fi
if [ "$KHADAS_BOARD" == "VIM1" ] && [ "$LINUX" == "mainline" ] && [ "$DISTRIB_RELEASE" == "xenial" ] && [ "$DISTRIB_TYPE" != "server" ] && [ "$DISTRIB_ARCH" == "arm64" ]; then
# VIM1 mainline X11 mali driver
## install mali.ko
# FIXME When kernel updated, force to rebuild meson-gx-mali-450
if [ ! -f $BUILD_IMAGES/meson-gx-mali-450/mali-${MAINLINE_LINUX_VER}.ko ]; then
rm -rf $BUILD/.stamps/meson-gx-mali-450
fi
build_package "meson-gx-mali-450:target"
build_package "xf86-video-armsoc_s905x:target"
cd $ROOT
fi
}