常见问答
- M051 系列(95)
- M0518 系列(97)
- M0519 系列(43)
- M0564 系列(1)
- Mini51 系列(90)
- Nano100 / 102 系列(101)
- Nano103 Base 系列(10)
- Nano110 / 112 LCD 系列(100)
- Nano120 USB 系列(111)
- Nano130 USB+LCD 系列(110)
- NUC029 系列(94)
- NUC100 / 200 系列(102)
- NUC120 / 122 / 123 / 220 USB 系列(116)
- NUC121/125 系列(1)
- NUC126 USB 系列(2)
- NUC130 / 230 CAN 系列(103)
- NUC131/NUC1311 CAN 系列(98)
- NUC140 / 240 USB+CAN 系列(114)
- M451 Base 系列(118)
- M451M 系列(117)
- M452 USB 系列(130)
- M4521 USB 系列(1)
- M453 CAN 系列(128)
- M463 CAN FD/USB HS 系列(1)
- M467 Ethernet/Crypto 系列(1)
- M471 系列(1)
- M479 Motor Control Series(1)
- M481 Base 系列(4)
- M482 USB FS OTG 系列(4)
- M483 CAN 系列(4)
- M484 USB HS OTG 系列(4)
- M485 Crypto 系列(4)
- M487 Ethernet 系列(4)
- M4TK 触摸 IC 系列(25)
- NUC442 / 472 系列(130)
- NUC472 Series(1)
- NUC505 系列(138)
产品
功能
+
常见问答
(Yocto) 开机后自动启动应用程序 日期:2025-01-17
系统启动后执行应用程序
由 Yocto 构建的 Linux 内核使用 systemd 初始化,因此我们需要添加一个系统服务来运行您想要运行的应用程序。
1. | 创建名为“ run- before- login- prompt. service”的 systemd 服务文件,并编辑以下内容。 /home/root/demo.sh 是你希望在启动后运行的应用程序。 |
[Unit] Description=Run script with systemd right before login prompt [Service] Type=idle RemainAfterExit=yes ExecStart=/home/root/demo.sh StandardOutput=journal+console [Install] WantedBy=multi-user.target |
|
2. | 将上述 service 文件放置在开发板的 /lib/systemd/system/run-before-login-prompt.service。 |
3. | 重新启动设备,它将在启动后自动运行。 |
4. | 您还可以使用 Yocto recipe 将服务文件添加到 /lib/systemd/system/ 中。 |
5. | 参考文件 FAQ MA35D1 Add a New Recipe in Yocto,这个 FAQ 演示了如何将文件安装到根目录系统并在启动后运行。 |
SUMMARY = "Demo how to install files to root filesystem and run after booting" LICENSE = "CLOSED" inherit systemd SYSTEMD_AUTO_ENABLE = "enable" SYSTEMD_SERVICE_${PN} = "run-before-login-prompt.service" SRC_URI = "file://run-before-login-prompt.service \ file://demo.sh \ " S = "${WORKDIR}" do_install() { install -d ${D}/${ROOT_HOME} install -m 0777 ${S}/demo.sh ${D}${ROOT_HOME}/demo.sh install -d ${D}/${systemd_unitdir}/system install -m 0644 ${S}/run-before-login-prompt.service ${D}${systemd_unitdir}/system } FILES_${PN} = "${bindir} ${systemd_unitdir}/system/* ${ROOT_HOME}" |
产品: | 微处理器 ,Arm Cortex-A35 微处理器 |
---|---|
应用: | |
功能: | Others,Auto run,Boot source,systemd,Yocto |