How to run gui apps? DRI/DRM with kmscube "failed to set mode: Permission denied"

Hi,

I cannot get my application to display anything, so i am trying to get some output on the device display.

kmscube errors out with

[Logs]    [2024-10-15T08:52:36.914Z] [kmscube] failed to set mode: Permission denied

Dockerfile

FROM balenalib/genericx86-64-ext-debian:latest

RUN apt-get update && apt-get install -y \
    kmscube \
    libdrm2 \
    libdrm-tests \
    libgbm1 \
    libegl1-mesa \
    libgles2-mesa \
    libgl1-mesa-dri \
    libinput10 \
    udev \
    --no-install-recommends

RUN apt-get install -y \
    x11-utils \
    mesa-utils \
    && apt-get clean

WORKDIR /root

CMD ["kmscube"]

Docker compose:

version: "2"
services:
  kmscube:
    build: .
    restart: always
    privileged: true
    environment:
      UDEV: 1
    devices:
      - "/dev/dri:/dev/dri"
      - "/dev/input:/dev/input"

Debugging output from host os:

root@d94785e:~# udevadm info /dev/dri/card0
P: /devices/pci0000:00/0000:00:02.0/drm/card0
N: dri/card0
L: 0
S: dri/by-path/pci-0000:00:02.0-card
E: DEVPATH=/devices/pci0000:00/0000:00:02.0/drm/card0
E: DEVNAME=/dev/dri/card0
E: DEVTYPE=drm_minor
E: MAJOR=226
E: MINOR=0
E: SUBSYSTEM=drm
E: USEC_INITIALIZED=5212994
E: ID_PATH=pci-0000:00:02.0
E: ID_PATH_TAG=pci-0000_00_02_0
E: ID_FOR_SEAT=drm-pci-0000_00_02_0
E: DEVLINKS=/dev/dri/by-path/pci-0000:00:02.0-card
E: TAGS=:seat:master-of-seat:uaccess:
E: CURRENT_TAGS=:seat:master-of-seat:uaccess:

root@d94785e:~# lsmod | grep i915
i915                 3465216  4
drm_buddy              20480  1 i915
ttm                    90112  1 i915
drm_display_helper    200704  1 i915
cec                    61440  2 drm_display_helper,i915
drm_kms_helper        225280  2 drm_display_helper,i915
i2c_algo_bit           12288  2 igb,i915
video                  69632  1 i915
drm                   745472  7 drm_kms_helper,drm_display_helper,drm_buddy,i915,ttm

root@d94785e:~# dmesg | grep -i drm
[    1.992384] ACPI: bus type drm_connector registered
[    3.911626] i915 0000:00:02.0: [drm] Using Transparent Hugepages
[    3.960301] i915 0000:00:02.0: [drm] Finished loading DMC firmware i915/icl_dmc_ver1_09.bin (v1.9)
[    4.021750] [drm] Initialized i915 1.6.0 20201103 for 0000:00:02.0 on minor 0
[    4.026463] fbcon: i915drmfb (fb0) is primary device
[    5.200135] i915 0000:00:02.0: [drm] fb0: i915drmfb frame buffer device

root@d94785e:~# ls -al /dev/dri
total 0
drwxr-xr-x  3 root root        100 Oct 15 08:05 .
drwxr-xr-x 19 root root       4540 Oct 15 08:20 ..
drwxr-xr-x  2 root root         80 Oct 15 08:20 by-path
crw-rw----  1 root video  226,   0 Oct 15 08:20 card0
crw-rw-rw-  1 root render 226, 128 Oct 15 08:20 renderD128

Hello @dotdev2

Could you please share more details of what hardware are you using here? What OS version?

Thanks!

Hi @mpous ,

All in one “terminal device” (integrated screen), Intel Celeron J6412, industrial motherboard, 15.6" full hd touch display.

BalenaOS 6.0.24+rev1

Best,
F

1 Like

Hi @dotdev2 ,

Can you share what exactly the service is attempting to run? I see the Dockerfile installs some necessary libraries etc, but is there anything else other than kmscube itself that is being executed when the service starts? I ask because I found another using running into the same error (albeit not on a balena device), and their issue was caused by a different GUI already running: Error message when trying to run kmscube - #3 by eran - DragonBoard410c - 96Boards Forum

Hi @joshbwlng,

No other services. I am only running the kmscube, shown in the Dockerfile. There are no other containers on the device.

root@d94785e:~# balena-engine ps
CONTAINER ID   IMAGE                                                            COMMAND                  CREATED          STATUS                            PORTS     NAMES
27fe2295e6e1   fbf2f583c34a                                                     "/usr/bin/entry.sh k…"   58 seconds ago   Restarting (243) 23 seconds ago             kmscube_1_1_10ca12e1ea5e
29c63feae328   registry2.balena-cloud.com/v2/139c93a57103e8c47c803435a0e94793   "/usr/src/app/entry.…"   25 hours ago     Up 7 minutes (healthy)                      balena_supervisor

I am using balenalib/genericx86-64-ext-debian:latest. If there is a better choice to run DRI/DRM gui applications such as kmscube please let me know.

The SDDM issue you referenced does not seem to be the issue, the image seems to be barebones.

Hi @joshbwlng,

Found plymouthd with an open drm device file descriptor running on the host.

root@d94785e:~# lsof /dev/dri/*
COMMAND    PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
plymouthd 1014 root    9u   CHR  226,0      0t0  737 /dev/dri/card0

Stopping all plymouth systemd units fixes the issue and kmscube runs perfectly.

systemctl stop plymouth*

How can i ensure plymouth is stops as the container starts?

I tried using dbus:

CMD \
    dbus-send --system --print-reply --dest=org.freedesktop.Plymouth /org/freedesktop/Plymouth org.freedesktop.Plymouth.Quit && \
    sleep 2 && \
    kmscube
version: "2"
services:
  kmscube:
    build: .
    restart: always
    privileged: true
    environment:
      UDEV: 1
      DBUS_SYSTEM_BUS_ADDRESS: unix:path=/host/run/dbus/system_bus_socket
    devices:
      - "/dev/dri:/dev/dri"
      - "/dev/input:/dev/input"
      - "/run/dbus/system_bus_socket:/run/dbus/system_bus_socket"
    labels:
      io.balena.features.dbus: '1'

But it does not seem to work.

Error org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.Plymouth was not provided by any .service files

Seems hacky anyway. What’s the correct way to ensure that plymouth is quit as the application containers are started? This problem repeats on every reboot.

Thanks!