This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA2PXEVM: [QT] Can't launch QT app in daemon service

Part Number: TDA2PXEVM


Hello All:

  we create a init script to launch all our product service.

in this script, the appman will launch our QT app, but it failed as "

XDG_RUNTIME_DIR not set in the environment."

and we copy some environment variable from weston script, then we got another error as

"Failed to create display (No such file or directory)"

Question

 how we can properly start my daemon service when all the system envrionment is ready

Thanks

#! /bin/sh

superman=/opt/ecarx/apps/appman/appman
apps_params=
LOGFILE=/tmp/system.log
ifconfig eth0 192.168.8.10 
cd /opt/vision_sdk
source /opt/vision_sdk/vision_sdk_load.sh
cd /opt/ecarx/apps/appman
test -x "$superman" || exit 0

# This is all a nasty hack                                          
        if test -z "$XDG_RUNTIME_DIR"; then                                 
            export XDG_RUNTIME_DIR=/run/user/root                           
        fi                                                                  
                                                                            
        if [ ! -d "$XDG_RUNTIME_DIR" ] ; then                               
            mkdir --parents $XDG_RUNTIME_DIR                                
            chmod 0700 $XDG_RUNTIME_DIR                                     
        fi                                   
case "$1" in
  start)
    echo -n "Starting superman daemon"
    start-stop-daemon --start  --exec $superman >> $LOGFILE 2>&1 
    echo "."
    ;;
  stop)
    echo -n "Stopping superman daemon"
    start-stop-daemon --stop --quiet
    echo "."
    ;;
  *)
    echo "Usage: /etc/init.d/ecarxinit {start|stop}"
    exit 1
esac

exit 0

  • Hi,

    which SDK you use? The rootfs of VisonSDK includes a limited set of components and might be missing some Qt dependencies.

    Can you try with PSDKLA's filesystem from here:

    Regards,

    Yordan

  • HI Yordan:

      we are using the visionSDK 3.05. and the QT environment is ok as we copy some QT dependency from PSDKLA.

    Normally, we can run QT app when  login to the system.

    This issue happened only when start a daemon service in linux init to start the QT app.

  • Hi,

    Please note that if the Qt Application is expected to run on top of Wayland, then you will have to specify that in the Qt launch command similar to how weston backend is specified. Have you taken care of that?

    Regards

    Karthik

  • Another related point is that the dependency of your service needs to be correctly configured. The Qt application should run after all dependent services are initialized.

    Regards

    Karthik

  • HI :

      The "ecarxinit.service" is the last spawned.

    [    8.734422] hub 2-0:1.0: 1 port detected
    [  OK  ] Reached target Network.
             Starting Network Name Resolution...
    [  OK  ] Started Getty on tty1.
    [  OK  ] Started Serial Getty on ttyS0.
             Starting LSB: Dropbear Secure Shell server...
             Starting weston.service...
    [  OK  ] Started Network Name Resolution.
    [  OK  ] Started LSB: Dropbear Secure Shell server.
    [  OK  ] Started weston.service.
             Starting telnetd.service...
             Starting tiipclad-daemon.service...
    [  OK  ] Started telnetd.service.
    [  OK  ] Started tiipclad-daemon.service.
             Starting ecarxinit.service...
    [    9.241524] DMA: Module install successful, device major num = 242 
    [    9.248160] DRV: Module install successful
    [  OK  ] Started ecarxinit.service.
    [   10.485625] cpsw 48484000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
    [   10.493534] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready

  • Karthik Ramanan said:
    Please note that if the Qt Application is expected to run on top of Wayland, then you will have to specify that in the Qt launch command similar to how weston backend is specified. Have you taken care of that?

    as described in /etc/powervr.ini

    [default]
    #WindowSystem=libpvrws_WAYLAND.so
    
    [weston]
    DbmDriverName=vdrm
    
    [weston-simple-egl]
    DbmDriverName=vdrm
    [avm_qt_app]
    DbmDriverName=vdrm
    

    no need to specify the QT launch command, just run "./avm_qt_app"

  • Thanks for the additional information. Are you still seeing the issue?

    Does it work if you launch it manually without running it from systemd service with the same commands/script that is invoked from the ecarxinit.service?

    Regards

    Karthik

  • Hi Karthik:

      Just confirmed that if we run the "/etc/init.d/ecarxinit.sh start" in the shell, then the QT application works well.

     As stated above, possible in systemd service that the environment is not propagate properly ?

     "XDG_RUNTIME_DIR not set in the environment."

    please have a look at this post 

  • Hi Karthik:

        Try as that post did, the issue is fixed.

  • Hi 

    And more, these environment are located in  /etc/profile.d/wayland_env.sh.

    what's the proper way to export these environment variables?

  • Hi,

    Thanks for the confirmation.

    You can refer to some of the oe-core recipes that does this and follow similar approach.

    1. oe-core/meta/recipes-graphics/wayland/weston-init/weston.service
    2. oe-core/meta/recipes-graphics/wayland/weston-init/weston-start

    Regards

    Karthik