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 <hector.palacios@digi.com>
This commit is contained in:
Hector Palacios 2021-09-28 12:08:53 +02:00
parent f647e6d442
commit f3ae964d10
3 changed files with 28 additions and 57 deletions

View File

@ -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 \"\";

View File

@ -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 \"\";

View File

@ -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