Skip to content

Commit

Permalink
Add new round robin handler
Browse files Browse the repository at this point in the history
Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
  • Loading branch information
gylstorffq committed May 26, 2021
1 parent 3a5d619 commit a92433f
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 15 deletions.
4 changes: 4 additions & 0 deletions kas/iot2050.yml
Expand Up @@ -40,6 +40,10 @@ repos:
cip-core:
url: https://gitlab.com/cip-project/cip-core/isar-cip-core.git
refspec: 872d532c95dc1ffcf2c1c2e21c4d26f8110376e1
patches:
01-swupdate-roundrobin:
path: patches/cip-core/v2-0001-Add-option-to-use-swupdate-handler-roundrobin.patch
repo: meta-iot2050

bblayers_conf_header:
standard: |
Expand Down
@@ -0,0 +1,182 @@
From 943f2156a077f462d73cf3ceae95ae7a43122b81 Mon Sep 17 00:00:00 2001
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
Date: Wed, 28 Apr 2021 16:45:51 +0200
Subject: [cip-dev][isar-cip-core][RFC v2] Add option to use
swupdate-handler-roundrobin

The new swupdate round robin handler is available under[1].
Add the Option `SWUPDATE_USE_ROUND_ROBIN_HANDLER_REPO` to
use the handler directly from the repository.

The handler currently doesn't support secureboot.

[1]:https://gitlab.com/cip-playground/swupdate-handler-roundrobin/

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
classes/swupdate-config.bbclass | 12 ++++++---
kas/opt/ebg-secure-boot-base.yml | 3 +++
.../files/secure-boot/sw-description.tmpl | 2 +-
recipes-core/images/files/sw-description.tmpl | 21 ++++++++++-----
.../files/swupdate.handler.efibootguard.ini | 26 +++++++++++++++++++
recipes-core/swupdate/swupdate.bb | 9 ++++++-
6 files changed, 62 insertions(+), 11 deletions(-)
create mode 100644 recipes-core/swupdate/files/swupdate.handler.efibootguard.ini

diff --git a/classes/swupdate-config.bbclass b/classes/swupdate-config.bbclass
index 4e46b37..a7a7aa4 100644
--- a/classes/swupdate-config.bbclass
+++ b/classes/swupdate-config.bbclass
@@ -21,9 +21,17 @@ KFEATURE_lua = ""
KFEATURE_lua[BUILD_DEB_DEPENDS] = "liblua5.3-dev"
KFEATURE_lua[KCONFIG_SNIPPETS] = "file://swupdate_defconfig_lua.snippet"

+SWUPDATE_USE_ROUND_ROBIN_HANDLER_REPO ?= "1"
+
+SRC_URI_append = " ${@ 'git://gitlab.com/cip-playground/swupdate-handler-roundrobin.git;protocol=https;destsuffix=swupdate-handler-roundrobin;name=swupdate-handler-roundrobin' \
+ if d.getVar('SWUPDATE_USE_ROUND_ROBIN_HANDLER_REPO') == '1' else '' \
+ }"
+SRCREV_swupdate-handler-roundrobin ?= "6ac9e49eaa4e866a3eda12eee3a223820ba8e0bf"
+SWUPDATE_LUASCRIPT ?= "swupdate-handler-roundrobin/swupdate_handlers_roundrobin.lua"
KFEATURE_luahandler = ""
KFEATURE_luahandler[KCONFIG_SNIPPETS] = "file://swupdate_defconfig_luahandler.snippet"
-KFEATURE_luahandler[SRC_URI] = "file://${SWUPDATE_LUASCRIPT}"
+KFEATURE_luahandler[SRC_URI] = "${@ 'file://${SWUPDATE_LUASCRIPT}' \
+ if d.getVar('SWUPDATE_USE_ROUND_ROBIN_HANDLER_REPO') == '0' else '' }"

KFEATURE_DEPS = ""
KFEATURE_DEPS[luahandler] = "lua"
@@ -57,8 +65,6 @@ KFEATURE_u-boot[DEBIAN_DEPENDS] = "${@ 'libubootenv0.1, u-boot-${MACHINE}-config
KFEATURE_u-boot[DEPENDS] = "libubootenv"
KFEATURE_u-boot[KCONFIG_SNIPPETS] = "file://swupdate_defconfig_u-boot.snippet"

-SWUPDATE_LUASCRIPT ?= "swupdate_handlers.lua"
-
def get_bootloader_featureset(d):
bootloader = d.getVar("SWUPDATE_BOOTLOADER", True) or ""
if bootloader == "efibootguard":
diff --git a/kas/opt/ebg-secure-boot-base.yml b/kas/opt/ebg-secure-boot-base.yml
index 30ca35a..484d0e5 100644
--- a/kas/opt/ebg-secure-boot-base.yml
+++ b/kas/opt/ebg-secure-boot-base.yml
@@ -16,3 +16,6 @@ local_conf_header:
initramfs: |
IMAGE_INSTALL += "initramfs-abrootfs-secureboot"
SWU_DESCRIPTION = "secureboot"
+ swupdate-secureboot: |
+ SWUPDATE_USE_ROUND_ROBIN_HANDLER_REPO = "0"
+ SWUPDATE_LUASCRIPT = "swupdate_handler.efibootguard.secureboot.lua"
diff --git a/recipes-core/images/files/secure-boot/sw-description.tmpl b/recipes-core/images/files/secure-boot/sw-description.tmpl
index bce97d0..897d819 100644
--- a/recipes-core/images/files/secure-boot/sw-description.tmpl
+++ b/recipes-core/images/files/secure-boot/sw-description.tmpl
@@ -16,7 +16,7 @@ software =
filename = "${ROOTFS_PARTITION_NAME}";
device = "fedcba98-7654-3210-cafe-5e0710000001,fedcba98-7654-3210-cafe-5e0710000002";
type = "roundrobin";
- compressed = "true";
+ compressed = "zlib";
filesystem = "ext4";
});
files: ({
diff --git a/recipes-core/images/files/sw-description.tmpl b/recipes-core/images/files/sw-description.tmpl
index bb34088..3309271 100644
--- a/recipes-core/images/files/sw-description.tmpl
+++ b/recipes-core/images/files/sw-description.tmpl
@@ -16,21 +16,30 @@ software =
filename = "${ROOTFS_PARTITION_NAME}";
device = "fedcba98-7654-3210-cafe-5e0710000001,fedcba98-7654-3210-cafe-5e0710000002";
type = "roundrobin";
- compressed = "true";
+ compressed = "zlib";
filesystem = "ext4";
+ properties: {
+ subtype = "image";
+ };
});
files: ({
filename = "${KERNEL_IMAGE}";
path = "vmlinuz";
- type = "kernelfile";
- device = "sda2,sda3";
+ type = "roundrobin";
+ device = "fedcba98-7654-3210-cafe-5e0710000001->sda2,fedcba98-7654-3210-cafe-5e0710000002->sda3";
filesystem = "vfat";
+ properties: {
+ subtype = "kernel";
+ };
},
{
filename = "${INITRD_IMAGE}";
- path = "initrd.img";
- type = "kernelfile";
- device = "sda2,sda3";
+ path = "${INITRD_IMAGE}";
+ type = "roundrobin";
+ device = "fedcba98-7654-3210-cafe-5e0710000001->sda2,fedcba98-7654-3210-cafe-5e0710000002->sda3";
filesystem = "vfat";
+ properties: {
+ subtype = "initrd";
+ };
});
}
diff --git a/recipes-core/swupdate/files/swupdate.handler.efibootguard.ini b/recipes-core/swupdate/files/swupdate.handler.efibootguard.ini
new file mode 100644
index 0000000..3aee76c
--- /dev/null
+++ b/recipes-core/swupdate/files/swupdate.handler.efibootguard.ini
@@ -0,0 +1,26 @@
+[image]
+chainhandler=raw
+
+[image.selector]
+method=cmdline_rr
+key=root
+
+[image.bootenv]
+kernelparams=root=PARTUUID=${rrtarget} ${cmdline_root}
+
+[kernel]
+chainhandler=rawfile
+
+[kernel.selector]
+method=cmdline_rrmap
+key=root
+
+[kernel.bootenv]
+kernelfile=C:BOOT${rrindex}:vmlinuz
+
+[initrd]
+chainhandler=rawfile
+
+[initrd.selector]
+method=cmdline_rrmap
+key=root
diff --git a/recipes-core/swupdate/swupdate.bb b/recipes-core/swupdate/swupdate.bb
index 526c72f..60e0772 100644
--- a/recipes-core/swupdate/swupdate.bb
+++ b/recipes-core/swupdate/swupdate.bb
@@ -29,6 +29,7 @@ DEBIAN_DEPENDS = "${shlibs:Depends}, ${misc:Depends}"
inherit dpkg
inherit swupdate-config

+SRC_URI += "file://swupdate.handler.${SWUPDATE_BOOTLOADER}.ini"
KFEATURES += "luahandler"

S = "${WORKDIR}/git"
@@ -46,5 +47,11 @@ do_prepare_build() {
echo "configs/${DEFCONFIG}" >> ${S}/.gitignore
fi
# luahandler
- install -m 0644 ${WORKDIR}/${SWUPDATE_LUASCRIPT} ${S}
+ if [ -e ${WORKDIR}/${SWUPDATE_LUASCRIPT} ]; then
+ install -m 0644 ${WORKDIR}/${SWUPDATE_LUASCRIPT} ${S}/swupdate_handlers.lua
+ fi
+ if [ -e ${WORKDIR}/swupdate.handler.${SWUPDATE_BOOTLOADER}.ini ]; then
+ install -m 0644 ${WORKDIR}/swupdate.handler.${SWUPDATE_BOOTLOADER}.ini ${S}/swupdate.handler.ini
+ echo "swupdate.handler.ini etc/" >> ${S}/debian/swupdate.install
+ fi
}
--
2.20.1

104 changes: 104 additions & 0 deletions patches/cip-core/v3-0001-swupdate-config-add-prefix-to-variables.patch
@@ -0,0 +1,104 @@
From 8e7245731a2e17c12b9d21835beef2c43127114b Mon Sep 17 00:00:00 2001
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
Date: Mon, 12 Apr 2021 11:56:21 +0200
Subject: [cip-dev][isar-cip-core][PATCH v3] swupdate-config: add prefix to
variables

The variables U_BOOT and BOOTLOADER are only used for swupdate.
Add the prefix SWUPDATE to indicate the intended usage.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
classes/swupdate-config.bbclass | 11 ++++++-----
kas/opt/ebg-secure-boot-snakeoil.yml | 2 +-
kas/opt/ebg-swu.yml | 4 ++--
kas/opt/qemu-swupdate.yml | 2 +-
4 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/classes/swupdate-config.bbclass b/classes/swupdate-config.bbclass
index 9909113..8aa6b90 100644
--- a/classes/swupdate-config.bbclass
+++ b/classes/swupdate-config.bbclass
@@ -45,19 +45,20 @@ KFEATURE_ubi[KCONFIG_SNIPPETS] = "file://swupdate_defconfig_ubi.snippet"

KFEATURE_DEPS[ubi] = "mtd"

+SWUPDATE_U_BOOT ?= "u-boot-${MACHINE}"
USE_U_BOOT_CONFIG ?= "true"
KFEATURE_u-boot = ""
KFEATURE_u-boot[BUILD_DEB_DEPENDS] = "libubootenv-dev"
KFEATURE_u-boot[DEBIAN_DEPENDS] = "${@ 'libubootenv0.1, u-boot-${MACHINE}-config' \
if d.getVar("USE_U_BOOT_CONFIG", True) == "true" \
else 'libubootenv0.1'}"
-KFEATURE_u-boot[DEPENDS] = "${U_BOOT} libubootenv"
+KFEATURE_u-boot[DEPENDS] = "${SWUPDATE_U_BOOT} libubootenv"
KFEATURE_u-boot[KCONFIG_SNIPPETS] = "file://swupdate_defconfig_u-boot.snippet"

SWUPDATE_LUASCRIPT ?= "swupdate_handlers.lua"

def get_bootloader_featureset(d):
- bootloader = d.getVar("BOOTLOADER", True) or ""
+ bootloader = d.getVar("SWUPDATE_BOOTLOADER", True) or ""
if bootloader == "efibootguard":
return "efibootguard"
if bootloader == "u-boot":
@@ -68,11 +69,11 @@ SWUPDATE_KFEATURES ??= ""
KFEATURES = "${SWUPDATE_KFEATURES}"
KFEATURES += "${@get_bootloader_featureset(d)}"

-# Astonishingly, as an anonymous python function, BOOTLOADER is always None
+# Astonishingly, as an anonymous python function, SWUPDATE_BOOTLOADER is always None
# one time before it gets set. So the following must be a task.
python do_check_bootloader () {
- bootloader = d.getVar("BOOTLOADER", True) or "None"
+ bootloader = d.getVar("SWUPDATE_BOOTLOADER", True) or "None"
if not bootloader in ["efibootguard", "u-boot"]:
- bb.warn("swupdate: BOOTLOADER set to incompatible value: " + bootloader)
+ bb.warn("swupdate: SWUPDATE_BOOTLOADER set to incompatible value: " + bootloader)
}
addtask check_bootloader before do_fetch
diff --git a/kas/opt/ebg-secure-boot-snakeoil.yml b/kas/opt/ebg-secure-boot-snakeoil.yml
index 8a72084..c0ed1a2 100644
--- a/kas/opt/ebg-secure-boot-snakeoil.yml
+++ b/kas/opt/ebg-secure-boot-snakeoil.yml
@@ -20,7 +20,7 @@ local_conf_header:
# Add snakeoil and ovmf binaries for qemu
IMAGER_BUILD_DEPS += "ebg-secure-boot-snakeoil ovmf-binaries"
IMAGER_INSTALL += "ebg-secure-boot-snakeoil"
- WKS_FILE = "${MACHINE}-${BOOTLOADER}-secureboot.wks"
+ WKS_FILE = "${MACHINE}-efibootguard-secureboot.wks"

ovmf: |
# snakeoil certs are only part of backports
diff --git a/kas/opt/ebg-swu.yml b/kas/opt/ebg-swu.yml
index aa3aed1..63dda09 100644
--- a/kas/opt/ebg-swu.yml
+++ b/kas/opt/ebg-swu.yml
@@ -15,7 +15,7 @@ header:
local_conf_header:
swupdate: |
IMAGE_INSTALL_append = " swupdate efibootguard"
- BOOTLOADER = "efibootguard"
+ SWUPDATE_BOOTLOADER = "efibootguard"

efibootguard: |
WDOG_TIMEOUT = "0"
@@ -23,4 +23,4 @@ local_conf_header:

wic: |
IMAGE_TYPE = "wic-swu-img"
- WKS_FILE ?= "${MACHINE}-${BOOTLOADER}.wks"
+ WKS_FILE ?= "${MACHINE}-${SWUPDATE_BOOTLOADER}.wks"
diff --git a/kas/opt/qemu-swupdate.yml b/kas/opt/qemu-swupdate.yml
index 3f5fedf..daebd2c 100644
--- a/kas/opt/qemu-swupdate.yml
+++ b/kas/opt/qemu-swupdate.yml
@@ -16,4 +16,4 @@ header:
local_conf_header:
qemu-wic: |
IMAGE_TYPE ?= "wic-swu-img"
- WKS_FILE = "qemu-amd64-${BOOTLOADER}.wks"
+ WKS_FILE = "qemu-amd64-${SWUPDATE_BOOTLOADER}.wks"
--
2.20.1

3 changes: 3 additions & 0 deletions recipes-core/images/files/sw-description.tmpl
Expand Up @@ -18,5 +18,8 @@ software =
type = "roundrobin";
compressed = "zlib";
filesystem = "ext4";
properties: {
subtype = "image";
};
});
}
9 changes: 9 additions & 0 deletions recipes-core/swupdate/files/swupdate.handler.u-boot.ini
@@ -0,0 +1,9 @@
[image]
chainhandler=raw

[image.selector]
method=cmdline_rr
key=root

[image.bootenv]
ustate=1
5 changes: 0 additions & 5 deletions recipes-core/swupdate/files/swupdate.handler.uboot.ini

This file was deleted.

4 changes: 2 additions & 2 deletions recipes-core/swupdate/files/swupdate.install
@@ -1,5 +1,5 @@
swupdate usr/bin
swupdate.cfg /etc
swupdate.handler.ini /etc
swupdate.cfg etc
swupdate_handlers.lua /usr/share/lua/5.3
acknowledge_update.sh usr/bin
swupdate.handler.ini etc/
11 changes: 3 additions & 8 deletions recipes-core/swupdate/swupdate.bbappend
Expand Up @@ -9,16 +9,11 @@
FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += "file://swupdate.install \
file://swupdate.handler.uboot.ini \
file://acknowledge_update.sh"
file://acknowledge_update.sh \
file://swupdate.handler.u-boot.ini"

do_prepare_build_append() {

sed -i '/^local configuration =.*/i --[===[ EXAMPLE configuration:' ${S}/swupdate_handlers.lua
sed -i '/^-- Default configuration .*/i --]===]' ${S}/swupdate_handlers.lua
sed -i '/swupdate.set_bootenv(\"swupdate\", value)/a swupdate.set_bootenv(\"ustate\", 1)' ${S}/swupdate_handlers.lua

cp ${WORKDIR}/swupdate.install ${S}/debian/swupdate.install
cp ${WORKDIR}/swupdate.handler.uboot.ini ${S}/swupdate.handler.ini
cp ${WORKDIR}/swupdate.handler.u-boot.ini ${S}/swupdate.handler.ini
cp ${WORKDIR}/acknowledge_update.sh ${S}/acknowledge_update.sh
}

0 comments on commit a92433f

Please sign in to comment.