From 2cf902f8d72a5e0096c93877fabf8ea21b5d42cd Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 15 Nov 2022 11:51:50 +0100 Subject: [PATCH] installer scripts: cover case where U-Boot env does not exist The U-Boot environment resides on a UBI volume. The uuu script relies on the environment to save part of the commands that U-Boot needs to execute after reboot in the middle of the installation. If the UBI volume 'uboot_config' does not exist the installer fails. This commit: - Creates a function -on the uuu script only- for obtaining the result of running any U-Boot command (0=success, 1=error). - Checks the existance of 'uboot_config' volume. - Runs 'ubivolscript' script to create the UBI volumes layout that generates the environment volume if it doesn't exist. - Increases the timeout for running the 'ubivolscript' since there are occasions in which 'ubi part' (which is part of the script) takes more time (if it cannot find the fastmap). Signed-off-by: Hector Palacios --- .../u-boot-dey/ccmp1/install_linux_fw_sd.txt | 8 ++++++++ .../u-boot-dey/ccmp1/install_linux_fw_usb.txt | 8 ++++++++ .../u-boot-dey/ccmp1/install_linux_fw_uuu.sh | 20 ++++++++++++++++++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_sd.txt index cda1d1379..d0dbb8d78 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_sd.txt @@ -119,6 +119,14 @@ if test $? -eq 1; then exit; 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 # - Reset environment to defaults # - Restore 'dualboot' if previously set diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_usb.txt index fc1b2a7f4..6831b34a7 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_usb.txt @@ -119,6 +119,14 @@ if test $? -eq 1; then exit; 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 # - Reset environment to defaults # - Restore 'dualboot' if previously set diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_uuu.sh b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_uuu.sh index ddecd9152..46c9d6dd4 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_uuu.sh +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccmp1/install_linux_fw_uuu.sh @@ -27,6 +27,12 @@ getenv() 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() { echo "Usage: $0 [options]" @@ -93,6 +99,13 @@ if [ "${dualboot}" = "yes" ]; then DUALBOOT=true; 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 + # remove redirect uuu fb: ucmd setenv stdout serial @@ -193,6 +206,11 @@ part_update "fsbl2" "${INSTALL_ATF_FILENAME}" 5000 part_update "fip-a" "${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 # - Reset environment to defaults @@ -223,7 +241,7 @@ sleep 8 uuu fb: ucmd setenv fastboot_buffer \${loadaddr} # Create UBI volumes -uuu "fb[-t 20000]:" ucmd run ubivolscript +uuu "fb[-t 45000]:" ucmd run ubivolscript if [ "${DUALBOOT}" = true ]; then # Update Linux A