I couldn’t work on the device for a few months, but yesterday I tried do finally upgrade to the new Debian. I tried it before and I remember that it didn’t go well. I got a lot of problems and I didn’t get the lima driver working even compiling everything myself. In the end, I gave up.
So I invested a lot of time yesterday, and today to understand what was made to get the lima driver working with X11. I know that getting everything working was difficult but if only a few know what was done it is difficult for people to keep updating it if we don’t have much experience.
I found many duplicated libraries, strange modifications in the kernel, but it looks like I could understand most of it. Maybe from now, we can run mainline Debian without modifications, and in the near future, I can create a bare minimal Debian for the clockworkpi without many unnecessary packages installed.
The first thing to do is to create a backup of your sdcard if something goes wrong. It is likely I forgot one or two steps, but the trick ones should be here.
The first thing to note is that to get the mesa working from a Debian package we need to use Debian 11 or sid, as is documented here:
I decided to go all the way to sid, so we get the new updates from mesa as soon it goes out without the need to be compiling everything myself. The idea is to go closer to a official Debian release with full package manager, so we leave the updating process to them.
So I modified my sources.list to point to the official sid repo:
deb http://deb.debian.org/debian unstable main contrib deb-src http://deb.debian.org/debian unstable main
I only have these two lines. so we can run:
sudo apt update sudo apt full-upgrade
I recommend using tmux or screen when running it. It will take about 30 minutes or more to complete and it is possible that the device gets unresponsive, the connection can drop… I wouldn’t recommend to reboot it in the middle. If the connection drops, try to connect a physical keyboard via USB, go to the terminal and reinitialize the upgrade. During the installation, it will ask about keeping or creating new configuration files, and I choose to keep.
Just to remind: Debian will try to install another kernel, but it won’t work on the cpi. So it is better to not have the /boot mounted during this process so we don’t give the chance to the package manager delete our kernel/dtbos and we end up not able to boot after. It is an easy fix, but better avoid.
After everything completed, you can restart and comes the fun part. The lima driver stops to work, but everything else still running.
If you run glxgears will see that it is software rendering, but the mesa installed is the 20.0.6 so, should be able to work with lima.
I recompiled mesa and xserver countless times to understand why. So I think the first thing to do is to give permission to the cpi user to use the direct rendering hardware (DRI). For some reason that I don’t really know my user (cpi) loosed this permission. I suspect that the Debian upgrade did it. Probably they don’t expect the user to start the X, normally it is done with a desktop manager loaded before.
sudo usermod -a -G render cpi sudo usermod -a -G video cpi
With this you should be able to get kmscube running well with the lima driver, and if you don’t use X at all (like me) you are fine.
but if try to use X11 you should be getting the following error:
[ 41.187] (EE) AIGLX error: sun4i-drm does not export required DRI extension [ 41.332] (II) IGLX: Loaded and initialized swrast
and you are using software rendering instead. After hours debugging I found why: The xserver doesn’t recognize drivers with hyphen in the name, like our driversun4i-drm. After founding this problem I understood why in the kernel compilation patch from here:
diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index dab2914fa293..7d7d0bb490b8 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -1106,6 +1106,8 @@ dtb-$(CONFIG_MACH_SUN8I) += \ sun8i-h3-orangepi-zero-plus2.dtb \ sun8i-h3-rervision-dvk.dtb \ sun8i-r16-bananapi-m2m.dtb \ + sun8i-r16-clockworkpi-cpi3.dtb \ + sun8i-r16-clockworkpi-cpi3-hdmi.dtb \ sun8i-r16-nintendo-nes-classic.dtb \ sun8i-r16-nintendo-super-nes-classic.dtb \ sun8i-r16-parrot.dtb \ diff --git a/arch/arm/boot/dts/sun8i-r16-clockworkpi-cpi3-hdmi.dts b/arch/arm/boot/dts/ sun8i-r16-clockworkpi-cpi3-hdmi.dts new file mode 100644 index 000000000000..22ba16fccb2f --- /dev/null +++ b/arch/arm/boot/dts/sun8i-r16-clockworkpi-cpi3-hdmi.dts @@ -0,0 +1,372 @@ +/*
they change the driver name to sun4i_drm on line 4816. I removed this section of my kernel so the kernel asks for the correct driver name sun4i-drm, the same generated by mesa, otherwise we have to create endless symbolic links to avoid this problem.
Fortunately I found the solution in one patch that address our problem without the need to modify the kernel. It is from one month ago:
This pacth is already in the master, and it should be available in the Debian repository xserver-xorg-core 1.20.9 when it comes out in a few weeks. But since I found the patch I added it to the deb source and generated my package xserver-xorg-core_1.20.8 with the patch applied.
I installed it with:
sudo dpkg -i xserver-xorg-core_1.20.8-2_armhf.deb
If someones ask I can provide the deb file. The good news is that it will be soon an official package, so no need to compile ourselves. But you need a kernel without the driver name change like mine.
I have my kernel here:
After my patched package installation I got X with hardware acceleration:
[ 30.666] (II) AIGLX: Loaded and initialized sun4i-drm [ 30.666] (II) GLX: Initialized DRI2 GL provider for screen 0
If you run now glxheads, you should get: