Home/Support/Support Forum/Chromium issues in CC8M Dev Kit: run as non root user and autostart with systemd
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Chromium issues in CC8M Dev Kit: run as non root user and autostart with systemd

0 votes
I have compiled DEY 3.0 and then added the meta-browser and required meta-clang layers in my bblayers.conf:

# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly


/usr/local/dey-3.0/sources/poky/meta \
/usr/local/dey-3.0/sources/poky/meta-poky \
/usr/local/dey-3.0/sources/poky/meta-yocto-bsp \
/usr/local/dey-3.0/sources/meta-openembedded/meta-oe \
/usr/local/dey-3.0/sources/meta-openembedded/meta-python \
/usr/local/dey-3.0/sources/meta-openembedded/meta-networking \
/usr/local/dey-3.0/sources/meta-openembedded/meta-webserver \
/usr/local/dey-3.0/sources/meta-qt5 \
/usr/local/dey-3.0/sources/meta-swupdate \
/usr/local/dey-3.0/sources/meta-freescale \
/usr/local/dey-3.0/sources/meta-fsl-demos \
/usr/local/dey-3.0/sources/meta-digi/meta-digi-arm \
/usr/local/dey-3.0/sources/meta-digi/meta-digi-dey \
/usr/local/dey-3.0/sources/meta-browser \
/usr/local/dey-3.0/sources/meta-clang \

And then, in the local,conf:

## Add Chromium
IMAGE_INSTALL_append = \
"${@bb.utils.contains('DISTRO_FEATURES', 'wayland', ' chromium-ozone-wayland libexif', \
bb.utils.contains('DISTRO_FEATURES', 'x11', ' chromium-x11 libexif', \
'', d), d)}"
"${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'commercial', \
bb.utils.contains('DISTRO_FEATURES', 'x11', 'commercial', \

Finally, I used bitbake dey-image-qt to build it all. The resulting image is the one I'm using in the dev kit.
I have so far been able to execute chromium successfuly by modifying the default weston.ini as follows:

use-g2d=1 #Set 2D renderer instead of default GLES
xwayland=true #Uncommented this line!




# WIDTHxHEIGHT Resolution size width and height in pixels
# off Disables the output
# preferred Uses the preferred mode
# current Uses the current crt controller mode

command=@bindir@/weston --backend=rdp-backend.so --shell=fullscreen-shell.so --no-clients-resize


and using the following flags:
chromium --no-sandbox --start-maximized --kiosk https://www.google.com

At first, without this the weston.init config, I was getting frecuent segmentation fault errors from chromium, but sadly I haven't been able reproduce them or determine what solved them.

The problem: We want to deploy our device's HMI via chromium. So far, I've been executing all this as root user. This is no good for a commertial solution (or any, if not testing) since it makes it vulnerable. However, I have created another user and tried to run chromium but gotten the following errors:

ccimx8mn-dvk:~$ chromium --no-sandbox --start-maximized --kiosk https://www.google.com
[904:904:1027/170421.864351:ERROR:wayland_connection.cc(60)] Failed to connect to Wayland display
[904:904:1027/170421.864414:FATAL:ozone_platform_wayland.cc(166)] Failed to initialize Wayland platform
Trace/breakpoint trap

For what I've found online, it seems that weston is executed and owned by root, and no other user may "capture" /run/user/0/wayland-0. In fact, I'm not able to execute any graphical app:

ccimx8mn-dvk:~$ weston-flower
failed to connect to Wayland display: No such file or directory
failed to create display: No such file or directory

Any idea about how to solve this? Thanks in advance for any help!
asked Oct 27, 2020 in Linux by sergiompopoli New to the Community (2 points)

Please log in or register to answer this question.

1 Answer

0 votes
Try export DISPLAY=:0.0
also, try
chromium --no-sandbox --start-maximized --kiosk -platform wayland
or set

export QT_QPA_PLATFORM=wayland

You are root, so permissions should not be an issue.
You may also need to run a wayland compositor (weston) before running your Qt Application.
answered Oct 29, 2020 by LeonidM Veteran of the Digi Community (4,359 points)
Hello Leonid, thank you for your answer.
So, the thing is that as root user, chromium starts and outputs to my touchscreen fine. Also, by default my QT_QPA_PLATFORM is wayland, probably because of the weston.ini config.
However, the issue is whenever I try to execute chromium with a NON root user. For example, the 'display' user. I ran 'useradd display' and 'passwd display', then login as display and get:

ccimx8mn-dvk:~$ weston-flower
failed to connect to Wayland display: No such file or directory
failed to create display: No such file or directory

And, as a matter of fact, there's no wayland-0 (or maybe it should be wayland-1000?) in the run directory:

ccimx8mn-dvk:~$ ls /run/user/1000/                                                                                                                                     
bus      systemd

Maybe I need to give the display user some permissions to access /run/user/0/wayland-0? Or allow the display user to execute the weston service by itself? Do you know how to do this?

BY the way, you said: "You may also need to run a wayland compositor (weston) before running your Qt Application." Yes, weston desktop is already running (I can see the DIGI desktop background in my touch screen) when I execute weston-flower and chromium from the display user.
have you tried doing "xhost +" as root, and then export DISPLAY=:0.0 as other user?
Oh I see what you mean: give permissions to all users to capture the display. Unfortunately:

root@ccimx8mn-dvk:~# xhost +
-sh: xhost: command not found

This must be because my image uses wayland, and not X...

Other idea is trying to start weston by the 'display' user, the same we want to start Chromium, but simply changing weston.service with


does not do the trick.
OK, I've managed some progress:
I have added the custom created user ('display') to the 'video' group by executing:
 usermod -a -G video display
and changing the 'User' in the /lib/systemd/system/weston.service like this:
And running systemctl daemon-reload.
Then, after rebooting, I can see that weston starts but the process is owned by the display user (instead of root, like before)! I can confirm that wayland-0 and      wayland-0.lock are now on /run/user/1000/
So, I can now execute graphical applications from the display user, like weston-flower and chromium.

My only remaining problem  is to properly execute chromium at startup... I have been struggling with systemd. I created a simple script for executing chromium /home/display/startChromium.sh

 export XDG_RUNTIME_DIR="/run/user/1000"
 sleep 2s #This wait seems to help...
 echo "Starting Chromium in kiosk mode"
 /usr/bin/chromium --start-maximized --kiosk https://www.digi.com/ &

and then calling it after weston starts up, by editing again /lib/systemd/system/weston.service and adding:

 # Weston does not successfully change VT, nor does systemd place us on
 # the VT it just activated for us. Switch manually:
 ExecStart=/usr/bin/weston-launch -- --log=/var/log/weston.log $OPTARGS
And running systemctl daemon-reload.

After rebooting, chromium is in the list of processes, but I have no longer a video output in the touchscreen, not even the weston desktop. Any idea of what might be causing this?

The output of systemctl status weston seems fine:

weston.service - Weston Wayland Compositor (on tty7)
   Loaded: loaded (/lib/systemd/system/weston.service; enabled; vendor preset: enabled)
   Active: [[0;1;32mactive (running)[[0m since Tue 2020-11-03 11:15:01 UTC; 12min ago
  Process: 3128 ExecStartPost=/home/display/startChromium.sh (code=exited, status=0/SUCCESS)
  Process: 3109 ExecStartPre=/usr/bin/chvt 7 (code=exited, status=0/SUCCESS)
 Main PID: 3127 (weston-launch)
    Tasks: 42 (limit: 804)
   Memory: 214.7M
   CGroup: /system.slice/weston.service
           ├─3196 /usr/bin/chromium --use-gl=egl --enable-gpu-rasterization --enable-impl-side-painting --ozone-platform=wayland --enable-gpu --enable-gpu-memory-buffer-video-frames --enable-accelerated-2d-c
anvas --enable-accelerated-vpx-decode --enable-native-gpu-memory-buffers --enable-zero-copy --gpu-no-context-lost --user-data-dir=/home/root/.chromium/ --disable-infobars --disable-session-crashed-bubble --ignor
e-certificate-errors --ignore-gpu-blacklist --no-sandbox --window-position=0,0 --no-first-run --in-process-gpu --start-maximized --kiosk https://www.digi.com/
           ├─3203 cat
           ├─3204 cat
           ├─3217 /usr/lib/chromium/chromium-bin --type=zygote --no-sandbox --user-data-dir=/home/root/.chromium/
           ├─3243 /usr/lib/chromium/chromium-bin --type=utility --field-trial-handle=9798557573055300389,9654855176757237191,131072 --lang=en-US --service-sandbox-type=network --no-sandbox --ignore-certifica
te-errors --use-gl=egl --ignore-certificate-errors --user-data-dir=/home/root/.chromium/ --service-request-channel-token=17941211565978641838 --shared-files=v8_context_snapshot_data:100,v8_natives_data:101
           └─3263 /usr/lib/chromium/chromium-bin --type=renderer --no-sandbox --enable-gpu-memory-buffer-video-frames --use-gl=egl --ozone-platform=wayland --field-trial-handle=9798557573055300389,9654855176
757237191,131072 --lang=en-US --user-data-dir=/home/root/.chromium/ --enable-auto-reload --num-raster-threads=2 --enable-zero-copy --enable-main-frame-before-activation --service-request-channel-token=7606999810
771839485 --renderer-client-id=4 --no-v8-untrusted-code-mitigations --shared-files=v8_context_snapshot_data:100,v8_natives_data:101
           ‣ 3127 /usr/bin/weston-launch -- --log=/var/log/weston.log

Nov 03 11:14:58 ccimx8mn-dvk systemd[1]: Starting Weston Wayland Compositor (on tty7)...
Nov 03 11:15:01 ccimx8mn-dvk systemd[1]: Started Weston Wayland Compositor (on tty7).

Maybe all this would be easier with crontab? or autostart?
Thank you for any help