ccimx93: uuu: add support to flash trustfence artifacts

https://onedigi.atlassian.net/browse/DEL-9058

Signed-off-by: Francisco Gil <francisco.gilmartinez@digi.com>
This commit is contained in:
Francisco Gil 2024-06-13 14:15:07 +02:00
parent 0a5274e06f
commit 86b97c888a
1 changed files with 30 additions and 6 deletions

View File

@ -39,8 +39,11 @@ show_usage()
echo " -i <dey-image-name> Image name that prefixes the image filenames, such as 'dey-image-qt', " echo " -i <dey-image-name> Image name that prefixes the image filenames, such as 'dey-image-qt', "
echo " 'dey-image-webkit', 'core-image-base'..." echo " 'dey-image-webkit', 'core-image-base'..."
echo " Defaults to '##DEFAULT_IMAGE_NAME##' if not provided." echo " Defaults to '##DEFAULT_IMAGE_NAME##' if not provided."
echo " -k <dek-blob-file> Update includes dek blob file."
echo " (requires -t)."
echo " -n No wait. Skips 10 seconds delay to stop script." echo " -n No wait. Skips 10 seconds delay to stop script."
echo " -u <u-boot-filename> U-Boot filename." echo " -u <u-boot-filename> U-Boot filename."
echo " -t Install Trustfence artifacts."
echo " Auto-determined by variant if not provided." echo " Auto-determined by variant if not provided."
echo " -U Update redundant bootloader partition." echo " -U Update redundant bootloader partition."
@ -51,6 +54,7 @@ show_usage()
# Params: # Params:
# 1. partition # 1. partition
# 2. file # 2. file
# 3. dek blob file when updating an encrypted bootloader
part_update() part_update()
{ {
echo "\033[36m" echo "\033[36m"
@ -59,10 +63,23 @@ part_update()
echo "=====================================================================================" echo "====================================================================================="
echo "\033[0m" echo "\033[0m"
if [ "${1}" = "bootloader" ] || [ "${1}" = "bootloader_redundant" ]; then if [ "${TRUSTFENCE}" = "true" ] && [ "${1}" = "bootloader" ]; then
uuu fb: flash "${1}" "${2}" uuu fb: download -f "${2}"
if [ -n "${DEK_BLOB_KEY}" ]; then
uuu fb: ucmd setenv uboot_size \${filesize}
uuu fb: ucmd setenv fastboot_buffer \${initrd_addr}
uuu fb: download -f "${3}"
uuu fb: ucmd setenv dek_size \${filesize}
uuu fb: ucmd trustfence update ram \${loadaddr} \${uboot_size} \${initrd_addr} \${dek_size}
else
uuu fb: ucmd trustfence update ram \${fastboot_buffer} \${fastboot_bytes}
fi
else else
uuu fb: flash -raw2sparse "${1}" "${2}" if [ "${1}" = "bootloader" ] || [ "${1}" = "bootloader_redundant" ]; then
uuu fb: flash "${1}" "${2}"
else
uuu fb: flash -raw2sparse "${1}" "${2}"
fi
fi fi
} }
@ -75,15 +92,18 @@ echo "############################################################"
# -b, -d, -n (booleans) # -b, -d, -n (booleans)
# -i <image-name> # -i <image-name>
# -u <u-boot-filename> # -u <u-boot-filename>
while getopts 'bdhi:nu:U' c # -k <dek-blob-name>
while getopts 'bdhti:nu:Uk:' c
do do
case $c in case $c in
b) BOOTCOUNT=true ;; b) BOOTCOUNT=true ;;
d) INSTALL_DUALBOOT=true && BOOTCOUNT=true ;; d) INSTALL_DUALBOOT=true && BOOTCOUNT=true ;;
h) show_usage ;; h) show_usage ;;
i) IMAGE_NAME=${OPTARG} ;; i) IMAGE_NAME=${OPTARG} ;;
k) DEK_BLOB_KEY=${OPTARG} ;;
n) NOWAIT=true ;; n) NOWAIT=true ;;
u) INSTALL_UBOOT_FILENAME=${OPTARG} ;; u) INSTALL_UBOOT_FILENAME=${OPTARG} ;;
t) TRUSTFENCE=true ;;
U) INSTALL_REDUNDANT_UBOOT=true ;; U) INSTALL_REDUNDANT_UBOOT=true ;;
esac esac
done done
@ -112,7 +132,7 @@ if [ -z "${INSTALL_UBOOT_FILENAME}" ]; then
som_hv="$(((hwid_2 & 0x78) >> 3))" som_hv="$(((hwid_2 & 0x78) >> 3))"
[ "${som_hv}" -lt "2" ] && SOCREV="-A0" [ "${som_hv}" -lt "2" ] && SOCREV="-A0"
fi fi
INSTALL_UBOOT_FILENAME="imx-boot-##MACHINE##${SOCREV}.bin" INSTALL_UBOOT_FILENAME="imx-boot-##SIGNED##-##MACHINE##${SOCREV}.bin"
fi fi
# remove redirect # remove redirect
@ -230,7 +250,7 @@ uuu fb: ucmd setenv fastboot_buffer \${loadaddr}
uuu fb: ucmd setenv forced_update 1 uuu fb: ucmd setenv forced_update 1
# Update U-Boot # Update U-Boot
part_update "bootloader" "${INSTALL_UBOOT_FILENAME}" part_update "bootloader" "${INSTALL_UBOOT_FILENAME}" "${DEK_BLOB_KEY}"
if [ "${INSTALL_REDUNDANT_UBOOT}" = true ]; then if [ "${INSTALL_REDUNDANT_UBOOT}" = true ]; then
part_update bootloader_redundant "${INSTALL_UBOOT_FILENAME}" part_update bootloader_redundant "${INSTALL_UBOOT_FILENAME}"
fi fi
@ -313,6 +333,10 @@ fi
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
# Set the dboot_kernel_var to fitimage if Trustfence is enabled
if [ "${TRUSTFENCE}" = "true" ] || echo "$INSTALL_UBOOT_FILENAME" | grep -q -e "signed" -e "encrypted"; then
uuu fb: ucmd setenv dboot_kernel_var fitimage
fi
if [ "${DUALBOOT}" != true ]; then if [ "${DUALBOOT}" != true ]; then
# Configure u-boot to boot into recovery mode # Configure u-boot to boot into recovery mode