HomeCommunityMobile, Graphics, and Gaming blog
December 16, 2016

How to compile a 4.9 kernel with Mali r15p0 kernel drivers for a MiQi device ( RK3288 )

Until I get a recent Mali User-Space drivers build from Rockchip or the Rockchip Mali User-space drivers DDK, here's how to compile an official (read Linus Torvalds git branch) 4.9 kernel, with the official Mali r15p0 Kernel drivers, in order to use ...

By Myy

Share
Reading time 2 minutes

Until I get a recent Mali User-Space drivers build from Rockchip or the Rockchip Mali User-space drivers DDK, here's how to compile an official (read Linus Torvalds git branch) 4.9 kernel, with the official Mali r15p0 Kernel drivers, in order to use it on a MiQi device ( RK3288 board ) with the Mali r12p0 User-Space drivers for Firefly boards.

You can also find this procedure and a pre-compiled kernel on my Github repository.

This procedure does not enable the UMP drivers however...

The procedure

# Get the kernel
export KERNEL_VERSION=v4.9
git clone --depth 1 --branch $KERNEL_VERSION 'git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git' &&
cd linux

# Download, prepare and copy the Mali Kernel-Space drivers. 
# Some TGZ are AWFULLY packaged with everything having 0777 rights.
export MALI_VERSION=r15p0-00rel0
wget "http://malideveloper.arm.com/downloads/drivers/TX011/$MALI_VERSION/TX011-SW-99002-$MALI_VERSION.tgz" &&
tar zxvf TX011-SW-99002-$MALI_VERSION.tgz &&
cd TX011-SW-99002-$MALI_VERSION &&
find . -type 'f' -exec chmod 0644 {} ';' &&
find . -type 'd' -exec chmod 0755 {} ';' &&
find . -name 'sconscript' -exec rm {} ';' &&
rm -r 'driver/product/kernel/patches' 'driver/product/kernel/license.txt' &&
cp -r driver/product/kernel/drivers/gpu/arm ../drivers/gpu/ &&
cp -r driver/product/kernel/drivers/base/ump ../drivers/base/ &&
cd .. &&
rm -r TX011-SW-99002-$MALI_VERSION TX011-SW-99002-$MALI_VERSION.tgz

# Apply the Rockchip DRM, Rockchip fbdev, RK3288 DTS and
# Kconfig/Makefile patches used to enable the compilation of the
# Mali driver
export GITHUB_REPO=Miouyouyou/MyyQi
export GIT_BRANCH=master
export PATCHES_FOLDER_URL=https://raw.githubusercontent.com/$GITHUB_REPO/$GIT_BRANCH/patches
export KERNEL_PATCHES_FOLDER_URL=$PATCHES_FOLDER_URL/kernel/$KERNEL_VERSION
wget $KERNEL_PATCHES_FOLDER_URL/0001-Rockchip-DRM-and-Framebuffer-patches-from-ARM-softwa.patch &&
wget $KERNEL_PATCHES_FOLDER_URL/0002-Integrate-the-Mali-GPU-address-to-the-rk3288-and-rk3.patch &&
wget $KERNEL_PATCHES_FOLDER_URL/0003-Post-Mali-Kernel-device-drivers-modifications.patch
export PATCHES="0001-Rockchip-DRM-and-Framebuffer-patches-from-ARM-softwa.patch 0002-Integrate-the-Mali-GPU-address-to-the-rk3288-and-rk3.patch 0003-Post-Mali-Kernel-device-drivers-modifications.patch"
git apply $PATCHES &&
rm $PATCHES
unset PATCHES

# Apply a patch to the Mali Midgard driver that adapt the
# get_user_pages calls to the new signature.
export MALI_PATCHES_FOLDER=$PATCHES_FOLDER_URL/Mali/$MALI_VERSION
wget $MALI_PATCHES_FOLDER/0001-Adapt-get_user_pages-calls-to-use-the-new-calling-pr.patch &&
git apply 0001-Adapt-get_user_pages-calls-to-use-the-new-calling-pr.patch &&
rm 0001-Adapt-get_user_pages-calls-to-use-the-new-calling-pr.patch

# Get the configuration file and compile the kernel
export ARCH=arm
# Uncomment the following if you're cross-compiling ! #export CROSS_COMPILE=armv7a-hardfloat-linux-gnueabi- make mrproper wget -O .config 'https://raw.githubusercontent.com/Miouyouyou/MyyQi/master/boot/config-4.9.0MyyMyy%2B' make rk3288-miqi.dtb zImage modules -j5



Testing

The compiled kernel was tested successfully with the r12p0 Mali User-Space fbdev and Wayland drivers for Firefly boards, using the Mali OpenGL SDK samples for fbdev tests and Mesa demos for Wayland tests.

The test methodology boiled down to:

# FBDEV. Require to download the Mali OpenGL ES SDK.
cp /path/to/Mali_OpenGL_ES_SDK_v2.4.4.71fdbd_Linux_x86.tar.gz /tmp
tar zxvf Mali_OpenGL_ES_SDK_v2.4.4.71fdbd_Linux_x86.tar.gz
cd Mali_OpenGL_ES_SDK_v2.4.4
TARGET="arm" TOOLCHAIN_ROOT="" cmake .
make -j5
export LD_LIBRARY_PATH=/path/where/mali-fbdev-drivers-are/fbdev
cd samples/opengl_31/compute_particles/
./compute_particles

# Wayland
cd /tmp
git clone git://cgit.freedesktop.org/mesa/demos --depth 1
cd demos
./autogen.sh --enable-wayland --enable-gles2
export LD_LIBRARY_PATH=/path/to/mali-wayland-folder
weston
# Inside the weston terminal
export LD_LIBRARY_PATH=/path/to/mali-wayland-folder
cd /tmp/demos/src/egl/opengles2
./es2gears_wayland

Patches

I've attached the patch applied on the Mali Kernel r15p0 drivers sources.


Log in to like this post
Myy's profile picture

By Myy

Share

Article text

Re-use is only permitted for informational and non-commercial or personal use only.

placeholder