Running a QtQuick App on RaspberryPi 4: Problem rendering app to screen.
-
I cross compiled Qt 5.14 and also cross compiled a QtQuick application. However, I encounter problems when starting it on the raspberry. I should note, that I needed to modify /boot/config.txt
[pi4] # Enable DRM VC4 V3D driver on top of the dispmanx display stack #dtoverlay=vc4-fkms-v3d #max_framebuffers=2 [all] #dtoverlay=vc4-fkms-v3d
I needed to comment out the dtoverlay, as otherwise I get the error "failed to add service - already in use?". I don't really understand what this line does, so I might also have broken something.
That said, if I start it from the command line interface, I get the error: "Could not find DRM device!" (My main QML has an ApplicationWindow as root item, so it might not work without a window manager, right?)
If I boot into the raspian desktop and try to start it there in a terminal, the application starts, a window border is drawn, but the application is not rendered into the window border. However, the application seems to be running fine, because if I use e.g. a short cut of my application like Ctrl O to open a file, the native open file dialog is opening. In the console I used to start my app I many times the following error: "QEGLPlatformContext: eglMakeCurrent failed: 3009"
Here is the relevant part of my config.summary when cross compiling Qt:
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 ................................. yes Session Management ..................... yes Features used by QPA backends: evdev .................................. yes libinput ............................... yes INTEGRITY HID .......................... no mtdev .................................. yes tslib .................................. yes xkbcommon .............................. yes X11 specific: XLib ................................. yes XCB Xlib ............................. yes EGL on 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 ...................... yes EGLFS GBM ............................ yes EGLFS VSP2 ........................... no EGLFS Mali ........................... no EGLFS Raspberry Pi ................... no EGLFS X11 ............................ yes LinuxFB ................................ yes
What should I do?
-
I forgot to mention that I use raspian buster. If I am in the raspian GUI and start it with
pi@raspberrypi:~ $ ./main -platform eglfs
I get again the error: "Could not find DRM device!".If I use linuxfb as platform, the application is rendered to the screen, but if I move the mouse, the buttons from the desktop and other windows shine through and it becomes a real mess
If I use xcb (probably the default otherwise I again get the "QEGLPlatformContext: eglMakeCurrent failed: 3009"
Maybe similar:
https://stackoverflow.com/questions/40490113/eglfs-on-raspberry2-failed-to-add-service-already-in-useEdit: I tried with commented out dtoverlay and using the LD_PRELOAD command as in the above stackoverflow post, then the application crash with a segfault:
Thread 1 "main" received signal SIGSEGV, Segmentation fault. 0xb6fa8624 in platform_get_handle () from /opt/vc/lib/libEGL.so (gdb) where #0 0xb6fa8624 in platform_get_handle () from /opt/vc/lib/libEGL.so #1 0xb6f9df30 in eglCreateWindowSurface () from /opt/vc/lib/libEGL.so #2 0xacd7d3be in ?? () from /opt/qt5pi/plugins/xcbglintegrations/libqxcb-egl-integration.so Backtrace stopped: previous frame identical to this frame (corrupt stack?)
The following post could also be relevant:
https://stackoverflow.com/questions/40490113/eglfs-on-raspberry2-failed-to-add-service-already-in-use -
If I want to use my application under the Raspberry PIXEL GUI, (lxde using the xcb platform plugin), which GL driver should I use:
Legacy, fake kms or full kms?And for the raspberry3, which device spec, the pi3-g++ or the pi3-vc4-g++?
I tried with Qt 5.13 and pi3-vc4-g++ and raspian buster, but the result is the same as iwth the pi4 makespec in Qt 5.14
-
Hello.
In config.txt, uncomment back the two lines you commented out:
[pi4]
#Enable DRM VC4 V3D driver on top of the dispmanx display stack
dtoverlay=vc4-fkms-v3d
max_framebuffers=2To build Qt, use the linux-rasp-pi4-v3d-g++ device
Boot into run-level3 (multi-user.target), i.e. without a window manager.
Set environment variables:
export QT_QPA_EGLFS_INTEGRATION = eglfs_kms
export QT_QPA_EGLFS_PHYSICAL_WIDTH = 520
export QT_QPA_EGLFS_PHYSICAL_HEIGHT = 330(What this means, see here https://doc.qt.io/qt-5/embedded-linux.html)
Launch your application with the option
-platform eglfs