Any GPU drivers on RK3568?

Board: ROCK pi 3A
System: Ubuntu 20.04
Does RK3568 have OpenGL or Vulkan dirvers available?
I saw this is-vulkan-api-available-on-radxa-zero, but it seems only for Android.

I am new to Arm linux. I use the Qt as the OpenCV backend, when I use the cv::imshow with HDMI monitor. This function takes a long time to run and increases a lot of CPU usage.
I am wondering if this phenomenon will be improved if OpenGL or Vulkan is enabled when compiling OpenCV or Qt.

1 Like

I don’t use Qt but in my case, cv::imshow takes a lot of CPU usage. i don’t know how to tell OpenCV to use hardware acceleration, but hardware acceleration is done with OpenGL ES and mali (legacy kernel) or panfrost (modern kernel). In my experiments i use SDL2 for hardware acceleration, reducing CPU usage from 300% to 80% (FHD). Maybe you need to tell (or build) Qt to use OpenGLES (if not already) and then OpenCV will output with hw accel.

1 Like

Yes, Qt can build with the OpenGL ES.
This is my first to use cross-compilation toolchain. Because I thought I needed to find an OpenGL ES driver first to enable OpenGL ES. I just want to show the result of image processing with cv::imshow.

So, you mean these released images already supported the OpenGL ES? Theoretically, I only need to set the path of the OpenGL ES library(.so and .h files ) in rock 3A when cross-compiling Qt?

No, i just wanted to tell you that you need to set up OpenGL ES, with mali or panfrost. not sure if the referred images have that support. You should search for dpkg -l|grep mali or dmesg|grep panfrost

I have my custom image and i don’t usually cross-compile, ahh, ok, sometimes the kernel :slight_smile:

1 Like

My Rock pi 3A was sent for repair, so I can’t confirm whether image already supported OpenGL ES.:frowning:
If not supported, Could you give me some advice on how to set it up? Shoule I also follow the steps in you reply?
I saw this Rock3A_8GB - Enabled hardware acceleration in Chrome!, it seems enable the OpenGL ES, unfortunately no documentation/info there.

Add these to the steps:

  • build Qt with OPENGL
  • build Opencv with -DWITH_QT=ON -DWITH_OPENGL=ON

I got my board back. And try the dpkg -l|grep mali or dmesg|grep panfrost, but seems no mali lib.

rock@rock-3a:~$ dpkg -l|grep mali
ii  gpg                                              2.2.19-3ubuntu2.2                   arm64        GNU Privacy Guard -- minimalist public key operations
ii  libmnl0:arm64                                    1.0.4-2                             arm64        minimalistic Netlink communication library
ii  libmoo-perl                                      2.003006-1                          all          Minimalist Object Orientation library (with Moose compatibility)
ii  librole-tiny-perl                                2.001004-1                          all          Perl module for minimalist role composition
ii  libtry-tiny-perl                                 0.30-1                              all          module providing minimalistic try/catch
rock@rock-3a:~$ dmesg|grep panfrost
rock@rock-3a:~$ 

Then I searched some forums, and ready to try the following two ways:

  • Buildroot, as you said, I can find libs such as libmali there, then I will study how to use the buildroot to make embeded linux with opengl supported.
  • Panfrost, panfrost seems need to the kernel version > 5.x, but the current radxa’s kernel version is 4.19. So I still need to build the kernel. By the way, I did find a image with panfrost https://github.com/qxhome/rk3568-kernel5.10-alldrivers/releases , but still need to figure out how to change the rootfs partition size on emmc(I don’t have a tool to read emmc directly). Maybe rebuild the source code to change the default rootfs size will work.

It looks like the two ways both need to rebuild the kernel. There’s still a lot to learn.:exploding_head::exploding_head:
Is there anything wrong with my ways?

No, that’s the way to go.

I suggest you try Manjaro and/or Armbian, but since you will be using Qt, you better start with a CLI image and build everything from scratch. Note that with the mainline kernel you don’t need the mali blobs but i think you will need to build the latest Mesa. Maybe you find some Images ready to build Qt.

You can ask these people for the best Image to start with for your case instead of building everything that takes a lot of times:
@amazingfate @igorp @spikerguy @mara

2 Likes

Panfrost driver in mainline kernel supports vulkan and opengl. You can try my image: https://github.com/amazingfate/armbian-rock3a-images/

Thank you so mach. I found your repository yesterday. But I only have rock3a board and emmc without emmc reader. This guide Install on eMMC from USB port seems to only support GPT images. I’m working on how to turn image into gpt. This page (https://docs.armbian.com/User-Guide_Getting-Started/#how-to-install-to-emmc-nand-sata-usb) looks like I have to have an SD card.

At this time, I am thinking of using the kernel of this repository to replace the kernel of Rockchip Debian SDK to regenerate the gpt image.

Armbian image is gpt partition table. You can try flashing it in maskrom mode.

Indeed! It seems work well.

But I need to take this opportunity to learn how to build kernel and image.

Oh, I was wrong about RKDevTool_Release_v2.84.
For the first time, I clicked on the dev partition button out of curiosity, and then I clicked run button and get “download boot failed”. I tried to disconnect and reconnect to the PC, and then click run button and the download is successful. I thought it was a GPT image issue. So sorry.

Rockpi4/dev/install-opencv - Radxa Wiki

after the install

cv::imshow can be used with an OpenGL Window

namedWindow("1",WINDOW_OPENGL);
imshow("1", in_image);
waitKey(0);

Unfortunately, this does not work for non Desktop:

Unable to init server: Could not connect: Connection refused

(OpenGLES:61329): Gtk-WARNING **: 14:47:34.966: cannot open display:

I spent a lot of time trying to solve the problem of Qt5.15.5 with openGL cross compile. Using armbian image from here:https://github.com/amazingfate/armbian-rock3a-images/

Maybe it’s a problem with the g++ version. The cross toolchain I used at the beginning was 9.4.0 in ubuntu20.04. There were variety errors when compiling Qt, because the versions in the armbian image were g++ 11.2.0 and ubuntu22. So I changed to aarch64-linux-gnu 11.2.2 and Ubuntu22.04 on my x86 PC, but there are still some errors when -sysroot is set. I tried to compile it all on rock3a, finally, this time there was no error, but it took nearly 5 hours to compile Qt, and no error was reported when compiling opencv, but at the end of compiling my own app, the following error appeared.

qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, webgl.

I use locate libqxcb.so to find the lib ane got
/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqxcb.so,
There are some libraries of Qt5 in the amrbian image. Then I set the export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/
and export QT_DEBUG_PLUGINS=1
there are part of output:

Cannot load library /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqxcb.so: (/lib/aarch64-linux-gnu/libQt5XcbQpa.so.5: undefined symbol: _ZN23QPlatformVulkanInstance22presentAboutToBeQueuedEP7QWindow, version Qt_5_PRIVATE_API)
QLibraryPrivate::loadPlugin failed on "/usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqxcb.so" : "Cannot load library /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqxcb.so: (/lib/aarch64-linux-gnu/libQt5XcbQpa.so.5: undefined symbol: _ZN23QPlatformVulkanInstance22presentAboutToBeQueuedEP7QWindow, version Qt_5_PRIVATE_API)"

So I am trying to compile this lib:(
Oh God!:no_mouth:‍:fog::no_mouth:‍:fog::no_mouth:‍:fog:

libqt5gui5 provides file /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqxcb.so. I guess the official qt5 package from ubuntu is not build with vulkan enabled.

I did not choose vulkan when using Qt ./configure.
Does this mean that f I want to use the /usr/lib/aarch64-linux-gnu/qt5/plugins/platforms/libqxcb.so , I have to compile Qt with vulkan. Otherwise, I have to compile the libqxcb.so with opengl.

By the way, here is config.summary:

EGL .................................... yes
  OpenVG ................................. no
  OpenGL:
    Desktop OpenGL ....................... no
    OpenGL ES 2.0 ........................ yes
    OpenGL ES 3.0 ........................ yes
    OpenGL ES 3.1 ........................ yes
    OpenGL ES 3.2 ........................ yes
  Vulkan ................................. no
  Session Management ..................... yes
Features used by QPA backends:
  evdev .................................. yes
  libinput ............................... no
  INTEGRITY HID .......................... no
  mtdev .................................. no
  tslib .................................. no
  xkbcommon .............................. yes
  X11 specific:
    XLib ................................. yes
    XCB Xlib ............................. yes
    EGL on X11 ........................... no
    xkbcommon-x11 ........................ yes
QPA backends:
  DirectFB ............................... no
  EGLFS .................................. yes
  EGLFS details:
    EGLFS OpenWFD ........................ no
    EGLFS i.Mx6 .......................... no
    EGLFS i.Mx6 Wayland .................. no
    EGLFS RCAR ........................... no
    EGLFS EGLDevice ...................... no
    EGLFS GBM ............................ no
    EGLFS VSP2 ........................... no
    EGLFS Mali ........................... no
    EGLFS Raspberry Pi ................... no
    EGLFS X11 ............................ no
  LinuxFB ................................ yes
  VNC .................................... yes
  XCB:
    Using system-provided xcb-xinput ..... no
    Native painting (experimental) ....... no
    GL integrations:
      GLX Plugin ......................... no
      EGL-X11 Plugin ..................... no

When I run my app, these options appear to cause the following error :

QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled
QFactoryLoader::QFactoryLoader() checking directory path "/home/dm/qt5.15.5/plugins/platforms/accessible" ...
QFactoryLoader::QFactoryLoader() checking directory path "/home/dm/rock3a/lib/qt5.15.5/plugins/accessible" ...
QFactoryLoader::QFactoryLoader() checking directory path "/home/dm/rock3a/build/accessible" ...
Trace/breakpoint trap

These dirs did not exist.

I checked the config.log and there is an error when test the egl-x11

> aarch64-linux-gnu-g++ -c -pipe --sysroot=/mnt/rock3a --sysroot=/mnt/rock3a -O2 -w -fPIC  -I. -I/home/dm-wsl/qt-everywhere-src-5.15.5/qtbase/mkspecs/linux-aarch64-gnu-g++ -o main.o main.cpp
> In file included from /mnt/rock3a/usr/include/EGL/egl.h:20,
>                  from main.cpp:7:
> main.cpp: In function ‘int main(int, char**)’:
> main.cpp:13:20: error: invalid conversion from ‘EGLNativeDisplayType’ {aka ‘void*’} to ‘Display*’ [-fpermissive]
>    13 |     Display *dpy = EGL_DEFAULT_DISPLAY;
>       |                    ^~~~~~~~~~~~~~~~~~~
>       |                    |
>       |                    EGLNativeDisplayType {aka void*}
> main.cpp:15:11: error: invalid conversion from ‘EGLNativeDisplayType’ {aka ‘void*’} to ‘Display*’ [-fpermissive]
>    15 |     dpy = egldpy;
>       |           ^~~~~~
>       |           |
>       |           EGLNativeDisplayType {aka void*}
> gmake: *** [Makefile:783: main.o] Error 1
test config.qtbase_gui.tests.egl-x11 FAILED

I’m not sure if this is the problem that is preventing my app from running cv::imshow

See if this bug is related: https://bugreports.qt.io/browse/QTBUG-72567