All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Quirin Gylstorff" <quirin.gylstorff@siemens.com>
To: cip-dev@lists.cip-project.org, Jan.Kiszka@siemens.com
Cc: Quirin Gylstorff <quirin.gylstorff@siemens.com>
Subject: [cip-dev] [isar-cip-core PATCH v3 5/5] swupdate: create swu file from wic image
Date: Fri, 24 Jul 2020 16:52:25 +0200	[thread overview]
Message-ID: <20200724145225.7895-6-Quirin.Gylstorff@siemens.com> (raw)
In-Reply-To: <20200724145225.7895-1-Quirin.Gylstorff@siemens.com>

[-- Attachment #1: Type: text/plain, Size: 4589 bytes --]

From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

Create a swu file for swupdate to update devices in the field.
This is done in the same step as the complete image build
to avoid diverging images.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 classes/extract-partition.bbclass             | 26 +++++++++++++
 classes/wic-swu-img.bbclass                   | 20 ++++++++++
 kas/opt/ebg-swu.yml                           |  4 +-
 recipes-core/images/cip-core-image.bb         | 10 +++++
 recipes-core/images/files/sw-description.tmpl | 37 +++++++++++++++++++
 5 files changed, 95 insertions(+), 2 deletions(-)
 create mode 100644 classes/extract-partition.bbclass
 create mode 100644 classes/wic-swu-img.bbclass
 create mode 100644 recipes-core/images/files/sw-description.tmpl

diff --git a/classes/extract-partition.bbclass b/classes/extract-partition.bbclass
new file mode 100644
index 0000000..e9de8fc
--- /dev/null
+++ b/classes/extract-partition.bbclass
@@ -0,0 +1,26 @@
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Siemens AG, 2020
+#
+# Authors:
+#  Quirin Gylstorff <quirin.gylstorff@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+SOURCE_IMAGE_FILE ?= "${WIC_IMAGE_FILE}"
+EXTRACT_PARTITIONS ?= "img4"
+
+do_extract_partition () {
+    for PARTITION in ${EXTRACT_PARTITIONS}; do
+        rm -f ${DEPLOY_DIR_IMAGE}/${PARTITION}.gz
+        PART_START=$(fdisk -lu ${SOURCE_IMAGE_FILE} | grep ${PARTITION} | awk '{ print $2 }'  )
+        PART_END=$(fdisk -lu ${SOURCE_IMAGE_FILE} | grep ${PARTITION} | awk '{ print $3 }'  )
+        PART_COUNT=$(expr ${PART_END} - ${PART_START} + 1 )
+
+        dd if=${SOURCE_IMAGE_FILE} of=${DEPLOY_DIR_IMAGE}/${PARTITION} bs=512 skip=${PART_START} count=${PART_COUNT}
+
+        gzip ${DEPLOY_DIR_IMAGE}/${PARTITION}
+    done
+}
diff --git a/classes/wic-swu-img.bbclass b/classes/wic-swu-img.bbclass
new file mode 100644
index 0000000..c8532ba
--- /dev/null
+++ b/classes/wic-swu-img.bbclass
@@ -0,0 +1,20 @@
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Siemens AG, 2020
+#
+# Authors:
+#  Quirin Gylstorff <quirin.gylstorff@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+
+
+inherit wic-img
+inherit extract-partition
+inherit swupdate-img
+
+SOURCE_IMAGE_FILE = "${WIC_IMAGE_FILE}"
+
+addtask do_extract_partition after do_wic_image
+addtask do_swupdate_image after do_extract_partition
diff --git a/kas/opt/ebg-swu.yml b/kas/opt/ebg-swu.yml
index 5b39730..304fa4d 100644
--- a/kas/opt/ebg-swu.yml
+++ b/kas/opt/ebg-swu.yml
@@ -22,5 +22,5 @@ local_conf_header:
     WICVARS += "WDOG_TIMEOUT"
 
   wic: |
-    IMAGE_TYPE = "wic-img"
-    WKS_FILE = "${MACHINE}-${BOOTLOADER}.wks"
+    IMAGE_TYPE = "wic-swu-img"
+    WKS_FILE ?= "${MACHINE}-${BOOTLOADER}.wks"
diff --git a/recipes-core/images/cip-core-image.bb b/recipes-core/images/cip-core-image.bb
index 9ee4b25..b1ed491 100644
--- a/recipes-core/images/cip-core-image.bb
+++ b/recipes-core/images/cip-core-image.bb
@@ -17,3 +17,13 @@ DESCRIPTION = "CIP Core image"
 IMAGE_INSTALL += "customizations"
 # for cip-testing
 IMAGE_INSTALL += "ltp-full"
+
+# for swupdate
+EXTRACT_PARTITIONS = "img4"
+ROOTFS_PARTITION_NAME="img4.gz"
+
+SRC_URI += "file://sw-description.tmpl"
+TEMPLATE_FILES += "sw-description.tmpl"
+TEMPLATE_VARS += "PN ROOTFS_PARTITION_NAME KERNEL_IMAGE INITRD_IMAGE"
+
+SWU_ADDITIONAL_FILES += "${INITRD_IMAGE} ${KERNEL_IMAGE} ${ROOTFS_PARTITION_NAME}"
diff --git a/recipes-core/images/files/sw-description.tmpl b/recipes-core/images/files/sw-description.tmpl
new file mode 100644
index 0000000..4d32f6f
--- /dev/null
+++ b/recipes-core/images/files/sw-description.tmpl
@@ -0,0 +1,37 @@
+#
+# CIP Core, generic profile
+#
+# Copyright (c) Siemens AG, 2020
+#
+# Authors:
+#  Quirin Gylstorff <quirin.gylstorff@siemens.com>
+#
+# SPDX-License-Identifier: MIT
+#
+software =
+{
+    version = "0.2";
+    name = "cip software update"
+    images: ({
+            filename = "${ROOTFS_PARTITION_NAME}";
+            device = "fedcba98-7654-3210-cafe-5e0710000001,fedcba98-7654-3210-cafe-5e0710000002";
+            type = "roundrobin";
+            compressed = true;
+            filesystem = "ext4";
+    });
+    files: ({
+            filename = "${KERNEL_IMAGE}";
+            path = "vmlinuz";
+            type = "kernelfile";
+            device = "sda2,sda3";
+            filesystem = "vfat";
+    },
+    {
+            filename = "${INITRD_IMAGE}";
+            path = "initrd.img";
+            type = "kernelfile";
+            device = "sda2,sda3";
+            filesystem = "vfat";
+    });
+}
+
-- 
2.20.1


[-- Attachment #2: Type: text/plain, Size: 419 bytes --]

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#5001): https://lists.cip-project.org/g/cip-dev/message/5001
Mute This Topic: https://lists.cip-project.org/mt/75767668/4520388
Group Owner: cip-dev+owner@lists.cip-project.org
Unsubscribe: https://lists.cip-project.org/g/cip-dev/leave/8129055/727948398/xyzzy  [cip-dev@archiver.kernel.org]
-=-=-=-=-=-=-=-=-=-=-=-

      parent reply	other threads:[~2020-07-24 14:52 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-25 13:21 [cip-dev] [isar-cip-core RFC 0/4] A/B Rootfs update with software update Quirin Gylstorff
2020-06-25 13:21 ` [cip-dev] [isar-cip-core RFC 1/4] recipes-bsp: Add efibootguard Quirin Gylstorff
2020-06-26 13:37   ` Jan Kiszka
2020-06-29  9:03     ` Quirin Gylstorff
2020-06-25 13:21 ` [cip-dev] [isar-cip-core RFC 2/4] patches: add libubootenv Quirin Gylstorff
2020-06-25 13:21 ` [cip-dev] [isar-cip-core RFC 3/4] recipes-core: add swupdate Quirin Gylstorff
2020-06-26 13:05   ` Jan Kiszka
2020-06-29  9:03     ` Quirin Gylstorff
2020-06-25 13:21 ` [cip-dev] [isar-cip-core RFC 4/4] wic: Add wks files for A/B Partition update Quirin Gylstorff
2020-06-29  9:56 ` [cip-dev] [isar-cip-core PATCH v2 0/5] A/B Rootfs update with software update Quirin Gylstorff
2020-06-29  9:56   ` [cip-dev] [isar-cip-core PATCH v2 1/5] recipes-bsp: Add efibootguard Quirin Gylstorff
2020-06-29  9:56   ` [cip-dev] [isar-cip-core PATCH v2 2/5] patches: add libubootenv Quirin Gylstorff
2020-06-29  9:56   ` [cip-dev] [isar-cip-core PATCH v2 3/5] recipes-core: add swupdate Quirin Gylstorff
2020-06-29  9:56   ` [cip-dev] [isar-cip-core PATCH v2 4/5] wic: Add wks files for A/B Partition update Quirin Gylstorff
2020-06-29  9:56   ` [cip-dev] [isar-cip-core PATCH v2 5/5] swupdate: create swu file from wic image Quirin Gylstorff
2020-07-29 17:07   ` [cip-dev] [isar-cip-core PATCH v2 0/5] A/B Rootfs update with software update Jan Kiszka
2020-07-24 14:52 ` [cip-dev] [isar-cip-core PATCH v3 " Quirin Gylstorff
2020-07-24 14:52   ` [cip-dev] [isar-cip-core PATCH v3 1/5] recipes-bsp: Add efibootguard Quirin Gylstorff
2020-07-24 14:52   ` [cip-dev] [isar-cip-core PATCH v3 2/5] patches: add libubootenv Quirin Gylstorff
2020-07-24 14:52   ` [cip-dev] [isar-cip-core PATCH v3 3/5] recipes-core: add swupdate Quirin Gylstorff
2020-07-24 14:52   ` [cip-dev] [isar-cip-core PATCH v3 4/5] wic: Add wks files for A/B Partition update Quirin Gylstorff
2020-07-24 14:52   ` Quirin Gylstorff [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200724145225.7895-6-Quirin.Gylstorff@siemens.com \
    --to=quirin.gylstorff@siemens.com \
    --cc=Jan.Kiszka@siemens.com \
    --cc=cip-dev@lists.cip-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.