How to properly use eglfs on Beaglebone Black?

Viewed 482

Project description

I am using Yocto to build my embedded Linux for Beaglebone Black. Embedded Linux will be used to host my Qt5 graphicall application.

Embedded Linux image is build for MACHINE defined in poky/meta-yocto-bsp/conf/machine/beaglebone-yocto.conf and not for the one from the repository meta-ti (this one gave me problems).

In the embedded Linux image that I am building I already managed to add (a) Qt5 libraries that my application needs to compile with bitbake and (b) my Qt5 application which sucessfully compiles with bitbake.

Qt5 libraries were appended to the image like this:

IMAGE_INSTALL += "qtbase qwt-qt5"

And my Qt application was appended like this:

IMAGE_INSTALL += "application"

So libraries are installed through recipes qtbase and qwt-qt5 while my application was installed through recipe application which I wrote myself.

I can post a list of files that each recipe installs on the target's root file system:

┌───┐
│ $ │ ziga > ziga--hypervisor > build--beaglbone_black_c2
└─┬─┘ /dev/pts/1
  └─> oe-pkgdata-util list-pkg-files qtbase qwt-qt5 application

application:
    /usr/bin/executable
qtbase:
    /usr/lib/libQt5Concurrent.so.5
    /usr/lib/libQt5Concurrent.so.5.14
    /usr/lib/libQt5Concurrent.so.5.14.2
    /usr/lib/libQt5Core.so.5
    /usr/lib/libQt5Core.so.5.14
    /usr/lib/libQt5Core.so.5.14.2
    /usr/lib/libQt5DBus.so.5
    /usr/lib/libQt5DBus.so.5.14
    /usr/lib/libQt5DBus.so.5.14.2
    /usr/lib/libQt5Gui.so.5
    /usr/lib/libQt5Gui.so.5.14
    /usr/lib/libQt5Gui.so.5.14.2
    /usr/lib/libQt5Network.so.5
    /usr/lib/libQt5Gui.so.5.14
    /usr/lib/libQt5Gui.so.5.14.2
    /usr/lib/libQt5Network.so.5
    /usr/lib/libQt5Network.so.5.14
    /usr/lib/libQt5Network.so.5.14.2
    /usr/lib/libQt5OpenGL.so.5
    /usr/lib/libQt5OpenGL.so.5.14
    /usr/lib/libQt5OpenGL.so.5.14.2
    /usr/lib/libQt5PrintSupport.so.5
    /usr/lib/libQt5PrintSupport.so.5.14
    /usr/lib/libQt5PrintSupport.so.5.14.2
    /usr/lib/libQt5Sql.so.5
    /usr/lib/libQt5Sql.so.5.14
    /usr/lib/libQt5Sql.so.5.14.2
    /usr/lib/libQt5Test.so.5
    /usr/lib/libQt5Test.so.5.14
    /usr/lib/libQt5Test.so.5.14.2
    /usr/lib/libQt5Widgets.so.5
    /usr/lib/libQt5Widgets.so.5.14
    /usr/lib/libQt5Widgets.so.5.14.2
    /usr/lib/libQt5XcbQpa.so.5
    /usr/lib/libQt5XcbQpa.so.5.14
    /usr/lib/libQt5XcbQpa.so.5.14.2
    /usr/lib/libQt5Xml.so.5
    /usr/lib/libQt5Xml.so.5.14
    /usr/lib/libQt5Xml.so.5.14.2
qwt-qt5:
    /usr/lib/libqwt.so.6
    /usr/lib/libqwt.so.6.1
    /usr/lib/libqwt.so.6.1.4

Application can't display graphics

Now I login to the target and run my application which can not display the graphics:

root@beaglebone-yocto:~# executable

2020/09/20 10:44:26.560: Warning: Could not connect to display
2020/09/20 10:44:26.581: Info: Could not load the Qt platform plugin "xcb" in "" even though it was found.
2020/09/20 10:44:26.581: Fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix the problem.

Available platform plugins are: minimal, offscreen, vnc, xcb.

Aborted

It looks like I have to somehow configure "Qt Platform Abstraction" (QPA) which is the platform abstraction layer for Qt5 with a lot of plugins (source) that also include a lot of platforms.

My application only uses a single window so I could probably go with qeglfs or qlinuxfb. But because Beaglebone Black integrates Imagination's GPU PowerVR SGX530 which supports OpenGL|ES 2.0 (source) and this is why I want to go with qeglfs platform. Note however that currently qeglfs platform was not listed in the above error report:

Available platform plugins are: minimal, offscreen, vnc, xcb.

I managed to install the qeglfs platform by creating a qtbase_%.bbappend file with this content:

PACKAGECONFIG:append = " eglfs gles2"

Note that this activates qtbase recipe's lines:

PACKAGECONFIG[eglfs] = "-eglfs,-noeglfs,drm"
PACKAGECONFIG[gles2] = "-opengl es2,,virtual/libgles2 virtual/egl"

These lines make sure that compilation includes eglfs as well as OpenGL|ES i.e. gles2. I chose to also include gles2 after reading / watching this (source, source):

enter image description here

So I asumed that eglfs also needs gles2.

Now eglfs is installed and is listed when I try to execute my application in the same way as before:

root@beaglebone-yocto:~# executable

2020/09/20 10:44:26.560: Warning: Could not connect to display
2020/09/20 10:44:26.581: Info: Could not load the Qt platform plugin "xcb" in "" even though it was found.
2020/09/20 10:44:26.581: Fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix the problem.

Available platform plugins are: eglfs, minimal, offscreen, vnc, xcb.

Aborted

But when I try to use eglfs I get errors:

root@beaglebone-yocto:~# env QT_QPA_PLATFORM=eglfs executable

2020/09/20 11:01:17.525: Warning: QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
error: XDG_RUNTIME_DIR not set in the environment
error: XDG_RUNTIME_DIR not set in the environment
error: XDG_RUNTIME_DIR not set in the environment
2020/09/20 11:01:17.533: Fatal: Could not  initialize egl display
Aborted

All the errors except for the last one can be fixed by adding some enviromental variables like this:

root@beaglebone-yocto:~# env QT_QPA_PLATFORM=eglfs XDG_RUNTIME_DIR=/tmp/runtime-root executable

2020/09/20 11:01:17.533: Fatal: Could not initialize egl display
Aborted

But as you can see the last error remains and I don't know how to fix it.

Debug info reveals nothing

I tried exporting some enviromental variables to make debug more verbose and then I ran application again:

root@beaglebone-yocto:~# export QT_LOGGING_RULES=true
root@beaglebone-yocto:~# export QSG_INFO=1
root@beaglebone-yocto:~# export QT_QPA_EGLFS_DEBUG=1
root@beaglebone-yocto:~# export QT_DEBUG_PLUGINS=1
root@beaglebone-yocto:~# export QT_QPA_PLATFORM=eglfs
root@beaglebone-yocto:~# export QT_QPA_EGLFS_INTEGRATION=none
root@beaglebone-yocto:~# export XDG_RUNTIME_DIR=/tmp/runtime-root
root@beaglebone-yocto:~# executable

2022/02/17 20:54:28.448: Debug: QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins/platforms" ...
2022/02/17 20:54:28.450: Debug: QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqeglfs.so"
2022/02/17 20:54:28.451: Warning: Found metadata in lib /usr/lib/plugins/platforms/libqeglfs.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "eglfs"
        ]
    },
    "archreq": 0,
    "className": "QEglFSIntegrationPlugin",
    "debug": false,
    "version": 331264
}


2022/02/17 20:54:28.451: Debug: Got keys from plugin meta data ("eglfs")
2022/02/17 20:54:28.451: Debug: QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqlinuxfb.so"
2022/02/17 20:54:28.452: Warning: Found metadata in lib /usr/lib/plugins/platforms/libqlinuxfb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "linuxfb"
        ]
    },
    "archreq": 0,
    "className": "QLinuxFbIntegrationPlugin",
    "debug": false,
    "version": 331264
}


2022/02/17 20:54:28.453: Debug: Got keys from plugin meta data ("linuxfb")
2022/02/17 20:54:28.453: Debug: QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqminimal.so"
2022/02/17 20:54:28.454: Warning: Found metadata in lib /usr/lib/plugins/platforms/libqminimal.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimal"
        ]
    },
    "archreq": 0,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 331264
}


2022/02/17 20:54:28.454: Debug: Got keys from plugin meta data ("minimal")
2022/02/17 20:54:28.454: Debug: QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqminimalegl.so"
2022/02/17 20:54:28.455: Warning: Found metadata in lib /usr/lib/plugins/platforms/libqminimalegl.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimalegl"
        ]
    },
    "archreq": 0,
    "className": "QMinimalEglIntegrationPlugin",
    "debug": false,
    "version": 331264
}


2022/02/17 20:54:28.456: Debug: Got keys from plugin meta data ("minimalegl")
2022/02/17 20:54:28.456: Debug: QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqoffscreen.so"
2022/02/17 20:54:28.457: Warning: Found metadata in lib /usr/lib/plugins/platforms/libqoffscreen.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "offscreen"
        ]
    },
    "archreq": 0,
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 331264
}


2022/02/17 20:54:28.457: Debug: Got keys from plugin meta data ("offscreen")
2022/02/17 20:54:28.457: Debug: QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqvnc.so"
2022/02/17 20:54:28.458: Warning: Found metadata in lib /usr/lib/plugins/platforms/libqvnc.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "vnc"
        ]
    },
    "archreq": 0,
    "className": "QVncIntegrationPlugin",
    "debug": false,
    "version": 331264
}


2022/02/17 20:54:28.458: Debug: Got keys from plugin meta data ("vnc")
2022/02/17 20:54:28.459: Debug: QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/platforms/libqxcb.so"
2022/02/17 20:54:28.459: Warning: Found metadata in lib /usr/lib/plugins/platforms/libqxcb.so, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "xcb"
        ]
    },
    "archreq": 0,
    "className": "QXcbIntegrationPlugin",
    "debug": false,
    "version": 331264
}


2022/02/17 20:54:28.460: Debug: Got keys from plugin meta data ("xcb")
2022/02/17 20:54:28.460: Debug: QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/platforms" ...
2022/02/17 20:54:28.512: Debug: loaded library "/usr/lib/plugins/platforms/libqeglfs.so"
2022/02/17 20:54:28.513: Debug: QFactoryLoader::QFactoryLoader() checking directory path "/usr/lib/plugins/egldeviceintegrations" ...
2022/02/17 20:54:28.514: Debug: QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/egldeviceintegrations/libqeglfs-emu-integration.so"
2022/02/17 20:54:28.515: Warning: Found metadata in lib /usr/lib/plugins/egldeviceintegrations/libqeglfs-emu-integration.so, metadata=
{
    "IID": "org.qt-project.qt.qpa.egl.QEglFSDeviceIntegrationFactoryInterface.5.5",
    "MetaData": {
        "Keys": [
            "eglfs_emu"
        ]
    },
    "archreq": 0,
    "className": "QEglFSEmulatorIntegrationPlugin",
    "debug": false,
    "version": 331264
}


2022/02/17 20:54:28.516: Debug: Got keys from plugin meta data ("eglfs_emu")
2022/02/17 20:54:28.516: Debug: QFactoryLoader::QFactoryLoader() looking at "/usr/lib/plugins/egldeviceintegrations/libqeglfs-x11-integration.so"
2022/02/17 20:54:28.517: Warning: Found metadata in lib /usr/lib/plugins/egldeviceintegrations/libqeglfs-x11-integration.so, metadata=
{
    "IID": "org.qt-project.qt.qpa.egl.QEglFSDeviceIntegrationFactoryInterface.5.5",
    "MetaData": {
        "Keys": [
            "eglfs_x11"
        ]
    },
    "archreq": 0,
    "className": "QEglFSX11IntegrationPlugin",
    "debug": false,
    "version": 331264
}


2022/02/17 20:54:28.517: Debug: Got keys from plugin meta data ("eglfs_x11")
2022/02/17 20:54:28.517: Debug: QFactoryLoader::QFactoryLoader() checking directory path "/usr/bin/egldeviceintegrations" ...
2022/02/17 20:54:28.543: Fatal: Could not initialize egl display

Now I get much more data, but not regarding the last error! That one remains unverbose as before. Really useless actually!

GPU is discovered by kernel - but not used

I also made sure that I added status = "okay" inside the devicetree's GPU device node. This enabled the GPU probing. So now I can see it in dmesg:

[    0.000000] AM335X ES2.1 (sgx neon)

I also installed executable kmscube which I could sucessfully execute and it rendered a cube with shaders. But it was slow and top revealed that it used 100% of my CPU! So probably GPU wasn't used in this case!

My display controllers & panels

I have two connectors on my device - first is HDMI and the second is my embedded panel. I installed modetest DRM & KVM utility which shows, how display controllers and panels are set up:

trying to open device 'i915'...failed
trying to open device 'amdgpu'...failed
trying to open device 'radeon'...failed
trying to open device 'nouveau'...failed
trying to open device 'vmwgfx'...failed
trying to open device 'omapdrm'...failed
trying to open device 'exynos'...failed
trying to open device 'tilcdc'...done
Encoders:
id  crtc    type    possible crtcs  possible clones 
33  32  LVDS    0x00000001  0x00000001
35  0   TMDS    0x00000001  0x00000002

Connectors:
id  encoder status      name        size (mm)   modes   encoders
34  33  connected   LVDS-1          0x0     1   33
  modes:
    index name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
  #0 800x480 34.89 800 840 888 928 480 493 496 525 17000 flags: nhsync, nvsync; type: preferred, driver
  props:
    1 EDID:
        flags: immutable blob
        blobs:

        value:
    2 DPMS:
        flags: enum
        enums: On=0 Standby=1 Suspend=2 Off=3
        value: 0
    5 link-status:
        flags: enum
        enums: Good=0 Bad=1
        value: 0
    6 non-desktop:
        flags: immutable range
        values: 0 1
        value: 0
    4 TILE:
        flags: immutable blob
        blobs:

        value:
    20 CRTC_ID:
        flags: object
        value: 32
36  0   disconnected    HDMI-A-1        0x0     0   35
  props:
    1 EDID:
        flags: immutable blob
        blobs:

        value:
    2 DPMS:
        flags: enum
        enums: On=0 Standby=1 Suspend=2 Off=3
        value: 0
    5 link-status:
        flags: enum
        enums: Good=0 Bad=1
        value: 0
    6 non-desktop:
        flags: immutable range
        values: 0 1
        value: 0
    4 TILE:
        flags: immutable blob
        blobs:

        value:
    20 CRTC_ID:
        flags: object
        value: 0

CRTCs:
id  fb  pos size
32  37  (0,0)   (800x480)
  #0 800x480 34.89 800 840 888 928 480 493 496 525 17000 flags: nhsync, nvsync; type: preferred, driver
  props:
    22 ACTIVE:
        flags: range
        values: 0 1
        value: 1
    23 MODE_ID:
        flags: blob
        blobs:

        value:
            68420000200348037803a0030000e001
            ed01f0010d020000230000000a000000
            48000000383030783438300000000000
            00000000000000000000000000000000
            00000000
    19 OUT_FENCE_PTR:
        flags: range
        values: 0 18446744073709551615
        value: 0
    24 VRR_ENABLED:
        flags: range
        values: 0 1
        value: 0

Planes:
id  crtc    fb  CRTC x,y    x,y gamma size  possible crtcs
31  32  37  0,0     0,0 0           0x00000001
  formats: BG16 RG24 XR24
  props:
    8 type:
        flags: immutable enum
        enums: Overlay=0 Primary=1 Cursor=2
        value: 1
    17 FB_ID:
        flags: object
        value: 37
    18 IN_FENCE_FD:
        flags: signed range
        values: -1 2147483647
        value: -1
    20 CRTC_ID:
        flags: object
        value: 32
    13 CRTC_X:
        flags: signed range
        values: -2147483648 2147483647
        value: 0
    14 CRTC_Y:
        flags: signed range
        values: -2147483648 2147483647
        value: 0
    15 CRTC_W:
        flags: range
        values: 0 2147483647
        value: 800
    16 CRTC_H:
        flags: range
        values: 0 2147483647
        value: 480
    9 SRC_X:
        flags: range
        values: 0 4294967295
        value: 0
    10 SRC_Y:
        flags: range
        values: 0 4294967295
        value: 0
    11 SRC_W:
        flags: range
        values: 0 4294967295
        value: 52428800
    12 SRC_H:
        flags: range
        values: 0 4294967295
        value: 31457280

Frame buffers:
id  size    pitch

Here everything looks correct and in general my displays are working fine. So this probably isn't root of my problem.

1 Answers

This looks like a similar issue on the Beagleboard forum. The dev was able to fix it doing this:

"I updated the kernel using these options: ./update_kernel.sh --ti-channel --lts-4_14 --sgx I had to install an additional package: apt install libdrm-dev I had to do a custom GBM library install, outlined here 9. Seems not everything was set up correctly as part of the image."

Source

Related