From f3ae964d10ac0872b26c0fb4ed383fd883c94197 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Tue, 28 Sep 2021 12:08:53 +0200 Subject: [PATCH] uboot: cc6ul: force erase of partitions before update on install scripts Install scripts may rework the partition table basing on the value of env variables. Information of UBI volumes may remain on the NAND that could later not correspond to the new partition table. Make sure the MTD partitions are erased prior to updating: - For Multi-MTD, append '-e' option to the update command. - For Single-MTD, erase the system partition. Signed-off-by: Hector Palacios --- .../ccimx6ul/install_linux_fw_sd.txt | 37 +++++-------------- .../ccimx6ul/install_linux_fw_usb.txt | 37 +++++-------------- .../ccimx6ul/install_linux_fw_uuu.sh | 11 +++++- 3 files changed, 28 insertions(+), 57 deletions(-) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt index e3fa6bad2..9a8494f19 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_sd.txt @@ -146,6 +146,8 @@ setenv bootcmd " saveenv; if test \"\$\{ubisysvols\}\" = yes; then run ubivolscript; + else + force_erase="-e" fi; if test \"\$\{dualboot\}\" = yes; then echo \"\"; @@ -153,10 +155,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux_a; - fi; - update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + update linux_a mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux_a!\"; echo \"\"; @@ -168,10 +167,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux_b; - fi; - update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + update linux_b mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux_b!\"; echo \"\"; @@ -183,10 +179,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs_a; - fi; - update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs_a mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs_a partition!\"; echo \"\"; @@ -198,10 +191,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs_b; - fi; - update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs_b mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs_b partition!\"; echo \"\"; @@ -214,10 +204,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux; - fi; - update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME}; + update linux mmc ${INSTALL_MMCDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux!\"; echo \"\"; @@ -229,10 +216,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part recovery; - fi; - update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME}; + update recovery mmc ${INSTALL_MMCDEV} ${INSTALL_RECOVERY_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; @@ -244,10 +228,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs; - fi; - update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs mmc ${INSTALL_MMCDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs partition!\"; echo \"\"; diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt index e9e7f4e91..7c7cf8c14 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ul/install_linux_fw_usb.txt @@ -146,6 +146,8 @@ setenv bootcmd " saveenv; if test \"\$\{ubisysvols\}\" = yes; then run ubivolscript; + else + force_erase="-e" fi; usb start; if test \"\$\{dualboot\}\" = yes; then @@ -154,10 +156,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_a\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux_a; - fi; - update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + update linux_a usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux_a!\"; echo \"\"; @@ -169,10 +168,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux_b\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux_b; - fi; - update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + update linux_b usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux_b!\"; echo \"\"; @@ -184,10 +180,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_a\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs_a; - fi; - update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs_a usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs_a partition!\"; echo \"\"; @@ -199,10 +192,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs_b\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs_b; - fi; - update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs_b usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs_b partition!\"; echo \"\"; @@ -215,10 +205,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_LINUX_FILENAME} on linux\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part linux; - fi; - update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME}; + update linux usb ${INSTALL_USBDEV} ${INSTALL_LINUX_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update linux!\"; echo \"\"; @@ -230,10 +217,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_RECOVERY_FILENAME} on recovery\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part recovery; - fi; - update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME}; + update recovery usb ${INSTALL_USBDEV} ${INSTALL_RECOVERY_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update recovery partition!\"; echo \"\"; @@ -245,10 +229,7 @@ setenv bootcmd " echo \">> Installing file ${INSTALL_ROOTFS_FILENAME} on rootfs\"; echo \"\"; echo \"\"; - if test ! -n \$\{ubisysvols\} || test \"\$\{ubisysvols\}\" = no; then - nand erase.part rootfs; - fi; - update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME}; + update rootfs usb ${INSTALL_USBDEV} ${INSTALL_ROOTFS_FILENAME} ${force_erase}; if test \$? -eq 1; then echo \"[ERROR] Failed to update rootfs partition!\"; echo \"\"; 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 01b626663..ae286effe 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 @@ -58,8 +58,16 @@ part_update() echo "=====================================================================================" echo "\033[0m" + # When in Multi-MTD mode, pass -e to update command to force the erase + # of the MTD partition before programming. This is usually done by + # 'update' command except when a UBI volume is already found. + # On the install script, the MTD partition table may have changed, so + # we'd better clean the partition. + if [ "${UBISYSVOLS}" != true ]; then + ERASE="-e" + fi uuu fb: download -f "${2}" - uuu "fb[-t ${3}]:" ucmd update "${1}" ram \${fastboot_buffer} \${fastboot_bytes} + uuu "fb[-t ${3}]:" ucmd update "${1}" ram \${fastboot_buffer} \${fastboot_bytes} ${ERASE} } clear @@ -259,6 +267,7 @@ uuu "fb[-t 10000]:" ucmd run partition_nand_linux if [ "${UBISYSVOLS}" = true ]; then uuu "fb[-t 10000]:" ucmd run ubivolscript + nand erase.part system fi if [ "${DUALBOOT}" = true ]; then