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 <hector.palacios@digi.com>

https://onedigi.atlassian.net/browse/DEL-7649
This commit is contained in:
Hector Palacios 2021-09-16 12:49:25 +02:00
parent 85d55a70a2
commit dae2b5000a
3 changed files with 194 additions and 92 deletions

View File

@ -83,6 +83,12 @@ done
# Enable the redirect support to get u-boot variables values # Enable the redirect support to get u-boot variables values
uuu fb: ucmd setenv stdout serial,fastboot 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 # Check if ubisysvols variable is active
ubisysvols=$(getenv "ubisysvols") ubisysvols=$(getenv "ubisysvols")
if [ "${ubisysvols}" = "yes" ]; then if [ "${ubisysvols}" = "yes" ]; then
@ -163,32 +169,43 @@ done;
[ "${ABORT}" = true ] && exit 1 [ "${ABORT}" = true ] && exit 1
# parts names
LINUX_NAME="linux"
RECOVERY_NAME="recovery"
ROOTFS_NAME="rootfs"
# Print warning about storage media being deleted # Print warning about storage media being deleted
if [ ! "${NOWAIT}" = true ]; then if [ "${NOWAIT}" != true ]; then
WAIT=10 WAIT=10
echo "" printf "\n"
echo " ====================" printf " ====================\n"
echo " = IMPORTANT! =" printf " = IMPORTANT! =\n"
echo " ====================" printf " ====================\n"
echo " This process will erase your NAND and will install the following files" printf " This process will erase your NAND and will install the following files\n"
echo " on the partitions of the NAND." printf " on the partitions of the NAND.\n"
echo "" printf "\n"
echo " PARTITION FILENAME" printf " PARTITION\tFILENAME\n"
echo " --------- --------" printf " ---------\t--------\n"
echo " bootloader ${INSTALL_UBOOT_FILENAME}" printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n"
echo " linux ${INSTALL_LINUX_FILENAME}" if [ "${DUALBOOT}" = true ]; then
echo " recovery ${INSTALL_RECOVERY_FILENAME}" printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n"
echo " rootfs ${INSTALL_ROOTFS_FILENAME}" printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n"
echo "" printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n"
echo " Press CTRL+C now if you wish to abort." printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n"
echo "" 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 while [ ${WAIT} -gt 0 ]; do
printf "\r Update process starts in %d " ${WAIT} printf "\r Update process starts in %d " ${WAIT}
sleep 1 sleep 1
WAIT=$(( ${WAIT} - 1 )) WAIT=$(( ${WAIT} - 1 ))
done done
printf "\r \n" printf "\r \n"
echo " Starting update process" printf " Starting update process\n"
fi fi
# Set fastboot buffer address to $loadaddr, just in case # Set fastboot buffer address to $loadaddr, just in case
@ -227,6 +244,11 @@ sleep 3
# Set fastboot buffer address to $loadaddr # Set fastboot buffer address to $loadaddr
uuu fb: ucmd setenv fastboot_buffer \${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 # Restore ubisysvols if previously active
if [ "${UBISYSVOLS}" = true ]; then if [ "${UBISYSVOLS}" = true ]; then
uuu fb: ucmd setenv ubisysvols yes uuu fb: ucmd setenv ubisysvols yes
@ -239,24 +261,34 @@ if [ "${UBISYSVOLS}" = true ]; then
uuu "fb[-t 10000]:" ucmd run ubivolscript uuu "fb[-t 10000]:" ucmd run ubivolscript
fi fi
# Update Linux if [ "${DUALBOOT}" = true ]; then
part_update "linux" "${INSTALL_LINUX_FILENAME}" 15000 # 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 if [ "${UBISYSVOLS}" != true ] && [ "${DUALBOOT}" != true ]; then
part_update "recovery" "${INSTALL_RECOVERY_FILENAME}" 15000
# Update Rootfs
part_update "rootfs" "${INSTALL_ROOTFS_FILENAME}" 90000
if [ ! "${UBISYSVOLS}" = true ]; then
# Erase the 'Update' partition # Erase the 'Update' partition
uuu fb: ucmd nand erase.part update uuu fb: ucmd nand erase.part update
fi fi
# Configure u-boot to boot into recovery mode if [ "${DUALBOOT}" != true ]; then
uuu fb: ucmd setenv boot_recovery yes # Configure u-boot to boot into recovery mode
uuu fb: ucmd setenv recovery_command wipe_update uuu fb: ucmd setenv boot_recovery yes
uuu fb: ucmd setenv recovery_command wipe_update
fi
uuu fb: ucmd saveenv uuu fb: ucmd saveenv
# Reset the target # Reset the target

View File

@ -79,6 +79,18 @@ do
esac esac
done 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 ""
echo "Determining image files to use..." echo "Determining image files to use..."
@ -127,32 +139,43 @@ done;
[ "${ABORT}" = true ] && exit 1 [ "${ABORT}" = true ] && exit 1
# parts names
LINUX_NAME="linux"
RECOVERY_NAME="recovery"
ROOTFS_NAME="rootfs"
# Print warning about storage media being deleted # Print warning about storage media being deleted
if [ ! "${NOWAIT}" = true ]; then if [ "${NOWAIT}" != true ]; then
WAIT=10 WAIT=10
echo "" printf "\n"
echo " ====================" printf " ====================\n"
echo " = IMPORTANT! =" printf " = IMPORTANT! =\n"
echo " ====================" printf " ====================\n"
echo " This process will erase your eMMC and will install the following files" printf " This process will erase your eMMC and will install the following files\n"
echo " on the partitions of the eMMC." printf " on the partitions of the eMMC.\n"
echo "" printf "\n"
echo " PARTITION FILENAME" printf " PARTITION\tFILENAME\n"
echo " --------- --------" printf " ---------\t--------\n"
echo " bootloader ${INSTALL_UBOOT_FILENAME}" printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n"
echo " linux ${INSTALL_LINUX_FILENAME}" if [ "${DUALBOOT}" = true ]; then
echo " recovery ${INSTALL_RECOVERY_FILENAME}" printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n"
echo " rootfs ${INSTALL_ROOTFS_FILENAME}" printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n"
echo "" printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n"
echo " Press CTRL+C now if you wish to abort." printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n"
echo "" 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 while [ ${WAIT} -gt 0 ]; do
printf "\r Update process starts in %d " ${WAIT} printf "\r Update process starts in %d " ${WAIT}
sleep 1 sleep 1
WAIT=$(( ${WAIT} - 1 )) WAIT=$(( ${WAIT} - 1 ))
done done
printf "\r \n" printf "\r \n"
echo " Starting update process" printf " Starting update process\n"
fi fi
# Set fastboot buffer address to $loadaddr, just in case # 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 # Set fastboot buffer address to $loadaddr, just in case
uuu fb: ucmd setenv fastboot_buffer \${loadaddr} uuu fb: ucmd setenv fastboot_buffer \${loadaddr}
# Update Linux # Restore dualboot if previously active
part_update "linux" "${INSTALL_LINUX_FILENAME}" if [ "${DUALBOOT}" = true ]; then
uuu fb: ucmd setenv dualboot yes
fi
# Update Recovery if [ "${DUALBOOT}" = true ]; then
part_update "recovery" "${INSTALL_RECOVERY_FILENAME}" # Update Linux A
part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}"
# Update Rootfs # Update Linux B
part_update "rootfs" "${INSTALL_ROOTFS_FILENAME}" 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 the rootfs image was originally compressed, remove the uncompressed image
if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then
rm -f "${INSTALL_ROOTFS_FILENAME}" rm -f "${INSTALL_ROOTFS_FILENAME}"
fi fi
# Configure u-boot to boot into recovery mode if [ "${DUALBOOT}" != true ]; then
uuu fb: ucmd setenv boot_recovery yes # Configure u-boot to boot into recovery mode
uuu fb: ucmd setenv recovery_command wipe_update uuu fb: ucmd setenv boot_recovery yes
uuu fb: ucmd setenv recovery_command wipe_update
fi
uuu fb: ucmd saveenv uuu fb: ucmd saveenv
# Reset the target # Reset the target

View File

@ -79,14 +79,20 @@ do
esac esac
done 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 ""
echo "Determining image files to use..." echo "Determining image files to use..."
# Determine U-Boot file to program basing on SOM's SOC type (linked to bus width) # Determine U-Boot file to program basing on SOM's SOC type (linked to bus width)
if [ -z ${INSTALL_UBOOT_FILENAME} ]; then 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 # 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 revision to the environment, use B0 by default
soc_rev=$(getenv "soc_rev") soc_rev=$(getenv "soc_rev")
@ -189,32 +195,43 @@ done;
[ "${ABORT}" = true ] && exit 1 [ "${ABORT}" = true ] && exit 1
# parts names
LINUX_NAME="linux"
RECOVERY_NAME="recovery"
ROOTFS_NAME="rootfs"
# Print warning about storage media being deleted # Print warning about storage media being deleted
if [ ! "${NOWAIT}" = true ]; then if [ "${NOWAIT}" != true ]; then
WAIT=10 WAIT=10
echo "" printf "\n"
echo " ====================" printf " ====================\n"
echo " = IMPORTANT! =" printf " = IMPORTANT! =\n"
echo " ====================" printf " ====================\n"
echo " This process will erase your eMMC and will install the following files" printf " This process will erase your eMMC and will install the following files\n"
echo " on the partitions of the eMMC." printf " on the partitions of the eMMC.\n"
echo "" printf "\n"
echo " PARTITION FILENAME" printf " PARTITION\tFILENAME\n"
echo " --------- --------" printf " ---------\t--------\n"
echo " bootloader ${INSTALL_UBOOT_FILENAME}" printf " bootloader\t${INSTALL_UBOOT_FILENAME}\n"
echo " linux ${INSTALL_LINUX_FILENAME}" if [ "${DUALBOOT}" = true ]; then
echo " recovery ${INSTALL_RECOVERY_FILENAME}" printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n"
echo " rootfs ${INSTALL_ROOTFS_FILENAME}" printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n"
echo "" printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n"
echo " Press CTRL+C now if you wish to abort." printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n"
echo "" 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 while [ ${WAIT} -gt 0 ]; do
printf "\r Update process starts in %d " ${WAIT} printf "\r Update process starts in %d " ${WAIT}
sleep 1 sleep 1
WAIT=$(( ${WAIT} - 1 )) WAIT=$(( ${WAIT} - 1 ))
done done
printf "\r \n" printf "\r \n"
echo " Starting update process" printf " Starting update process\n"
fi fi
# Skip user confirmation for U-Boot update # 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 # Set fastboot buffer address to $loadaddr, just in case
uuu fb: ucmd setenv fastboot_buffer \${loadaddr} uuu fb: ucmd setenv fastboot_buffer \${loadaddr}
# Update Linux # Restore dualboot if previously active
part_update "linux" "${INSTALL_LINUX_FILENAME}" if [ "${DUALBOOT}" = true ]; then
uuu fb: ucmd setenv dualboot yes
fi
# Update Recovery if [ "${DUALBOOT}" = true ]; then
part_update "recovery" "${INSTALL_RECOVERY_FILENAME}" # Update Linux A
part_update "${LINUX_NAME}_a" "${INSTALL_LINUX_FILENAME}"
# Update Rootfs # Update Linux B
part_update "rootfs" "${INSTALL_ROOTFS_FILENAME}" 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 the rootfs image was originally compressed, remove the uncompressed image
if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then if [ -f ${COMPRESSED_ROOTFS_IMAGE} ] && [ -f ${INSTALL_ROOTFS_FILENAME} ]; then
rm -f "${INSTALL_ROOTFS_FILENAME}" rm -f "${INSTALL_ROOTFS_FILENAME}"
fi fi
# Configure u-boot to boot into recovery mode if [ "${DUALBOOT}" != true ]; then
uuu fb: ucmd setenv boot_recovery yes # Configure u-boot to boot into recovery mode
uuu fb: ucmd setenv recovery_command wipe_update uuu fb: ucmd setenv boot_recovery yes
uuu fb: ucmd setenv recovery_command wipe_update
fi
uuu fb: ucmd saveenv uuu fb: ucmd saveenv
# Reset the target # Reset the target