diff mbox series

[meta-arago,scarthgap,RFC,1/4] swupdate: add systemd service to rootfs

Message ID 20251202111603.1616989-2-anshuld@ti.com
State New
Headers show
Series Add support for SWUpdate | expand

Commit Message

Anshul Dalal Dec. 2, 2025, 11:15 a.m. UTC
This patch adds basic support for A/B dual update mechanism where the
rootfs is duplicated to provide redundancy in case of an update failure.

The bbappend adds the modifications required to make SWUpdate suitable
for our use case. The new swupdate systemd service invokes swupdate.sh
on startup which starts an update server on the target platform.

The "ti-swupdate" override is used to selectively enable SWUpdate
support to the final tisdk image.

Signed-off-by: Anshul Dalal <anshuld@ti.com>
---
 meta-arago-distro/conf/distro/arago.conf      |  1 +
 .../recipes-swupdate/swupdate/files/defconfig |  9 ++++++
 .../swupdate/files/swupdate.cfg               | 13 +++++++++
 .../swupdate/files/swupdate.sh                | 11 ++++++++
 .../swupdate/swupdate_%.bbappend              | 28 +++++++++++++++++++
 .../wic/sdimage-2part-swupdate.wks            |  6 ++++
 6 files changed, 68 insertions(+)
 create mode 100644 meta-arago-distro/recipes-swupdate/swupdate/files/defconfig
 create mode 100644 meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.cfg
 create mode 100644 meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh
 create mode 100644 meta-arago-distro/recipes-swupdate/swupdate/swupdate_%.bbappend
 create mode 100644 meta-arago-distro/wic/sdimage-2part-swupdate.wks
diff mbox series

Patch

diff --git a/meta-arago-distro/conf/distro/arago.conf b/meta-arago-distro/conf/distro/arago.conf
index abbe4faf..d8630718 100644
--- a/meta-arago-distro/conf/distro/arago.conf
+++ b/meta-arago-distro/conf/distro/arago.conf
@@ -34,6 +34,7 @@  IMAGE_FSTYPES += "tar.xz.md5sum"
 
 # Extra boot files for WIC images
 do_image_wic[depends] += "tisdk-uenv:do_deploy"
+WKS_FILE:ti-swupdate = "sdimage-2part-swupdate.wks"
 IMAGE_BOOT_FILES += "uEnv.txt"
 
 # Mask any broken recipes (currently none)
diff --git a/meta-arago-distro/recipes-swupdate/swupdate/files/defconfig b/meta-arago-distro/recipes-swupdate/swupdate/files/defconfig
new file mode 100644
index 00000000..b1362eaa
--- /dev/null
+++ b/meta-arago-distro/recipes-swupdate/swupdate/files/defconfig
@@ -0,0 +1,9 @@ 
+CONFIG_HW_COMPATIBILITY=y
+# CONFIG_LUA is not set
+# CONFIG_BOOTLOADER_NONE is not set
+CONFIG_SYSTEMD=y
+CONFIG_WEBSERVER=y
+CONFIG_CFI=y
+CONFIG_EMMC_HANDLER=y
+CONFIG_RAW=y
+CONFIG_SHELLSCRIPTHANDLER=y
diff --git a/meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.cfg b/meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.cfg
new file mode 100644
index 00000000..5cb04b0c
--- /dev/null
+++ b/meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.cfg
@@ -0,0 +1,13 @@ 
+globals :
+{
+	verbose = true;
+	loglevel = 5;
+	syslog = true;
+};
+
+webserver :
+{
+	document_root = "/www";
+	userid		= 0;
+	groupid		= 0;
+};
diff --git a/meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh b/meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh
new file mode 100644
index 00000000..bb3a3593
--- /dev/null
+++ b/meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh
@@ -0,0 +1,11 @@ 
+#!/bin/sh
+
+rootfs=$(swupdate -g)
+
+if [ $rootfs == '/dev/mmcblk0p2' ];then
+	SELECTION="-e stable,copy1"
+else
+	SELECTION="-e stable,copy2"
+fi
+
+swupdate -H @MACHINE@:1.0 ${SELECTION} -p 'reboot' -f /etc/swupdate.cfg -w "-r /www -p 8080"
diff --git a/meta-arago-distro/recipes-swupdate/swupdate/swupdate_%.bbappend b/meta-arago-distro/recipes-swupdate/swupdate/swupdate_%.bbappend
new file mode 100644
index 00000000..0ce763f9
--- /dev/null
+++ b/meta-arago-distro/recipes-swupdate/swupdate/swupdate_%.bbappend
@@ -0,0 +1,28 @@ 
+inherit swupdate-lib
+
+FILESEXTRAPATHS:append := "${THISDIR}/files:"
+
+FILES:${PN} += " \
+  ${SWUPDATE_HW_COMPATIBILITY_FILE} \
+"
+
+SRC_URI += " \
+    file://defconfig \
+    file://swupdate.sh \
+    file://swupdate.cfg \
+    "
+
+do_install:append () {
+  install -d ${D}
+  echo "${MACHINE} 1.0" > ${D}/${@d.getVar("SWUPDATE_HW_COMPATIBILITY_FILE")}
+
+  # We don't make use of conf.d in our swupdate.sh
+  rm -rf ${D}${libdir}/swupdate/conf.d
+
+  install -m 0755 ${WORKDIR}/swupdate.sh ${D}${libdir}/swupdate/
+  sed -i "s#@MACHINE@#${MACHINE}#g" ${D}${libdir}/swupdate/swupdate.sh
+
+  install -d ${D}${sysconfdir}
+  install -m 644 ${WORKDIR}/swupdate.cfg ${D}${sysconfdir}
+  sed -i "s#@MACHINE@#${MACHINE}#g" ${D}${sysconfdir}/swupdate.cfg
+}
diff --git a/meta-arago-distro/wic/sdimage-2part-swupdate.wks b/meta-arago-distro/wic/sdimage-2part-swupdate.wks
new file mode 100644
index 00000000..cf3b6f03
--- /dev/null
+++ b/meta-arago-distro/wic/sdimage-2part-swupdate.wks
@@ -0,0 +1,6 @@ 
+# short-description: Create SD card image with A/B partitions for SWUpdate
+# long-description: Creates a partitioned SD card image for TI platforms with SWUpdate support.
+# Check https://sbabic.github.io/swupdate/scenarios.html#double-copy-with-fall-back
+
+part / --source rootfs --fstype=ext4 --label rootfs_1 --align 1024 --use-uuid
+part / --source rootfs --fstype=ext4 --label rootfs_2 --align 1024 --use-uuid