title: eglfs on raspberry2 -- * failed to add service - already in use?
body: <p>that's is my first post here.</p>
  
  <p>I'd like to keep it short...</p>
  
  <p><strong>Following problem:</strong></p>
  
  <p>i want to run a qt5/qtquickcontrols2 application utilising the eglfs backend on a raspberry-pi 2b, accelerated by vc4, of course.
  Ideally, it should run in kiosk mode and it definitely needs accelerated gl functionality.
  To minimise problems, I tested with the command:</p>
  
  <p><code>LD_PRELOAD="/opt/vc/lib/libGLESv2.so /opt/vc/lib/libEGL.so" qmlscene ./gallery.qml</code></p>
  
  <p>where gallery.qml is simply the widget preview example project from qt-creator (followed <a href="https://aur.archlinux.org/packages/qt5-qpa-rpi-plugin/" rel="noreferrer" title="these">these</a> instructions...).
  I'm getting following error output:</p>
  
  <pre><code>[manjaro@Loki gallery]$ LD_PRELOAD="/opt/vc/lib/libGLESv2.so /opt/vc/lib/libEGL.so" qmlscene ./gallery.qml
  qt.qpa.egldeviceintegration: EGL device integration plugin keys: ("eglfs_brcm", "eglfs_kms", "eglfs_x11")
  qt.qpa.egldeviceintegration: EGL device integration plugin keys (sorted): ("eglfs_brcm", "eglfs_kms", "eglfs_x11")
  qt.qpa.egldeviceintegration: Trying to load device EGL integration "eglfs_brcm"
  qt.qpa.egldeviceintegration: Using EGL device integration "eglfs_brcm"
  * failed to add service - already in use?
  </code></pre>
  
  <p>I also tested the same running a crosscompiled binary - same error.
  All but the last line come from verbose debugging output of qt5,
  which i set via environment variable, details will follow.</p>
  
  <p><strong>System / Environment:</strong></p>
  
  <ul>
  <li>raspberry-pi 2b</li>
  <li>qt-5.7.0</li>
  <li>Manjaro-ARM (based on Arch Linux ARM)</li>
  <li>all firmware stuff, tools, boot stuff, kernel are installed and up to date</li>
  </ul>
  
  <p>Other settings...</p>
  
  <pre><code>[manjaro@Loki gallery]$ uname -a
  Linux Loki 4.4.28-1-MANJARO-ARM #1 SMP Sat Oct 29 21:01:09 CDT 2016 armv7l GNU/Linux
  </code></pre>
  
  <p>My config.txt</p>
  
  <pre><code>dtparam=audio=on
  #hdmi_drive=2
  avoid_warnings=2
  disable_overscan=1
  disable_splash=1
  boot_delay=0
  
  # activate raspi cam
  start_x=1
  
  # tuning gpu accel and memory usage
  gpu_mem=320
  dtoverlay=vc4-kms-v3d
  </code></pre>
  
  <p>My cmdline.txt</p>
  
  <pre><code>root=/dev/mmcblk0p2 rw  rootwait console=tty1 selinux=0 quiet plymouth.ignore-serial-consoles dwc_otg.lpm_enable=0 elevator=deadline fsck.repair=yes
  </code></pre>
  
  <p>printenv gives following:</p>
  
  <pre><code>XDG_SESSION_ID=c1
  TERM=xterm
  SHELL=/bin/bash
  SSH_CLIENT=192.168.0.100 43274 22
  QT_QPA_EGLFS_INTEGRATION=eglfs_brcm
  OLDPWD=/home/manjaro
  SSH_TTY=/dev/pts/0
  USER=manjaro
  MOZ_PLUGIN_PATH=/usr/lib/mozilla/plugins
  MAIL=/var/spool/mail/manjaro
  PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/vc/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
  PWD=/home/manjaro/opt
  LANG=de_DE.UTF-8
  QT_QPA_PLATFORM=eglfs
  SHLVL=1
  HOME=/home/manjaro
  LOGNAME=manjaro
  QT_LOGGING_RULES=qt.qpa.*=true
  DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
  SSH_CONNECTION=192.168.0.100 43274 192.168.0.107 22
  XDG_RUNTIME_DIR=/run/user/1000
  _=/usr/bin/printenv
  </code></pre>
  
  <p>You can see several Qt specific settings: debugging , using eglfs as default backend and the most interesting:
  <code>QT_QPA_EGLFS_INTEGRATION=eglfs_brcm</code> which means that broadcom eglfs plugin should be used. Along <code>eglfs_brcm</code> i tried <code>eglfs_kms</code> too (just out of curiosity):</p>
  
  <pre><code>[manjaro@Loki gallery]$ export QT_QPA_EGLFS_INTEGRATION=eglfs_kms
  [manjaro@Loki gallery]$ LD_PRELOAD="/opt/vc/lib/libGLESv2.so /opt/vc/lib/libEGL.so" qmlscene ./gallery.qml 
  qt.qpa.egldeviceintegration: EGL device integration plugin keys: ("eglfs_brcm", "eglfs_kms", "eglfs_x11")
  qt.qpa.egldeviceintegration: EGL device integration plugin keys (sorted): ("eglfs_kms", "eglfs_brcm", "eglfs_x11")
  qt.qpa.egldeviceintegration: Trying to load device EGL integration "eglfs_kms"
  qt.qpa.egldeviceintegration: Using EGL device integration "eglfs_kms"
  qt.qpa.input: udev device discovery for type QFlags(0x10)
  qt.qpa.input: Found matching devices ("/dev/dri/card0")
  qt.qpa.eglfs.kms: Found the following video devices: ("/dev/dri/card0")
  qt.qpa.eglfs.kms: Using "/dev/dri/card0"
  qt.qpa.eglfs.kms: Opening device "/dev/dri/card0"
  qt.qpa.eglfs.kms: Creating GBM device for file descriptor 5 obtained from "/dev/dri/card0"
  * failed to add service - already in use?
  </code></pre>
  
  <p>It seems to be neither a problem with the video core, nor a problem of the "stock" Qt of manjaro-arm. It simply says something could being blocked, but what? Any hints?</p>
  
  <p>Overlays and drivers seem to work, glxgears achieved ~60FPS running on xfce4.
  Following is interesting too:</p>
  
  <pre><code>[root@Loki gallery]# vcdbg log msg|&amp; grep -v gpioman|grep -iv hdmi
  001042.905: *** Restart logging
  001043.889: Read command line from file 'cmdline.txt'
  root=/dev/mmcblk0p2 rw  rootwait console=tty1 selinux=0 nofb dwc_otg.lpm_enable=0 elevator=deadline fsck.repair=yes
  001409.425: Loading 'kernel7.img' to 0x8000 size 0x5ea25c
  001413.076: Kernel trailer DTOK property says yes
  001413.091: Kernel trailer DDTK property says yes
  001415.514: Loading 'bcm2709-rpi-2-b.dtb' to 0x5f225c size 0x3bfc
  001514.479: dtparam: audio=on
  001567.591: Loaded overlay 'vc4-kms-v3d'
  001836.841: Device tree loaded to 0x2effbc00 (size 0x430d)
  005904.220: vchiq_core: vchiq_init_state: slot_zero = 0xd0400000, is_master = 1
  005911.919: TV service:host side not connected, dropping notification 0x00000002, 0x00000001, 0x00000010
  007999.619: camsubs: Looking for camera 0: i2c_port = 0, led gpio = 32, power enable gpio = 41
  008000.339: camsubs: Camera not found
  008000.377: camsubs: Looking for camera 0: i2c_port = 0, led gpio = 32, power enable gpio = 41
  008001.091: camsubs: Camera not found
  008001.128: camsubs: Looking for camera 0: i2c_port = 0, led gpio = 32, power enable gpio = 41
  008001.844: camsubs: Camera not found
  </code></pre>
  
  <p>Looks pretty much like it should to me.</p>
  
  <p><strong>I tried following things:</strong></p>
  
  <p>I played around with gpu_mem split, tried values between 128 and 448.
  Checking gpu mem looks as expected, but no effect on executing mentioned app.</p>
  
  <pre><code>[manjaro@Loki gallery]$ vcgencmd get_mem gpu
  gpu=320M
  </code></pre>
  
  <p>I also created following udev rule in order to fix an error I initially faced</p>
  
  <pre><code>[manjaro@Loki gallery]$ cat /etc/udev/rules.d/10-vchiq-permissions.rules 
  SUBSYSTEM=="vchiq",GROUP="video",MODE="0660"
  
  [manjaro@Loki gallery]$ groups
  wheel video storage power users
  </code></pre>
  
  <p>Without the mentioned udev rule, I'd get following error:</p>
  
  <pre><code>[manjaro@Loki gallery]$ LD_PRELOAD="/opt/vc/lib/libGLESv2.so /opt/vc/lib/libEGL.so" qmlscene ./gallery.qml 
  qt.qpa.egldeviceintegration: EGL device integration plugin keys: ("eglfs_brcm", "eglfs_kms", "eglfs_x11")
  qt.qpa.egldeviceintegration: EGL device integration plugin keys (sorted): ("eglfs_brcm", "eglfs_kms", "eglfs_x11")
  qt.qpa.egldeviceintegration: Trying to load device EGL integration "eglfs_brcm"
  qt.qpa.egldeviceintegration: Using EGL device integration "eglfs_brcm"
  * failed to open vchiq instance
  </code></pre>
  
  <p>Damn... I'm out of ideas now...
  I'd appreciate every little hint which could help...</p>
  
  <p><strong>Please do not:</strong></p>
  
  <ul>
  <li>anser to read several docs (i allready spent tons of time)</li>
  <li>suggest to try another distro (that's NOT a solution)</li>
  <li>suggest to reflash my sdcard (NOT a solution too)</li>
  </ul>
  
  <p>Who got Qt-5.7/qtquickcontrols2/QML working on raspberrypi 2 through EGLFS utilizing the vc4???
  Thank you very very much for every single breadcrumb...</p>