From cd2e2633cd54ebcab53cfce60ecfb44b6d316540 Mon Sep 17 00:00:00 2001 From: Josef Holzmayr Date: Wed, 12 Jun 2024 10:36:30 +0200 Subject: [PATCH 1/3] feat: meta-mender-update-modules: add SWU The SWU Update Module provides a simple wrapper around the SWUpdate client for artifact installation. This commit add the recipe providing the canonical Update Module and artifact generation scripts. Changelog: Title Ticket: None Signed-off-by: Josef Holzmayr --- .../mender-update-modules/mender-swu_git.bb | 25 +++++++++++++++++++ .../mender-update-modules.inc | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 meta-mender-update-modules/recipes-mender/mender-update-modules/mender-swu_git.bb diff --git a/meta-mender-update-modules/recipes-mender/mender-update-modules/mender-swu_git.bb b/meta-mender-update-modules/recipes-mender/mender-update-modules/mender-swu_git.bb new file mode 100644 index 00000000..d5702f68 --- /dev/null +++ b/meta-mender-update-modules/recipes-mender/mender-update-modules/mender-swu_git.bb @@ -0,0 +1,25 @@ +DESCRIPTION = "The SWU Update Module" + +require mender-update-modules.inc + +inherit allarch + +RDEPENDS:${PN} += "jq swupdate-client" + +do_configure[noexec] = "1" +do_compile[noexec] = "1" + +do_install() { + install -d ${D}/${datadir}/mender/modules/v3 + install -m 755 ${S}/swu/module/swu ${D}/${datadir}/mender/modules/v3/swu +} + +do_install:class-native() { + install -d ${D}/${bindir} + install -m 755 ${S}/swu/module-artifact-gen/swu-artifact-gen ${D}/${bindir}/swu-artifact-gen +} + +FILES:${PN} += "${datadir}/mender/modules/v3/swu" +FILES:${PN}-class-native += "${bindir}/swu-artifact-gen" + +BBCLASSEXTEND = "native" diff --git a/meta-mender-update-modules/recipes-mender/mender-update-modules/mender-update-modules.inc b/meta-mender-update-modules/recipes-mender/mender-update-modules/mender-update-modules.inc index 052548b8..e92f33f8 100644 --- a/meta-mender-update-modules/recipes-mender/mender-update-modules/mender-update-modules.inc +++ b/meta-mender-update-modules/recipes-mender/mender-update-modules/mender-update-modules.inc @@ -4,6 +4,6 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=86d3f3a95c324c9479bd8986968f4327" SRC_URI = "git://github.com/mendersoftware/mender-update-modules.git;branch=master;protocol=https" -SRCREV = "a9f676eefe2e482ba3f7a6ad2d8c15ab3327a54f" +SRCREV = "699391004c7a7ffa1cb71fb36f44175a6a7f4c0f" S = "${WORKDIR}/git" From 6594a9c5b77b42776089cd078d3350c55457663e Mon Sep 17 00:00:00 2001 From: Josef Holzmayr Date: Wed, 12 Jun 2024 11:27:52 +0200 Subject: [PATCH 2/3] feat: demos: add qemuarm64-swupdate build Add a kas configuration file and demo layer to build an image for the qemuarm64 target to showcase the SWU Update Module. Changelog: Title Ticket: None Signed-off-by: Josef Holzmayr --- kas/demos/meta-mender-swupdate/LICENSE | 202 ++++++++++++++++++ kas/demos/meta-mender-swupdate/README | 53 +++++ .../meta-mender-swupdate/conf/layer.conf | 12 ++ .../conf/machine/qemuarm64-swupdate.conf | 27 +++ .../0001-env-in-fat-defconfig-2022.01.patch | 25 +++ .../0002-swupdate_boot-boot-commands.patch | 64 ++++++ .../recipes-bsp/u-boot/files/fw_env.config | 30 +++ .../recipes-bsp/u-boot/u-boot_%.bbappend | 8 + .../base-files/base-files_%.bbappend | 9 + .../base-files/files/qemuall/fstab.append | 2 + .../recipes-core/images/all-images.bb | 22 ++ .../images/files/sw-description.in | 42 ++++ .../recipes-core/images/main-image.bb | 16 ++ .../recipes-core/images/swu-image.bb | 32 +++ .../swupdate/files/09-swupdate-args.in | 9 + .../recipes-support/swupdate/files/defconfig | 146 +++++++++++++ .../swupdate/files/swupdate.cfg | 6 + .../swupdate/swupdate_%.bbappend | 28 +++ .../meta-mender-swupdate/wic/image-qemu.wks | 12 ++ kas/demos/qemuarm64-swupdate.yml | 41 ++++ 20 files changed, 786 insertions(+) create mode 100644 kas/demos/meta-mender-swupdate/LICENSE create mode 100644 kas/demos/meta-mender-swupdate/README create mode 100644 kas/demos/meta-mender-swupdate/conf/layer.conf create mode 100644 kas/demos/meta-mender-swupdate/conf/machine/qemuarm64-swupdate.conf create mode 100644 kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/0001-env-in-fat-defconfig-2022.01.patch create mode 100644 kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/0002-swupdate_boot-boot-commands.patch create mode 100644 kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/fw_env.config create mode 100644 kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/u-boot_%.bbappend create mode 100644 kas/demos/meta-mender-swupdate/recipes-core/base-files/base-files_%.bbappend create mode 100644 kas/demos/meta-mender-swupdate/recipes-core/base-files/files/qemuall/fstab.append create mode 100644 kas/demos/meta-mender-swupdate/recipes-core/images/all-images.bb create mode 100644 kas/demos/meta-mender-swupdate/recipes-core/images/files/sw-description.in create mode 100644 kas/demos/meta-mender-swupdate/recipes-core/images/main-image.bb create mode 100644 kas/demos/meta-mender-swupdate/recipes-core/images/swu-image.bb create mode 100644 kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/09-swupdate-args.in create mode 100644 kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/defconfig create mode 100644 kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/swupdate.cfg create mode 100644 kas/demos/meta-mender-swupdate/recipes-support/swupdate/swupdate_%.bbappend create mode 100644 kas/demos/meta-mender-swupdate/wic/image-qemu.wks create mode 100644 kas/demos/qemuarm64-swupdate.yml diff --git a/kas/demos/meta-mender-swupdate/LICENSE b/kas/demos/meta-mender-swupdate/LICENSE new file mode 100644 index 00000000..57bc88a1 --- /dev/null +++ b/kas/demos/meta-mender-swupdate/LICENSE @@ -0,0 +1,202 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/kas/demos/meta-mender-swupdate/README b/kas/demos/meta-mender-swupdate/README new file mode 100644 index 00000000..f056b54d --- /dev/null +++ b/kas/demos/meta-mender-swupdate/README @@ -0,0 +1,53 @@ +This README file contains information on the contents of the meta-mender-swupdate layer. + +Please see the corresponding sections below for details. + +Dependencies +============ + + URI: https://git.yoctoproject.org/poky + branch: kirkstone + + URI: https://git.openembedded.org/meta-openembedded + branch: kirkstone + + URI: https://git.yoctoproject.org/meta-arm + branch: kirkstone + + URI: https://github.com/mendersoftware/meta-mender + branch: kirkstone + + URI: https://github.com/sbabic/meta-swupdate + branch: kirkstone + +Patches +======= + +Please the README file in the top level directory. + +Table of Contents +================= + + I. Adding the meta-mender-swupdate layer to your build + II. Misc + + +I. Adding the meta-mender-swupdate layer to your build +================================================= + +Run 'bitbake-layers add-layer meta-mender-swupdate' + +II. Misc +======== + +The layer supports building a SWUpdate-enabled image for QEMU AAarch64. For more details on the QEMU build used, please see the `meta-mender-qemu-community` layer. + +It is strongly recommended to use the [`qemuarm64-swupdate`](../qemuarm64-swupdate.yml) kas configuration file for the build setup. You can build and run the result using these commands: + +``` +kas shell qemuarm64-swupdate.yml +bitbake all-images +runqemu nographic slirp +``` + +More details on using kas: https://hub.mender.io/t/using-kas-to-reproduce-your-yocto-builds/6020 \ No newline at end of file diff --git a/kas/demos/meta-mender-swupdate/conf/layer.conf b/kas/demos/meta-mender-swupdate/conf/layer.conf new file mode 100644 index 00000000..cfb75ebc --- /dev/null +++ b/kas/demos/meta-mender-swupdate/conf/layer.conf @@ -0,0 +1,12 @@ +# We have a conf and classes directory, add to BBPATH +BBPATH .= ":${LAYERDIR}" + +# We have recipes-* directories, add to BBFILES +BBFILES += "${LAYERDIR}/recipes-*/*/*.bb \ + ${LAYERDIR}/recipes-*/*/*.bbappend" + +BBFILE_COLLECTIONS += "mender-swupdate" +BBFILE_PATTERN_mender-swupdate = "^${LAYERDIR}/" +BBFILE_PRIORITY_mender-swupdate = "6" + +LAYERSERIES_COMPAT_mender-swupdate = "kirkstone" \ No newline at end of file diff --git a/kas/demos/meta-mender-swupdate/conf/machine/qemuarm64-swupdate.conf b/kas/demos/meta-mender-swupdate/conf/machine/qemuarm64-swupdate.conf new file mode 100644 index 00000000..220cabbf --- /dev/null +++ b/kas/demos/meta-mender-swupdate/conf/machine/qemuarm64-swupdate.conf @@ -0,0 +1,27 @@ +MACHINEOVERRIDES =. "qemuarm64:" + +require ${COREBASE}/meta/conf/machine/qemuarm64.conf + +KMACHINE = "qemuarm64" + +include conf/machine/include/soc-family.inc + +WKS_FILE = "image-qemu.wks" + +EXTRA_IMAGEDEPENDS:append = " virtual/bootloader" +PREFERRED_PROVIDER_virtual/bootloader = "u-boot" +IMAGE_BOOT_FILES = "u-boot.bin boot.scr" + +# Support runqemu script +QB_DEFAULT_FSTYPE = "wic" +QB_DRIVE_TYPE = "/dev/vdb" +QB_SYSTEM_NAME = "qemu-system-aarch64" +QB_DEFAULT_BIOS = "u-boot.bin" + +# Used to generate the swupdate update description file +OTA_PARTITION_A = "vda2" +OTA_PARTITION_B = "vda3" + +IMAGE_FSTYPES:append = " ext4.gz wic wic.bmap" +MACHINE_ESSENTIAL_EXTRA_RDEPENDS += "kernel-image" +do_image_wic[depends] += "mtools-native:do_populate_sysroot dosfstools-native:do_populate_sysroot virtual/bootloader:do_deploy" \ No newline at end of file diff --git a/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/0001-env-in-fat-defconfig-2022.01.patch b/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/0001-env-in-fat-defconfig-2022.01.patch new file mode 100644 index 00000000..a891edf1 --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/0001-env-in-fat-defconfig-2022.01.patch @@ -0,0 +1,25 @@ +diff -Naur a/configs/qemu_arm64_defconfig b/configs/qemu_arm64_defconfig +--- a/configs/qemu_arm64_defconfig 2022-03-29 13:53:40.086225070 +0100 ++++ b/configs/qemu_arm64_defconfig 2022-03-29 14:09:48.213001877 +0100 +@@ -3,7 +3,7 @@ + CONFIG_ARCH_QEMU=y + CONFIG_SYS_MALLOC_LEN=0x1000000 + CONFIG_NR_DRAM_BANKS=1 +-CONFIG_ENV_SIZE=0x40000 ++CONFIG_ENV_SIZE=0x4000 + CONFIG_ENV_SECT_SIZE=0x40000 + CONFIG_AHCI=y + CONFIG_DISTRO_DEFAULTS=y +@@ -26,8 +26,10 @@ + CONFIG_CMD_TPM=y + CONFIG_CMD_MTDPARTS=y + CONFIG_OF_BOARD=y +-CONFIG_ENV_IS_IN_FLASH=y +-CONFIG_ENV_ADDR=0x4000000 ++CONFIG_ENV_IS_IN_FAT=y ++CONFIG_ENV_FAT_INTERFACE="virtio" ++CONFIG_ENV_FAT_DEVICE_AND_PART="0:1" ++CONFIG_ENV_FAT_FILE="uboot.env" + CONFIG_SCSI_AHCI=y + CONFIG_AHCI_PCI=y + CONFIG_DFU_TFTP=y diff --git a/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/0002-swupdate_boot-boot-commands.patch b/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/0002-swupdate_boot-boot-commands.patch new file mode 100644 index 00000000..923d57d1 --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/0002-swupdate_boot-boot-commands.patch @@ -0,0 +1,64 @@ +# Add swupdate_boot boot command to u-boot environment, run as the first boot command + +diff --git a/include/config_distro_bootcmd.h b/include/config_distro_bootcmd.h +index 3f724aa10f..7deb304653 100644 +--- a/include/config_distro_bootcmd.h ++++ b/include/config_distro_bootcmd.h +@@ -319,6 +319,38 @@ + BOOT_TARGET_DEVICES_references_VIRTIO_without_CONFIG_CMD_VIRTIO + #endif + ++#ifdef CONFIG_CMD_VIRTIO ++#define BOOTENV_SHARED_SWUPDATE \ ++ "swupdate_boot=" \ ++ BOOTENV_RUN_PCI_ENUM \ ++ BOOTENV_RUN_VIRTIO_INIT \ ++ "if virtio dev ${devnum}; then " \ ++ "devtype=virtio; " \ ++ "if env exists rootpart; then " \ ++ "echo Booting from partition ${rootpart}; " \ ++ "else " \ ++ "setenv rootpart 2; saveenv; " \ ++ "echo Boot partition not set, default to ${rootpart}; " \ ++ "fi; " \ ++ "setenv bootargs \"root=/dev/vda${rootpart} rootwait\"; " \ ++ "if test -e ${devtype} ${devnum}:${rootpart} /boot/Image; then " \ ++ "load ${devtype} ${devnum}:${rootpart} ${kernel_addr_r} /boot/Image; " \ ++ "booti ${kernel_addr_r} - ${fdt_addr}; " \ ++ "else " \ ++ "load ${devtype} ${devnum}:${rootpart} ${kernel_addr_r} /boot/zImage; " \ ++ "bootz ${kernel_addr_r} - ${fdt_addr}; " \ ++ "fi; " \ ++ "fi\0" ++#define BOOTENV_DEV_SWUPDATE BOOTENV_DEV_BLKDEV ++#define BOOTENV_DEV_NAME_SWUPDATE BOOTENV_DEV_NAME_BLKDEV ++#else ++#define BOOTENV_SHARED_SWUPDATE ++#define BOOTENV_DEV_SWUPDATE \ ++ BOOT_TARGET_DEVICES_references_SWUPDATE_without_CONFIG_CMD_SWUPDATE ++#define BOOTENV_DEV_NAME_SWUPDATE \ ++ BOOT_TARGET_DEVICES_references_SWUPDATE_without_CONFIG_CMD_SWUPDATE ++#endif ++ + #if defined(CONFIG_CMD_DHCP) + #if defined(CONFIG_EFI_LOADER) + /* http://www.iana.org/assignments/dhcpv6-parameters/dhcpv6-parameters.xml */ +@@ -430,6 +462,7 @@ + BOOTENV_SHARED_UBIFS \ + BOOTENV_SHARED_EFI \ + BOOTENV_SHARED_VIRTIO \ ++ BOOTENV_SHARED_SWUPDATE \ + "boot_prefixes=/ /boot/\0" \ + "boot_scripts=boot.scr.uimg boot.scr\0" \ + "boot_script_dhcp=boot.scr.uimg\0" \ +diff -Naur a/include/configs/qemu-arm.h b/include/configs/qemu-arm.h +--- a/include/configs/qemu-arm.h 2022-03-29 13:53:40.346225830 +0100 ++++ b/include/configs/qemu-arm.h 2022-03-30 14:08:52.003821014 +0100 +@@ -22,6 +22,7 @@ + /* Environment options */ + + #define BOOT_TARGET_DEVICES(func) \ ++ func(SWUPDATE, swupdate, 0) \ + func(USB, usb, 0) \ + func(SCSI, scsi, 0) \ + func(VIRTIO, virtio, 0) \ diff --git a/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/fw_env.config b/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/fw_env.config new file mode 100644 index 00000000..5c809d9c --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/files/fw_env.config @@ -0,0 +1,30 @@ +# Configuration file for fw_(printenv/setenv) utility. +# Up to two entries are valid, in this case the redundant +# environment sector is assumed present. +# Notice, that the "Number of sectors" is not required on NOR and SPI-dataflash. +# Futhermore, if the Flash sector size is omitted, this value is assumed to +# be the same as the Environment size, which is valid for NOR and SPI-dataflash +# Device offset must be prefixed with 0x to be parsed as a hexadecimal value. + +# NOR example +# MTD device name Device offset Env. size Flash sector size Number of sectors +#/dev/mtd1 0x0000 0x4000 0x4000 +#/dev/mtd2 0x0000 0x4000 0x4000 + +# MTD SPI-dataflash example +# MTD device name Device offset Env. size Flash sector size Number of sectors +#/dev/mtd5 0x4200 0x4200 +#/dev/mtd6 0x4200 0x4200 + +# NAND example +#/dev/mtd0 0x4000 0x4000 0x20000 2 + +# On a block device a negative offset is treated as a backwards offset from the +# end of the device/partition, rather than a forwards offset from the start. + +# Block device example +#/dev/mmcblk0 0xc0000 0x20000 +#/dev/mmcblk0 -0x20000 0x20000 + +# VFAT example +/boot/uboot.env 0x0000 0x4000 diff --git a/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/u-boot_%.bbappend b/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/u-boot_%.bbappend new file mode 100644 index 00000000..41063e1e --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-bsp/u-boot/u-boot_%.bbappend @@ -0,0 +1,8 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" + +# The patches are only used on qemu - For the raspberrypi3 we provide a custom boot script in rpi-uboot-scr +SRC_URI:append:qemuall = " \ + file://0001-env-in-fat-defconfig-2022.01.patch \ + file://0002-swupdate_boot-boot-commands.patch \ + file://fw_env.config \ +" \ No newline at end of file diff --git a/kas/demos/meta-mender-swupdate/recipes-core/base-files/base-files_%.bbappend b/kas/demos/meta-mender-swupdate/recipes-core/base-files/base-files_%.bbappend new file mode 100644 index 00000000..0a4fa882 --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-core/base-files/base-files_%.bbappend @@ -0,0 +1,9 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/files/${SOC_FAMILY}:${THISDIR}/files:" + +SRC_URI += " \ + file://fstab.append \ +" + +do_install:append () { + cat ${WORKDIR}/fstab.append >> ${D}${sysconfdir}/fstab +} diff --git a/kas/demos/meta-mender-swupdate/recipes-core/base-files/files/qemuall/fstab.append b/kas/demos/meta-mender-swupdate/recipes-core/base-files/files/qemuall/fstab.append new file mode 100644 index 00000000..59a74c8e --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-core/base-files/files/qemuall/fstab.append @@ -0,0 +1,2 @@ +/dev/vda1 /boot vfat defaults 0 0 +/dev/vda4 /media ext4 defaults 0 0 diff --git a/kas/demos/meta-mender-swupdate/recipes-core/images/all-images.bb b/kas/demos/meta-mender-swupdate/recipes-core/images/all-images.bb new file mode 100644 index 00000000..48c17025 --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-core/images/all-images.bb @@ -0,0 +1,22 @@ +DESCRIPTION = "Main image as standalone and wrapped in SWU" + +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +inherit image + +# Disable most of the image build process +do_rootfs[noexec] = "1" +do_rootfs_wicenv[noexec] = "1" +do_image[noexec] = "1" +do_image_wic[noexec] = "1" +do_image_ext3[noexec] = "1" +do_image_ext4[noexec] = "1" +do_image_tar[noexec] = "1" +do_image_complete[noexec] = "1" +do_image_complete_setscene[noexec] = "1" +do_image_qa[noexec] = "1" +do_image_qa_setscene[noexec] = "1" +do_build[noexec] = "1" + +do_image[depends] += "swu-image:do_swuimage main-image:do_image_complete" diff --git a/kas/demos/meta-mender-swupdate/recipes-core/images/files/sw-description.in b/kas/demos/meta-mender-swupdate/recipes-core/images/files/sw-description.in new file mode 100644 index 00000000..9346600b --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-core/images/files/sw-description.in @@ -0,0 +1,42 @@ +software = { + version = "__SWUPDATE_SOFTWARE_VERSION"; + + __SWUPDATE_HARDWARE_VERSION = { + hardware-compatibility: [ "1.0" ]; + stable: { + copy1: { + images: ( + { + filename = "base-image-__MACHINE.ext4.gz"; + type = "raw"; + compressed = "zlib"; + device = "/dev/__OTA_PARTITION_A"; + } + ); + uboot: ( + { + name = "rootpart"; + value = "2"; + } + ); + } + + copy2: { + images: ( + { + filename = "base-image-__MACHINE.ext4.gz"; + type = "raw"; + compressed = "zlib"; + device = "/dev/__OTA_PARTITION_B"; + } + ); + uboot: ( + { + name = "rootpart"; + value = "3"; + } + ); + } + } + } +} diff --git a/kas/demos/meta-mender-swupdate/recipes-core/images/main-image.bb b/kas/demos/meta-mender-swupdate/recipes-core/images/main-image.bb new file mode 100644 index 00000000..686fc696 --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-core/images/main-image.bb @@ -0,0 +1,16 @@ +require recipes-core/images/core-image-minimal.bb + +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +IMAGE_INSTALL:append = " \ + cpio \ + vim \ + strace \ + mender-auth \ + mender-connect \ + mender-update \ + mender-swu \ + u-boot-env \ + u-boot-fw-utils \ +" \ No newline at end of file diff --git a/kas/demos/meta-mender-swupdate/recipes-core/images/swu-image.bb b/kas/demos/meta-mender-swupdate/recipes-core/images/swu-image.bb new file mode 100644 index 00000000..afd89307 --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-core/images/swu-image.bb @@ -0,0 +1,32 @@ +DESCRIPTION = "SWU wrapped main image" + +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +inherit swupdate + +SRC_URI = "\ + file://sw-description.in \ +" + +# we need this because it goes into the SWU +IMAGE_DEPENDS = "main-image" + +# images and files that will be included in the .swu image +SWUPDATE_IMAGES = "main-image-${MACHINE}" + +python() { + d.appendVarFlag("SWUPDATE_IMAGES_FSTYPES", f"main-image-{d.getVar('MACHINE')}", ".ext4.gz") +} + +do_swupdate_update_swdescription() { + # Yocto dependency checking can be broken if we modify the source file + # directly during the build process, create a 'output' file to modify + cp ${WORKDIR}/sw-description.in ${WORKDIR}/sw-description + sed -i -e "s%__SWUPDATE_SOFTWARE_VERSION%${SWUPDATE_SOFTWARE_VERSION}%" ${WORKDIR}/sw-description + sed -i -e "s%__SWUPDATE_HARDWARE_VERSION%${SWUPDATE_HARDWARE_VERSION}%" ${WORKDIR}/sw-description + sed -i -e "s%__OTA_PARTITION_A%${OTA_PARTITION_A}%" ${WORKDIR}/sw-description + sed -i -e "s%__OTA_PARTITION_B%${OTA_PARTITION_B}%" ${WORKDIR}/sw-description + sed -i -e "s%__MACHINE%${MACHINE}%" ${WORKDIR}/sw-description +} +addtask do_swupdate_update_swdescription before do_swuimage after do_unpack do_prepare_recipe_sysroot diff --git a/kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/09-swupdate-args.in b/kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/09-swupdate-args.in new file mode 100644 index 00000000..69bcf3fd --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/09-swupdate-args.in @@ -0,0 +1,9 @@ +rootfs=$(swupdate -g) + +if [ "$rootfs" == '/dev/__OTA_PARTITION_A' ]; then + selection="-e stable,copy2" +else + selection="-e stable,copy1" +fi + +SWUPDATE_ARGS="-H __SWUPDATE_HARDWARE_VERSION:1.0 ${selection}" diff --git a/kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/defconfig b/kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/defconfig new file mode 100644 index 00000000..16e53616 --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/defconfig @@ -0,0 +1,146 @@ +# +# Automatically generated file; DO NOT EDIT. +# SWUpdate Configuration +# + +# +# SWUpdate Settings +# + +# +# General Configuration +# +CONFIG_CURL=y +CONFIG_CURL_SSL=y +# CONFIG_DISKFORMAT is not set +CONFIG_SYSTEMD=y +CONFIG_DEFAULT_CONFIG_FILE="/etc/swupdate.cfg" +CONFIG_SCRIPTS=y +CONFIG_HW_COMPATIBILITY=y +CONFIG_HW_COMPATIBILITY_FILE="/etc/hwrevision" +CONFIG_SW_VERSIONS_FILE="/etc/sw-versions" + +# +# Socket Paths +# +CONFIG_SOCKET_CTRL_PATH="" +CONFIG_SOCKET_PROGRESS_PATH="" +# CONFIG_MTD is not set +CONFIG_LUA=y +CONFIG_LUAPKG="lua" +# CONFIG_FEATURE_SYSLOG is not set + +# +# Build Options +# +CONFIG_CROSS_COMPILE="" +CONFIG_SYSROOT="" +CONFIG_EXTRA_CFLAGS="" +CONFIG_EXTRA_LDFLAGS="" +CONFIG_EXTRA_LDLIBS="" + +# +# Debugging Options +# +# CONFIG_DEBUG is not set +# CONFIG_WERROR is not set +# CONFIG_NOCLEANUP is not set + +# +# Bootloader support +# + +# +# Bootloader Interfaces +# +# CONFIG_BOOTLOADER_NONE is not set +# CONFIG_BOOTLOADER_EBG is not set +CONFIG_UBOOT=y +CONFIG_UBOOT_FWENV="/etc/fw_env.config" +CONFIG_UBOOT_DEFAULTENV="/etc/u-boot-initial-env" +# CONFIG_BOOTLOADER_GRUB is not set +CONFIG_BOOTLOADER_DEFAULT_UBOOT=y +# CONFIG_BOOTLOADER_DEFAULT_NONE is not set +# CONFIG_UPDATE_STATE_CHOICE_NONE is not set +CONFIG_UPDATE_STATE_CHOICE_BOOTLOADER=y +CONFIG_UPDATE_STATE_BOOTLOADER="ustate" + +# +# Interfaces +# +# CONFIG_DOWNLOAD is not set +# CONFIG_DOWNLOAD_SSL is not set +# CONFIG_CHANNEL_CURL is not set +# CONFIG_SURICATTA is not set + +# +# Features +# +# CONFIG_SURICATTA_SSL is not set + +# +# Server +# +# CONFIG_SURICATTA_HAWKBIT is not set +# CONFIG_SURICATTA_GENERAL is not set +# CONFIG_WEBSERVER is not set +# CONFIG_MONGOOSE is not set +# CONFIG_MONGOOSEIPV6 is not set +# CONFIG_MONGOOSESSL is not set + +# +# Security +# +# CONFIG_SSL_IMPL_NONE is not set +CONFIG_SSL_IMPL_OPENSSL=y +# CONFIG_SSL_IMPL_WOLFSSL is not set +# CONFIG_SSL_IMPL_MBEDTLS is not set +CONFIG_CHANNEL_CURL_SSL=y +CONFIG_HASH_VERIFY=y +# CONFIG_SIGNED_IMAGES is not set +CONFIG_ENCRYPTED_IMAGES=y +# CONFIG_ENCRYPTED_SW_DESCRIPTION is not set +# CONFIG_PKCS11 is not set + +# +# Compressors (zlib always on) +# +CONFIG_GUNZIP=y +# CONFIG_ZSTD is not set + +# +# Parsers +# + +# +# Parser Features +# +CONFIG_LIBCONFIG=y +CONFIG_PARSERROOT="" +CONFIG_JSON=y +# CONFIG_LUAEXTERNAL is not set +# CONFIG_SETSWDESCRIPTION is not set + +# +# Handlers +# + +# +# Image Handlers +# +CONFIG_ARCHIVE=y +CONFIG_LOCALE=y +CONFIG_BOOTLOADERHANDLER=y +# CONFIG_DELTA is not set +# CONFIG_DISKPART is not set +# CONFIG_DISKFORMAT_HANDLER is not set +CONFIG_LUASCRIPTHANDLER=y +# CONFIG_HANDLER_IN_LUA is not set +CONFIG_RAW=y +# CONFIG_RDIFFHANDLER is not set +# CONFIG_READBACKHANDLER is not set +CONFIG_REMOTE_HANDLER=y +CONFIG_SHELLSCRIPTHANDLER=y +# CONFIG_SWUFORWARDER_HANDLER is not set +# CONFIG_UCFWHANDLER is not set +# CONFIG_UNIQUEUUID is not set diff --git a/kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/swupdate.cfg b/kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/swupdate.cfg new file mode 100644 index 00000000..5e8ba0eb --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-support/swupdate/files/swupdate.cfg @@ -0,0 +1,6 @@ +globals : +{ + verbose = true; + loglevel = 6; + syslog = true; +}; \ No newline at end of file diff --git a/kas/demos/meta-mender-swupdate/recipes-support/swupdate/swupdate_%.bbappend b/kas/demos/meta-mender-swupdate/recipes-support/swupdate/swupdate_%.bbappend new file mode 100644 index 00000000..aa7e4e67 --- /dev/null +++ b/kas/demos/meta-mender-swupdate/recipes-support/swupdate/swupdate_%.bbappend @@ -0,0 +1,28 @@ +FILESEXTRAPATHS:prepend := "${THISDIR}/files:" + +SRC_URI:append = " \ + file://09-swupdate-args.in \ + file://swupdate.cfg \ + file://defconfig \ +" + +do_swupdate_args_update() { + # Yocto dependency checking can be broken if we modify the source file + # directly during the build process, create a 'output' file to modify + cp ${WORKDIR}/09-swupdate-args.in ${WORKDIR}/09-swupdate-args + sed -i -e "s%__SWUPDATE_HARDWARE_VERSION%${SWUPDATE_HARDWARE_VERSION}%" ${WORKDIR}/09-swupdate-args + sed -i -e "s%__OTA_PARTITION_A%${OTA_PARTITION_A}%" ${WORKDIR}/09-swupdate-args + + echo "${MACHINE} ${SWUPDATE_HARDWARE_VERSION}" > ${WORKDIR}/hwrevision +} +addtask do_swupdate_args_update before do_install after do_unpack + + +do_install:append() { + install -Dm 0644 ${WORKDIR}/09-swupdate-args ${D}${libdir}/swupdate/conf.d/09-swupdate-args + install -Dm 0644 ${WORKDIR}/swupdate.cfg ${D}${sysconfdir}/swupdate.cfg + + install -Dm 0644 ${WORKDIR}/hwrevision ${D}${sysconfdir}/hwrevision +} + +SYSTEMD_AUTO_ENABLE = "disable" \ No newline at end of file diff --git a/kas/demos/meta-mender-swupdate/wic/image-qemu.wks b/kas/demos/meta-mender-swupdate/wic/image-qemu.wks new file mode 100644 index 00000000..84958ec3 --- /dev/null +++ b/kas/demos/meta-mender-swupdate/wic/image-qemu.wks @@ -0,0 +1,12 @@ +part /boot --fstype=vfat --ondisk vda --offset 2048s --align 4 --fixed-size 63M --active --label boot + +# rootfs slot A +part / --source rootfs --fstype=ext4 --ondisk vda --label root-a --align 4 --fixed-size 256M + +# rootfs slot B +part --fstype=ext4 --ondisk vda --label root-b --align 4 --fixed-size 256M + +# /media (auto-mounted via /etc/fstab) +part --fstype=ext4 --ondisk vda --label media --align 4 --fixed-size 448M + +bootloader --ptable msdos --timeout 1 diff --git a/kas/demos/qemuarm64-swupdate.yml b/kas/demos/qemuarm64-swupdate.yml new file mode 100644 index 00000000..237aa63d --- /dev/null +++ b/kas/demos/qemuarm64-swupdate.yml @@ -0,0 +1,41 @@ +header: + version: 11 + includes: + - kas/include/mender-base.yml + +repos: + meta-openembedded: + layers: + meta-python: + meta-networking: + meta-filesystems: + + meta-swupdate: + url: https://github.com/sbabic/meta-swupdate + refspec: kirkstone + + meta-mender: + layers: + meta-mender-demo: + + meta-mender-community: + layers: + meta-mender-client-only: + meta-mender-update-modules: + kas/demos/meta-mender-swupdate: + +local_conf_header: + no-full-client: | + MENDER_EFI_LOADER = "" + MENDER_UPDATE_POLL_INTERVAL_SECONDS = "5" + MENDER_INVENTORY_POLL_INTERVAL_SECONDS = "5" + MENDER_RETRY_POLL_INTERVAL_SECONDS = "30" + swupdate: | + # Versioning env variables + SWUPDATE_HARDWARE_VERSION = "1.0" + SWUPDATE_SOFTWARE_VERSION = "1.0" + +machine: qemuarm64-swupdate + +target: + - all-images \ No newline at end of file From c4750e1f33bbfaab6707ec2b14f6a7f06651a50e Mon Sep 17 00:00:00 2001 From: Josef Holzmayr Date: Wed, 12 Jun 2024 11:32:34 +0200 Subject: [PATCH 3/3] chore: kas: add qemuarm64-swupdate to GitHub Action Build the qemuarm64-swupdate demo as part of the default build workflow. Signed-off-by: Josef Holzmayr --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 87090326..7fdeefb6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -95,6 +95,9 @@ jobs: experimental: true - board: stm32mp15-disco experimental: true + - board: qemuarm64-swupdate + subpath: demos + experimental: true runs-on: [self-hosted, linux, x64] container: