Skip to contentSkip to conversation

Add support for SWUpdate

RFC PATCH In review Anshul Dalal 6 participants 12 messages Dec 2, 2025 – May 29

lore
Share & tools
lore
#0 lore raw

cover Add support for SWUpdate

Hi all,

This RFC adds support for SWUpdate[1] to meta-arago, this provides us with OTA updates with A/B redundancy for the rootfs.

For now the support is enabled for eMMC boot only based on the 'ti-swupdate' override. The below steps can be used to test this RFC on an AM62x EVM:

1. Add 'meta-swupdate' layer[2] to the SDK sources directory.

2. Since the bootloader side changes have not been merged to ti-u-boot yet, make use of the 'swupdate' branch from my own U-Boot fork[3].

3. Enable 'swupdate' support by setting the 'ti-swupdate' override in local.conf as follows:

DISTROOVERRIDES:append = ":ti-swupdate"

4. Flash the U-Boot binaries to the correct offsets on boot0 partition as per the docs[4] and run 'env save' on first boot to save the environment to eMMC's hw partition.

Regards,
Anshul

[1]: https://swupdate.org/
[2]: https://github.com/sbabic/meta-swupdate
[3]: https://github.com/ArchUsr64/u-boot/tree/swupdate
[4]: https://software-dl.ti.com/processor-sdk-linux-rt/esd/AM62X/latest/exports/docs/linux/How_to_Guides/Target/How_to_emmc_boot.html#how-to-emmc-boot

Anshul Dalal (4):
swupdate: add systemd service to rootfs
swupdate: add creation of update image
swupdate: add bootloader support
swupdate: enable authentication for update image

 meta-arago-distro/conf/distro/arago.conf      |  3 ++
 .../images/files/sw-description               | 46 +++++++++++++++++++
 .../recipes-swupdate/images/update-image.bb   | 27 +++++++++++
 .../libubootenv/files/fw_env.config           |  5 ++
 .../libubootenv/libubootenv_%.bbappend        | 10 ++++
 .../recipes-swupdate/swupdate/files/defconfig | 12 +++++
 .../swupdate/files/swupdate.cfg               | 13 ++++++
 .../swupdate/files/swupdate.sh                | 15 ++++++
 .../swupdate/swupdate_%.bbappend              | 35 ++++++++++++++
 .../wic/sdimage-2part-swupdate.wks            |  6 +++
 10 files changed, 172 insertions(+)
 create mode 100644 meta-arago-distro/recipes-swupdate/images/files/sw-description
 create mode 100644 meta-arago-distro/recipes-swupdate/images/update-image.bb
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend
 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
Signature · 1 line
2.52.0
#1 lore raw

RFC PATCH 1/4 swupdate: add systemd service to rootfs

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.

---
 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
meta-arago-distro/conf/distro/arago.conf +1 -0
index abbe4faf..d8630718 100644
@@ -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)
meta-arago-distro/recipes-swupdate/swupdate/files/defconfig new file +9 -0
new file mode 100644
index 00000000..b1362eaa
@@ -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
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.cfg new file +13 -0
new file mode 100644
index 00000000..5cb04b0c
@@ -0,0 +1,13 @@
+globals :
+{
+	verbose = true;
+	loglevel = 5;
+	syslog = true;
+};
+
+webserver :
+{
+	document_root = "/www";
+	userid		= 0;
+	groupid		= 0;
+};
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh new file +11 -0
new file mode 100644
index 00000000..bb3a3593
@@ -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"
meta-arago-distro/recipes-swupdate/swupdate/swupdate_%.bbappend new file +28 -0
new file mode 100644
index 00000000..0ce763f9
@@ -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
+}
meta-arago-distro/wic/sdimage-2part-swupdate.wks new file +6 -0
new file mode 100644
index 00000000..cf3b6f03
@@ -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
Signature · 1 line
2.52.0
#2 lore raw

RFC PATCH 2/4 swupdate: add creation of update image

In reply to Anshul Dalal

SWUpdate makes use of a CPIO archive with a sw-description header that contains the metadata for the update image.

This patch adds a new update-image recipe which enables creation of such image based on what the user sets IMAGE_BASENAME to.

---
 meta-arago-distro/conf/distro/arago.conf      |  2 ++
 .../images/files/sw-description               | 32 +++++++++++++++++++
 .../recipes-swupdate/images/update-image.bb   | 23 +++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 meta-arago-distro/recipes-swupdate/images/files/sw-description
 create mode 100644 meta-arago-distro/recipes-swupdate/images/update-image.bb
meta-arago-distro/conf/distro/arago.conf +2 -0
index d8630718..42124577 100644
@@ -31,6 +31,8 @@ SDK_NAME = "${SDK_NAME_PREFIX}-${SDK_VERSION}"
 SDKPATHINSTALL = "/opt/${SDK_NAME}"
 
 IMAGE_FSTYPES += "tar.xz.md5sum"
+IMAGE_FSTYPES:append:ti-swupdate = " ext4.gz"
+IMAGE_INSTALL:append:ti-swupdate = " swupdate swupdate-www"
 
 # Extra boot files for WIC images
 do_image_wic[depends] += "tisdk-uenv:do_deploy"
meta-arago-distro/recipes-swupdate/images/files/sw-description new file +32 -0
new file mode 100644
index 00000000..8dc4e2b2
@@ -0,0 +1,32 @@
+software =
+{
+	version = "0.1.0";
+
+	@@MACHINE@@ = {
+		hardware-compatibility: [ "1.0"];
+		stable : {
+
+			copy1 : {
+				images: (
+					{
+						filename = "@@IMAGE_BASENAME@@-@@MACHINE@@.rootfs.ext4.gz";
+						device = "/dev/mmcblk0p1";
+						type = "raw";
+						compressed = "zlib";
+					},
+				);
+			};
+
+			copy2 : {
+				images: (
+					{
+						filename = "@@IMAGE_BASENAME@@-@@MACHINE@@.rootfs.ext4.gz";
+						device = "/dev/mmcblk0p2";
+						type = "raw";
+						compressed = "zlib";
+					},
+				);
+			};
+		};
+	}
+}
meta-arago-distro/recipes-swupdate/images/update-image.bb new file +23 -0
new file mode 100644
index 00000000..33b0b74c
@@ -0,0 +1,23 @@
+inherit swupdate
+
+IMAGE_BASENAME ?= "tisdk-default-image"
+
+LICENSE = "MIT"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
+
+SRC_URI = "\
+    file://sw-description \
+"
+
+# images to build before building swupdate image
+IMAGE_DEPENDS = "${IMAGE_BASENAME}"
+
+SWUPDATE_IMAGES = "${IMAGE_BASENAME}"
+
+SWUPDATE_IMAGES_FSTYPES[tisdk-base-image] = ".rootfs.ext4.gz"
+SWUPDATE_IMAGES_FSTYPES[tisdk-tiny-image] = ".rootfs.ext4.gz"
+SWUPDATE_IMAGES_FSTYPES[tisdk-default-image] = ".rootfs.ext4.gz"
+SWUPDATE_IMAGES_FSTYPES[tisdk-bootstrap-image] = ".rootfs.ext4.gz"
+SWUPDATE_IMAGES_FSTYPES[tisdk-jailhouse-image] = ".rootfs.ext4.gz"
+SWUPDATE_IMAGES_FSTYPES[tisdk-thinlinux-image] = ".rootfs.ext4.gz"
+SWUPDATE_IMAGES_FSTYPES[tisdk-bootstrap-base-image] = ".rootfs.ext4.gz"
Signature · 1 line
2.52.0
#3 lore raw

RFC PATCH 3/4 swupdate: add bootloader support

In reply to Anshul Dalal

U-Boot uses the 'bootpart' env variable to configure the rootfs for the kernel at boot. The BACKUP_REG0 MMR is also used to store bootcount as per U-Boot requirements[1].

After each reset, U-Boot increments the bootcount and it's reset to 0 by the swupdate service indicating a successful boot. If the kernel panics however (eg. if the update failed), the bootcount is never reset and keeps on getting incremented by U-Boot until it reaches certain threshold after which U-Boot switches to the other non-updated partition to ensure a successful boot.

This patch adds support for the same to the final .swu image generated by the update-image recipe.

[1]: https://docs.u-boot.org/en/latest/api/bootcount.html

---
 .../recipes-swupdate/images/files/sw-description     | 12 ++++++++++++
 .../recipes-swupdate/libubootenv/files/fw_env.config |  5 +++++
 .../libubootenv/libubootenv_%.bbappend               | 10 ++++++++++
 .../recipes-swupdate/swupdate/files/defconfig        |  2 ++
 .../recipes-swupdate/swupdate/files/swupdate.sh      |  4 ++++
 .../recipes-swupdate/swupdate/swupdate_%.bbappend    |  2 ++
 6 files changed, 35 insertions(+)
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend
meta-arago-distro/recipes-swupdate/images/files/sw-description +12 -0
index 8dc4e2b2..241bc95c 100644
@@ -15,6 +15,12 @@ software =
 						compressed = "zlib";
 					},
 				);
+				uboot: (
+					{
+						name = "bootpart";
+						value = "0:1";
+					},
+				);
 			};
 
 			copy2 : {
@@ -26,6 +32,12 @@ software =
 						compressed = "zlib";
 					},
 				);
+				uboot: (
+					{
+						name = "bootpart";
+						value = "0:2";
+					},
+				);
 			};
 		};
 	}
meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config new file +5 -0
new file mode 100644
index 00000000..57eec5fc
@@ -0,0 +1,5 @@
+# Describes the env location for U-Boot in the hw partition
+# Second entry indicates redundant env
+# Boot dev			Offset		Size
+/dev/mmcblk0boot0	0x680000	0x20000
+/dev/mmcblk0boot0	0x6a0000	0x20000
meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend new file +10 -0
new file mode 100644
index 00000000..e3d142f2
@@ -0,0 +1,10 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+SRC_URI:append = " file://fw_env.config"
+
+do_install:append() {
+	install -d ${D}${sysconfdir}
+	install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}
+}
+
+FILES:${PN}:append = " ${sysconfdir}"
meta-arago-distro/recipes-swupdate/swupdate/files/defconfig +2 -0
index b1362eaa..4a2d78c0 100644
@@ -1,8 +1,10 @@
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_LUA is not set
 # CONFIG_BOOTLOADER_NONE is not set
+CONFIG_UBOOT=y
 CONFIG_SYSTEMD=y
 CONFIG_WEBSERVER=y
+CONFIG_BOOTLOADERHANDLER=y
 CONFIG_CFI=y
 CONFIG_EMMC_HANDLER=y
 CONFIG_RAW=y
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +4 -0
index bb3a3593..2083062e 100644
@@ -8,4 +8,8 @@ else
 	SELECTION="-e stable,copy2"
 fi
 
+# BACKUP_REG0 MMR on AM62x
+UBOOT_BOOTCOUNT_ADDR=0x4301c100
+
+devmem2 $UBOOT_BOOTCOUNT_ADDR w 0
 swupdate -H @MACHINE@:1.0 ${SELECTION} -p 'reboot' -f /etc/swupdate.cfg -w "-r /www -p 8080"
meta-arago-distro/recipes-swupdate/swupdate/swupdate_%.bbappend +2 -0
index 0ce763f9..20f87435 100644
@@ -2,6 +2,8 @@ inherit swupdate-lib
 
 FILESEXTRAPATHS:append := "${THISDIR}/files:"
 
+RDEPENDS:${PN} += "devmem2"
+
 FILES:${PN} += " \
   ${SWUPDATE_HW_COMPATIBILITY_FILE} \
 "
Signature · 1 line
2.52.0
#4 lore raw

Re: [meta-arago][scarthgap][PATCH RFC 3/4] swupdate: add bootloader support

Quoted 105 lines · Anshul Dalal via lists.yoctoproject.org

U-Boot uses the 'bootpart' env variable to configure the rootfs for the kernel at boot. The BACKUP_REG0 MMR is also used to store bootcount as per U-Boot requirements[1].

After each reset, U-Boot increments the bootcount and it's reset to 0 by the swupdate service indicating a successful boot. If the kernel panics however (eg. if the update failed), the bootcount is never reset and keeps on getting incremented by U-Boot until it reaches certain threshold after which U-Boot switches to the other non-updated partition to ensure a successful boot.

This patch adds support for the same to the final .swu image generated by the update-image recipe.

[1]: https://docs.u-boot.org/en/latest/api/bootcount.html

---
  .../recipes-swupdate/images/files/sw-description     | 12 ++++++++++++
  .../recipes-swupdate/libubootenv/files/fw_env.config |  5 +++++
  .../libubootenv/libubootenv_%.bbappend               | 10 ++++++++++
  .../recipes-swupdate/swupdate/files/defconfig        |  2 ++
  .../recipes-swupdate/swupdate/files/swupdate.sh      |  4 ++++
  .../recipes-swupdate/swupdate/swupdate_%.bbappend    |  2 ++
  6 files changed, 35 insertions(+)

create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend

meta-arago-distro/recipes-swupdate/images/files/sw-description +12 -0
index 8dc4e2b2..241bc95c 100644
@@ -15,6 +15,12 @@ software =
  						compressed = "zlib";
  					},
  				);
+				uboot: (
+					{
+						name = "bootpart";
+						value = "0:1";
+					},
+				);
  			};
 
  			copy2 : {
@@ -26,6 +32,12 @@ software =
  						compressed = "zlib";
  					},
  				);
+				uboot: (
+					{
+						name = "bootpart";
+						value = "0:2";
+					},
+				);
  			};
  		};
  	}
meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config new file +5 -0
new file mode 100644
index 00000000..57eec5fc
@@ -0,0 +1,5 @@
+# Describes the env location for U-Boot in the hw partition
+# Second entry indicates redundant env
+# Boot dev			Offset		Size
+/dev/mmcblk0boot0	0x680000	0x20000
+/dev/mmcblk0boot0	0x6a0000	0x20000
meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend new file +10 -0
new file mode 100644
index 00000000..e3d142f2
@@ -0,0 +1,10 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+SRC_URI:append = " file://fw_env.config"
+
+do_install:append() {
+	install -d ${D}${sysconfdir}
+	install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}
+}
+
+FILES:${PN}:append = " ${sysconfdir}"
meta-arago-distro/recipes-swupdate/swupdate/files/defconfig +2 -0
index b1362eaa..4a2d78c0 100644
@@ -1,8 +1,10 @@
  CONFIG_HW_COMPATIBILITY=y
  # CONFIG_LUA is not set
  # CONFIG_BOOTLOADER_NONE is not set
+CONFIG_UBOOT=y
  CONFIG_SYSTEMD=y
  CONFIG_WEBSERVER=y
+CONFIG_BOOTLOADERHANDLER=y
  CONFIG_CFI=y
  CONFIG_EMMC_HANDLER=y
  CONFIG_RAW=y
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +0 -0
index bb3a3593..2083062e 100644

meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh else · line 14

Quoted 7 lines
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +4 -0
@@ -8,4 +8,8 @@ else
  	SELECTION="-e stable,copy2"
  fi
 
+# BACKUP_REG0 MMR on AM62x
+UBOOT_BOOTCOUNT_ADDR=0x4301c100
+
+devmem2 $UBOOT_BOOTCOUNT_ADDR w 0

Yuck, magic memory locations and /dev/mem, I'm trying to get rid of our dependence on /dev/mem in general so let's not add to the problem. How about CONFIG_BOOTCOUNT_FS?

Or maybe store it in an EFI variable, look into efivarfs and see if we can do something with that to allow usersapce access to this count.

Andrew

Quoted 14 lines
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +0 -0
  swupdate -H @MACHINE@:1.0 ${SELECTION} -p 'reboot' -f /etc/swupdate.cfg -w "-r /www -p 8080"
meta-arago-distro/recipes-swupdate/swupdate/swupdate_%.bbappend +2 -0
index 0ce763f9..20f87435 100644
@@ -2,6 +2,8 @@ inherit swupdate-lib
 
  FILESEXTRAPATHS:append := "${THISDIR}/files:"
 
+RDEPENDS:${PN} += "devmem2"
+
  FILES:${PN} += " \
    ${SWUPDATE_HW_COMPATIBILITY_FILE} \
  "
#5 lore raw

Re: [meta-arago][scarthgap][PATCH RFC 3/4] swupdate: add bootloader support

Quoted 109 lines · Andrew Davis
Quoted 108 lines · Anshul Dalal via lists.yoctoproject.org

U-Boot uses the 'bootpart' env variable to configure the rootfs for the kernel at boot. The BACKUP_REG0 MMR is also used to store bootcount as per U-Boot requirements[1].

After each reset, U-Boot increments the bootcount and it's reset to 0 by the swupdate service indicating a successful boot. If the kernel panics however (eg. if the update failed), the bootcount is never reset and keeps on getting incremented by U-Boot until it reaches certain threshold after which U-Boot switches to the other non-updated partition to ensure a successful boot.

This patch adds support for the same to the final .swu image generated by the update-image recipe.

[1]: https://docs.u-boot.org/en/latest/api/bootcount.html

---
  .../recipes-swupdate/images/files/sw-description     | 12 ++++++++++++
  .../recipes-swupdate/libubootenv/files/fw_env.config |  5 +++++
  .../libubootenv/libubootenv_%.bbappend               | 10 ++++++++++
  .../recipes-swupdate/swupdate/files/defconfig        |  2 ++
  .../recipes-swupdate/swupdate/files/swupdate.sh      |  4 ++++
  .../recipes-swupdate/swupdate/swupdate_%.bbappend    |  2 ++
  6 files changed, 35 insertions(+)

create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend

meta-arago-distro/recipes-swupdate/images/files/sw-description +12 -0
index 8dc4e2b2..241bc95c 100644
@@ -15,6 +15,12 @@ software =
  						compressed = "zlib";
  					},
  				);
+				uboot: (
+					{
+						name = "bootpart";
+						value = "0:1";
+					},
+				);
  			};
 
  			copy2 : {
@@ -26,6 +32,12 @@ software =
  						compressed = "zlib";
  					},
  				);
+				uboot: (
+					{
+						name = "bootpart";
+						value = "0:2";
+					},
+				);
  			};
  		};
  	}
meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config new file +5 -0
new file mode 100644
index 00000000..57eec5fc
@@ -0,0 +1,5 @@
+# Describes the env location for U-Boot in the hw partition
+# Second entry indicates redundant env
+# Boot dev			Offset		Size
+/dev/mmcblk0boot0	0x680000	0x20000
+/dev/mmcblk0boot0	0x6a0000	0x20000
meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend new file +10 -0
new file mode 100644
index 00000000..e3d142f2
@@ -0,0 +1,10 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+SRC_URI:append = " file://fw_env.config"
+
+do_install:append() {
+	install -d ${D}${sysconfdir}
+	install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}
+}
+
+FILES:${PN}:append = " ${sysconfdir}"
meta-arago-distro/recipes-swupdate/swupdate/files/defconfig +2 -0
index b1362eaa..4a2d78c0 100644
@@ -1,8 +1,10 @@
  CONFIG_HW_COMPATIBILITY=y
  # CONFIG_LUA is not set
  # CONFIG_BOOTLOADER_NONE is not set
+CONFIG_UBOOT=y
  CONFIG_SYSTEMD=y
  CONFIG_WEBSERVER=y
+CONFIG_BOOTLOADERHANDLER=y
  CONFIG_CFI=y
  CONFIG_EMMC_HANDLER=y
  CONFIG_RAW=y
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +0 -0
index bb3a3593..2083062e 100644
@@ -8,4 +8,8 @@ else
  	SELECTION="-e stable,copy2"
  fi
 
Quoted 9 lines

meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh else · line 14

Quoted 4 lines
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +4 -0
+# BACKUP_REG0 MMR on AM62x
+UBOOT_BOOTCOUNT_ADDR=0x4301c100
+
+devmem2 $UBOOT_BOOTCOUNT_ADDR w 0

Yuck, magic memory locations and /dev/mem, I'm trying to get rid of our dependence on /dev/mem in general so let's not add to the problem. How about CONFIG_BOOTCOUNT_FS?

As Yogesh suggested, it might be better to go with env since it's more commonly used.

This would eliminate the need for devmem as well.

Quoted 4 lines

Or maybe store it in an EFI variable, look into efivarfs and see if we can do something with that to allow usersapce access to this count.

The A/B rollback is already well supported with EFI (that's how CIP does it for example), what we want to provide is redundancy for the entire software stack including the bootloader. This RFC doesn't implement it yet but this will be added in a later revision.

Regards,
Anshul

[snip]

#6 lore raw

Re: [meta-arago][scarthgap][PATCH RFC 3/4] swupdate: add bootloader support

In reply to Anshul Dalal
Quoted 64 lines · Anshul Dalal via lists.yoctoproject.org

U-Boot uses the 'bootpart' env variable to configure the rootfs for the kernel at boot. The BACKUP_REG0 MMR is also used to store bootcount as per U-Boot requirements[1].

After each reset, U-Boot increments the bootcount and it's reset to 0 by the swupdate service indicating a successful boot. If the kernel panics however (eg. if the update failed), the bootcount is never reset and keeps on getting incremented by U-Boot until it reaches certain threshold after which U-Boot switches to the other non-updated partition to ensure a successful boot.

This patch adds support for the same to the final .swu image generated by the update-image recipe.

[1]: https://docs.u-boot.org/en/latest/api/bootcount.html

---
 .../recipes-swupdate/images/files/sw-description     | 12 ++++++++++++
 .../recipes-swupdate/libubootenv/files/fw_env.config |  5 +++++
 .../libubootenv/libubootenv_%.bbappend               | 10 ++++++++++
 .../recipes-swupdate/swupdate/files/defconfig        |  2 ++
 .../recipes-swupdate/swupdate/files/swupdate.sh      |  4 ++++
 .../recipes-swupdate/swupdate/swupdate_%.bbappend    |  2 ++
 6 files changed, 35 insertions(+)
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend
meta-arago-distro/recipes-swupdate/images/files/sw-description +12 -0
index 8dc4e2b2..241bc95c 100644
@@ -15,6 +15,12 @@ software =
 						compressed = "zlib";
 					},
 				);
+				uboot: (
+					{
+						name = "bootpart";
+						value = "0:1";
+					},
+				);
 			};
 
 			copy2 : {
@@ -26,6 +32,12 @@ software =
 						compressed = "zlib";
 					},
 				);
+				uboot: (
+					{
+						name = "bootpart";
+						value = "0:2";
+					},
+				);
 			};
 		};
 	}
meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config new file +0 -0
new file mode 100644
index 00000000..57eec5fc

meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config line 5

Quoted 5 lines
meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config new file +5 -0
@@ -0,0 +1,5 @@
+# Describes the env location for U-Boot in the hw partition
+# Second entry indicates redundant env
+# Boot dev			Offset		Size
+/dev/mmcblk0boot0	0x680000	0x20000
+/dev/mmcblk0boot0	0x6a0000	0x20000

Does this fw_env.config work for all machines?

meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend line 3

Quoted 9 lines
meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend new file +3 -0
new file mode 100644
index 00000000..e3d142f2
@@ -0,0 +1,10 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+SRC_URI:append = " file://fw_env.config"

If this config is not tested on all boards, it would be best to only append it to the machines that are tested.

Quoted 27 lines
meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend new file +7 -0
+
+do_install:append() {
+	install -d ${D}${sysconfdir}
+	install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}
+}
+
+FILES:${PN}:append = " ${sysconfdir}"
meta-arago-distro/recipes-swupdate/swupdate/files/defconfig +2 -0
index b1362eaa..4a2d78c0 100644
@@ -1,8 +1,10 @@
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_LUA is not set
 # CONFIG_BOOTLOADER_NONE is not set
+CONFIG_UBOOT=y
 CONFIG_SYSTEMD=y
 CONFIG_WEBSERVER=y
+CONFIG_BOOTLOADERHANDLER=y
 CONFIG_CFI=y
 CONFIG_EMMC_HANDLER=y
 CONFIG_RAW=y
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +0 -0
index bb3a3593..2083062e 100644

meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh else · line 14

Quoted 7 lines
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +4 -0
@@ -8,4 +8,8 @@ else
 	SELECTION="-e stable,copy2"
 fi
 
+# BACKUP_REG0 MMR on AM62x
+UBOOT_BOOTCOUNT_ADDR=0x4301c100
+
+devmem2 $UBOOT_BOOTCOUNT_ADDR w 0

Using devmem2 might be a bad idea. Consider using fw_setenv [1] to set the bootcount to 0.

[1] https://manpages.debian.org/testing/libubootenv-tool/fw_setenv.8.en.html

-- Yogesh

Quoted 28 lines
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +0 -0
 swupdate -H @MACHINE@:1.0 ${SELECTION} -p 'reboot' -f /etc/swupdate.cfg -w "-r /www -p 8080"
meta-arago-distro/recipes-swupdate/swupdate/swupdate_%.bbappend +2 -0
index 0ce763f9..20f87435 100644
@@ -2,6 +2,8 @@ inherit swupdate-lib
 
 FILESEXTRAPATHS:append := "${THISDIR}/files:"
 
+RDEPENDS:${PN} += "devmem2"
+
 FILES:${PN} += " \
   ${SWUPDATE_HW_COMPATIBILITY_FILE} \
 "
Signature · 11 lines
2.52.0



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#16850): https://lists.yoctoproject.org/g/meta-arago/message/16850
Mute This Topic: https://lists.yoctoproject.org/mt/116574476/9980049
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-arago/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
#7 lore raw

Re: [meta-arago][scarthgap][PATCH RFC 3/4] swupdate: add bootloader support

Quoted 64 lines · Yogesh Hegde
Quoted 63 lines · Anshul Dalal via lists.yoctoproject.org

U-Boot uses the 'bootpart' env variable to configure the rootfs for the kernel at boot. The BACKUP_REG0 MMR is also used to store bootcount as per U-Boot requirements[1].

After each reset, U-Boot increments the bootcount and it's reset to 0 by the swupdate service indicating a successful boot. If the kernel panics however (eg. if the update failed), the bootcount is never reset and keeps on getting incremented by U-Boot until it reaches certain threshold after which U-Boot switches to the other non-updated partition to ensure a successful boot.

This patch adds support for the same to the final .swu image generated by the update-image recipe.

[1]: https://docs.u-boot.org/en/latest/api/bootcount.html

---
 .../recipes-swupdate/images/files/sw-description     | 12 ++++++++++++
 .../recipes-swupdate/libubootenv/files/fw_env.config |  5 +++++
 .../libubootenv/libubootenv_%.bbappend               | 10 ++++++++++
 .../recipes-swupdate/swupdate/files/defconfig        |  2 ++
 .../recipes-swupdate/swupdate/files/swupdate.sh      |  4 ++++
 .../recipes-swupdate/swupdate/swupdate_%.bbappend    |  2 ++
 6 files changed, 35 insertions(+)
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend
meta-arago-distro/recipes-swupdate/images/files/sw-description +12 -0
index 8dc4e2b2..241bc95c 100644
@@ -15,6 +15,12 @@ software =
 						compressed = "zlib";
 					},
 				);
+				uboot: (
+					{
+						name = "bootpart";
+						value = "0:1";
+					},
+				);
 			};
 
 			copy2 : {
@@ -26,6 +32,12 @@ software =
 						compressed = "zlib";
 					},
 				);
+				uboot: (
+					{
+						name = "bootpart";
+						value = "0:2";
+					},
+				);
 			};
 		};
 	}
meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config new file +0 -0
new file mode 100644
index 00000000..57eec5fc
Quoted 9 lines

meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config line 5

Quoted 6 lines
meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config new file +5 -0
@@ -0,0 +1,5 @@
+# Describes the env location for U-Boot in the hw partition
+# Second entry indicates redundant env
+# Boot dev			Offset		Size
+/dev/mmcblk0boot0	0x680000	0x20000
+/dev/mmcblk0boot0	0x6a0000	0x20000

Does this fw_env.config work for all machines?

No, AM64x and J7200 make use of different offsets. Though it might make sense to move the libubootenv configuration to meta-ti altogether with the config under libubootenv/files/<SOC_OVERRIDE>/fw_env.config.

Since this config is not only useful for SWUpdate with arago but anybody trying to make use fw_* tools on our platforms.

Quoted 4 lines
Quoted 4 lines
meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend new file +0 -1
new file mode 100644
index 00000000..e3d142f2
--- /dev/null
Quoted 9 lines

meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend line 3

Quoted 5 lines

+++ b/meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend

meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend new file +3 -0
@@ -0,0 +1,10 @@
+FILESEXTRAPATHS:prepend := "${THISDIR}/files:"
+
+SRC_URI:append = " file://fw_env.config"

If this config is not tested on all boards, it would be best to only append it to the machines that are tested.

That's fair, perhaps we should error out on builds with untested platforms with 'ti-swupdate' active.

Quoted 30 lines
Quoted 30 lines
meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend new file +7 -0
+
+do_install:append() {
+	install -d ${D}${sysconfdir}
+	install -m 644 ${WORKDIR}/fw_env.config ${D}${sysconfdir}
+}
+
+FILES:${PN}:append = " ${sysconfdir}"
meta-arago-distro/recipes-swupdate/swupdate/files/defconfig +2 -0
index b1362eaa..4a2d78c0 100644
@@ -1,8 +1,10 @@
 CONFIG_HW_COMPATIBILITY=y
 # CONFIG_LUA is not set
 # CONFIG_BOOTLOADER_NONE is not set
+CONFIG_UBOOT=y
 CONFIG_SYSTEMD=y
 CONFIG_WEBSERVER=y
+CONFIG_BOOTLOADERHANDLER=y
 CONFIG_CFI=y
 CONFIG_EMMC_HANDLER=y
 CONFIG_RAW=y
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +0 -0
index bb3a3593..2083062e 100644
@@ -8,4 +8,8 @@ else
 	SELECTION="-e stable,copy2"
 fi
 
Quoted 8 lines

meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh else · line 14

Quoted 4 lines
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +4 -0
+# BACKUP_REG0 MMR on AM62x
+UBOOT_BOOTCOUNT_ADDR=0x4301c100
+
+devmem2 $UBOOT_BOOTCOUNT_ADDR w 0

Using devmem2 might be a bad idea. Consider using fw_setenv [1] to set the bootcount to 0.

Yeah, this should be trivial to support with libubootenv-bin added to IMAGE_INSTALL.

Regards,
Anshul

Quoted 29 lines
Quoted 29 lines
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +0 -0
 swupdate -H @MACHINE@:1.0 ${SELECTION} -p 'reboot' -f /etc/swupdate.cfg -w "-r /www -p 8080"
meta-arago-distro/recipes-swupdate/swupdate/swupdate_%.bbappend +2 -0
index 0ce763f9..20f87435 100644
@@ -2,6 +2,8 @@ inherit swupdate-lib
 
 FILESEXTRAPATHS:append := "${THISDIR}/files:"
 
+RDEPENDS:${PN} += "devmem2"
+
 FILES:${PN} += " \
   ${SWUPDATE_HW_COMPATIBILITY_FILE} \
 "
Signature · 11 lines
2.52.0



-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#16850): https://lists.yoctoproject.org/g/meta-arago/message/16850
Mute This Topic: https://lists.yoctoproject.org/mt/116574476/9980049
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/meta-arago/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
#8 lore raw

RFC PATCH 4/4 swupdate: enable authentication for update image

In reply to Anshul Dalal

To ensure the platform can only be updated from an authorised source, this patch adds signing to the .swu update image using the pre-existing custMpk keys from ti-secdev.

---
 .../recipes-swupdate/images/files/sw-description             | 2 ++
 meta-arago-distro/recipes-swupdate/images/update-image.bb    | 4 ++++
 meta-arago-distro/recipes-swupdate/swupdate/files/defconfig  | 1 +
 .../recipes-swupdate/swupdate/files/swupdate.sh              | 2 +-
 .../recipes-swupdate/swupdate/swupdate_%.bbappend            | 5 +++++
 5 files changed, 13 insertions(+), 1 deletion(-)
meta-arago-distro/recipes-swupdate/images/files/sw-description +2 -0
index 241bc95c..8a7e5f4d 100644
@@ -13,6 +13,7 @@ software =
 						device = "/dev/mmcblk0p1";
 						type = "raw";
 						compressed = "zlib";
+						sha256 = "$swupdate_get_sha256(@@IMAGE_BASENAME@@-@@MACHINE@@.rootfs.ext4.gz)";
 					},
 				);
 				uboot: (
@@ -30,6 +31,7 @@ software =
 						device = "/dev/mmcblk0p2";
 						type = "raw";
 						compressed = "zlib";
+						sha256 = "$swupdate_get_sha256(@@IMAGE_BASENAME@@-@@MACHINE@@.rootfs.ext4.gz)";
 					},
 				);
 				uboot: (
meta-arago-distro/recipes-swupdate/images/update-image.bb +4 -0
index 33b0b74c..6176e5a6 100644
@@ -1,4 +1,5 @@
 inherit swupdate
+inherit ti-secdev
 
 IMAGE_BASENAME ?= "tisdk-default-image"
 
@@ -21,3 +22,6 @@ SWUPDATE_IMAGES_FSTYPES[tisdk-bootstrap-image] = ".rootfs.ext4.gz"
 SWUPDATE_IMAGES_FSTYPES[tisdk-jailhouse-image] = ".rootfs.ext4.gz"
 SWUPDATE_IMAGES_FSTYPES[tisdk-thinlinux-image] = ".rootfs.ext4.gz"
 SWUPDATE_IMAGES_FSTYPES[tisdk-bootstrap-base-image] = ".rootfs.ext4.gz"
+
+SWUPDATE_SIGNING = "RSA"
+SWUPDATE_PRIVATE_KEY = "${TI_SECURE_DEV_PKG}/keys/custMpk.key"
meta-arago-distro/recipes-swupdate/swupdate/files/defconfig +1 -0
index 4a2d78c0..0bf605f7 100644
@@ -4,6 +4,7 @@ CONFIG_HW_COMPATIBILITY=y
 CONFIG_UBOOT=y
 CONFIG_SYSTEMD=y
 CONFIG_WEBSERVER=y
+CONFIG_SIGNED_IMAGES=y
 CONFIG_BOOTLOADERHANDLER=y
 CONFIG_CFI=y
 CONFIG_EMMC_HANDLER=y
meta-arago-distro/recipes-swupdate/swupdate/files/swupdate.sh +1 -1
index 2083062e..fc32e4cf 100644
@@ -12,4 +12,4 @@ fi
 UBOOT_BOOTCOUNT_ADDR=0x4301c100
 
 devmem2 $UBOOT_BOOTCOUNT_ADDR w 0
-swupdate -H @MACHINE@:1.0 ${SELECTION} -p 'reboot' -f /etc/swupdate.cfg -w "-r /www -p 8080"
+swupdate -H @MACHINE@:1.0 ${SELECTION} -p 'reboot' -f /etc/swupdate.cfg -w "-r /www -p 8080" -k /etc/custMpk.pub
meta-arago-distro/recipes-swupdate/swupdate/swupdate_%.bbappend +5 -0
index 20f87435..bff44926 100644
@@ -1,4 +1,5 @@
 inherit swupdate-lib
+inherit ti-secdev
 
 FILESEXTRAPATHS:append := "${THISDIR}/files:"
 
@@ -8,6 +9,8 @@ FILES:${PN} += " \
   ${SWUPDATE_HW_COMPATIBILITY_FILE} \
 "
 
+DEPENDS += "openssl-native"
+
 SRC_URI += " \
     file://defconfig \
     file://swupdate.sh \
@@ -27,4 +30,6 @@ do_install:append () {
   install -d ${D}${sysconfdir}
   install -m 644 ${WORKDIR}/swupdate.cfg ${D}${sysconfdir}
   sed -i "s#@MACHINE@#${MACHINE}#g" ${D}${sysconfdir}/swupdate.cfg
+
+  openssl rsa -in ${TI_SECURE_DEV_PKG}/keys/custMpk.key -pubout -out ${D}/etc/custMpk.pub
 }
Signature · 1 line
2.52.0
#9 lore raw
In reply to Anshul Dalal
Quoted 13 lines · Anshul Dalal via lists.yoctoproject.org

Hi all,

This RFC adds support for SWUpdate[1] to meta-arago, this provides us with OTA updates with A/B redundancy for the rootfs.

For now the support is enabled for eMMC boot only based on the 'ti-swupdate' override. The below steps can be used to test this RFC on an AM62x EVM:

1. Add 'meta-swupdate' layer[2] to the SDK sources directory.

2. Since the bootloader side changes have not been merged to ti-u-boot yet, make use of the 'swupdate' branch from my own U-Boot fork[3].

Quoted 8 lines

3. Enable 'swupdate' support by setting the 'ti-swupdate' override in local.conf as follows:

DISTROOVERRIDES:append = ":ti-swupdate"

4. Flash the U-Boot binaries to the correct offsets on boot0 partition as per the docs[4] and run 'env save' on first boot to save the environment to eMMC's hw partition.

Why not use a more established A/B solution, such as RAUC (or even Mender)?

Quoted 37 lines

Regards,
Anshul

[1]: https://swupdate.org/
[2]: https://github.com/sbabic/meta-swupdate
[3]: https://github.com/ArchUsr64/u-boot/tree/swupdate
[4]: https://software-dl.ti.com/processor-sdk-linux-rt/esd/AM62X/latest/exports/docs/linux/How_to_Guides/Target/How_to_emmc_boot.html#how-to-emmc-boot

Anshul Dalal (4):
swupdate: add systemd service to rootfs
swupdate: add creation of update image
swupdate: add bootloader support
swupdate: enable authentication for update image

 meta-arago-distro/conf/distro/arago.conf      |  3 ++
 .../images/files/sw-description               | 46 +++++++++++++++++++
 .../recipes-swupdate/images/update-image.bb   | 27 +++++++++++
 .../libubootenv/files/fw_env.config           |  5 ++
 .../libubootenv/libubootenv_%.bbappend        | 10 ++++
 .../recipes-swupdate/swupdate/files/defconfig | 12 +++++
 .../swupdate/files/swupdate.cfg               | 13 ++++++
 .../swupdate/files/swupdate.sh                | 15 ++++++
 .../swupdate/swupdate_%.bbappend              | 35 ++++++++++++++
 .../wic/sdimage-2part-swupdate.wks            |  6 +++
 10 files changed, 172 insertions(+)
 create mode 100644 meta-arago-distro/recipes-swupdate/images/files/sw-description
 create mode 100644 meta-arago-distro/recipes-swupdate/images/update-image.bb
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend
 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
Signature · 1 line
2.52.0
#10 lore raw

Hi Denys,

Quoted 17 lines · Denys Dmytriyenko
Quoted 16 lines · Anshul Dalal via lists.yoctoproject.org

Hi all,

This RFC adds support for SWUpdate[1] to meta-arago, this provides us with OTA updates with A/B redundancy for the rootfs.

For now the support is enabled for eMMC boot only based on the 'ti-swupdate' override. The below steps can be used to test this RFC on an AM62x EVM:

1. Add 'meta-swupdate' layer[2] to the SDK sources directory.

2. Since the bootloader side changes have not been merged to ti-u-boot yet, make use of the 'swupdate' branch from my own U-Boot fork[3].

3. Enable 'swupdate' support by setting the 'ti-swupdate' override in local.conf as follows:

Quoted 7 lines
Quoted 5 lines

DISTROOVERRIDES:append = ":ti-swupdate"

4. Flash the U-Boot binaries to the correct offsets on boot0 partition as per the docs[4] and run 'env save' on first boot to save the environment to eMMC's hw partition.

Why not use a more established A/B solution, such as RAUC (or even Mender)?

SWUpdate is still the most widely requested option from users of TI K3 SoC. Its a more versatile than RAUC as it provides flexibility wrt image level vs file vs block level updates.

AFAIK, Both RAUC and SWUpdate are equally powerfully and well established. Could you help me understand why RAUC is more established than SWUpdate?

AGL seems to be on OSTree. OpenWRT, CIP is SWUPdate. Buildroot supports both (default is SWUpdate), so there isnt a common theme. Though SWUpdate seems more common in industrial focused distro space as far as my knowledge goes.

Mender is a different story though, its open source but has commercial element to it. And at least K3 based beagle devices are already supported via mender.io [1].

[1] https://hub.mender.io/t/board-support-index/5742

Regards
Vignesh

#11 lore raw
In reply to Anshul Dalal

Hello Anshul, All,

Le 02/12/2025 à 12:15, Anshul Dalal a écrit :

Quoted 4 lines

Hi all,

This RFC adds support for SWUpdate[1] to meta-arago, this provides us with OTA updates with A/B redundancy for the rootfs.

Do you have some recommendation when an upgrade should include a TI firmwares updates (TI SCI, DM)? On the rootfs we can have some remoteproc firmwares built with a specific TI SDK version that imply a specific TI SCI/DM firmware version being used.

What if we want to update the system with OTA? It seems we have to update u-boot too.

Example:
The system is running with a Yocto kirkstone based image and we want to deploy a new Scarthgap based image. The kirkstone image will provide a DSP firmware build with the TI SDK 09.02.00.05 while the Scarthgap image will provide a DSP firmware build with the TI SDK 11.02.00.06.

On meta-ti kirkstone I had a regression with a DSP firmware at runtime due to a ti-linux-fw version bump: https://lists.yoctoproject.org/g/meta-ti/message/19322
(It was probably due to an IPC/mailbox change between TI SDK 9 and 10).

The K3 bootflow that is already complex doesn't seems to expect using A/B redundancy for the bootloader. One of the "safer" solution would to flash the eMMC with a new image after booting with an SD card.

Best regards,
Romain

Quoted 52 lines

For now the support is enabled for eMMC boot only based on the 'ti-swupdate' override. The below steps can be used to test this RFC on an AM62x EVM:

1. Add 'meta-swupdate' layer[2] to the SDK sources directory.

2. Since the bootloader side changes have not been merged to ti-u-boot yet, make use of the 'swupdate' branch from my own U-Boot fork[3].

3. Enable 'swupdate' support by setting the 'ti-swupdate' override in local.conf as follows:

DISTROOVERRIDES:append = ":ti-swupdate"

4. Flash the U-Boot binaries to the correct offsets on boot0 partition as per the docs[4] and run 'env save' on first boot to save the environment to eMMC's hw partition.

Regards,
Anshul

[1]: https://swupdate.org/
[2]: https://github.com/sbabic/meta-swupdate
[3]: https://github.com/ArchUsr64/u-boot/tree/swupdate
[4]: https://software-dl.ti.com/processor-sdk-linux-rt/esd/AM62X/latest/exports/docs/linux/How_to_Guides/Target/How_to_emmc_boot.html#how-to-emmc-boot

Anshul Dalal (4):
swupdate: add systemd service to rootfs
swupdate: add creation of update image
swupdate: add bootloader support
swupdate: enable authentication for update image

 meta-arago-distro/conf/distro/arago.conf      |  3 ++
 .../images/files/sw-description               | 46 +++++++++++++++++++
 .../recipes-swupdate/images/update-image.bb   | 27 +++++++++++
 .../libubootenv/files/fw_env.config           |  5 ++
 .../libubootenv/libubootenv_%.bbappend        | 10 ++++
 .../recipes-swupdate/swupdate/files/defconfig | 12 +++++
 .../swupdate/files/swupdate.cfg               | 13 ++++++
 .../swupdate/files/swupdate.sh                | 15 ++++++
 .../swupdate/swupdate_%.bbappend              | 35 ++++++++++++++
 .../wic/sdimage-2part-swupdate.wks            |  6 +++
 10 files changed, 172 insertions(+)
 create mode 100644 meta-arago-distro/recipes-swupdate/images/files/sw-description
 create mode 100644 meta-arago-distro/recipes-swupdate/images/update-image.bb
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/files/fw_env.config
 create mode 100644 meta-arago-distro/recipes-swupdate/libubootenv/libubootenv_%.bbappend
 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