Skip to content

Instantly share code, notes, and snippets.

@danmons
Last active July 15, 2025 02:50
Show Gist options
  • Save danmons/c00366c223ae404c23b97c51c8a1b0ee to your computer and use it in GitHub Desktop.
Save danmons/c00366c223ae404c23b97c51c8a1b0ee to your computer and use it in GitHub Desktop.
Orange Pi 5B + Armbian + Pathor / Panfrost / PanVK / Vulkan
# Tested 2025-02-12
# This will probably be out of date once Armbian updates
# These steps manually overwrite system files. This is for testing only. Do not run this on important/production things.
# This is not a script. These are just notes. Don't run this - use it as a guide only.
# Pathor and panvk require at least kernel 6.13 to produce a picture over HDMI
# And bleeding edge Mesa for the drivers
# To start this process, you will need to be running one of the Armbian 6.12 based images on your OPi5B board
# (6.1 based images will not work):
# https://www.armbian.com/orangepi-5/
# On a different system (can be x86, as long as it runs docker - WSL is fine and will work), clone the Armbian build git repo:
git clone --recurse-submodules=yes https://github.com/armbian/build.git
# Head into the repo and build the latest kernel/modules/device-tree for your board:
cd build
./compile.sh kernel BOARD=orangepi5 BRANCH=edge KERNEL_GIT=shallow
./compile.sh kernel-dtb BOARD=orangepi5 BRANCH=edge KERNEL_GIT=shallow
# In `output/debs` will be 4 deb package files. scp/rsync them to your OrangePi5B board
# and install them with
sudo dpkg -i *deb
# If you see any dependency errors, fix them with
sudo apt-get install -f -y
# Reboot to run the new kernel, and verify with
uname -a
# showing kernel 6.13 or higher.
# You MUST be on 6.13 or higher for the Mesa drivers to work.
# From here down, all operations are done as root inside your Armbian system on your OPi5B board
# On your OPi5B system, ensure that you have both the `deb` and `deb-src` repos enabled in /etc/apt/sources.list
# Then install some pre-requisite tools:
apt clean
apt update
apt install -y git gcc g++ make automake apt-rdepends mesa-utils vulkan-tools python3-venv python3-pip
# Mesa 25.1.0-devel update
# New OpenCL / NIR / SPIRV stuff has been added to the PanVK drivers
# this requires SPIRV-Tools to be updated past what Bookworm offers
# And LLVM/Clang requirements
apt install -y libclang-cpp15-dev libclang-15-dev clang-15 llvm-15-dev llvm-15 clang-15 lld-15 libllvmspirvlib-15-dev libllvmspirvlib15
# Normally you can run `apt-get build-dep mesa`
# but the versions supplied with Debian are too old, so we have to find these manually using apt-rdepends:
apt install $( apt-rdepends --build-depends --follow=none mesa | grep -v meson | grep ^' Build-Depends:' | awk '{print $2}' | tr '\n' ' ' )
# Meson, mako and ninja are required to build, however the Debian packages are too old. So we'll install them with pip:
python3 -m venv /opt/newmeson
source /opt/newmeson/bin/activate
pip install meson mako ninja
# Running `which meson` should return the full path to meson inside your /opt/newmeson Python virtual environment.
# Clone SPIRV-Tools needed for new OpenCL additions to PanVK
cd ~
git clone --recurse-submodules=yes https://github.com/KhronosGroup/SPIRV-Tools
# We need to clone the SPIRV-Headers inside that repo
git clone https://github.com/KhronosGroup/SPIRV-Headers SPIRV-Tools/external/spirv-headers
# Build and install SPIRV-Tools
cd SPIRV-Tools
mkdir builddir
cd builddir
cmake -DCMAKE_INSTALL_PREFIX=/usr -G Ninja ../
cmake --build .
cmake --install .
# Clone the Mesa git repo and cd into it
cd ~
git clone --recurse-submodules=yes https://gitlab.freedesktop.org/mesa/mesa.git
cd mesa
# If you've cloned this before, simply enter the directory and pull the newest changes
cd mesa
git pull --recurse-submodules=yes
# If you've built this before, remove the old `builddir` folder
rm -rf builddir
# Set up the project for the components needed:
# We want the Panfrost Gallium drivers for OpenGL
# We'll install Zink as well to play with OpenGL via Vulkan
# We'll use the Panfrost Vulkan drivers to install PanVK
# And the drm-shim tools seem to be required to make OpenGL work on this GPU
meson setup -Dprefix=/usr -Dgles2=enabled -Dgallium-drivers=panfrost,zink -Dvulkan-drivers=panfrost -Dvideo-codecs=all -Dtools=drm-shim,nir,panfrost -Dperfetto=true -Dteflon=true -Ddatasources=panfrost -Dbuildtype=release builddir/
# Compile
meson compile -C builddir/
# Install
meson install -C builddir/
# The drivers will overwrite your existing system files in /usr/lib. Note that if you `apt-get upgrade` at some later date
# and those updates re-install the Debian-supplied Mesa, this will break, and you'll need to
# recompile and reinstall again.
# Once installed, reboot, log in to your Arbian desktop, and run the following to check that the Panfrost drivers are active:
# For text based information about running drives:
glxinfo -B
vulkaninfo --summary
# Two small demo apps to test GLX and Vulkan:
glxgears
vkcube
# Note that these drivers are under heavy development, so expect bugs.
# Currently the Vulkan drivers are only at Vulkan 1.1, so games/apps that need Vulkan 1.3 or newer probably won't work.
# Note that Flatpak apps have a habit of installing their own Mesa builds, so if you want to try out games and emulators
# they'll need to be installed some other way - AppImage installs will work, and source installs too.
@sairuk
Copy link

sairuk commented Feb 28, 2025

handy guide, thanks a couple of notes

ln:71 needed cmake installed
ln:92 needed to pip install pyyaml

@sairuk
Copy link

sairuk commented Feb 28, 2025

to use a later version of Mesa with flatpak see mesa-git runtime on flathub-beta should just need to match your for the application branch

flatpak remote-add --if-not-exists --user flathub-beta https://flathub.org/beta-repo/flathub-beta.flatpakrepo
flatpak install --user flathub-beta org.freedesktop.Platform.GL.mesa-git//24.08

set the envvar FLATPAK_GL_DRIVERS to mesa-git prior to launch to use the alt runtime

FLATPAK_GL_DRIVERS=mesa-git flatpak run com.geeks3d.furmark

current mesa-git flatpak 24.08 still runs with llvmpipe so not much point, retained here for reference tho

@khanh-it
Copy link

(6.1 based images will not work):

Any idea why I still CAN compile the latest Mesa on kernel 6.1.84?
Linux orangepi5 6.1.84-vendor-rk35xx #1 SMP Thu Jan 9 03:09:01 CET 2025 aarch64 aarch64 aarch64 GNU/Linux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment