我正在尝试使用 SWUpdate 和 Hawkbit 设置嵌入式 linux 更新系统。我使用 Yocto 作为构建系统。我能够创建一个安装了 SWUpdate 二进制文件的图像,如 SWUpdate 文档中给出的那样。现在,我想在启动时启动 SWUpdate 守护程序,为此我正在使用 Systemd 服务。SWUpdate systemd 集成
但是我在启动时遇到了启动 swupdate 守护进程的问题。
swupdate.service:
[Unit]
Description=SWUpdate daemon
Documentation=https://github.com/sbabic/swupdate
Documentation=https://sbabic.github.io/swupdate
[Service]
ExecStart=@LIBDIR@/swupdate/swupdate.sh
KillMode=mixed
[Install]
WantedBy=multi-user.target
当我systemctl status swupdate.service
用 bitbaked 图像启动我的电路板后,我得到:
* swupdate.service - SWUpdate daemon
Loaded: loaded (/lib/systemd/system/swupdate.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2022-02-10 12:41:49 UTC; 12min ago
TriggeredBy: * swupdate.socket
Docs: https://github.com/sbabic/swupdate
https://sbabic.github.io/swupdate
Process: 311 ExecStart=/usr/lib/swupdate/swupdate.sh (code=exited, status=1/FAILURE)
Main PID: 311 (code=exited, status=1/FAILURE)
Feb 10 12:41:49 dh-stm32mp1-dhcor-avenger96 systemd[1]: Started SWUpdate daemon.
Feb 10 12:41:49 dh-stm32mp1-dhcor-avenger96 swupdate.sh[311]: /usr/lib/swupdate/conf.d/09-swupdate-args: line 10: [: ==: unary operator expected
Feb 10 12:41:49 dh-stm32mp1-dhcor-avenger96 swupdate.sh[311]: /usr/bin/swupdate: invalid option -- 'u'
Feb 10 12:41:49 dh-stm32mp1-dhcor-avenger96 swupdate.sh[311]: /usr/bin/swupdate: invalid option -- 'u'
Feb 10 12:41:49 dh-stm32mp1-dhcor-avenger96 swupdate.sh[311]: Try /usr/bin/swupdate -h for usage
Feb 10 12:41:49 dh-stm32mp1-dhcor-avenger96 systemd[1]: swupdate.service: Main process exited, code=exited, status=1/FAILURE
Feb 10 12:41:49 dh-stm32mp1-dhcor-avenger96 systemd[1]: swupdate.service: Failed with result 'exit-code'.
Feb 10 12:41:49 dh-stm32mp1-dhcor-avenger96 systemd[1]: swupdate.service: Start request repeated too quickly.
Feb 10 12:41:49 dh-stm32mp1-dhcor-avenger96 systemd[1]: swupdate.service: Failed with result 'exit-code'.
Feb 10 12:41:49 dh-stm32mp1-dhcor-avenger96 systemd[1]: Failed to start SWUpdate daemon.
结果ps ax | grep swupdate
:
234 ? Ss 0:03 /usr/bin/swupdate-progress -r -w
392 ttySTM0 S+ 0:00 grep swupdate
swupdate.sh 和 swupdate.service 文件中没有任何更改。元软件更新
swupdate.sh:
#!/bin/sh
# Override these variables in sourced script(s) located
# in /usr/lib/swupdate/conf.d or /etc/swupdate/conf.d
SWUPDATE_ARGS="-v ${SWUPDATE_EXTRA_ARGS}"
SWUPDATE_WEBSERVER_ARGS=""
SWUPDATE_SURICATTA_ARGS=""
# source all files from /etc/swupdate/conf.d and /usr/lib/swupdate/conf.d/
# A file found in /etc replaces the same file in /usr
for f in `(test -d /usr/lib/swupdate/conf.d/ && ls -1 /usr/lib/swupdate/conf.d/; test -d /etc/swupdate/conf.d && ls -1 /etc/swupdate/conf.d) | sort -u`; do
if [ -f /etc/swupdate/conf.d/$f ]; then
. /etc/swupdate/conf.d/$f
else
. /usr/lib/swupdate/conf.d/$f
fi
done
# handle variable escaping in a simmple way. Use exec to forward open filedescriptors from systemd open.
if [ "$SWUPDATE_WEBSERVER_ARGS" != "" -a "$SWUPDATE_SURICATTA_ARGS" != "" ]; then
exec /usr/bin/swupdate $SWUPDATE_ARGS -w "$SWUPDATE_WEBSERVER_ARGS" -u "$SWUPDATE_SURICATTA_ARGS"
elif [ "$SWUPDATE_WEBSERVER_ARGS" != "" ]; then
exec /usr/bin/swupdate $SWUPDATE_ARGS -w "$SWUPDATE_WEBSERVER_ARGS"
elif [ "$SWUPDATE_SURICATTA_ARGS" != "" ]; then
exec /usr/bin/swupdate $SWUPDATE_ARGS -u "$SWUPDATE_SURICATTA_ARGS"
else
exec /usr/bin/swupdate $SWUPDATE_ARGS
fi
09-swupdate-args:此脚本确保使用正确的参数调用 Suricatta,并$
使用正确的值更新占位符。它位于/usr/lib/swupdate/conf.d
09-swupdate-args:
rootfs=`mount | grep "on / type" | cut -d':' -f 2 | cut -d' ' -f 1`
if [ $rootfs == '/dev/mmcblk0p4' ];then
selection="-e stable,copy2"
else
selection="-e stable,copy1"
fi
state=`fw_printenv ustate | cut -f 2 -d'='`
if [ $state == 1 ];then
SWUPDATE_SURICATTA_ARGS="-c 2"
else
SWUPDATE_SURICATTA_ARGS=" "
fi
SWUPDATE_ARGS="-H dh-stm32mp1-dhcor-avenger96:1.0 ${selection} -f /etc/swupdate.cfg"
也fw_printenv ustate | cut -f 2 -d'='
导致空。这是什么意思?
如果有人遇到过 SWUpdate 的这个问题,你能告诉我这里缺少什么吗?以及如何解决这个问题?
您的帮助将不胜感激。
提前致谢
PS:我正在使用 SWUpdate v2021.04.0 来更新我基于 STM32MP1 的 Avenger96 板。如果这里缺少任何信息,请告诉我。