diff --git a/meta-digi-dey/recipes-digi/swu-images/files/image_template_mmc b/meta-digi-dey/recipes-digi/swu-images/files/image_template_mmc new file mode 100644 index 000000000..cbbe5d655 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/image_template_mmc @@ -0,0 +1,8 @@ + { + filename = "##IMG_NAME##"; + device = "##DEV##"; + type = "raw"; + sha256 = "$swupdate_get_sha256(##IMG_NAME##)"; + compressed = "zlib"; + installed-directly = true; + } diff --git a/meta-digi-dey/recipes-digi/swu-images/files/image_template_nand b/meta-digi-dey/recipes-digi/swu-images/files/image_template_nand new file mode 100644 index 000000000..cefb14271 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/image_template_nand @@ -0,0 +1,7 @@ + { + filename = "##IMG_NAME##"; + volume = "##DEV##"; + type = "ubivol"; + sha256 = "$swupdate_get_sha256(##IMG_NAME##)"; + installed-directly = true; + } diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description b/meta-digi-dey/recipes-digi/swu-images/files/sw-description deleted file mode 100644 index 8d0af5f13..000000000 --- a/meta-digi-dey/recipes-digi/swu-images/files/sw-description +++ /dev/null @@ -1,167 +0,0 @@ -software = -{ - version = "##SW_VERSION##"; - description = "##DESCRIPTION##"; - - mmc = { - primary: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - device = "##BOOT_DEV_A##"; - type = "raw"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - device = "##ROOTFS_DEV_A##"; - type = "raw"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - compressed = "zlib"; - installed-directly = true; - } - ); - uboot: ( - { - name = "upgrade_available"; - value = "1"; - }, - { - name = "rootfstype" - value = "##ROOTFS_TYPE##" - } - ); - } - secondary: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - device = "##BOOT_DEV_B##"; - type = "raw"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - device = "##ROOTFS_DEV_B##"; - type = "raw"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - compressed = "zlib"; - installed-directly = true; - } - ); - uboot: ( - { - name = "upgrade_available"; - value = "1"; - }, - { - name = "rootfstype" - value = "##ROOTFS_TYPE##" - } - ); - } - single: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - device = "##BOOT_DEV##"; - type = "raw"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - device = "##ROOTFS_DEV##"; - type ="raw"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - compressed = "zlib"; - installed-directly = true; - } - ); - } - platform = { - ref = "#./single"; - } - } - mtd = { - primary: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - volume = "##BOOT_DEV_A##"; - type = "ubivol"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - volume = "##ROOTFS_DEV_A##"; - type = "ubivol"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - installed-directly = true; - } - ); - uboot: ( - { - name = "upgrade_available"; - value = "1"; - }, - { - name = "rootfstype" - value = "##ROOTFS_TYPE##" - } - ); - } - secondary: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - volume = "##BOOT_DEV_B##"; - type = "ubivol"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - volume = "##ROOTFS_DEV_B##"; - type = "ubivol"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - installed-directly = true; - } - ); - uboot: ( - { - name = "upgrade_available"; - value = "1"; - }, - { - name = "rootfstype" - value = "##ROOTFS_TYPE##" - } - ); - } - single: { - images: ( - { - filename = "##BOOTIMG_NAME##"; - volume = "##BOOT_DEV##"; - type = "ubivol"; - sha256 = "$swupdate_get_sha256(##BOOTIMG_NAME##)"; - installed-directly = true; - }, - { - filename = "##ROOTIMG_NAME##"; - volume = "##ROOTFS_DEV##"; - type ="ubivol"; - sha256 = "$swupdate_get_sha256(##ROOTIMG_NAME##)"; - installed-directly = true; - } - ); - } - platform = { - ref = "#./single"; - } - }; -} diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-uboot b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-uboot index 6270310d6..c72e564ba 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-uboot +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-uboot @@ -1,6 +1,6 @@ software = { - version = "##SW_VERSION##"; + version = "##FW_VERSION##"; description = "##DESCRIPTION##"; mmc = { diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description_template b/meta-digi-dey/recipes-digi/swu-images/files/sw-description_template new file mode 100644 index 000000000..c6bcca558 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description_template @@ -0,0 +1,52 @@ +software = +{ + version = "@@DEY_FIRMWARE_VERSION@@"; + description = "@@DESCRIPTION@@"; + + @@SWUPDATE_STORAGE_TYPE@@ = { + primary: { + images: ( + ##IMAGES_PRIMARY## + ); + uboot: ( + { + name = "upgrade_available"; + value = "1"; + }, + { + name = "rootfstype" + value = "@@ROOTFS_TYPE@@" + } + ); + } + secondary: { + images: ( + ##IMAGES_SECONDARY## + ); + uboot: ( + { + name = "upgrade_available"; + value = "1"; + }, + { + name = "rootfstype" + value = "@@ROOTFS_TYPE@@" + } + ); + } + single: { + images: ( + ##IMAGES_SINGLE## + ); + uboot: ( + { + name = "rootfstype" + value = "@@ROOTFS_TYPE@@" + } + ); + } + platform = { + ref = "#./single"; + } + }; +} diff --git a/meta-digi-dey/recipes-digi/swu-images/swu.inc b/meta-digi-dey/recipes-digi/swu-images/swu.inc index 444615d1e..2e022730e 100644 --- a/meta-digi-dey/recipes-digi/swu-images/swu.inc +++ b/meta-digi-dey/recipes-digi/swu-images/swu.inc @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2022, Digi International Inc. +# Copyright (C) 2016-2023, Digi International Inc. SUMMARY = "Generate update package for SWUpdate" SECTION = "base" @@ -6,10 +6,12 @@ LICENSE = "GPL-2.0-only" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6" SRC_URI = " \ - file://sw-description \ + file://sw-description_template \ file://sw-description-uboot \ file://swupdate_uboot_nand.sh \ file://swupdate_uboot_mmc.sh \ + file://image_template_mmc \ + file://image_template_nand \ " inherit swupdate @@ -18,20 +20,27 @@ IMAGE_DEPENDS = "${@get_baseimg_pn(d)}" IMG_NAME = "${IMAGE_DEPENDS}" +# Determine the correct UBoot update script file to use depending on storage type. +SWUPDATE_UBOOT_SCRIPT = "${@oe.utils.conditional('STORAGE_MEDIA', 'mmc', 'swupdate_uboot_mmc.sh', 'swupdate_uboot_nand.sh', d)}" + +# Determine the storage type. +SWUPDATE_STORAGE_TYPE = "${@oe.utils.conditional('STORAGE_MEDIA', 'mmc', 'mmc', 'mtd', d)}" + +# Avoid all 'SRC_URI' files to be included in the SWU image. Include only 'SWUPDATE_IMAGES' files and 'sw-description' (added by default). +INHIBIT_SWUPDATE_ADD_SRC_URI = "true" + SWUPDATE_IMAGES = " \ ${IMG_NAME} \ ${@oe.utils.ifelse(d.getVar('SWUPDATE_UBOOTIMG') == 'true', '${UBOOT_PREFIX}', '')} \ + ${@oe.utils.ifelse(d.getVar('SWUPDATE_UBOOTIMG') == 'true', '${SWUPDATE_UBOOT_SCRIPT}', '')} \ " -SOFTWARE_VERSION ?= "0.0.1" DESCRIPTION = "${@oe.utils.ifelse(d.getVar('TRUSTFENCE_ENCRYPT_ROOTFS') == '1', 'Encrypted rootfs ${IMG_NAME} update', '${IMG_NAME} update')}" UBOOT_EXT ?= ".${UBOOT_SUFFIX}" UBOOTIMG_OFFSET ?= "${BOOTLOADER_SEEK_BOOT}" -SWUPDATE_STORAGE_MEDIA = "${@oe.utils.conditional('STORAGE_MEDIA', 'mmc', 'swupdate_uboot_mmc.sh', 'swupdate_uboot_nand.sh', d)}" - python () { img_fstypes = d.getVar('BOOTFS_EXT') + " " + d.getVar('ROOTFS_EXT') d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", d.getVar('IMG_NAME'), img_fstypes) @@ -51,7 +60,6 @@ def get_baseimg_pn(d): file_name = d.getVar('PN') return file_name[:file_name.find("-swu")] - # Dual boot partition names for eMMC or MTD BOOT_DEV_NAME_A ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p1', 'linux_a', d)}" BOOT_DEV_NAME_B ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p2', 'linux_b', d)}" @@ -59,35 +67,58 @@ ROOTFS_DEV_NAME_A ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0 ROOTFS_DEV_NAME_B ?= "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '/dev/mmcblk0p4', 'rootfs_b', d)}" ROOTFS_TYPE = "${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', 'squashfs', '', d)}" + +# Image template based on storage type. +IMAGE_TEMPLATE_FILE = "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '${WORKDIR}/image_template_mmc', '${WORKDIR}/image_template_nand', d)}" + do_unpack[postfuncs] += "fill_description" fill_description() { if [ "${SWUPDATE_UBOOTIMG}" = "true" ]; then cp ${WORKDIR}/sw-description-uboot ${WORKDIR}/sw-description + cp ${WORKDIR}/${SWUPDATE_UBOOT_SCRIPT} ${DEPLOY_DIR_IMAGE}/${SWUPDATE_UBOOT_SCRIPT} if [ "${TRUSTFENCE_DEK_PATH}" != "0" ] && [ "${TRUSTFENCE_DEK_PATH}" != "default" ]; then sed -i -e "s,##UBOOTIMG_ENC##,enc,g" "${WORKDIR}/sw-description" else sed -i -e "s,##UBOOTIMG_ENC##,normal,g" "${WORKDIR}/sw-description" fi sed -i -e "s,##UBOOTIMG_NAME##,${UBOOT_PREFIX}-${MACHINE}${UBOOT_EXT},g" "${WORKDIR}/sw-description" - sed -i -e "s,##SWUPDATE_UBOOT_SCRIPT##,${SWUPDATE_STORAGE_MEDIA},g" "${WORKDIR}/sw-description" + sed -i -e "s,##SWUPDATE_UBOOT_SCRIPT##,${SWUPDATE_UBOOT_SCRIPT},g" "${WORKDIR}/sw-description" sed -i -e "s,##UBOOTIMG_OFFSET##,${UBOOTIMG_OFFSET},g" "${WORKDIR}/sw-description" + else + cp ${WORKDIR}/sw-description_template ${WORKDIR}/sw-description fi - sed -i -e "s,##BOOTIMG_NAME##,${IMG_NAME}-${MACHINE}${BOOTFS_EXT},g" "${WORKDIR}/sw-description" - sed -i -e "s,##BOOT_DEV##,${BOOT_DEV_NAME},g" "${WORKDIR}/sw-description" - sed -i -e "s,##ROOTIMG_NAME##,${IMG_NAME}-${MACHINE}${ROOTFS_EXT},g" "${WORKDIR}/sw-description" - sed -i -e "s,##ROOTFS_DEV##,${ROOTFS_DEV_NAME_FINAL},g" "${WORKDIR}/sw-description" - sed -i -e "s,##SW_VERSION##,${SOFTWARE_VERSION},g" "${WORKDIR}/sw-description" - sed -i -e "s,##DESCRIPTION##,${DESCRIPTION},g" "${WORKDIR}/sw-description" - # Dualboot description - sed -i -e "s,##BOOT_DEV_A##,${BOOT_DEV_NAME_A},g" "${WORKDIR}/sw-description" - sed -i -e "s,##BOOT_DEV_B##,${BOOT_DEV_NAME_B},g" "${WORKDIR}/sw-description" - sed -i -e "s,##ROOTFS_DEV_A##,${ROOTFS_DEV_NAME_A},g" "${WORKDIR}/sw-description" - sed -i -e "s,##ROOTFS_DEV_B##,${ROOTFS_DEV_NAME_B},g" "${WORKDIR}/sw-description" + # Build image names. + BOOT_IMAGE_NAME="${IMG_NAME}-${MACHINE}${BOOTFS_EXT}" + ROOTFS_IMAGE_NAME="${IMG_NAME}-${MACHINE}${ROOTFS_EXT}" + + # Add primary bank images section for dual boot systems. + printf "%s,\n%s\n" \ + "$(sed -e "s,##IMG_NAME##,${BOOT_IMAGE_NAME},g" -e "s,##DEV##,${BOOT_DEV_NAME_A},g" -e "/compressed/d" "${IMAGE_TEMPLATE_FILE}")" \ + "$(sed -e "s,##IMG_NAME##,${ROOTFS_IMAGE_NAME},g" -e "s,##DEV##,${ROOTFS_DEV_NAME_A},g" "${IMAGE_TEMPLATE_FILE}")" \ + > images_temp.txt + sed -i -e "/##IMAGES_PRIMARY##/r images_temp.txt" -e "/##IMAGES_PRIMARY##/d" "${WORKDIR}/sw-description" + + # Add secondary bank images section for dual boot systems. + printf "%s,\n%s\n" \ + "$(sed -e "s,##IMG_NAME##,${BOOT_IMAGE_NAME},g" -e "s,##DEV##,${BOOT_DEV_NAME_B},g" -e "/compressed/d" "${IMAGE_TEMPLATE_FILE}")" \ + "$(sed -e "s,##IMG_NAME##,${ROOTFS_IMAGE_NAME},g" -e "s,##DEV##,${ROOTFS_DEV_NAME_B},g" "${IMAGE_TEMPLATE_FILE}")" \ + > images_temp.txt + sed -i -e "/##IMAGES_SECONDARY##/r images_temp.txt" -e "/##IMAGES_SECONDARY##/d" "${WORKDIR}/sw-description" + + # Add images section for single boot systems. + printf "%s,\n%s\n" \ + "$(sed -e "s,##IMG_NAME##,${BOOT_IMAGE_NAME},g" -e "s,##DEV##,${BOOT_DEV_NAME},g" -e "/compressed/d" "${IMAGE_TEMPLATE_FILE}")" \ + "$(sed -e "s,##IMG_NAME##,${ROOTFS_IMAGE_NAME},g" -e "s,##DEV##,${ROOTFS_DEV_NAME_FINAL},g" "${IMAGE_TEMPLATE_FILE}")" \ + > images_temp.txt + sed -i -e "/##IMAGES_SINGLE##/r images_temp.txt" -e "/##IMAGES_SINGLE##/d" "${WORKDIR}/sw-description" + + # Remove 'compressed' flag for read-only file systems as they use 'squashfs' images. if [ -n "${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', '1', '', d)}" ]; then - sed -i '/compressed/d' "${WORKDIR}/sw-description" + sed -i -e "/compressed/d" "${WORKDIR}/sw-description" fi - sed -i -e "s,##ROOTFS_TYPE##,${ROOTFS_TYPE},g" "${WORKDIR}/sw-description" + # Clean dir. + rm -f images_temp.txt }