Skip to content

Commit

Permalink
Implement support for remote updates via hawkBit
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  • Loading branch information
tpetazzoni committed Mar 9, 2020
1 parent a7d0c59 commit be6bfee
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/sh

DAEMON="swupdate"
PIDFILE="/var/run/$DAEMON.pid"

PART_STATUS=$(sgdisk -A 4:get:2 /dev/mmcblk0)
if test "${PART_STATUS}" = "4:2:1" ; then
ROOTFS=rootfs-2
else
ROOTFS=rootfs-1
fi

if test -f /update-ok ; then
SURICATTA_ARGS="-c 2"
rm -f /update-ok
fi

start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -b -q -m -S -p "$PIDFILE" -x "/usr/bin/$DAEMON" \
-- -f /etc/swupdate/swupdate.cfg -L -e rootfs,${ROOTFS} -u "${SURICATTA_ARGS}"
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}

stop() {
printf 'Stopping %s: ' "$DAEMON"
start-stop-daemon -K -q -p "$PIDFILE"
status=$?
if [ "$status" -eq 0 ]; then
rm -f "$PIDFILE"
echo "OK"
else
echo "FAIL"
fi
return "$status"
}

restart() {
stop
sleep 1
start
}

case "$1" in
start|stop|restart)
"$1";;
reload)
# Restart, since there is no true "reload" feature.
restart;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
#!/bin/sh

PART_STATUS=$(sgdisk -A 4:get:2 /dev/mmcblk0)
if test "${PART_STATUS}" = "4:2:1" ; then
NEXT_ROOTFS=/dev/mmcblk0p5
else
NEXT_ROOTFS=/dev/mmcblk0p4
fi

# Add update marker
mount ${NEXT_ROOTFS} /mnt
touch /mnt/update-ok
umount /mnt

sgdisk -A 4:toggle:2 -A 5:toggle:2 /dev/mmcblk0
reboot
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
globals :
{
postupdatecmd = "/etc/swupdate/postupdate.sh";
};

suricatta :
{
tenant = "default";
id = "DEV001";
url = "http://192.168.42.1:8080";
};
4 changes: 4 additions & 0 deletions board/stmicroelectronics/stm32mp157-dk/swupdate.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONFIG_BOOTLOADER_NONE=y
CONFIG_SURICATTA=y
CONFIG_WEBSERVER=y
CONFIG_RAW=y

0 comments on commit be6bfee

Please sign in to comment.