How to run qt app in service on I.MX8M

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to run qt app in service on I.MX8M

1,733 Views
coindu
Contributor IV

I hope the qt app run automatically  when the board power-on.

the environment :

sdk version  is 4.9.88 SDK and build with  DISTRO=fsl-imx-xwayland param

test_qt.service contents is as follows

```

[Unit]
Description=qt test
After=weston.service

[Service]
Type=oneshot
EnvironmentFile=-/etc/default/test_env
ExecStart=/home/root/test_timer -platform wayland-egl
TimeoutSec=20000

[Install]
WantedBy=multi-user.target

```

test_env 

···

#!/bin/sh
XDG_RUNTIME_DIR=/run/user/0
if test -z "$XDG_RUNTIME_DIR"; then
   XDG_RUNTIME_DIR=/run/user/0
   if ! test -d "${XDG_RUNTIME_DIR}"; then
   mkdir --parents "${XDG_RUNTIME_DIR}"
   chmod 0700 "${XDG_RUNTIME_DIR}"
   fi
fi

···

 

But the qt faild to run  

journalctl -u test_qt --no-page

···

-- Logs begin at Mon 2019-04-15 00:47:52 UTC, end at Mon 2019-04-15 00:47:58 UTC. --
Apr 15 00:47:54 imx8mqevk systemd[1]: Starting qt test...
Apr 15 00:47:55 imx8mqevk test_qt[3302]: Failed to create display (No such file or directory)
Apr 15 00:47:55 imx8mqevk systemd[1]: test_qt.service: Main process exited, code=exited, status=1/FAILURE
Apr 15 00:47:55 imx8mqevk systemd[1]: Failed to start qt test.
Apr 15 00:47:55 imx8mqevk systemd[1]: test_qt.service: Unit entered failed state.
Apr 15 00:47:55 imx8mqevk systemd[1]: test_qt.service: Failed with result 'exit-code'.

···

if i exec the systemctl start test_qt,it will run suceess.

how to resolve it,or give a qt sample to run with service

Look forward to your reply ,thanks.

0 Kudos
3 Replies

1,254 Views
coindu
Contributor IV

Thanks for you reply. I have been found the way to run qt as a service.

xxx.service 

ExecStart=/home/root/test_qt.sh

test_qt.sh

#!/bin/sh

export XDG_RUNTIME_DIR=/run/user/0
export QT_QPA_PLATFORM=wayland

./home/root/test_qt_app

0 Kudos

1,254 Views
joanxie
NXP TechSupport
NXP TechSupport

thanks for your sharing

0 Kudos

1,254 Views
joanxie
NXP TechSupport
NXP TechSupport

maybe you can refer to the document as below for imx6:

https://community.nxp.com/docs/DOC-95380 

0 Kudos