To begin, you need an appropriate version of the vendor userspace. Older or newer versions may have incompatible ABIs. For a mainline kernel, you can build out of tree and insmod the resulting mali_kbase.ko.

Mesa driver

Download the sources for the Mesa driver, contained in the mesa repository.

$ cd ~
$ git clone -b master.

Create a local prefix to install mesa, to avoid disrupting the system OpenGL drivers:

$ mkdir ~/gfx-prefix

Next, configure, build, and install mesa (meson requires absolute paths prefix, adjust that; TODO non-Rockchip systems):

$ cd ~/mesa
$ mkdir build
$ cd build
$ meson .. . -Ddri-drivers= -Dvulkan-drivers= -Dgallium-drivers=panfrost,rockchip -Dlibunwind=false --prefix=/home/guest/gfx-prefix
$ ninja install

This may take a while, so brew a cup of tea. If everything goes well, the mesa driver will be installed to the local prefix.


Allow non-root users to access the hardware

# chmod 0666 /dev/mali0

You can also add udev rule for this, e.g. add a fragment like this to /etc/udev/rules.d/50-mali.rules

KERNEL=="mali0", MODE="0666", GROUP="video"

Set LD_LIBRARY_PATH to point to the mesa installation (edit guest and gfx-prefix accordingly):

$ export LD_LIBRARY_PATH=/home/guest/gfx-prefix/lib/arm-linux-gnueabihf/ 

Or on a distro without multi-arch support:

$ export LD_LIBRARY_PATH=/home/guest/gfx-prefix/lib/

You may now run (GBM) OpenGL ES 2.0 programs from the console, which will render to a DRM surface. X11 is not yet supported.

$ kmscube
$ glmark2-es2-drm -brefract

You can also run some Wayland compositors and run Wayland OpenGL ES 2.0 programs from there, rendering into a Wayland window.

$ weston
$ es2gears_wayland # From within Weston
$ glmark2-es2-wayland -bjellyfish # Ditto