_Mark_
Posts: 101
Joined: Sun Jun 02, 2013 8:04 am

RPi4: Qt5 and GPU confusion

Wed Jan 29, 2020 11:52 pm

After several years I come back to RPi4 and I need to update my own rootfs to run Qt5/QML applications, using hw acceleration.
All the trials I did in these weeks failed utterly:

Buildroot RPi4 64-bit with Mesa drivers
Tried with and without `dtoverlay=vc4-fkms-v3d` in `config.txt`. I always get this error: "Could not find DRM device!".

Buildroot RPi4 32-bit with rpi-userland
No more DRM error, but nothing happens when I launch a Qt5 application. I mean, nothing is rendered on the screen.

Yocto RPi4 with vchiq (from https://jumpnowtek.com/rpi/Raspberry-Pi ... Yocto.html)
Same as above.
Enabling `dtoverlay=vc4-fkms-v3d` leads to "device already in use" error.
Using `-platform eglfs` the applications hang and nothing is shown, as above.
Running the applications with `-platform linuxfb` leads to run with wrong colors, and - I guess - without any GPU acceleration.

So far, I haven't catch a working setup yet. And I'm a bit (...) confused about DRM/KMS/eglfs/vc4/vc6/mesa/opengl/fb stuff.

Would you please help me to understand how to run Qt5/QML applications on RPi4 with hardware (GPU) acceleration?
Of course feel free to ask me any details you might need. I'm working on so much systems I don't know what to tell...

I read through this huge thread: https://www.raspberrypi.org/forums/view ... 8&t=243611, but it's so long I didn't find a clear answer to my doubts.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 30164
Joined: Sat Jul 30, 2011 7:41 pm

Re: RPi4: Qt5 and GPU confusion

Thu Jan 30, 2020 7:46 am

So, have you tried vanilla raspbian running the desktop?
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Working in the Applications Team.

_Mark_
Posts: 101
Joined: Sun Jun 02, 2013 8:04 am

Re: RPi4: Qt5 and GPU confusion

Thu Jan 30, 2020 7:53 am

jamesh wrote:
Thu Jan 30, 2020 7:46 am
So, have you tried vanilla raspbian running the desktop?
No, don't want any desktop environment! I may try Raspbian Lite (without X), but I would prefer a customized distro because I need specific features not so easy to achieve with the default os.
It seems there's a lack of documentations on both Qt and RPi sides.
I mean, I don't find a document where I can read:

> To run Qt/QML application on RPi with GPU acceleration you need to compile Qt5 with this mandatory configuration flags, install those libraries, add these lines in config.txt

Am I asking too much? :D

lspd
Posts: 1
Joined: Thu Feb 20, 2020 12:29 pm

Re: RPi4: Qt5 and GPU confusion

Thu Feb 20, 2020 1:17 pm

Hi,

I have also been struggling making Qt works with hw acceleration and buildroot and I finally succeeded.
I am not sure what I did or why it didn't work in the first place though.
Here what I know :
I used the defconfig raspberryPi4-64 in which I changed the following :
In Toolchain I selected glibc instead of uClibc otherwise I got a segmentation fault with every Qt applications
In Graphics libraries I selected Gallium v3d (BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D), Gallium v4c (BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4) and Gallium KMSRO (BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO) and OpenGl ES ((BR2_PACKAGE_MESA3D_OPENGL_ES)
I selected Qt5 with OpenGl ES 2.0+ (BR2_PACKAGE_QT5BASE_OPENGL_ES2) and eglfs (BR2_PACKAGE_QT5BASE_EGLFS) and the modules I wanted
In Hardware handling/Firmware i select the 'extended' firmware to boot ((BR2_PACKAGE_RPI_FIRMWARE_X), I am not sure this is needed.
Then on the Rp4 I figured that the mesa gpu modules didn't started automatically at boot but did start successfully with the command 'modprobe vc4 & modprobe v3d'. I think this is may be your issue if you got the message "Could not find DRM device!".
You can also check these directories :
/lib/modules/4.X.X.X/kernel/drivers/gpu/drm see if you have drm.ko, v3d/v3d.ko and vc4/vc4.ko (otherwise it means some mesa drivers are missing) /usr/lib/dri see if you have v3d_dir.so and vc4_dri.so, at some point I was missing vc4_dri.so and it causes an other error with Qt applications.
If you have the modules you should be able to run vc4 and v3d with modprobe, you can check with lsmod command if it is running. While running you should have card0 and card1 in /dev/dri and no more "Could not find DRM device!". From what I read online card0 is for 3d acceleration with v3d and card1 for render with vc4. At some point I was able to load the module but still get nothing in /dev/dri, I don't know why, maybe because i was missing 'dtoverlay=vc4-fkms-v3d` in `config.txt.

That it, I hope it can help somebody.

hbabuc
Posts: 3
Joined: Fri Oct 09, 2020 7:51 am

Re: RPi4: Qt5 and GPU confusion

Fri Oct 09, 2020 12:01 pm

lspd wrote:
Thu Feb 20, 2020 1:17 pm
Hi,

I have also been struggling making Qt works with hw acceleration and buildroot and I finally succeeded.
I am not sure what I did or why it didn't work in the first place though.
Here what I know :
I used the defconfig raspberryPi4-64 in which I changed the following :
In Toolchain I selected glibc instead of uClibc otherwise I got a segmentation fault with every Qt applications
In Graphics libraries I selected Gallium v3d (BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D), Gallium v4c (BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4) and Gallium KMSRO (BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO) and OpenGl ES ((BR2_PACKAGE_MESA3D_OPENGL_ES)
I selected Qt5 with OpenGl ES 2.0+ (BR2_PACKAGE_QT5BASE_OPENGL_ES2) and eglfs (BR2_PACKAGE_QT5BASE_EGLFS) and the modules I wanted
In Hardware handling/Firmware i select the 'extended' firmware to boot ((BR2_PACKAGE_RPI_FIRMWARE_X), I am not sure this is needed.
Then on the Rp4 I figured that the mesa gpu modules didn't started automatically at boot but did start successfully with the command 'modprobe vc4 & modprobe v3d'. I think this is may be your issue if you got the message "Could not find DRM device!".
You can also check these directories :
/lib/modules/4.X.X.X/kernel/drivers/gpu/drm see if you have drm.ko, v3d/v3d.ko and vc4/vc4.ko (otherwise it means some mesa drivers are missing) /usr/lib/dri see if you have v3d_dir.so and vc4_dri.so, at some point I was missing vc4_dri.so and it causes an other error with Qt applications.
If you have the modules you should be able to run vc4 and v3d with modprobe, you can check with lsmod command if it is running. While running you should have card0 and card1 in /dev/dri and no more "Could not find DRM device!". From what I read online card0 is for 3d acceleration with v3d and card1 for render with vc4. At some point I was able to load the module but still get nothing in /dev/dri, I don't know why, maybe because i was missing 'dtoverlay=vc4-fkms-v3d` in `config.txt.

That it, I hope it can help somebody.
Hello friend,
I did it what you all said and I can't execute my Qt5 qml app. I'm getting this error message :
QStandardPaths: wrong permission on runtime directory /usr/bin/, 7755 instead of 7700
drmModeGetResources failed (Operation not supported)
no screens available, assuming 24 -bit color
Cannot create window: no screens available.


If you solved this issue can you help me ? My topic is here -> viewtopic.php?f=29&t=287800

By the way kmscube working properly on my system.

shrsulav
Posts: 1
Joined: Wed Dec 16, 2020 11:50 am

Re: RPi4: Qt5 and GPU confusion

Wed Dec 16, 2020 11:54 am

lspd wrote:
Thu Feb 20, 2020 1:17 pm
Hi,

I have also been struggling making Qt works with hw acceleration and buildroot and I finally succeeded.
I am not sure what I did or why it didn't work in the first place though.
Here what I know :
I used the defconfig raspberryPi4-64 in which I changed the following :
In Toolchain I selected glibc instead of uClibc otherwise I got a segmentation fault with every Qt applications
In Graphics libraries I selected Gallium v3d (BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_V3D), Gallium v4c (BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_VC4) and Gallium KMSRO (BR2_PACKAGE_MESA3D_GALLIUM_DRIVER_KMSRO) and OpenGl ES ((BR2_PACKAGE_MESA3D_OPENGL_ES)
I selected Qt5 with OpenGl ES 2.0+ (BR2_PACKAGE_QT5BASE_OPENGL_ES2) and eglfs (BR2_PACKAGE_QT5BASE_EGLFS) and the modules I wanted
In Hardware handling/Firmware i select the 'extended' firmware to boot ((BR2_PACKAGE_RPI_FIRMWARE_X), I am not sure this is needed.
Then on the Rp4 I figured that the mesa gpu modules didn't started automatically at boot but did start successfully with the command 'modprobe vc4 & modprobe v3d'. I think this is may be your issue if you got the message "Could not find DRM device!".
You can also check these directories :
/lib/modules/4.X.X.X/kernel/drivers/gpu/drm see if you have drm.ko, v3d/v3d.ko and vc4/vc4.ko (otherwise it means some mesa drivers are missing) /usr/lib/dri see if you have v3d_dir.so and vc4_dri.so, at some point I was missing vc4_dri.so and it causes an other error with Qt applications.
If you have the modules you should be able to run vc4 and v3d with modprobe, you can check with lsmod command if it is running. While running you should have card0 and card1 in /dev/dri and no more "Could not find DRM device!". From what I read online card0 is for 3d acceleration with v3d and card1 for render with vc4. At some point I was able to load the module but still get nothing in /dev/dri, I don't know why, maybe because i was missing 'dtoverlay=vc4-fkms-v3d` in `config.txt.

That it, I hope it can help somebody.
Were you able to figure out why we need to execute 'modprobe vc4 & modprobe v3d' to load the drivers? Why isn't it loading automatically?
I have the 'dtoverlay=vc4-fkms-v3d' in the config file.

Return to “Advanced users”