0

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.

Preeti
  • 535
  • 1
  • 6
  • 30
  • Change `==` to `=` in **09-swupdate-args**. ([man test](https://linux.die.net/man/1/test)). – Ian Abbott Feb 11 '22 at 15:09
  • Looking at [swupdate.c](https://github.com/sbabic/swupdate/blob/master/core/swupdate.c), the `-u` (`--suricatta`) command line option is only supported if `CONFIG_SURICATTA` is defined. You may need to configure it to enable the option. (I'm sure there must be a way to do that in Yocto, but I do not use it. For a manual configuration, `make menuconfig` would be used, similar to Linux kernel configuration.) – Ian Abbott Feb 11 '22 at 15:37
  • Hello @IanAbbott Yes, I have enabled `CONFIG_SURICATTA` using option `bitbake -c menuconfig swupdate` as given in [SWUpdate config](https://sbabic.github.io/swupdate/swupdate-best-practise.html#swupdate-builtin-configuration) – Preeti Feb 11 '22 at 15:58
  • Hello @IanAbbott after doing changes in default configuration using `bitbake -c menuconfig swupdate`, new `.config` file will be generated. But I am not sure where this file will be saved and I don't want to change default config every-time I bitbake. So, I need to save this file and pass it `swupdate_%.bbappend` as `defconfig`. Any idea where this `.config` file will be saved? – Preeti Feb 11 '22 at 16:19
  • 1
    Well I don't know Yocto that well, but I suppose the examples at [meta-swupdate-boards](https://github.com/sbabic/meta-swupdate-boards) would be a good start. – Ian Abbott Feb 11 '22 at 16:52

0 Answers0