Failed to start SWUpdate deamon on bootup

815 Views Asked by At

I am trying to set-up an embedded linux update system with SWUpdate and Hawkbit. I am using Yocto as build system. I am able to create an image with SWUpdate binaries installed as given in SWUpdate documentation. Now, I want to start SWUpdate deamon on bootup and for this I am using Systemd services. SWUpdate systemd integration

But I am facing an issue to start swupdate deamon on bootup.

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

When I do systemctl status swupdate.service after booting my board with bitbaked image I get:

* 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.

Result of ps ax | grep swupdate:

  234 ?               Ss     0:03  /usr/bin/swupdate-progress -r -w
  392 ttySTM0  S+     0:00 grep swupdate

No changes are made in swupdate.sh and swupdate.service files. meta-swupdate

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: This script ensures Suricatta is invoked with the correct parameters, and updates the $ placeholders with the correct values. It's located in /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"

And also fw_printenv ustate | cut -f 2 -d'=' results in empty. What does this mean?

If anyone has faced this issue with SWUpdate, Can you please let me know what is missing here? and how to resolve this?

Your help will be much appreciated.

Thanks in advance

P.S: I am using SWUpdate v2021.04.0 to update my STM32MP1 based Avenger96 board. Please let me know if any info is missing here.

0

There are 0 best solutions below