Rock 3A OpenGL driver

Hi,
How to enable and configure OpenGL on Debian Rock 3A ?
I have this error:

Testing video drivers…

SDL_VIDEODRIVER available: x11 wayland dummy

SDL_Init(): No available video device

Exiting: 107

root@rock-3a:/home/root/prova# echo $SDL_VIDEODRIVER

root@rock-3a:/home/root/prova#

Thanks

Rock 3A support OpenGLES 3.2.

In order to have 3D HW acceleration (aka OpenGLES 3) with legacy kernel you need the following steps:

  1. Set up RGA
  2. Set up libmali for rk3568 (X11)
  3. Set up X11 glamor
  4. Build and install this SDL here:
    https://github.com/avafinger/SDL

Rockchip had 1.,2. and 3. with pre-built deb packages but for some reason they removed it or moved it to somewhere else.

While i worked on this, someone ported this work to buildroot , so i think you can find everything there.

If you want OpenGLES and SDL with mainline kernel, there seems to be a working panfrost but i haven’t follow this work. With panfrost you just need to build a stock SDL with latest mesa, i think.

Good luck.

I wanted to use TotalCross to make touch GUI, which works on Raspberry OS, but here it gives me this error due to OpenGL 2.
However it is very cumbersome, I am trying Electronjs and it seems to work.
I also ported the distro from Debian Buster to Debian 11 Bullseye.

Thanks for the help

I got this issue too.
---- SDL still use CPU but NOT GPU for accelerating, thought hwaccel had been setup.

Is it a driver problem,
Have you solve it?
Thanks.

Did you build and install item 4.?

Make sure you remove the stock SDL before you build it and run glmark2-es2.
Here is how you build and install:

git clone https://github.com/avafinger/SDL
cd SDL
export  CFLAGS="-I/usr/src/linux-headers-$(uname -r)/include"
rm ./include/SDL_config.h
./autogen.sh
./configure --prefix=/usr --enable-video-kmsdrm --enable-video-rockchip --enable-video-x11 --disable-video-vulkan  --disable-video-wayland 
make
sudo make install

Testing the SDL with hardware acceleration:

cd test/
./testgles2 (or sudo ./testgles2 if you don't have user permission)

Oh,thanks a lot ! I installed SDL2 as your suggest. SDL2 seems work OK.

but an error occurred when run “ glmark2-es2 ”:
ERROR: The DDK is not compatible with any of the Mali GPUs on the system.
The DDK was built for 0x860 r2p0 status range [0…15], but none of the GPUs matched:
Error: eglInitialize() failed with error: 0x3001
Error: main: Could not initialize canvas

then I check the OpenGL version:
glxinfo |grep “OpenGL version” => OpenGL version string: 3.1 Mesa 18.3.6

I notice it’s a wrong version for RockChip, but how can i update OpenGL to a right version like “OpenGL ES 3.2” for RockChip. I’m confused about that. Can i get more help from you ?

Thanks~

Running glmark2-es2 ensures that you have mali working in your setup.
If glmark2-es2 does not work, sdl will not work with hw accel.

AFAIK there are two versions of mali blob, you got the wrong one for your kernel version Try the other version.

That means you still have gl rendering by software only.

Good reading:

Yes,it’s still using software rendering.

but I’ve install OpenGL ES2.0 by “sudo apt-get install libgles2-mesa libgles2-mesa-dev”.
And “libMali.so” has been found at common lib paths.

What else i’m missing?

thanks~

Is it not sudo apt-get install mesa-utils and that will bring in all dependencies such as mesa-drm

Often the repo’s lag behind and its better to git clone mesa-drm & mesa and build.
This was always a pretty easy guide and is still relevent

Last time I ran its the most up to date 21.3.8 version as likely your kernel doesn’t support the newer 22. tree

Its just DRM & Mesa you need

sorry, i had a bit of a problem.
I encountered a strange situation, I installed a 16Gb emmc with a clean Debian Buster image.
Then I installed a 16Gb SD card on which I upgraded to Bullseye 11 and on which I am running these tests.
the problem that at every 2 reboots or at random I discovered that it gave me the Debian 10 screen and then the boot was from emmc, but now I want to work from SD and then transfer each update tried, so as to use the SD for testing , but without removing the emmc mounted all in one box.
Radxa did not foresee an Emmc-SD microswitch, it would have been useful, but after all I had a problem and I panicked, I could not restart neither SD nor Emmc even using one at a time. By mounting the memories on a linux PC, I discovered that both sd and emmc had the boot folder empty, but how was this possible? Reading in the wiki I deduced that since there is the possibility that the SD writes to the emmc to transfer the content using the appropriate jumpers as per the scheme, my continuous reboots, even abrupt, have corrupted these files.
Now I use both memories again, but I keep the Maskrom jumper short, and it goes perfectly from SD, when I’m ready I will remove the jumper and the SD and everything will start from emmc.

All this is not in the documentation, and they even say that jumpers are no longer needed.

root@rock-3a:~/SDL# make
/bin/bash build-scripts/updaterev.sh
/bin/bash build-scripts/mkinstalldirs build
mkdir -p – build
touch build/.created
CC build/SDL.lo
CC build/SDL_assert.lo
CC build/SDL_dataqueue.lo
CC build/SDL_error.lo
CC build/SDL_hints.lo
CC build/SDL_log.lo
CC build/SDL_atomic.lo
CC build/SDL_spinlock.lo
CC build/SDL_audio.lo
CC build/SDL_audiocvt.lo
CC build/SDL_audiodev.lo
In file included from /usr/include/aarch64-linux-gnu/bits/fcntl-linux.h:353,
from /usr/include/aarch64-linux-gnu/bits/fcntl.h:61,
from /usr/include/fcntl.h:35,
from /root/SDL/src/audio/SDL_audiodev.c:27:
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/falloc.h:13:2: error: unknown type name ‘__s16’
13 | __s16 l_type;
| ^~~~~
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/falloc.h:14:2: error: unknown type name ‘__s16’
14 | __s16 l_whence;
| ^~~~~
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/falloc.h:15:2: error: unknown type name ‘__s64’
15 | __s64 l_start;
| ^~~~~
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/falloc.h:16:2: error: unknown type name ‘__s64’
16 | __s64 l_len; /* len == 0 means until end of file */
| ^~~~~
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/falloc.h:17:2: error: unknown type name ‘__s32’
17 | __s32 l_sysid;
| ^~~~~
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/falloc.h:18:2: error: unknown type name ‘__u32’
18 | __u32 l_pid;
| ^~~~~
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/falloc.h:19:2: error: unknown type name ‘__s32’
19 | __s32 l_pad[4]; /* reserved area */
| ^~~~~
In file included from /usr/include/aarch64-linux-gnu/asm/stat.h:1,
from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/stat.h:6,
from /usr/include/aarch64-linux-gnu/bits/statx.h:31,
from /usr/include/aarch64-linux-gnu/sys/stat.h:446,
from /root/SDL/src/audio/SDL_audiodev.c:29:
/usr/include/asm-generic/stat.h:24:8: error: redefinition of ‘struct stat’
24 | struct stat {
| ^~~~
In file included from /usr/include/fcntl.h:78,
from /root/SDL/src/audio/SDL_audiodev.c:27:
/usr/include/aarch64-linux-gnu/bits/stat.h:58:8: note: originally defined here
58 | struct stat
| ^~~~
/usr/include/asm-generic/stat.h:37:8: error: expected ‘:’, ‘,’, ‘;’, ‘}’ or ‘attribute’ before ‘.’ token
37 | long st_atime; /* Time of last access. */
| ^~~~~~~~
In file included from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/uapi/linux/stat.h:5,
from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/stat.h:7,
from /usr/include/aarch64-linux-gnu/bits/statx.h:31,
from /usr/include/aarch64-linux-gnu/sys/stat.h:446,
from /root/SDL/src/audio/SDL_audiodev.c:29:
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/types.h:15:26: error: conflicting types for ‘fd_set’
15 | typedef __kernel_fd_set fd_set;
| ^~~~~~
In file included from /usr/include/aarch64-linux-gnu/sys/types.h:179,
from include/SDL_stdinc.h:40,
from include/SDL_log.h:40,
from /root/SDL/src/audio/…/SDL_internal.h:125,
from /root/SDL/src/audio/SDL_audiodev.c:21:
/usr/include/aarch64-linux-gnu/sys/select.h:70:5: note: previous declaration of ‘fd_set’ was here
70 | } fd_set;
| ^~~~~~
In file included from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/uapi/linux/stat.h:5,
from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/stat.h:7,
from /usr/include/aarch64-linux-gnu/bits/statx.h:31,
from /usr/include/aarch64-linux-gnu/sys/stat.h:446,
from /root/SDL/src/audio/SDL_audiodev.c:29:
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/types.h:16:25: error: conflicting types for ‘dev_t’
16 | typedef __kernel_dev_t dev_t;
| ^~~~~
In file included from include/SDL_stdinc.h:40,
from include/SDL_log.h:40,
from /root/SDL/src/audio/…/SDL_internal.h:125,
from /root/SDL/src/audio/SDL_audiodev.c:21:
/usr/include/aarch64-linux-gnu/sys/types.h:59:17: note: previous declaration of ‘dev_t’ was here
59 | typedef __dev_t dev_t;
| ^~~~~
In file included from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/uapi/linux/stat.h:5,
from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/stat.h:7,
from /usr/include/aarch64-linux-gnu/bits/statx.h:31,
from /usr/include/aarch64-linux-gnu/sys/stat.h:446,
from /root/SDL/src/audio/SDL_audiodev.c:29:
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/types.h:26:26: error: conflicting types for ‘timer_t’
26 | typedef __kernel_timer_t timer_t;
| ^~~~~~~
In file included from /usr/include/aarch64-linux-gnu/sys/types.h:130,
from include/SDL_stdinc.h:40,
from include/SDL_log.h:40,
from /root/SDL/src/audio/…/SDL_internal.h:125,
from /root/SDL/src/audio/SDL_audiodev.c:21:
/usr/include/aarch64-linux-gnu/bits/types/timer_t.h:7:19: note: previous declaration of ‘timer_t’ was here
7 | typedef __timer_t timer_t;
| ^~~~~~~
In file included from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/uapi/linux/stat.h:5,
from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/stat.h:7,
from /usr/include/aarch64-linux-gnu/bits/statx.h:31,
from /usr/include/aarch64-linux-gnu/sys/stat.h:446,
from /root/SDL/src/audio/SDL_audiodev.c:29:
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/types.h:46:26: error: conflicting types for ‘loff_t’
46 | typedef __kernel_loff_t loff_t;
| ^~~~~~
In file included from include/SDL_stdinc.h:40,
from include/SDL_log.h:40,
from /root/SDL/src/audio/…/SDL_internal.h:125,
from /root/SDL/src/audio/SDL_audiodev.c:21:
/usr/include/aarch64-linux-gnu/sys/types.h:42:18: note: previous declaration of ‘loff_t’ was here
42 | typedef __loff_t loff_t;
| ^~~~~~
In file included from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/uapi/linux/stat.h:5,
from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/stat.h:7,
from /usr/include/aarch64-linux-gnu/bits/statx.h:31,
from /usr/include/aarch64-linux-gnu/sys/stat.h:446,
from /root/SDL/src/audio/SDL_audiodev.c:29:
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/types.h:112:15: error: conflicting types for ‘uint64_t’
112 | typedef u64 uint64_t;
| ^~~~~~~~
In file included from /usr/include/stdint.h:37,
from /usr/lib/gcc/aarch64-linux-gnu/10/include/stdint.h:9,
from /usr/include/inttypes.h:27,
from include/SDL_stdinc.h:75,
from include/SDL_log.h:40,
from /root/SDL/src/audio/…/SDL_internal.h:125,
from /root/SDL/src/audio/SDL_audiodev.c:21:
/usr/include/aarch64-linux-gnu/bits/stdint-uintn.h:27:20: note: previous declaration of ‘uint64_t’ was here
27 | typedef __uint64_t uint64_t;
| ^~~~~~~~
In file included from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/uapi/linux/stat.h:5,
from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/stat.h:7,
from /usr/include/aarch64-linux-gnu/bits/statx.h:31,
from /usr/include/aarch64-linux-gnu/sys/stat.h:446,
from /root/SDL/src/audio/SDL_audiodev.c:29:
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/types.h:113:15: error: conflicting types for ‘u_int64_t’
113 | typedef u64 u_int64_t;
| ^~~~~~~~~
In file included from include/SDL_stdinc.h:40,
from include/SDL_log.h:40,
from /root/SDL/src/audio/…/SDL_internal.h:125,
from /root/SDL/src/audio/SDL_audiodev.c:21:
/usr/include/aarch64-linux-gnu/sys/types.h:161:20: note: previous declaration of ‘u_int64_t’ was here
161 | typedef __uint64_t u_int64_t;
| ^~~~~~~~~
In file included from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/uapi/linux/stat.h:5,
from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/stat.h:7,
from /usr/include/aarch64-linux-gnu/bits/statx.h:31,
from /usr/include/aarch64-linux-gnu/sys/stat.h:446,
from /root/SDL/src/audio/SDL_audiodev.c:29:
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/types.h:114:15: error: conflicting types for ‘int64_t’
114 | typedef s64 int64_t;
| ^~~~~~~
In file included from /usr/include/aarch64-linux-gnu/sys/types.h:155,
from include/SDL_stdinc.h:40,
from include/SDL_log.h:40,
from /root/SDL/src/audio/…/SDL_internal.h:125,
from /root/SDL/src/audio/SDL_audiodev.c:21:
/usr/include/aarch64-linux-gnu/bits/stdint-intn.h:27:19: note: previous declaration of ‘int64_t’ was here
27 | typedef __int64_t int64_t;
| ^~~~~~~
In file included from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/uapi/linux/stat.h:5,
from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/stat.h:7,
from /usr/include/aarch64-linux-gnu/bits/statx.h:31,
from /usr/include/aarch64-linux-gnu/sys/stat.h:446,
from /root/SDL/src/audio/SDL_audiodev.c:29:
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/types.h:135:23: error: conflicting types for ‘blkcnt_t’
135 | typedef unsigned long blkcnt_t;
| ^~~~~~~~
In file included from include/SDL_stdinc.h:40,
from include/SDL_log.h:40,
from /root/SDL/src/audio/…/SDL_internal.h:125,
from /root/SDL/src/audio/SDL_audiodev.c:21:
/usr/include/aarch64-linux-gnu/sys/types.h:192:20: note: previous declaration of ‘blkcnt_t’ was here
192 | typedef __blkcnt_t blkcnt_t; /* Type to count number of disk blocks. */
| ^~~~~~~~
In file included from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/time.h:5,
from /usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/stat.h:19,
from /usr/include/aarch64-linux-gnu/bits/statx.h:31,
from /usr/include/aarch64-linux-gnu/sys/stat.h:446,
from /root/SDL/src/audio/SDL_audiodev.c:29:
/usr/src/linux-headers-4.19.193-42-rockchip-ge29be2b2ed27/include/linux/cache.h:6:10: fatal error: asm/cache.h: No such file or directory
6 | #include <asm/cache.h>
| ^~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:297: build/SDL_audiodev.lo] Error 1

and in any case, OpenGL doesn’t work for me.

Weird kernel headers, i think your kernel headers are a copy of the kernel tree that is not intended for userland.

Anyway, build in a new console session without the:
export CFLAGS="-I/usr/src/linux-headers-$(uname -r)/include"

it will use the default kernel-headers.

Hey @avaf I’ve come to this thread quite late but it seems the build steps are out of date correct?

Could you add updated steps?

Thanks!