Run splashscreen at Raspberry Pi boot before running Qt App
-
I developed a PyQt app with Qt-5.15.2 that is fully functional on a Raspberry Pi 4 with standard Raspbian OS. I would like however to start my application as soon as the RPi4 boots, avoiding the user to see or get access to the desktop before the Qt app starts. For doing that, I tried to use systemd services, to run my app executable automatically at startup.
So I am trying to run two services at RPi 4 startup:
-
one is my Qt App which I made executable and which has to wait for the graphical.target before running, which makes it start only after the raspberry loads the desktop.
-
the second is a simple splash screen which I would like to start from the very early boot of the RPi (thus hiding the console log) and ending just before the Qt app starts, therefore hiding everything, including the desktop frame, till the full-screen app appears.
Following several different guides, I tried various combination of parameters in the systemd files, such as:
[Unit] Description= My Qt App Service After=graphical.target [Service] Type=simple User=pi Environment=DISPLAY=:0 WorkingDirectory=/home/pi ExecStart=/home/pi/myqtApp [Install] WantedBy=multi-user.target
for the Qt app (starting after the desktop loaded)
and:
[Unit] Description=Splash Screen Service DefaultDependencies=no After=local-fs.target Before=graphical.target [Service] ExecStart=/usr/bin/fbi -d /dev/fb0 --once --noverbose -a /opt/splashscreen.jpg StandardInput=tty StandardOutput=tty [Install] WantedBy=sysinit.target
For the splash screen service.
I also modified the /boot/config.txt with display_splash=1 and /boot/cmdline.txt with
console=serial0,115200 console=tty1 root=PARTUUID=c8e5bf6e-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait logo.nologo consoleblank=0 loglevel=1 quiet vt.global_cursor_default=0
Now, two things happen depending on whether I set console=tty1 or tty3 (a guide suggested doing this) in the cmdline.txt file,
if tty1 is set, then the splash screen page is only briefly shown during startup, and then the desktop loads, and finally, my qt app starts. But I would like the splash screen to persist till the app starts without showing the desktop loading.
if tty3 is set, then the splash screen page is shown immediately at startup, but then the boot is stuck on it and nothing else is shown. In this case, I can see that my Qt app service started (no errors appear in its status) however somehow the splash screen service does not stop and therefore my qt app is not shown.
I would like everything to work as in this second case, with only the splash screen appearing since the beginning, but, of course, being replaced by the qt app as soon as the graphics allow it to run properly. I tried many other combinations of parameters in the service files but nothing seems to work.
I am also considering purchasing a Commercial License for Qt in order to use Boot2Qt but I am afraid that I would then not be able to use PyQt. I would also consider any other option to really start my application at raspberry pi boot.
-