Hello,
I am currently working on the deployment of a qt application on jetsonTX2 (connect tech orbitty motherboard) with a graphical user interface.
I have installed l4t32.2.1 (ubuntu 18.04) on the TX2. My application uses qt, opencv (built with Cuda) and a driver for my camera.
Qt was cross compiled with the “-opengl es2” option.
My application works normally when I launch it from the TX2 (from the desktop environment), it launches full screen as expected using the eglfs plugin.
Now, I want the application to start automatically when the jetson TX2 boots. I can launch the application at startup using the auto-login function of lightdm and creating a .desktop file in the directory /etc/xdg/autostart. Everything is ok with this method.
However, I would like to achieve this without loading the graphical environment (“display manager”, desktop and so on) to have a lighter system. So, I have uninstalled the following packages: unity, lightdm and gnome-shell. The jetson TX2 then starts in console mode and asks for a login and a password. When I connect, I can launch my application with the following command:
startx my_application
Everything seems to work normally, the GUI appears and it is possible to interact normally. My problem is that I can not find a way to launch my application automatically after booting.
I have tried to create an autostart script in /etc/init.d/ and then to run it with update-rc.d autostart defaults but without success. Below are the contents of my scripts:
autostart.sh
#!/bin/sh
# https://wiki.debian.org/LSBInitScripts
### BEGIN INIT INFO
# Provides: autostart
# Required-Start: $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Autostart
### END INIT INFO
case "$1" in
start)
logger "Starting autostart scripts"
# your scripts here
/home/my_app/startup.sh
logger $?
exit 0
;;
*)
echo "It's just a startup script and has no arguments or commands"
exit 1
;;
esac
startup.sh
#!/bin/sh
echo "Démarrage de mon application"
startx ./bin/my_application -platform eglfs > log.txt 2>&1 &
In the file /var/log/syslog I just have this line “Nov 8 22:18:50 pilotweeder autostart[4244]: Démarrage de mon application” but the application is not started and my “log.txt” file is empty.
Then, I have tried to make a service with systemd. Here is the content of my_app.service file:
[Unit]
Description=MyApp
#After=lightdm.service org.freedesktop.login1.service
[Service]
#Environment="DISPLAY=:0.0"
#Environment="QT_QPA_PLATFORM=eglfs"
#Environment="QT_QPA_EGLFS_PHYSICAL_WIDTH=535"
#Environment="QT_QPA_EGLFS_PHYSICAL_HEIGHT=300"
#Environment="QT_QPA_FONTDIR=/usr/share/fonts/truetype"
#Environment="XDG_RUNTIME_DIR=/tmp/runtime-nvidia"
Type=simple
TimeoutStartSec=60
WorkingDirectory=/home
#ExecStartPre=/etc/profile.d/qt_eglfs.sh
ExecStart=/home/my_app/startup.sh
Restart=always
#Restart=on-abort
[Install]
WantedBy=multi-user.target
Here is systemctl status :
● my_app.service - MyApp
Loaded: loaded (/etc/systemd/system/my_app.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Fri 2019-11-08 22:27:55 CET; 7s ago
Process: 6949 ExecStart=/home/my_app/startup.sh (code=exited, status=0/
Main PID: 6949 (code=exited, status=0/SUCCESS)
nov. 08 22:27:55 pilotweeder systemd[1]: my_app.service: Service hold-off time over, scheduling restart.
nov. 08 22:27:55 pilotweeder systemd[1]: my_app.service: Scheduled restart job, restart counter is at 5.
nov. 08 22:27:55 pilotweeder systemd[1]: Stopped MyApp.
nov. 08 22:27:55 pilotweeder systemd[1]: my_app.service: Start request repeated too quickly.
nov. 08 22:27:55 pilotweeder systemd[1]: my_app.service: Failed with result 'start-limit-hit'.
nov. 08 22:27:55 pilotweeder systemd[1]: Failed to start MyApp.
And journalctl -xe
-- Subject: Unit my_app.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit my_app.service has finished shutting down.
nov. 08 22:27:55 pilotweeder systemd[1]: Started MyApp.
-- Subject: Unit my_app.service has finished start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit my_app.service has finished starting up.
--
-- The start-up result is RESULT.
nov. 08 22:27:55 pilotweeder startup.sh[6949]: Démarrage de mon application
nov. 08 22:27:55 pilotweeder systemd[1]: my_app.service: Service hold-off time over, scheduling restart.
nov. 08 22:27:55 pilotweeder systemd[1]: my_app.service: Scheduled restart job, restart counter is at 5.
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Automatic restarting of the unit my_app.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
nov. 08 22:27:55 pilotweeder systemd[1]: Stopped MyApp.
-- Subject: Unit my_app.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit my_app.service has finished shutting down.
nov. 08 22:27:55 pilotweeder systemd[1]: my_app.service: Start request repeated too quickly.
nov. 08 22:27:55 pilotweeder systemd[1]: my_app.service: Failed with result 'start-limit-hit'.
nov. 08 22:27:55 pilotweeder systemd[1]: Failed to start MyApp.
-- Subject: Unit my_app.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- Unit my_app.service has failed.
I think that the problem may come from the fact that I am not yet logged in when I run the service. But even if this is the explanation, I have no idea how to resolve this issue. Any idea from anyone would be greatly appreciated !