HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
HOME
  • GM-3568JHF
  • M4-R1
  • M5-R1
  • SC-3568HA
  • M-K1HSE
  • CF-NRS1
  • CF-CRA2
  • 1684XB-32T
  • 1684X-416T
  • C-3568BQ
  • C-3588LQ
  • GC-3568JBAF
  • C-K1BA
Shop
  • English
  • 简体中文
  • GM-3568JHF

    • 1. Introduction

      • GM-3568JHF Introduction
    • 2. Quick Start

      • 01 Environment Construction
      • 02 Compilation Instructions
      • 03 Burning Guide
      • 04 Debugging Tools
      • 05 Software Update
      • 06 View information
      • 07 Test Command
      • 08 Application Compilation
      • 09 Source code acquisition
    • 3. Peripherals and Interfaces

      • USB
      • Display and touch
      • Ethernet
      • WIFI
      • Bluetooth
      • TF-Card
      • Audio
      • Serial Port
      • CAN
      • RTC
    • 4. Application Development

      • 01 UART read and write case
      • 02 Key detection case
      • 03 LED light flashing case
      • 04 MIPI screen detection case
      • 05 Read USB device information example
      • 06 FAN Detection Case
      • 07 FPGA FSPI Communication Case
      • 08 FPGA DMA read and write case
      • 09 GPS debugging case
      • 10 Ethernet Test Cases
      • 11 RS485 reading and writing examples
      • 12 FPGA IIC read and write examples
      • 13 PN532 NFC card reader case
      • 14 TF card reading and writing case
    • 5. QT Development

      • 01 ARM64 cross compiler environment construction
      • 02 QT program added automatic startup service
    • 6. Others

      • 01 Modification of the root directory file system
      • 02 System auto-start service

02 QT program added automatic startup service

This document will introduce how to modify systemd to automatically start the QT program at boot time

1 Create systemd configuration file

In the /etc/systemd/system/ directory, create a service configuration file, taking qt_display.service as an example

# 在 /etc/systemd/system/ 目录下,创建服务配置文件
sudo vim /etc/systemd/system/qt_display.service

Configuration file example

# qt_display.service
[Unit]
Description=Qt Display Application
After=graphical.target
Requires=graphical.target
Wants=graphical.target

[Service]
Type=simple
ExecStartPre=/bin/sleep 10
ExecStart=/home/linaro/Desktop/ad_test/build-ad_display-Desktop-Debug/ad_display -d ad7606 -m 1
User=root
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/root/.Xauthority"
Environment="LD_LIBRARY_PATH=/home/linaro/Desktop/qwt-6.1.4/build/lib:$LD_LIBRARY_PATH"
Restart=on-failure
RestartSec=3

[Install]
WantedBy=graphical.target

Meaning of each parameter in the configuration file

[Unit]

Description=Service Description

After=The service starts after which target or service starts

Requires=This service requires a target or service to be active before it can start.

Wants=The service would like a target or service to be active, but will not force it.

[Service]

Type=Service Type

ExecStartPre=Commands and scripts executed before the main process starts

ExecStart=Command to execute when starting the service --- main process

User=The user identity that runs the service

Environment=Set environment variables

Restart=Restart service request

RestartSec=Restart delay time

[Install]

WantedBy=Specifies when the target starts the service

2 Start system services

Reload system services, enable and start services

# 重新加载系统服务
sudo systemctl daemon-reload

# 启用服务
sudo systemctl enable qt_display.service

#启动服务
sudo systemctl start qt_display.service

Check whether the service starts normally. If it is normal, restart the system and verify whether the service starts automatically when the computer is turned on. If there is a problem, execute the following command to query the error

# 检查服务状态
sudo systemctl status qt_display.service

# 查看系统日志
journalctl -u qt_display.service

3 Other common commands

# 禁用系统服务
sudo systemctl disable qt_display.service

#停止服务
sudo systemctl stop qt_display.service
Edit this page on GitHub
Last Updated:
Contributors: zwhuang
Prev
01 ARM64 cross compiler environment construction