diff --git a/meta-digi-arm/conf/machine/include/digi-defaults.inc b/meta-digi-arm/conf/machine/include/digi-defaults.inc index 72d2068a9..1aa4cc4e8 100644 --- a/meta-digi-arm/conf/machine/include/digi-defaults.inc +++ b/meta-digi-arm/conf/machine/include/digi-defaults.inc @@ -89,6 +89,7 @@ BOOT_SCRIPTS += "boot.scr:boot.scr" # This can be used to enable U-Boot update through swupdate SWUPDATE_UBOOTIMG ?= "false" +SWUPDATE_UBOOTIMG_REDUNDANT ?= "false" # ConnectCore Cloud Services packages to install CCCS_PKGS ?= "cccs-gs-demo dey-examples-cccs" diff --git a/meta-digi-dey/classes/dey-swupdate-common.bbclass b/meta-digi-dey/classes/dey-swupdate-common.bbclass index aa707fc55..bad51a542 100644 --- a/meta-digi-dey/classes/dey-swupdate-common.bbclass +++ b/meta-digi-dey/classes/dey-swupdate-common.bbclass @@ -124,6 +124,18 @@ def get_swupdate_uboot_enc(d): SWUPDATE_UBOOT_ENC ?= "${@get_swupdate_uboot_enc(d)}" +# Retrieve the redundant U-Boot value. +def get_uboot_redundant(d): + if d.getVar("SWUPDATE_UBOOTIMG") == "true" and d.getVar("SWUPDATE_UBOOTIMG_REDUNDANT") == "true": + if any(d.getVar("MACHINE").startswith(platform) for platform in ("ccimx6", "ccimx8")): + bb.warn("Target does not support updating redundant U-Boot. Continuing with single SWU U-Boot update.") + return "single" + return "redundant" + + return "single" + +SWUPDATE_UBOOT_REDUNDANT = "${@get_uboot_redundant(d)}" + ####################################### ########## SWU Update Script ########## ####################################### 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 index 059bb2783..061b3e493 100644 --- a/meta-digi-dey/recipes-digi/swu-images/files/script_template_uboot +++ b/meta-digi-dey/recipes-digi/swu-images/files/script_template_uboot @@ -1,6 +1,6 @@ { filename = "@@SWUPDATE_UBOOT_SCRIPT_NAME@@"; type = "preinstall"; - data = "@@SWUPDATE_UBOOT_NAME@@ @@SWUPDATE_UBOOT_ENC@@ @@SWUPDATE_UBOOT_OFFSET@@ @@SWUPDATE_UBOOT_NAME_TFA@@"; + data = "@@SWUPDATE_UBOOT_NAME@@ @@SWUPDATE_UBOOT_ENC@@ @@SWUPDATE_UBOOT_OFFSET@@ @@SWUPDATE_UBOOT_REDUNDANT@@ @@SWUPDATE_UBOOT_NAME_TFA@@"; sha256 = "$swupdate_get_sha256(@@SWUPDATE_UBOOT_SCRIPT_NAME@@)"; } diff --git a/meta-digi-dey/recipes-digi/swu-images/files/swupdate_uboot_mmc.sh b/meta-digi-dey/recipes-digi/swu-images/files/swupdate_uboot_mmc.sh index fa0d26520..fa76b176a 100755 --- a/meta-digi-dey/recipes-digi/swu-images/files/swupdate_uboot_mmc.sh +++ b/meta-digi-dey/recipes-digi/swu-images/files/swupdate_uboot_mmc.sh @@ -16,8 +16,10 @@ UBOOT_NAME="$1" UBOOT_ENC="$2" UBOOT_SEEK_KB="$3" +UBOOT_REDUNDANT="$4" UBOOT_FILE="/tmp/${UBOOT_NAME}" UBOOT_BLOCK_MAIN="mmcblk0boot0" +UBOOT_BLOCK_REDUNDANT="mmcblk0boot1" UBOOT_MMC_DEV_MAIN="/dev/${UBOOT_BLOCK_MAIN}" UBOOT_MMC_DUMP="/tmp/u-boot-dump.hex" UBOOT_ENCRYPTED_DEK="/tmp/u-boot-encrypted-with-dek.imx" @@ -258,6 +260,10 @@ if [ "${UBOOT_ENC}" = "enc" ]; then fi # Write U-Boot write_uboot_emmc ${UBOOT_BLOCK_MAIN} +# Check if redundant U-Boot update is requested. +if [ "${UBOOT_REDUNDANT}" = "redundant" ]; then + write_uboot_emmc ${UBOOT_BLOCK_REDUNDANT} +fi # Clean intermediate artifacts. clean_artifacts 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 d7884570f..c94d29cc4 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 @@ -16,7 +16,8 @@ UBOOT_NAME="$1" UBOOT_ENC="$2" UBOOT_SEEK_KB="$3" -UBOOT_TFA_NAME="$4" +UBOOT_REDUNDANT="$4" +UBOOT_TFA_NAME="$5" UBOOT_TFA_FILE="/tmp/${UBOOT_TFA_NAME}" UBOOT_FILE="/tmp/${UBOOT_NAME}" UBOOT_NAND_DUMP="/tmp/u-boot-dump.hex" @@ -148,6 +149,13 @@ if expr "${PLATFORM}" : "ccmp1.*" >/dev/null; then write_file_to_nand "/dev/mtd$(get_mtd_number_from_partition fsbl1)" "${UBOOT_TFA_FILE}" # Install U-Boot FIP file in fip-a partition. write_file_to_nand "/dev/mtd$(get_mtd_number_from_partition fip-a)" "${UBOOT_FILE}" + # Check if redundant U-Boot update is requested. + if [ "${UBOOT_REDUNDANT}" = "redundant" ]; then + # Install TFA file in fsbl2 partition (redundant). + write_file_to_nand "/dev/mtd$(get_mtd_number_from_partition fsbl2)" "${UBOOT_TFA_FILE}" + # Install U-Boot FIP file in fip-b partition (redundant). + write_file_to_nand "/dev/mtd$(get_mtd_number_from_partition fip-b)" "${UBOOT_FILE}" + fi else # Mount debug file system to remove some kobs-ng warnings. if ! grep -qs debugfs /proc/mounts; then