How the EGT Launcher is Started on Linux
When we create an embedded Linux boot system for Microchip MPU using buildroot, we can select the appropriate configuration file for graphical applications. The resulting Linux image will automatically start the EGT launcher, similar to the EGT graphical launcher. Next, we will analyze how to implement the startup of the EGT launcher through scripts in embedded Linux after power-up.
- First, check the EGT startup script
cd output/target/etc/systemd/system/multi-user.target.wants
ls -al
total 8
drwxr-xr-x 2 afan afan 4096 Dec 31 2024 .
drwxr-xr-x 3 afan afan 4096 Dec 31 2024 ..
lrwxrwxrwx 1 afan afan 39 Dec 31 2024 egtdemo.service -> /usr/lib/systemd/system/egtdemo.service
- Check the directory where the actual EGT startup script is located
cd ../../../../usr/lib/systemd/system
ls
alsa-restore.service local-fs.target suspend.target systemd-reboot.service
alsa-restore.service.d local-fs.target.wants swap.target systemd-remount-fs.service
alsa-state.service [email protected] sys-fs-fuse-connections.mount systemd-resolved.service
alsa-state.service.d multi-user.target sysinit.target systemd-soft-reboot.service
[email protected] multi-user.target.wants sysinit.target.wants systemd-suspend.service
basic.target network-online.target sys-kernel-config.mount systemd-sysctl.service
[email protected] network-pre.target sys-kernel-debug.mount systemd-timedated.service
boot-complete.target nfs-mountd.service systemd-ask-password-console.path systemd-tmpfiles-clean.service
console-getty.service nfs-utils.service systemd-ask-password-console.service systemd-tmpfiles-clean.timer
[email protected] nss-lookup.target systemd-ask-password-wall.path systemd-tmpfiles-setup-dev-early.service
ctrl-alt-del.target nss-user-lookup.target systemd-ask-password-wall.service systemd-tmpfiles-setup-dev.service
dbus-org.freedesktop.hostname1.service ntpd.service systemd-boot-check-no-failures.service systemd-tmpfiles-setup.service
dbus-org.freedesktop.timedate1.service paths.target systemd-exit.service systemd-udevd-control.socket
dbus.service poweroff.target systemd-fsck-root.service systemd-udevd-kernel.socket
dbus.socket printer.target [email protected] systemd-udevd.service
debug-shell.service proc-fs-nfsd.mount systemd-growfs-root.service systemd-udev-settle.service
default.target radvd.service [email protected] systemd-udev-trigger.service
dev-hugepages.mount reboot.target systemd-halt.service systemd-update-done.service
dev-mqueue.mount remote-fs-pre.target systemd-hostnamed.service systemd-vconsole-setup.service
dhcpd.service.example remote-fs.target systemd-journal-catalog-update.service system-update-cleanup.service
egtdemo.service rescue.service systemd-journald-audit.socket system-update-pre.target
exit.target rpcbind.target [email protected] timers.target.wants
factory-reset.target rpc_pipefs.target systemd-journald.socket time-set.target
final.target rpc-statd-notify.service [email protected] time-sync.target
first-boot-complete.target rpc-statd.service [email protected] tmp.mount
fstrim.service run-nfs-rpc_pipefs.mount systemd-journal-flush.service umount.target
fstrim.timer [email protected] systemd-kexec.service usb-gadget.target
getty-pre.target shutdown.target systemd-machine-id-commit.service [email protected]
[email protected] sigpwr.target systemd-modules-load.service [email protected]
[email protected] sleep.target systemd-networkd.service [email protected]
getty.target slices.target systemd-networkd.socket [email protected]
graphical.target smartcard.target systemd-ne
- Check the content of the actual EGT startup script
cat egtdemo.service
[Unit]
Description=EGT Application Launcher Service
After=network.target
ConditionPathExists=/dev/dri/card0
[Service]
Type=simple
ExecStart=sh -c 'egt-launcher /opt/applications/resources /usr/share/egt'
RemainAfterExit=yes
Restart=on-failure
[Install]
WantedBy=multi-user.target
- Check the network service that the EGT startup script depends on
cat network.target
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Network
Documentation=man:systemd.special(7)
Documentation=https://systemd.io/NETWORK_ONLINE
After=network-pre.target
RefuseManualStart=yes
egtdemo.service is a systemd service unit file that defines how the service named “EGT Application Launcher” runs on a Linux system. systemd is the default service manager for most modern Linux distributions, and unit files are used to specify the rules for starting and stopping services and their operational behavior.
Next, we will analyze it section by section:
1. [Unit] Section
This section contains metadata (description) and dependency configuration for the service.
- Description=EGT Application Launcher Service
The human-readable name/description of the service (translated meaning: “EGT Application Launcher Service”), used to identify the service in commands like systemctl status, making it easier for users to recognize.
- After=network.target
This specifies that the service should start after the network.target is reached. The network.target indicates that the system network is up and available, ensuring that the EGT launcher starts only when the network service is ready (suitable for scenarios where EGT applications depend on network access).
- ConditionPathExists=/dev/dri/card0
This is a prerequisite for the service to start: the file /dev/dri/card0 must exist. This file is the device node for the graphics card (GPU) using the Direct Rendering Infrastructure (DRI) (DRI is the subsystem in Linux for hardware-accelerated graphics). This condition ensures that the service runs only on systems with an available GPU — which is crucial for EGT (Embedded GUI Toolkit) as EGT relies on graphics hardware for interface rendering.
2. [Service] Section
This section defines the operational rules of the service, including the executable to start and its behavior policies.
- Type=simple
This identifies the service as a “simple type”: systemd considers the main process defined in ExecStart as the completion of the service startup. This is the most common type for simple services.
- ExecStart=sh -c ‘egt-launcher /opt/applications/resources /usr/share/egt’
This is the command executed when the service starts, with the following meanings:
- sh -c ‘…’: Executes the command within the parentheses through the shell (providing flexibility for command execution, supporting path resolution, etc.);
- egt-launcher: The core executable (i.e., the EGT application launcher used to start applications developed based on EGT);
- /opt/applications/resources and /usr/share/egt: Parameters passed to egt-launcher (typically the application resource file path and the resource directory of the EGT library).
- RemainAfterExit=yes
By default, when the main process of the service exits, systemd marks the service as “inactive”. Setting this option to yes means that even if the egt-launcher process exits, the service will still be marked as “active”. This is suitable for scenarios where the launcher starts long-running applications in the background or needs to monitor the overall operation of the application through the service status.
- Restart=on-failure
This configures systemd’s automatic restart policy: when the service exits due to a failure (such as crashing, exiting with a non-zero status code, or being terminated unexpectedly), the service will automatically restart. This configuration ensures that the EGT application automatically recovers in case of errors, enhancing availability.
3. [Install] Section
This section controls the installation and boot startup configuration of the service (i.e., the behavior when “enabling the service”).
- WantedBy=multi-user.target
This specifies that when the service is “enabled” via the systemctl enable command, it will automatically start when the system reaches the multi-user.target. The multi-user.target represents a fully booted system with a command-line interface (but no graphical login interface) — even so, if the EGT application uses framebuffer or headless graphical mode, it can still run in this state.
Summary
The core functionality and operational logic of this service are as follows:
- Startup prerequisites: The system must have an available GPU (existence of /dev/dri/card0) and the network must be ready;
- Core behavior: Start the EGT application via egt-launcher and specify the resource file path;
- Status maintenance: Even if the launcher process exits, the service remains marked as “active”;
- Fault recovery: Automatically restart the service in case of failure;
- Boot startup: Automatically run when the system enters multi-user command line state after being enabled.
Usage
Save this file as /etc/systemd/system/egt-launcher.service, then enable and start the service with the following commands:
sudo systemctl enable egt-launcher.service # Set to start on boot
sudo systemctl start egt-launcher.service # Start the service immediately