diff --git a/meta-digi-arm/conf/machine/include/ccmp1.inc b/meta-digi-arm/conf/machine/include/ccmp1.inc index 0189ba36b..484b798df 100644 --- a/meta-digi-arm/conf/machine/include/ccmp1.inc +++ b/meta-digi-arm/conf/machine/include/ccmp1.inc @@ -80,3 +80,6 @@ UBOOT_ENV = "${@bb.utils.contains('TRUSTFENCE_FIT_IMG', '1', 'boot', '', d)}" # Partitions to blacklist for swupdate: # fsbl1, fsbl2, metadata1, metadata2, fip-a, fip-b SWUPDATE_MTD_BLACKLIST = "0 1 2 3 4 5" + +# Bootloader Flash offset +BOOTLOADER_SEEK_BOOT = "0" diff --git a/meta-digi-dey/classes/dey-swupdate-common.bbclass b/meta-digi-dey/classes/dey-swupdate-common.bbclass index 7e3031d3e..b06ddf026 100644 --- a/meta-digi-dey/classes/dey-swupdate-common.bbclass +++ b/meta-digi-dey/classes/dey-swupdate-common.bbclass @@ -88,10 +88,29 @@ SWUPDATE_IS_IMAGES_UPDATE = "${@update_based_on_images(d)}" # 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)}" +SWUPDATE_UBOOT_SCRIPT_NAME = "${@os.path.basename(d.getVar('SWUPDATE_UBOOT_SCRIPT'))}" -UBOOT_EXT ?= ".${UBOOT_SUFFIX}" +SWUPDATE_UBOOT_PREFIX ?= "${UBOOT_PREFIX}" +SWUPDATE_UBOOT_PREFIX:ccmp1 ?= "fip" +SWUPDATE_UBOOT_PREFIX_TFA ?= "tf-a" -UBOOTIMG_OFFSET ?= "${BOOTLOADER_SEEK_BOOT}" +SWUPDATE_UBOOT_EXT ?= ".${UBOOT_SUFFIX}" +SWUPDATE_UBOOT_EXT_TFA ?= ".stm32" + +SWUPDATE_UBOOT_NAME ?= "${SWUPDATE_UBOOT_PREFIX}-${MACHINE}${SWUPDATE_UBOOT_EXT}" +SWUPDATE_UBOOT_NAME:ccmp1 ?= "${SWUPDATE_UBOOT_PREFIX}-${MACHINE}-optee${SWUPDATE_UBOOT_EXT}" +SWUPDATE_UBOOT_NAME_TFA ?= "${@oe.utils.conditional('DEY_SOC_VENDOR', 'STM', '${SWUPDATE_UBOOT_PREFIX_TFA}-${MACHINE}-nand${SWUPDATE_UBOOT_EXT_TFA}', '', d)}" + +SWUPDATE_UBOOT_OFFSET ?= "0" +SWUPDATE_UBOOT_OFFSET:ccimx6 ?= "1" + +# Retrieve the correct encryption type. +def get_swupdate_uboot_enc(d): + if d.getVar('TRUSTFENCE_DEK_PATH') and d.getVar('TRUSTFENCE_DEK_PATH') != "0" : + return "enc" + return "normal" + +SWUPDATE_UBOOT_ENC ?= "${@get_swupdate_uboot_enc(d)}" ####################################### ########## SWU Update Script ########## diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description-images_template b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description-images_template index d617686f8..a7a30256e 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description-images_template +++ b/meta-digi-dey/recipes-digi/swu-images/files/ccimx6ul/sw-description-images_template @@ -8,11 +8,13 @@ software = images: ( ##IMAGES_PRIMARY## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); uboot: ( { @@ -25,11 +27,13 @@ software = images: ( ##IMAGES_SECONDARY## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); uboot: ( { @@ -42,11 +46,13 @@ software = images: ( ##IMAGES_SINGLE## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); uboot: ( { diff --git a/meta-digi-dey/recipes-digi/swu-images/files/ccmp1/sw-description-images_template b/meta-digi-dey/recipes-digi/swu-images/files/ccmp1/sw-description-images_template index 0cc414a85..5f333df7b 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/ccmp1/sw-description-images_template +++ b/meta-digi-dey/recipes-digi/swu-images/files/ccmp1/sw-description-images_template @@ -8,11 +8,13 @@ software = images: ( ##IMAGES_PRIMARY## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); uboot: ( { @@ -29,11 +31,13 @@ software = images: ( ##IMAGES_SECONDARY## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); uboot: ( { @@ -50,11 +54,13 @@ software = images: ( ##IMAGES_SINGLE## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); uboot: ( { diff --git a/meta-digi-dey/recipes-digi/swu-images/files/file_template_uboot b/meta-digi-dey/recipes-digi/swu-images/files/file_template_uboot new file mode 100644 index 000000000..b50c47257 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/file_template_uboot @@ -0,0 +1,5 @@ + { + filename = "##FILE_NAME##"; + path = "##FILE_PATH##"; + sha256 = "$swupdate_get_sha256(##FILE_NAME##)"; + } diff --git a/meta-digi-dey/recipes-digi/swu-images/files/script_template_uboot b/meta-digi-dey/recipes-digi/swu-images/files/script_template_uboot new file mode 100644 index 000000000..059bb2783 --- /dev/null +++ b/meta-digi-dey/recipes-digi/swu-images/files/script_template_uboot @@ -0,0 +1,6 @@ + { + filename = "@@SWUPDATE_UBOOT_SCRIPT_NAME@@"; + type = "preinstall"; + data = "@@SWUPDATE_UBOOT_NAME@@ @@SWUPDATE_UBOOT_ENC@@ @@SWUPDATE_UBOOT_OFFSET@@ @@SWUPDATE_UBOOT_NAME_TFA@@"; + sha256 = "$swupdate_get_sha256(@@SWUPDATE_UBOOT_SCRIPT_NAME@@)"; + } diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-files_template b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-files_template index d03492e00..c885c9b1e 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-files_template +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-files_template @@ -13,6 +13,7 @@ software = path = "/"; sha256 = "$swupdate_get_sha256(@@SWUPDATE_FILES_TARGZ_FILE_NAME@@)"; } + ##FILES_UBOOT## ); scripts: ( { @@ -20,6 +21,7 @@ software = sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); uboot: ( { @@ -40,6 +42,7 @@ software = path = "/system/"; sha256 = "$swupdate_get_sha256(@@SWUPDATE_FILES_TARGZ_FILE_NAME@@)"; } + ##FILES_UBOOT## ); scripts: ( { @@ -47,6 +50,7 @@ software = sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); } platform = { diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-images_template b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-images_template index dd0559912..bd681c61a 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-images_template +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-images_template @@ -8,12 +8,14 @@ software = images: ( ##IMAGES_PRIMARY## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); uboot: ( { @@ -26,12 +28,14 @@ software = images: ( ##IMAGES_SECONDARY## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); uboot: ( { @@ -44,12 +48,14 @@ software = images: ( ##IMAGES_SINGLE## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; type = "shellscript"; } + ##SCRIPT_UBOOT## ); } platform = { diff --git a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-rdiff_template b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-rdiff_template index 797095ed8..c2e73479a 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-rdiff_template +++ b/meta-digi-dey/recipes-digi/swu-images/files/sw-description-rdiff_template @@ -8,6 +8,7 @@ software = images: ( ##IMAGES_PRIMARY## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; @@ -15,6 +16,7 @@ software = data = "$swupdate_get_sha256(@@SWUPDATE_RDIFF_ROOTFS_SOURCE_FILE@@)" sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; } + ##SCRIPT_UBOOT## ); uboot: ( { @@ -27,6 +29,7 @@ software = images: ( ##IMAGES_SECONDARY## ); + ##FILES_UBOOT## scripts: ( { filename = "@@SWUPDATE_SCRIPT_NAME@@"; @@ -34,6 +37,7 @@ software = data = "$swupdate_get_sha256(@@SWUPDATE_RDIFF_ROOTFS_SOURCE_FILE@@)" sha256 = "$swupdate_get_sha256(@@SWUPDATE_SCRIPT_NAME@@)"; } + ##SCRIPT_UBOOT## ); uboot: ( { 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 deleted file mode 100644 index c72e564ba..000000000 --- a/meta-digi-dey/recipes-digi/swu-images/files/sw-description-uboot +++ /dev/null @@ -1,77 +0,0 @@ -software = -{ - version = "##FW_VERSION##"; - description = "##DESCRIPTION##"; - - mmc = { - platform: { - 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; - } - ); - files: ( - { - filename = "##UBOOTIMG_NAME##"; - path = "##UBOOT_IMAGE_PATH##"; - sha256 = "$swupdate_get_sha256(##UBOOTIMG_NAME##)"; - } - ); - scripts: ( - { - filename = "##SWUPDATE_UBOOT_SCRIPT##"; - type = "preinstall"; - data = "##UBOOTIMG_NAME## ##UBOOTIMG_ENC## ##UBOOTIMG_OFFSET##; - sha256 = "$swupdate_get_sha256(##SWUPDATE_UBOOT_SCRIPT##)"; - } - ); - }; - }; - mtd = { - platform: { - 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; - } - ); - files: ( - { - filename = "##UBOOTIMG_NAME##"; - path = "##UBOOT_IMAGE_PATH##"; - sha256 = "$swupdate_get_sha256(##UBOOTIMG_NAME##)"; - } - ); - scripts: ( - { - filename = "##SWUPDATE_UBOOT_SCRIPT##"; - type = "postinstall"; - data = "##UBOOTIMG_NAME## ##UBOOTIMG_ENC##"; - sha256 = "$swupdate_get_sha256(##SWUPDATE_UBOOT_SCRIPT##)"; - } - ); - }; - }; -} diff --git a/meta-digi-dey/recipes-digi/swu-images/files/swupdate_uboot_nand.sh b/meta-digi-dey/recipes-digi/swu-images/files/swupdate_uboot_nand.sh index 58f9b4de6..c92620ce7 100755 --- a/meta-digi-dey/recipes-digi/swu-images/files/swupdate_uboot_nand.sh +++ b/meta-digi-dey/recipes-digi/swu-images/files/swupdate_uboot_nand.sh @@ -1,7 +1,7 @@ #!/bin/sh #=============================================================================== # -# Copyright (C) 2022 by Digi International Inc. +# Copyright (C) 2022-2023 by Digi International Inc. # All rights reserved. # # This program is free software; you can redistribute it and/or modify it @@ -15,6 +15,7 @@ UBOOT_FILE="$1" UBOOT_ENC="$2" +TFA_FILE="$4" echo "**** Start U-Boot update process *****" @@ -70,24 +71,60 @@ dump_dek () return 0 } +install_fwu () +{ + FLASH_DEV="$1" + FW_FILE="$2" + + flash_eraseall ${FLASH_DEV} + rc=$? + if [ "$rc" -ne 0 ]; then + echo "U-Boot: erasing ${FLASH_DEV} failed" + exit $rc + fi + nandwrite -p ${FLASH_DEV} /tmp/${FW_FILE} + if [ "$rc" -ne 0 ]; then + echo "U-Boot: failed to write firmware to ${FLASH_DEV}" + exit $rc + fi +} + +COMP_CCMP1=$(cat /proc/device-tree/compatible | grep "\bdigi,ccmp1\b") + if [ "${UBOOT_ENC}" = "enc" ]; then - dump_dek - rc=$? - if [ "$rc" -ne 0 ]; then - echo "u-boot: DEK dump failed" - exit $rc + if [ "${COMP_CCMP1}" = "digi,ccmp1" ]; then + # Currently not supported for these platforms + echo "*** Encrypted U-boot currently not support for CCMP1 ***" + else + dump_dek + rc=$? + if [ "$rc" -ne 0 ]; then + echo "u-boot: DEK dump failed" + exit $rc + fi + cat $UBOOT_FILE $OUTPUT_FILE > /tmp/$ENCRYPTED_UBOOT_DEK + rc=$? + if [ "$rc" -ne 0 ]; then + echo "u-boot: Merging DEK with U-Boot image failed (DEV/FILE = $UBOOT_FILE)" + exit $rc + fi + UBOOT_FILE="${ENCRYPTED_UBOOT_DEK}" fi - cat $UBOOT_FILE $OUTPUT_FILE > /tmp/$ENCRYPTED_UBOOT_DEK - rc=$? - if [ "$rc" -ne 0 ]; then - echo "u-boot: Merging DEK with U-Boot image failed (DEV/FILE = $UBOOT_FILE)" - exit $rc - fi - UBOOT_FILE="${ENCRYPTED_UBOOT_DEK}" fi -# install U-Boot onto the Nand Flash -kobs-ng init -x -v /mnt/update/${UBOOT_FILE} +if [ "${COMP_CCMP1}" = "digi,ccmp1" ]; then + # install TF-A onto fsbl1 partition + mtd_num="$(sed -ne "/fsbl1/s,^mtd\([0-9]\+\).*,\1,g;T;p" /proc/mtd)" + TFA_DEV="/dev/mtd${mtd_num}" + install_fwu ${TFA_DEV} ${TFA_FILE} + # install U-Boot onto FIP-a partition + mtd_num="$(sed -ne "/fip-a/s,^mtd\([0-9]\+\).*,\1,g;T;p" /proc/mtd)" + FIP_DEV="/dev/mtd${mtd_num}" + install_fwu ${FIP_DEV} ${UBOOT_FILE} +else + # install U-Boot onto the Nand Flash + kobs-ng init -x -v /tmp/${UBOOT_FILE} +fi rc=$? if [ "$rc" -ne 0 ]; then echo "u-Boot: Updating U-Boot partition failed" diff --git a/meta-digi-dey/recipes-digi/swu-images/swu.inc b/meta-digi-dey/recipes-digi/swu-images/swu.inc index 6d6933350..9aff6d212 100644 --- a/meta-digi-dey/recipes-digi/swu-images/swu.inc +++ b/meta-digi-dey/recipes-digi/swu-images/swu.inc @@ -9,13 +9,14 @@ SRC_URI = " \ file://sw-description-images_template \ file://sw-description-files_template \ file://sw-description-rdiff_template \ - file://sw-description-uboot \ file://swupdate_uboot_nand.sh \ file://swupdate_uboot_mmc.sh \ file://image_template_mmc \ file://image_template_nand \ file://image_template_rdiff_mmc \ file://image_template_rdiff_nand \ + file://file_template_uboot \ + file://script_template_uboot\ file://update_images.sh \ file://update_files.sh \ file://update_rdiff.sh \ @@ -31,8 +32,7 @@ SWUPDATE_IMAGES = " \ ${@oe.utils.ifelse(d.getVar('SWUPDATE_IS_IMAGES_UPDATE') == 'true', '${IMG_NAME}', '')} \ ${@oe.utils.ifelse(d.getVar('SWUPDATE_IS_FILES_UPDATE') == 'true', '${SWUPDATE_FILES_TARGZ_FILE_NAME}', '')} \ ${@oe.utils.ifelse(d.getVar('SWUPDATE_IS_RDIFF_UPDATE') == 'true', '${IMG_NAME} ${SWUPDATE_RDIFF_ROOTFS_DELTA_FILE_NAME}', '')} \ - ${@oe.utils.ifelse(d.getVar('SWUPDATE_UBOOTIMG') == 'true', '${UBOOT_PREFIX}', '')} \ - ${@oe.utils.ifelse(d.getVar('SWUPDATE_UBOOTIMG') == 'true', '${SWUPDATE_UBOOT_SCRIPT}', '')} \ + ${@oe.utils.ifelse(d.getVar('SWUPDATE_UBOOTIMG') == 'true', '${SWUPDATE_UBOOT_NAME} ${SWUPDATE_UBOOT_NAME_TFA} ${SWUPDATE_UBOOT_SCRIPT_NAME}', '')} \ ${SWUPDATE_SCRIPT_NAME} \ " @@ -43,8 +43,11 @@ python () { img_fstypes = img_fstypes + " " + d.getVar('ROOTFS_EXT') d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", d.getVar('IMG_NAME'), img_fstypes) if (d.getVar('SWUPDATE_UBOOTIMG') == "true"): - uboot_fstypes = d.getVar('UBOOT_EXT') - d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", d.getVar('UBOOT_PREFIX'), uboot_fstypes) + uboot_fstypes = d.getVar('SWUPDATE_UBOOT_EXT') + d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", d.getVar('SWUPDATE_UBOOT_PREFIX'), uboot_fstypes) + if (d.getVar('DEY_SOC_VENDOR') == "STM"): + uboot_tfa_fstypes = d.getVar('SWUPDATE_UBOOT_EXT_TFA') + d.setVarFlag("SWUPDATE_IMAGES_FSTYPES", d.getVar('SWUPDATE_UBOOT_PREFIX_TFA'), uboot_tfa_fstypes) } # Execute extra tasks before creating SWU update package. @@ -65,6 +68,15 @@ python do_swuimage:prepend() { updatescript = os.path.join(workdir, updatescript) if os.path.isfile(updatescript): shutil.copyfile(updatescript, os.path.join(imgdeploydir, os.path.basename(updatescript))) + + # Copy U-Boot script file. + if d.getVar('SWUPDATE_UBOOTIMG') == "true": + uboot_updatescript = d.getVar('SWUPDATE_UBOOT_SCRIPT_NAME', True) + if "/" not in uboot_updatescript: + workdir = d.getVar('WORKDIR', True) + uboot_updatescript = os.path.join(workdir, uboot_updatescript) + if os.path.isfile(uboot_updatescript): + shutil.copyfile(uboot_updatescript, os.path.join(imgdeploydir, os.path.basename(uboot_updatescript))) } # Upgrade available. @@ -73,18 +85,7 @@ UPGRADE_AVAILABLE:ccimx6 = "1" # Create and fill 'sw-description' file. 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_UBOOT_SCRIPT},g" "${WORKDIR}/sw-description" - sed -i -e "s,##UBOOTIMG_OFFSET##,${UBOOTIMG_OFFSET},g" "${WORKDIR}/sw-description" - elif [ "${SWUPDATE_IS_FILES_UPDATE}" = "true" ]; then + if [ "${SWUPDATE_IS_FILES_UPDATE}" = "true" ]; then cp ${WORKDIR}/sw-description-files_template ${WORKDIR}/sw-description elif [ "${SWUPDATE_IS_RDIFF_UPDATE}" = "true" ]; then cp ${WORKDIR}/sw-description-rdiff_template ${WORKDIR}/sw-description @@ -92,7 +93,45 @@ fill_description() { cp ${WORKDIR}/sw-description-images_template ${WORKDIR}/sw-description fi + # Add U-Boot sections if required. + if [ "${SWUPDATE_UBOOTIMG}" = "true" ]; then + # Add U-Boot files section. + UBOOT_FILE_TEMPLATE="file_template_uboot" + FILES_TEMPLATE="%s\n" + if [ "${DEY_SOC_VENDOR}" = "STM" ]; then + FILES_TEMPLATE="%s,\n%s\n" + fi + if [ "${SWUPDATE_IS_FILES_UPDATE}" != "true" ]; then + FILES_TEMPLATE=" files: (\n${FILES_TEMPLATE} );\n" + else + FILES_TEMPLATE=" ,\n${FILES_TEMPLATE}" + fi + if [ "${DEY_SOC_VENDOR}" = "STM" ]; then + printf "${FILES_TEMPLATE}" \ + "$(sed -e "s,##FILE_NAME##,${SWUPDATE_UBOOT_NAME},g" -e "s,##FILE_PATH##,/tmp/${SWUPDATE_UBOOT_NAME},g" "${UBOOT_FILE_TEMPLATE}")" \ + "$(sed -e "s,##FILE_NAME##,${SWUPDATE_UBOOT_NAME_TFA},g" -e "s,##FILE_PATH##,/tmp/${SWUPDATE_UBOOT_NAME_TFA},g" "${UBOOT_FILE_TEMPLATE}")" \ + > template_out.txt + else + printf "${FILES_TEMPLATE}" \ + "$(sed -e "s,##FILE_NAME##,${SWUPDATE_UBOOT_NAME},g" -e "s,##FILE_PATH##,/tmp/${SWUPDATE_UBOOT_NAME},g" "${UBOOT_FILE_TEMPLATE}")" \ + > template_out.txt + fi + sed -i -e "/##FILES_UBOOT##/r template_out.txt" -e "/##FILES_UBOOT##/d" "${WORKDIR}/sw-description" + + # Add U-Boot script section. + UBOOT_SCRIPT_TEMPLATE="script_template_uboot" + printf " ,\n%s\n" \ + "$(cat "${UBOOT_SCRIPT_TEMPLATE}")" \ + > template_out.txt + sed -i -e "/##SCRIPT_UBOOT##/r template_out.txt" -e "/##SCRIPT_UBOOT##/d" "${WORKDIR}/sw-description" + else + # Remove U-Boot entries if U-Boot is not being updated. + sed -i -e "s,##FILES_UBOOT##,,g" "${WORKDIR}/sw-description" + sed -i -e "s,##SCRIPT_UBOOT##,,g" "${WORKDIR}/sw-description" + fi + if [ "${SWUPDATE_IS_FILES_UPDATE}" = "true" ]; then + rm -f template_out.txt return 0 fi @@ -111,23 +150,23 @@ fill_description() { 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" "${BOOT_IMAGE_TEMPLATE}")" \ "$(sed -e "s,##IMG_NAME##,${ROOTFS_IMAGE_NAME},g" -e "s,##DEV##,${ROOTFS_DEV_NAME_A},g" "${ROOTFS_IMAGE_TEMPLATE}")" \ - > images_temp.txt - sed -i -e "/##IMAGES_PRIMARY##/r images_temp.txt" -e "/##IMAGES_PRIMARY##/d" "${WORKDIR}/sw-description" + > template_out.txt + sed -i -e "/##IMAGES_PRIMARY##/r template_out.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" "${BOOT_IMAGE_TEMPLATE}")" \ "$(sed -e "s,##IMG_NAME##,${ROOTFS_IMAGE_NAME},g" -e "s,##DEV##,${ROOTFS_DEV_NAME_B},g" "${ROOTFS_IMAGE_TEMPLATE}")" \ - > images_temp.txt - sed -i -e "/##IMAGES_SECONDARY##/r images_temp.txt" -e "/##IMAGES_SECONDARY##/d" "${WORKDIR}/sw-description" + > template_out.txt + sed -i -e "/##IMAGES_SECONDARY##/r template_out.txt" -e "/##IMAGES_SECONDARY##/d" "${WORKDIR}/sw-description" # Add images section for single boot systems. if [ "${SWUPDATE_IS_RDIFF_UPDATE}" != "true" ]; then printf "%s,\n%s\n" \ "$(sed -e "s,##IMG_NAME##,${BOOT_IMAGE_NAME},g" -e "s,##DEV##,${BOOT_DEV_NAME},g" -e "/compressed/d" "${BOOT_IMAGE_TEMPLATE}")" \ "$(sed -e "s,##IMG_NAME##,${ROOTFS_IMAGE_NAME},g" -e "s,##DEV##,${ROOTFS_DEV_NAME_FINAL},g" "${ROOTFS_IMAGE_TEMPLATE}")" \ - > images_temp.txt - sed -i -e "/##IMAGES_SINGLE##/r images_temp.txt" -e "/##IMAGES_SINGLE##/d" "${WORKDIR}/sw-description" + > template_out.txt + sed -i -e "/##IMAGES_SINGLE##/r template_out.txt" -e "/##IMAGES_SINGLE##/d" "${WORKDIR}/sw-description" fi # Remove 'compressed' flag for read-only file systems as they use 'squashfs' images. @@ -136,7 +175,7 @@ fill_description() { fi # Clean dir. - rm -f images_temp.txt + rm -f template_out.txt } fill_description[dirs] = "${DEPLOY_DIR_IMAGE} ${WORKDIR}" do_unpack[postfuncs] += "fill_description"