From dae2b5000a98dabf0f9a3a97edf7de202de77223 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Thu, 16 Sep 2021 12:49:25 +0200 Subject: [PATCH] uboot: add dualboot support to uuu firmware install script Check the status of 'dualboot' env variable. If set to "yes", use the dualboot partition table in the script and restore the variable (default is "no") after resetting the environment. Also, for dualboot, there's no need to wipe the recovery partition or boot into recovery mode. For dualboot, this script programs both systems A and B with the same images. Signed-off-by: Hector Palacios https://onedigi.atlassian.net/browse/DEL-7649 --- .../ccimx6ul/install_linux_fw_uuu.sh | 94 ++++++++++++------ .../ccimx8m/install_linux_fw_uuu.sh | 96 +++++++++++++------ .../ccimx8x/install_linux_fw_uuu.sh | 96 ++++++++++++------- 3 files changed, 194 insertions(+), 92 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh index 8d22d569c..01b626663 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_uuu.sh @@ -83,6 +83,12 @@ done # Enable the redirect support to get u-boot variables values uuu fb: ucmd setenv stdout serial,fastboot +# Check if dualboot variable is active +dualboot=$(getenv "dualboot") +if [ "${dualboot}" = "yes" ]; then + DUALBOOT=true; +fi + # Check if ubisysvols variable is active ubisysvols=$(getenv "ubisysvols") if [ "${ubisysvols}" = "yes" ]; then @@ -163,32 +169,43 @@ done; [ "${ABORT}" = true ] && exit 1 +# parts names +LINUX_NAME="linux" +RECOVERY_NAME="recovery" +ROOTFS_NAME="rootfs" # Print warning about storage media being deleted -if [ ! "${NOWAIT}" = true ]; then +if [ "${NOWAIT}" != true ]; then WAIT=10 - echo "" - echo " ====================" - echo " = IMPORTANT! =" - echo " ====================" - echo " This process will erase your NAND and will install the following files" - echo " on the partitions of the NAND." - echo "" - echo " PARTITION FILENAME" - echo " --------- --------" - echo " bootloader ${INSTALL_UBOOT_FILENAME}" - echo " linux ${INSTALL_LINUX_FILENAME}" - echo " recovery ${INSTALL_RECOVERY_FILENAME}" - echo " rootfs ${INSTALL_ROOTFS_FILENAME}" - echo "" - echo " Press CTRL+C now if you wish to abort." - echo "" + printf "\n" + printf " ====================\n" + printf " = IMPORTANT! =\n" + printf " ====================\n" + printf " This process will erase your NAND and will install the following files\n" + printf " on the partitions of the NAND.\n" + printf "\n" + printf " PARTITION\tFILENAME\n" + printf " ---------\t--------\n" + printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n" + if [ "${DUALBOOT}" = true ]; then + printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n" + printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n" + printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n" + printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n" + else + printf " ${LINUX_NAME}\t${INSTALL_LINUX_FILENAME}\n" + printf " ${RECOVERY_NAME}\t${INSTALL_RECOVERY_FILENAME}\n" + printf " ${ROOTFS_NAME}\t${INSTALL_ROOTFS_FILENAME}\n" + fi + printf "\n" + printf " Press CTRL+C now if you wish to abort.\n" + printf "\n" while [ ${WAIT} -gt 0 ]; do printf "\r Update process starts in %d " ${WAIT} sleep 1 WAIT=$(( ${WAIT} - 1 )) done printf "\r \n" - echo " Starting update process" + printf " Starting update process\n" fi # Set fastboot buffer address to $loadaddr, just in case @@ -227,6 +244,11 @@ sleep 3 # Set fastboot buffer address to $loadaddr uuu fb: ucmd setenv fastboot_buffer \${loadaddr} +# Restore dualboot if previously active +if [ "${DUALBOOT}" = true ]; then + uuu fb: ucmd setenv dualboot yes +fi + # Restore ubisysvols if previously active if [ "${UBISYSVOLS}" = true ]; then uuu fb: ucmd setenv ubisysvols yes @@ -239,24 +261,34 @@ if [ "${UBISYSVOLS}" = true ]; then uuu "fb[-t 10000]:" ucmd run ubivolscript fi -# Update Linux -part_update "linux" "${INSTALL_LINUX_FILENAME}" 15000 +if [ "${DUALBOOT}" = true ]; then + # Update Linux A + part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" 15000 + # Update Linux B + part_update "${LINUX_NAME}_b" "${INSTALL_LINUX_FILENAME}" 15000 + # Update Rootfs A + part_update "${ROOTFS_NAME}_a" "${INSTALL_ROOTFS_FILENAME}" 90000 + # Update Rootfs B + part_update "${ROOTFS_NAME}_b" "${INSTALL_ROOTFS_FILENAME}" 90000 +else + # Update Linux + part_update "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}" 15000 + # Update Recovery + part_update "${RECOVERY_NAME}" "${INSTALL_RECOVERY_FILENAME}" 15000 + # Update Rootfs + part_update "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}" 90000 +fi -# Update Recovery -part_update "recovery" "${INSTALL_RECOVERY_FILENAME}" 15000 - -# Update Rootfs -part_update "rootfs" "${INSTALL_ROOTFS_FILENAME}" 90000 - -if [ ! "${UBISYSVOLS}" = true ]; then +if [ "${UBISYSVOLS}" != true ] && [ "${DUALBOOT}" != true ]; then # Erase the 'Update' partition uuu fb: ucmd nand erase.part update fi -# Configure u-boot to boot into recovery mode -uuu fb: ucmd setenv boot_recovery yes -uuu fb: ucmd setenv recovery_command wipe_update - +if [ "${DUALBOOT}" != true ]; then + # Configure u-boot to boot into recovery mode + uuu fb: ucmd setenv boot_recovery yes + uuu fb: ucmd setenv recovery_command wipe_update +fi uuu fb: ucmd saveenv # Reset the target diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh index 401ba22c0..a723997f7 100755 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8m/install_linux_fw_uuu.sh @@ -79,6 +79,18 @@ do esac done +# Enable the redirect support to get u-boot variables values +uuu fb: ucmd setenv stdout serial,fastboot + +# Check if dualboot variable is active +dualboot=$(getenv "dualboot") +if [ "${dualboot}" = "yes" ]; then + DUALBOOT=true; +fi + +# remove redirect +uuu fb: ucmd setenv stdout serial + echo "" echo "Determining image files to use..." @@ -127,32 +139,43 @@ done; [ "${ABORT}" = true ] && exit 1 +# parts names +LINUX_NAME="linux" +RECOVERY_NAME="recovery" +ROOTFS_NAME="rootfs" # Print warning about storage media being deleted -if [ ! "${NOWAIT}" = true ]; then +if [ "${NOWAIT}" != true ]; then WAIT=10 - echo "" - echo " ====================" - echo " = IMPORTANT! =" - echo " ====================" - echo " This process will erase your eMMC and will install the following files" - echo " on the partitions of the eMMC." - echo "" - echo " PARTITION FILENAME" - echo " --------- --------" - echo " bootloader ${INSTALL_UBOOT_FILENAME}" - echo " linux ${INSTALL_LINUX_FILENAME}" - echo " recovery ${INSTALL_RECOVERY_FILENAME}" - echo " rootfs ${INSTALL_ROOTFS_FILENAME}" - echo "" - echo " Press CTRL+C now if you wish to abort." - echo "" + printf "\n" + printf " ====================\n" + printf " = IMPORTANT! =\n" + printf " ====================\n" + printf " This process will erase your eMMC and will install the following files\n" + printf " on the partitions of the eMMC.\n" + printf "\n" + printf " PARTITION\tFILENAME\n" + printf " ---------\t--------\n" + printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n" + if [ "${DUALBOOT}" = true ]; then + printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n" + printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n" + printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n" + printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n" + else + printf " ${LINUX_NAME}\t${INSTALL_LINUX_FILENAME}\n" + printf " ${RECOVERY_NAME}\t${INSTALL_RECOVERY_FILENAME}\n" + printf " ${ROOTFS_NAME}\t${INSTALL_ROOTFS_FILENAME}\n" + fi + printf "\n" + printf " Press CTRL+C now if you wish to abort.\n" + printf "\n" while [ ${WAIT} -gt 0 ]; do printf "\r Update process starts in %d " ${WAIT} sleep 1 WAIT=$(( ${WAIT} - 1 )) done printf "\r \n" - echo " Starting update process" + printf " Starting update process\n" fi # Set fastboot buffer address to $loadaddr, just in case @@ -211,24 +234,39 @@ uuu fb: ucmd setenv fastboot_dev mmc # Set fastboot buffer address to $loadaddr, just in case uuu fb: ucmd setenv fastboot_buffer \${loadaddr} -# Update Linux -part_update "linux" "${INSTALL_LINUX_FILENAME}" +# Restore dualboot if previously active +if [ "${DUALBOOT}" = true ]; then + uuu fb: ucmd setenv dualboot yes +fi -# Update Recovery -part_update "recovery" "${INSTALL_RECOVERY_FILENAME}" - -# Update Rootfs -part_update "rootfs" "${INSTALL_ROOTFS_FILENAME}" +if [ "${DUALBOOT}" = true ]; then + # Update Linux A + part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" + # Update Linux B + part_update "${LINUX_NAME}_b" "${INSTALL_LINUX_FILENAME}" + # Update Rootfs A + part_update "${ROOTFS_NAME}_a" "${INSTALL_ROOTFS_FILENAME}" + # Update Rootfs B + part_update "${ROOTFS_NAME}_b" "${INSTALL_ROOTFS_FILENAME}" +else + # Update Linux + part_update "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}" + # Update Recovery + part_update "${RECOVERY_NAME}" "${INSTALL_RECOVERY_FILENAME}" + # Update Rootfs + part_update "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}" +fi # If the rootfs image was originally compressed, remove the uncompressed image if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then rm -f "${INSTALL_ROOTFS_FILENAME}" fi -# Configure u-boot to boot into recovery mode -uuu fb: ucmd setenv boot_recovery yes -uuu fb: ucmd setenv recovery_command wipe_update - +if [ "${DUALBOOT}" != true ]; then + # Configure u-boot to boot into recovery mode + uuu fb: ucmd setenv boot_recovery yes + uuu fb: ucmd setenv recovery_command wipe_update +fi uuu fb: ucmd saveenv # Reset the target diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh index 6f3316ba6..8da80e9c5 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/install_linux_fw_uuu.sh @@ -79,14 +79,20 @@ do esac done +# Enable the redirect support to get u-boot variables values +uuu fb: ucmd setenv stdout serial,fastboot + +# Check if dualboot variable is active +dualboot=$(getenv "dualboot") +if [ "${dualboot}" = "yes" ]; then + DUALBOOT=true; +fi + echo "" echo "Determining image files to use..." # Determine U-Boot file to program basing on SOM's SOC type (linked to bus width) if [ -z ${INSTALL_UBOOT_FILENAME} ]; then - # Enable the redirect support to get u-boot variables values - uuu fb: ucmd setenv stdout serial,fastboot - # Since SOMs with the B0 SOC might have an older U-Boot that doesn't export the # SOC revision to the environment, use B0 by default soc_rev=$(getenv "soc_rev") @@ -189,32 +195,43 @@ done; [ "${ABORT}" = true ] && exit 1 +# parts names +LINUX_NAME="linux" +RECOVERY_NAME="recovery" +ROOTFS_NAME="rootfs" # Print warning about storage media being deleted -if [ ! "${NOWAIT}" = true ]; then +if [ "${NOWAIT}" != true ]; then WAIT=10 - echo "" - echo " ====================" - echo " = IMPORTANT! =" - echo " ====================" - echo " This process will erase your eMMC and will install the following files" - echo " on the partitions of the eMMC." - echo "" - echo " PARTITION FILENAME" - echo " --------- --------" - echo " bootloader ${INSTALL_UBOOT_FILENAME}" - echo " linux ${INSTALL_LINUX_FILENAME}" - echo " recovery ${INSTALL_RECOVERY_FILENAME}" - echo " rootfs ${INSTALL_ROOTFS_FILENAME}" - echo "" - echo " Press CTRL+C now if you wish to abort." - echo "" + printf "\n" + printf " ====================\n" + printf " = IMPORTANT! =\n" + printf " ====================\n" + printf " This process will erase your eMMC and will install the following files\n" + printf " on the partitions of the eMMC.\n" + printf "\n" + printf " PARTITION\tFILENAME\n" + printf " ---------\t--------\n" + printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n" + if [ "${DUALBOOT}" = true ]; then + printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n" + printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n" + printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n" + printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n" + else + printf " ${LINUX_NAME}\t${INSTALL_LINUX_FILENAME}\n" + printf " ${RECOVERY_NAME}\t${INSTALL_RECOVERY_FILENAME}\n" + printf " ${ROOTFS_NAME}\t${INSTALL_ROOTFS_FILENAME}\n" + fi + printf "\n" + printf " Press CTRL+C now if you wish to abort.\n" + printf "\n" while [ ${WAIT} -gt 0 ]; do printf "\r Update process starts in %d " ${WAIT} sleep 1 WAIT=$(( ${WAIT} - 1 )) done printf "\r \n" - echo " Starting update process" + printf " Starting update process\n" fi # Skip user confirmation for U-Boot update @@ -270,24 +287,39 @@ uuu fb: ucmd setenv fastboot_dev mmc # Set fastboot buffer address to $loadaddr, just in case uuu fb: ucmd setenv fastboot_buffer \${loadaddr} -# Update Linux -part_update "linux" "${INSTALL_LINUX_FILENAME}" +# Restore dualboot if previously active +if [ "${DUALBOOT}" = true ]; then + uuu fb: ucmd setenv dualboot yes +fi -# Update Recovery -part_update "recovery" "${INSTALL_RECOVERY_FILENAME}" - -# Update Rootfs -part_update "rootfs" "${INSTALL_ROOTFS_FILENAME}" +if [ "${DUALBOOT}" = true ]; then + # Update Linux A + part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}" + # Update Linux B + part_update "${LINUX_NAME}_b" "${INSTALL_LINUX_FILENAME}" + # Update Rootfs A + part_update "${ROOTFS_NAME}_a" "${INSTALL_ROOTFS_FILENAME}" + # Update Rootfs B + part_update "${ROOTFS_NAME}_b" "${INSTALL_ROOTFS_FILENAME}" +else + # Update Linux + part_update "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}" + # Update Recovery + part_update "${RECOVERY_NAME}" "${INSTALL_RECOVERY_FILENAME}" + # Update Rootfs + part_update "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}" +fi # If the rootfs image was originally compressed, remove the uncompressed image if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then rm -f "${INSTALL_ROOTFS_FILENAME}" fi -# Configure u-boot to boot into recovery mode -uuu fb: ucmd setenv boot_recovery yes -uuu fb: ucmd setenv recovery_command wipe_update - +if [ "${DUALBOOT}" != true ]; then + # Configure u-boot to boot into recovery mode + uuu fb: ucmd setenv boot_recovery yes + uuu fb: ucmd setenv recovery_command wipe_update +fi uuu fb: ucmd saveenv # Reset the target