ccmp25: implement firmware deployment scripts

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

Signed-off-by: Javier Viguera <javier.viguera@digi.com>
This commit is contained in:
Javier Viguera 2024-07-25 19:18:47 +02:00
parent 5ba3466c08
commit 2a9e657e0f
3 changed files with 221 additions and 177 deletions

View File

@ -7,9 +7,10 @@
install_abort=0 install_abort=0
BASEFILENAME=0 BASEFILENAME=0
setenv INSTALL_ATF_FILENAME tf-a-##MACHINE##-${module_ram}-emmc.stm32 setenv INSTALL_ATF_FILENAME tf-a-##MACHINE##-emmc.stm32
setenv INSTALL_FIP_FILENAME fip-##MACHINE##-${module_ram}-optee.bin setenv INSTALL_METADATA_FILENAME metadata-##MACHINE##.bin
setenv INSTALL_MMCDEV 1 setenv INSTALL_FIP_FILENAME fip-##MACHINE##-optee.bin
setenv INSTALL_MMCDEV 2
if test -z "${image-name}"; then if test -z "${image-name}"; then
setenv image-name ##DEFAULT_IMAGE_NAME## setenv image-name ##DEFAULT_IMAGE_NAME##
@ -23,12 +24,12 @@ done
if test "${BASEFILENAME}" = "0"; then if test "${BASEFILENAME}" = "0"; then
BASEFILENAME="${image-name}" BASEFILENAME="${image-name}"
fi fi
setenv INSTALL_LINUX_FILENAME ${BASEFILENAME}-##MACHINE##.boot.ubifs setenv INSTALL_LINUX_FILENAME ${BASEFILENAME}-##MACHINE##.boot.vfat
setenv INSTALL_RECOVERY_FILENAME ${BASEFILENAME}-##MACHINE##.recovery.ubifs setenv INSTALL_RECOVERY_FILENAME ${BASEFILENAME}-##MACHINE##.recovery.vfat
setenv INSTALL_ROOTFS_FILENAME ${BASEFILENAME}-##MACHINE##.ubifs setenv INSTALL_ROOTFS_FILENAME ${BASEFILENAME}-##MACHINE##.ext4
# Check for presence of firmware files on the SD card # Check for presence of firmware files on the SD card
FILES="${INSTALL_ATF_FILENAME} ${INSTALL_FIP_FILENAME} ${INSTALL_LINUX_FILENAME}" FILES="${INSTALL_ATF_FILENAME} ${INSTALL_METADATA_FILENAME} ${INSTALL_FIP_FILENAME} ${INSTALL_LINUX_FILENAME}"
if test "${dualboot}" != "yes"; then if test "${dualboot}" != "yes"; then
FILES="${FILES} ${INSTALL_RECOVERY_FILENAME}" FILES="${FILES} ${INSTALL_RECOVERY_FILENAME}"
fi fi
@ -46,8 +47,6 @@ if test ! -e mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; then
if test ! -e mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; then if test ! -e mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; then
echo "ERROR: Could not find file ${INSTALL_ROOTFS_FILENAME}"; echo "ERROR: Could not find file ${INSTALL_ROOTFS_FILENAME}";
install_abort=1; install_abort=1;
else
setenv rootfstype squashfs
fi fi
fi fi
if test "${install_abort}" = "1"; then if test "${install_abort}" = "1"; then
@ -61,13 +60,15 @@ echo "############################################################"
echo "# Linux firmware install from micro SD #" echo "# Linux firmware install from micro SD #"
echo "############################################################" echo "############################################################"
echo "" echo ""
echo " This process will erase your NAND and will install the following files" echo " This process will erase your eMMC and will install the following files"
echo " on the partitions of the NAND." echo " on the partitions of the eMMC."
echo "" echo ""
echo " PARTITION FILENAME" echo " PARTITION FILENAME"
echo " --------- --------" echo " --------- --------"
echo " fsbl1 ${INSTALL_ATF_FILENAME}" echo " boot1 ${INSTALL_ATF_FILENAME}"
echo " fsbl2 ${INSTALL_ATF_FILENAME}" echo " boot2 ${INSTALL_ATF_FILENAME}"
echo " metadata1 ${INSTALL_METADATA_FILENAME}"
echo " metadata2 ${INSTALL_METADATA_FILENAME}"
echo " fip-a ${INSTALL_FIP_FILENAME}" echo " fip-a ${INSTALL_FIP_FILENAME}"
echo " fip-b ${INSTALL_FIP_FILENAME}" echo " fip-b ${INSTALL_FIP_FILENAME}"
if test "${dualboot}" = "yes"; then if test "${dualboot}" = "yes"; then
@ -101,22 +102,44 @@ setenv forced_update 1
# the first reset. # the first reset.
setenv bootdelay 0 setenv bootdelay 0
# Update ATF and FIP images # Set target MMC device index to eMMC
setenv mmcdev 0
# Update ATF, METADATA and FIP images
echo "" echo ""
echo "" echo ""
echo ">> Installing ATF boot loader image ${INSTALL_ATF_FILENAME}" echo ">> Installing ATF boot loader image ${INSTALL_ATF_FILENAME}"
echo "" echo ""
echo "" echo ""
update fsbl1 mmc ${INSTALL_MMCDEV} ${INSTALL_ATF_FILENAME} update boot1 mmc ${INSTALL_MMCDEV} ${INSTALL_ATF_FILENAME}
if test $? -eq 1; then if test $? -eq 1; then
echo "[ERROR] Failed to update fsbl1!"; echo "[ERROR] Failed to update boot1!";
echo ""; echo "";
echo "Aborted."; echo "Aborted.";
exit; exit;
fi fi
update fsbl2 mmc ${INSTALL_MMCDEV} ${INSTALL_ATF_FILENAME} update boot2 mmc ${INSTALL_MMCDEV} ${INSTALL_ATF_FILENAME}
if test $? -eq 1; then if test $? -eq 1; then
echo "[ERROR] Failed to update fsbl2!"; echo "[ERROR] Failed to update boot2!";
echo "";
echo "Aborted.";
exit;
fi
echo ""
echo ""
echo ">> Installing METADATA boot loader image ${INSTALL_ATF_FILENAME}"
echo ""
echo ""
update metadata1 mmc ${INSTALL_MMCDEV} ${INSTALL_METADATA_FILENAME}
if test $? -eq 1; then
echo "[ERROR] Failed to update metadata1!";
echo "";
echo "Aborted.";
exit;
fi
update metadata2 mmc ${INSTALL_MMCDEV} ${INSTALL_METADATA_FILENAME}
if test $? -eq 1; then
echo "[ERROR] Failed to update metadata2!";
echo ""; echo "";
echo "Aborted."; echo "Aborted.";
exit; exit;
@ -141,39 +164,45 @@ if test $? -eq 1; then
exit; exit;
fi fi
# Check if uboot_config volume exists (U-Boot env)
ubi part UBI
ubi check uboot_config
if test $? -eq 1; then
# Create volumes layout (including U-Boot env)
run ubivolscript;
fi
# Set 'bootcmd' to the second part of the script that will # Set 'bootcmd' to the second part of the script that will
# - Reset environment to defaults # - Reset environment to defaults
# - Restore 'dualboot' if previously set # - Restore 'dualboot' if previously set
# - Run 'ubivolscript' script to re-partition the UBI partition and save the # - Save the environment
# environment # - Force on-the-fly updates to avoid possible verification errors
# - Partition the eMMC user data area for Linux
# - If Dual Boot # - If Dual Boot
# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b # - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b
# - Set bootlimit to 3 # - Set bootlimit to 3
# - If Normal Boot: # - If Normal Boot:
# - Update the system partitions: linux, recovery, rootfs # - Update the system partitions: linux, recovery, rootfs
# - Erase the 'update' partition
# - Configure recovery to wipe 'update' partition # - Configure recovery to wipe 'update' partition
# - Run 'recovery' and let the system boot after # - Run 'recovery' and let the system boot after
setenv bootcmd " setenv bootcmd "
env default -a; env default -a;
setenv dualboot ${dualboot}; setenv dualboot ${dualboot};
setenv rootfstype ${rootfstype};
setenv install_dualboot ${install_dualboot}; setenv install_dualboot ${install_dualboot};
run ubivolscript; saveenv;
setenv otf-update yes;
echo \"\";
echo \"\";
echo \">> Creating Linux partition table on the eMMC\";
echo \"\";
echo \"\";
run partition_mmc_linux;
if test \$? -eq 1; then
echo \"[ERROR] Failed to create Linux partition table!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
if test \"\$\{dualboot\}\" = yes; then if test \"\$\{dualboot\}\" = yes; then
echo \"\"; echo \"\";
echo \"\"; echo \"\";
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux_a!\"; echo \"[ERROR] Failed to update linux_a!\";
echo \"\"; echo \"\";
@ -186,7 +215,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux_b!\"; echo \"[ERROR] Failed to update linux_b!\";
echo \"\"; echo \"\";
@ -199,7 +228,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update rootfs_a partition!\"; echo \"[ERROR] Failed to update rootfs_a partition!\";
echo \"\"; echo \"\";
@ -212,7 +241,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update rootfs_b partition!\"; echo \"[ERROR] Failed to update rootfs_b partition!\";
echo \"\"; echo \"\";
@ -227,7 +256,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux!\"; echo \"[ERROR] Failed to update linux!\";
echo \"\"; echo \"\";
@ -239,7 +268,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME} ${force_erase}; update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update recovery partition!\"; echo \"[ERROR] Failed to update recovery partition!\";
echo \"\"; echo \"\";
@ -251,7 +280,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update rootfs partition!\"; echo \"[ERROR] Failed to update rootfs partition!\";
echo \"\"; echo \"\";
@ -262,6 +291,7 @@ setenv bootcmd "
setenv boot_recovery yes; setenv boot_recovery yes;
setenv recovery_command wipe_update; setenv recovery_command wipe_update;
fi; fi;
setenv otf-update;
saveenv; saveenv;
echo \"\"; echo \"\";
echo \"\"; echo \"\";

View File

@ -1,14 +1,15 @@
# #
# U-Boot script for installing Linux images created by Yocto from a USB stick # U-Boot script for installing Linux images created by Yocto from a USB stick
# into the NAND # into the eMMC
# #
# Reset temp variables # Reset temp variables
install_abort=0 install_abort=0
BASEFILENAME=0 BASEFILENAME=0
setenv INSTALL_ATF_FILENAME tf-a-##MACHINE##-${module_ram}-nand.stm32 setenv INSTALL_ATF_FILENAME tf-a-##MACHINE##-emmc.stm32
setenv INSTALL_FIP_FILENAME fip-##MACHINE##-${module_ram}-optee.bin setenv INSTALL_METADATA_FILENAME metadata-##MACHINE##.bin
setenv INSTALL_FIP_FILENAME fip-##MACHINE##-optee.bin
setenv INSTALL_USBDEV 0 setenv INSTALL_USBDEV 0
if test -z "${image-name}"; then if test -z "${image-name}"; then
@ -23,12 +24,12 @@ done
if test "${BASEFILENAME}" = "0"; then if test "${BASEFILENAME}" = "0"; then
BASEFILENAME="${image-name}" BASEFILENAME="${image-name}"
fi fi
setenv INSTALL_LINUX_FILENAME ${BASEFILENAME}-##MACHINE##.boot.ubifs setenv INSTALL_LINUX_FILENAME ${BASEFILENAME}-##MACHINE##.boot.vfat
setenv INSTALL_RECOVERY_FILENAME ${BASEFILENAME}-##MACHINE##.recovery.ubifs setenv INSTALL_RECOVERY_FILENAME ${BASEFILENAME}-##MACHINE##.recovery.vfat
setenv INSTALL_ROOTFS_FILENAME ${BASEFILENAME}-##MACHINE##.ubifs setenv INSTALL_ROOTFS_FILENAME ${BASEFILENAME}-##MACHINE##.ext4
# Check for presence of firmware files on the USB # Check for presence of firmware files on the USB
FILES="${INSTALL_ATF_FILENAME} ${INSTALL_FIP_FILENAME} ${INSTALL_LINUX_FILENAME}" FILES="${INSTALL_ATF_FILENAME} ${INSTALL_METADATA_FILENAME} ${INSTALL_FIP_FILENAME} ${INSTALL_LINUX_FILENAME}"
if test "${dualboot}" != "yes"; then if test "${dualboot}" != "yes"; then
FILES="${FILES} ${INSTALL_RECOVERY_FILENAME}" FILES="${FILES} ${INSTALL_RECOVERY_FILENAME}"
fi fi
@ -46,11 +47,7 @@ if test ! -e usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; then
if test ! -e usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; then if test ! -e usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; then
echo "ERROR: Could not find file ${INSTALL_ROOTFS_FILENAME}"; echo "ERROR: Could not find file ${INSTALL_ROOTFS_FILENAME}";
install_abort=1; install_abort=1;
else
setenv rootfstype squashfs
fi fi
else
setenv rootfstype
fi fi
if test "${install_abort}" = "1"; then if test "${install_abort}" = "1"; then
echo "To install a different image, set variable 'image-name', e.g.:" echo "To install a different image, set variable 'image-name', e.g.:"
@ -63,13 +60,15 @@ echo "############################################################"
echo "# Linux firmware install from USB #" echo "# Linux firmware install from USB #"
echo "############################################################" echo "############################################################"
echo "" echo ""
echo " This process will erase your NAND and will install the following files" echo " This process will erase your eMMC and will install the following files"
echo " on the partitions of the NAND." echo " on the partitions of the eMMC."
echo "" echo ""
echo " PARTITION FILENAME" echo " PARTITION FILENAME"
echo " --------- --------" echo " --------- --------"
echo " fsbl1 ${INSTALL_ATF_FILENAME}" echo " boot1 ${INSTALL_ATF_FILENAME}"
echo " fsbl2 ${INSTALL_ATF_FILENAME}" echo " boot2 ${INSTALL_ATF_FILENAME}"
echo " metadata1 ${INSTALL_METADATA_FILENAME}"
echo " metadata2 ${INSTALL_METADATA_FILENAME}"
echo " fip-a ${INSTALL_FIP_FILENAME}" echo " fip-a ${INSTALL_FIP_FILENAME}"
echo " fip-b ${INSTALL_FIP_FILENAME}" echo " fip-b ${INSTALL_FIP_FILENAME}"
if test "${dualboot}" = "yes"; then if test "${dualboot}" = "yes"; then
@ -103,22 +102,44 @@ setenv forced_update 1
# the first reset. # the first reset.
setenv bootdelay 0 setenv bootdelay 0
# Update ATF and FIP images # Set target MMC device index to eMMC
setenv mmcdev 0
# Update ATF, METADATA and FIP images
echo "" echo ""
echo "" echo ""
echo ">> Installing ATF boot loader image ${INSTALL_ATF_FILENAME}" echo ">> Installing ATF boot loader image ${INSTALL_ATF_FILENAME}"
echo "" echo ""
echo "" echo ""
update fsbl1 usb ${INSTALL_USBDEV} ${INSTALL_ATF_FILENAME} update boot1 usb ${INSTALL_USBDEV} ${INSTALL_ATF_FILENAME}
if test $? -eq 1; then if test $? -eq 1; then
echo "[ERROR] Failed to update fsbl1!"; echo "[ERROR] Failed to update boot1!";
echo ""; echo "";
echo "Aborted."; echo "Aborted.";
exit; exit;
fi fi
update fsbl2 usb ${INSTALL_USBDEV} ${INSTALL_ATF_FILENAME} update boot2 usb ${INSTALL_USBDEV} ${INSTALL_ATF_FILENAME}
if test $? -eq 1; then if test $? -eq 1; then
echo "[ERROR] Failed to update fsbl2!"; echo "[ERROR] Failed to update boot2!";
echo "";
echo "Aborted.";
exit;
fi
echo ""
echo ""
echo ">> Installing METADATA boot loader image ${INSTALL_ATF_FILENAME}"
echo ""
echo ""
update metadata1 usb ${INSTALL_USBDEV} ${INSTALL_METADATA_FILENAME}
if test $? -eq 1; then
echo "[ERROR] Failed to update metadata1!";
echo "";
echo "Aborted.";
exit;
fi
update metadata2 usb ${INSTALL_USBDEV} ${INSTALL_METADATA_FILENAME}
if test $? -eq 1; then
echo "[ERROR] Failed to update metadata2!";
echo ""; echo "";
echo "Aborted."; echo "Aborted.";
exit; exit;
@ -143,32 +164,38 @@ if test $? -eq 1; then
exit; exit;
fi fi
# Check if uboot_config volume exists (U-Boot env)
ubi part UBI
ubi check uboot_config
if test $? -eq 1; then
# Create volumes layout (including U-Boot env)
run ubivolscript;
fi
# Set 'bootcmd' to the second part of the script that will # Set 'bootcmd' to the second part of the script that will
# - Reset environment to defaults # - Reset environment to defaults
# - Restore 'dualboot' if previously set # - Restore 'dualboot' if previously set
# - Run 'ubivolscript' script to re-partition the UBI partition and save the # - Save the environment
# environment # - Force on-the-fly updates to avoid possible verification errors
# - Partition the eMMC user data area for Linux
# - If Dual Boot # - If Dual Boot
# - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b # - Update the system partitions: linux_a, linux_b, rootfs_a, rootfs_b
# - Set bootlimit to 3 # - Set bootlimit to 3
# - If Normal Boot: # - If Normal Boot:
# - Update the system partitions: linux, recovery, rootfs # - Update the system partitions: linux, recovery, rootfs
# - Erase the 'update' partition
# - Configure recovery to wipe 'update' partition # - Configure recovery to wipe 'update' partition
# - Run 'recovery' and let the system boot after # - Run 'recovery' and let the system boot after
setenv bootcmd " setenv bootcmd "
env default -a; env default -a;
setenv dualboot ${dualboot}; setenv dualboot ${dualboot};
setenv rootfstype ${rootfstype};
setenv install_dualboot ${install_dualboot}; setenv install_dualboot ${install_dualboot};
run ubivolscript; saveenv;
setenv otf-update yes;
echo \"\";
echo \"\";
echo \">> Creating Linux partition table on the eMMC\";
echo \"\";
echo \"\";
run partition_mmc_linux;
if test \$? -eq 1; then
echo \"[ERROR] Failed to create Linux partition table!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
usb start; usb start;
if test \"\$\{dualboot\}\" = yes; then if test \"\$\{dualboot\}\" = yes; then
echo \"\"; echo \"\";
@ -176,7 +203,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux_a!\"; echo \"[ERROR] Failed to update linux_a!\";
echo \"\"; echo \"\";
@ -189,7 +216,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux_b!\"; echo \"[ERROR] Failed to update linux_b!\";
echo \"\"; echo \"\";
@ -202,7 +229,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update rootfs_a partition!\"; echo \"[ERROR] Failed to update rootfs_a partition!\";
echo \"\"; echo \"\";
@ -215,7 +242,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update rootfs_b partition!\"; echo \"[ERROR] Failed to update rootfs_b partition!\";
echo \"\"; echo \"\";
@ -230,7 +257,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update linux!\"; echo \"[ERROR] Failed to update linux!\";
echo \"\"; echo \"\";
@ -242,7 +269,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME} ${force_erase}; update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update recovery partition!\"; echo \"[ERROR] Failed to update recovery partition!\";
echo \"\"; echo \"\";
@ -254,7 +281,7 @@ setenv bootcmd "
echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\";
echo \"\"; echo \"\";
echo \"\"; echo \"\";
update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME};
if test \$? -eq 1; then if test \$? -eq 1; then
echo \"[ERROR] Failed to update rootfs partition!\"; echo \"[ERROR] Failed to update rootfs partition!\";
echo \"\"; echo \"\";
@ -265,6 +292,7 @@ setenv bootcmd "
setenv boot_recovery yes; setenv boot_recovery yes;
setenv recovery_command wipe_update; setenv recovery_command wipe_update;
fi; fi;
setenv otf-update;
saveenv; saveenv;
echo \"\"; echo \"\";
echo \"\"; echo \"\";

View File

@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
#=============================================================================== #===============================================================================
# #
# Copyright (C) 2022-2024 by Digi International Inc. # Copyright (C) 2024 by Digi International Inc.
# All rights reserved. # All rights reserved.
# #
# This program is free software; you can redistribute it and/or modify it # This program is free software; you can redistribute it and/or modify it
@ -27,12 +27,6 @@ getenv()
uuu -v fb: ucmd printenv "${1}" | sed -ne "s,^${1}=,,g;T;p" uuu -v fb: ucmd printenv "${1}" | sed -ne "s,^${1}=,,g;T;p"
} }
check_cmd()
{
uuu -v fb: acmd ${1} > /dev/null 2> /dev/null
uuu -v fb: ucmd echo retval=\$? | sed -ne "s,^retval=,,g;T;p"
}
show_usage() show_usage()
{ {
echo "Usage: $0 [options]" echo "Usage: $0 [options]"
@ -59,19 +53,21 @@ show_usage()
# 1. partition # 1. partition
# 2. file # 2. file
# 3. timeout (in ms) # 3. timeout (in ms)
# Description:
# - downloads image to RAM
# - runs 'update' command from RAM
part_update() part_update()
{ {
echo "\033[36m" printf "\033[36m\n"
echo "=====================================================================================" printf "=====================================================================================\n"
echo "Updating '${1}' partition with file: ${2}" printf "Updating '%s' partition with file: %s\n" "${1}" "${2}"
echo "=====================================================================================" printf "=====================================================================================\n"
echo "\033[0m" printf "\033[0m\n"
uuu fb: download -f "${2}" if echo "${1}" | grep -qs "^boot[0-9]$"; then
uuu "fb[-t ${3}]:" ucmd update "${1}" ram \${fastboot_buffer} \${filesize} ${ERASE} uuu "fb[-t ${3}]:" flash "${1}" "${2}"
elif echo "${2}" | grep -qs "\.gz$"; then
uuu "fb[-t ${3}]:" flash -raw2sparse "${1}" "${2}/*"
else
uuu "fb[-t ${3}]:" flash -raw2sparse "${1}" "${2}"
fi
} }
clear clear
@ -84,7 +80,7 @@ echo "############################################################"
# -b, -d, -n (booleans) # -b, -d, -n (booleans)
# -f <fip-filename> # -f <fip-filename>
# -i <image-name> # -i <image-name>
while getopts 'a:bdf:hi:n' c while getopts 'a:bdf:hi:nt' c
do do
case $c in case $c in
a) INSTALL_ATF_FILENAME=${OPTARG} ;; a) INSTALL_ATF_FILENAME=${OPTARG} ;;
@ -107,35 +103,23 @@ if [ "${dualboot}" = "yes" ]; then
DUALBOOT=true; DUALBOOT=true;
fi fi
# Check if uboot_config volume exists (U-Boot env)
uuu "fb[-t 15000]:" ucmd ubi part UBI
check=$(check_cmd "ubi check uboot_config")
if [ "${check}" = "1" ]; then
RUNVOLS=true
fi
# Check module_ram variable exists
module_ram=$(getenv "module_ram")
if [ -z "${module_ram}" ]; then
module_ram="512MB" # Default variant
fi
# remove redirect
uuu fb: ucmd setenv stdout serial
echo "" echo ""
echo "Determining image files to use..." echo "Determining image files to use..."
# Determine ATF file to program # Determine ATF file to program
if [ -z "${INSTALL_ATF_FILENAME}" ]; then if [ -z "${INSTALL_ATF_FILENAME}" ]; then
INSTALL_ATF_FILENAME="tf-a-##MACHINE##-${module_ram}-nand.stm32##SIGNED_TFA##" INSTALL_ATF_FILENAME="tf-a-##MACHINE##-emmc.stm32##SIGNED_TFA##"
fi fi
INSTALL_METADATA_FILENAME="metadata-##MACHINE##.bin"
# Determine FIP file to program # Determine FIP file to program
if [ -z "${INSTALL_FIP_FILENAME}" ]; then if [ -z "${INSTALL_FIP_FILENAME}" ]; then
INSTALL_FIP_FILENAME="fip-##MACHINE##-${module_ram}-optee##SIGNED##.bin" INSTALL_FIP_FILENAME="fip-##MACHINE##-optee##SIGNED##.bin"
fi fi
# remove redirect
uuu fb: ucmd setenv stdout serial
# Determine linux, recovery, and rootfs image filenames to update # Determine linux, recovery, and rootfs image filenames to update
if [ -z "${IMAGE_NAME}" ]; then if [ -z "${IMAGE_NAME}" ]; then
IMAGE_NAME="##DEFAULT_IMAGE_NAME##" IMAGE_NAME="##DEFAULT_IMAGE_NAME##"
@ -149,34 +133,34 @@ done
if [ -z "${BASEFILENAME}" ]; then if [ -z "${BASEFILENAME}" ]; then
BASEFILENAME="${IMAGE_NAME}" BASEFILENAME="${IMAGE_NAME}"
fi fi
INSTALL_LINUX_FILENAME="${BASEFILENAME}-##MACHINE##.boot.ubifs" INSTALL_LINUX_FILENAME="${BASEFILENAME}-##MACHINE##.boot.vfat"
INSTALL_RECOVERY_FILENAME="${BASEFILENAME}-##MACHINE##.recovery.ubifs" INSTALL_RECOVERY_FILENAME="${BASEFILENAME}-##MACHINE##.recovery.vfat"
INSTALL_ROOTFS_FILENAME="${BASEFILENAME}-##MACHINE##.ubifs"
# Verify existence of files before starting the update # Verify existence of files before starting the update
FILES="${INSTALL_ATF_FILENAME} ${INSTALL_FIP_FILENAME} ${INSTALL_LINUX_FILENAME}" FILES="${INSTALL_ATF_FILENAME} ${INSTALL_METADATA_FILENAME} ${INSTALL_FIP_FILENAME} ${INSTALL_LINUX_FILENAME}"
if [ "${DUALBOOT}" != true ]; then if [ "${DUALBOOT}" != true ]; then
FILES="${FILES} ${INSTALL_RECOVERY_FILENAME}" FILES="${FILES} ${INSTALL_RECOVERY_FILENAME}"
fi fi
for f in ${FILES}; do for f in ${FILES}; do
if [ ! -f ${f} ]; then if [ ! -f "${f}" ]; then
echo "\033[31m[ERROR] Could not find file '${f}'\033[0m" printf "\033[31m[ERROR] Could not find file '%s'\033[0m\n" "${f}"
ABORT=true ABORT=true
fi fi
done; done;
# Verify what kind of rootfs is going to be programmed # Verify what kind of rootfs is going to be programmed
if [ ! -f ${INSTALL_ROOTFS_FILENAME} ]; then ROOTFS_FILENAME="${BASEFILENAME}-##MACHINE##.ext4"
echo "\033[31m[ERROR] Could not find file '${INSTALL_ROOTFS_FILENAME}'\033[0m" ROOTFS_FILENAME_GZ="${ROOTFS_FILENAME}.gz"
INSTALL_ROOTFS_FILENAME="${BASEFILENAME}-##MACHINE##.squashfs" ROOTFS_FILENAME_SQFS="${BASEFILENAME}-##MACHINE##.squashfs"
echo "\033[32m[INFO] Trying with file '${INSTALL_ROOTFS_FILENAME}'\033[0m" if [ -f "${ROOTFS_FILENAME_GZ}" ]; then
if [ -f "${INSTALL_ROOTFS_FILENAME}" ]; then INSTALL_ROOTFS_FILENAME="${ROOTFS_FILENAME_GZ}"
SQUASHFS=true elif [ -f "${ROOTFS_FILENAME}" ]; then
else INSTALL_ROOTFS_FILENAME="${ROOTFS_FILENAME}"
echo "\033[31m[ERROR] Could not find file '${INSTALL_ROOTFS_FILENAME}'\033[0m" elif [ -f "${ROOTFS_FILENAME_SQFS}" ]; then
ABORT=true INSTALL_ROOTFS_FILENAME="${ROOTFS_FILENAME_SQFS}"
fi else
printf "\033[31m[ERROR] Could not find any rootfs image\033[0m\n"
ABORT=true
fi fi
[ "${ABORT}" = true ] && exit 1 [ "${ABORT}" = true ] && exit 1
@ -197,28 +181,30 @@ if [ "${NOWAIT}" != true ]; then
printf " ====================\n" printf " ====================\n"
printf " = IMPORTANT! =\n" printf " = IMPORTANT! =\n"
printf " ====================\n" printf " ====================\n"
printf " This process will erase your NAND and will install the following files\n" printf " This process will erase your eMMC and will install the following files\n"
printf " on the partitions of the NAND.\n" printf " on the partitions of the eMMC.\n"
printf "\n" printf "\n"
printf " PARTITION\tFILENAME\n" printf " PARTITION\tFILENAME\n"
printf " ---------\t--------\n" printf " ---------\t--------\n"
printf " fsbl1\t${INSTALL_ATF_FILENAME}\n" printf " boot1\t%s\n" "${INSTALL_ATF_FILENAME}"
printf " fsbl2\t${INSTALL_ATF_FILENAME}\n" printf " boot2\t%s\n" "${INSTALL_ATF_FILENAME}"
printf " fip-a\t${INSTALL_FIP_FILENAME}\n" printf " metadata1\t%s\n" "${INSTALL_METADATA_FILENAME}"
printf " fip-b\t${INSTALL_FIP_FILENAME}\n" printf " metadata2\t%s\n" "${INSTALL_METADATA_FILENAME}"
printf " fip-a\t%s\n" "${INSTALL_FIP_FILENAME}"
printf " fip-b\t%s\n" "${INSTALL_FIP_FILENAME}"
if [ "${DUALBOOT}" = true ]; then if [ "${DUALBOOT}" = true ]; then
printf " ${LINUX_NAME}_a\t${INSTALL_LINUX_FILENAME}\n" printf " %s_a\t%s\n" "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}"
if [ "${INSTALL_DUALBOOT}" = true ]; then if [ "${INSTALL_DUALBOOT}" = true ]; then
printf " ${LINUX_NAME}_b\t${INSTALL_LINUX_FILENAME}\n" printf " %s_b\t%s\n" "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}"
fi fi
printf " ${ROOTFS_NAME}_a\t${INSTALL_ROOTFS_FILENAME}\n" printf " %s_a\t%s\n" "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}"
if [ "${INSTALL_DUALBOOT}" = true ]; then if [ "${INSTALL_DUALBOOT}" = true ]; then
printf " ${ROOTFS_NAME}_b\t${INSTALL_ROOTFS_FILENAME}\n" printf " %s_b\t%s\n" "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}"
fi fi
else else
printf " ${LINUX_NAME}\t${INSTALL_LINUX_FILENAME}\n" printf " %s\t%s\n" "${LINUX_NAME}" "${INSTALL_LINUX_FILENAME}"
printf " ${RECOVERY_NAME}\t${INSTALL_RECOVERY_FILENAME}\n" printf " %s\t%s\n" "${RECOVERY_NAME}" "${INSTALL_RECOVERY_FILENAME}"
printf " ${ROOTFS_NAME}\t${INSTALL_ROOTFS_FILENAME}\n" printf " %s\t%s\n" "${ROOTFS_NAME}" "${INSTALL_ROOTFS_FILENAME}"
fi fi
printf "\n" printf "\n"
printf " Press CTRL+C now if you wish to abort.\n" printf " Press CTRL+C now if you wish to abort.\n"
@ -226,32 +212,27 @@ if [ "${NOWAIT}" != true ]; then
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"
printf " Starting update process\n" printf " Starting update process\n"
fi fi
# Set fastboot buffer address to $loadaddr, just in case
uuu fb: ucmd setenv fastboot_buffer \${loadaddr}
# Skip user confirmation for U-Boot update # Skip user confirmation for U-Boot update
uuu fb: ucmd setenv forced_update 1 uuu fb: ucmd setenv forced_update 1
# Update ATF # Update ATF
part_update "fsbl1" "${INSTALL_ATF_FILENAME}" 5000 part_update "boot1" "${INSTALL_ATF_FILENAME}" 5000
part_update "fsbl2" "${INSTALL_ATF_FILENAME}" 5000 part_update "boot2" "${INSTALL_ATF_FILENAME}" 5000
# Update metadata
part_update "metadata1" "${INSTALL_METADATA_FILENAME}" 5000
part_update "metadata2" "${INSTALL_METADATA_FILENAME}" 5000
# Update FIP # Update FIP
part_update "fip-a" "${INSTALL_FIP_FILENAME}" 5000 part_update "fip-a" "${INSTALL_FIP_FILENAME}" 5000
part_update "fip-b" "${INSTALL_FIP_FILENAME}" 5000 part_update "fip-b" "${INSTALL_FIP_FILENAME}" 5000
# Environment volume does not exist and needs to be created
if [ "${RUNVOLS}" = true ]; then
# Create UBI volumes
uuu "fb[-t 45000]:" ucmd run ubivolscript
fi
# Set 'bootcmd' for the second part of the script that will # Set 'bootcmd' for the second part of the script that will
# - Reset environment to defaults # - Reset environment to defaults
# - Keep the 'dualboot' status # - Keep the 'dualboot' status
@ -266,12 +247,24 @@ uuu fb: ucmd setenv bootcmd "
bootcount reset; bootcount reset;
${bootlimit_cmd}; ${bootlimit_cmd};
saveenv; saveenv;
echo \"\";
echo \"\";
echo \">> Creating Linux partition table on the eMMC\";
echo \"\";
echo \"\";
run partition_mmc_linux;
if test \$? -eq 1; then
echo \"[ERROR] Failed to create Linux partition table!\";
echo \"\";
echo \"Aborted.\";
exit;
fi;
echo \"\";
echo \"\";
echo \">> Start installation Linux firmware files\";
echo \"\";
echo \"\";
saveenv; saveenv;
echo \"\";
echo \"\";
echo \">> Installing Linux firmware\";
echo \"\";
echo \"\";
fastboot 0; fastboot 0;
" "
@ -279,13 +272,11 @@ uuu fb: ucmd saveenv
uuu fb: acmd reset uuu fb: acmd reset
# Wait for the target to reset # Wait for the target to reset
sleep 8 sleep 3
# Set fastboot buffer address to $loadaddr # Restart fastboot with the latest MMC partition configuration
uuu fb: ucmd setenv fastboot_buffer \${loadaddr} uuu fb: ucmd setenv fastboot_dev sata
uuu fb: ucmd setenv fastboot_dev mmc
# Create UBI volumes
uuu "fb[-t 45000]:" ucmd run ubivolscript
if [ "${DUALBOOT}" = true ]; then if [ "${DUALBOOT}" = true ]; then
# Update Linux A # Update Linux A
@ -315,25 +306,20 @@ else
fi fi
# Set the dboot_kernel_var to fitimage if Trustfence is enabled # Set the dboot_kernel_var to fitimage if Trustfence is enabled
if [ "${TRUSTFENCE}" = "true" ] || echo "$INSTALL_UBOOT_FILENAME" | grep -q -e "signed"; then if [ "${TRUSTFENCE}" = "true" ] || echo "${INSTALL_UBOOT_FILENAME}" | grep -q -e "signed"; then
uuu fb: ucmd setenv dboot_kernel_var fitimage uuu fb: ucmd setenv dboot_kernel_var fitimage
uuu fb: ucmd saveenv uuu fb: ucmd saveenv
fi fi
# Set the rootfstype if squashfs
if [ "${SQUASHFS}" = true ]; then
uuu fb: ucmd setenv rootfstype squashfs
uuu fb: ucmd saveenv
fi
# Reset the bootcount # Reset the bootcount
uuu fb: ucmd bootcount reset uuu fb: acmd bootcount reset
# Reset the target # Reset the target
uuu fb: acmd reset uuu fb: acmd reset
echo "\033[32m" printf "\033[32m\n"
echo "=============================================================" printf "=============================================================\n"
echo "Done! Wait for the target to complete first boot process." printf "Done! Wait for the target to complete first boot process.\n"
echo "=============================================================" printf "=============================================================\n"
echo "\033[0m" printf "\033[0m\n"
exit exit