u-boot-dey: restore modified env vars in case of error on bootscript

The boot script appends values to certain variables such as
$extra_bootargs and $overlays.

If the final instruction of the boot script (dboot command)
fails, these variables contain the new values, plus the original
one. Since the user recovers the prompt, he may do a 'saveenv'
to save the environment, and the modified variables will be
saved, only to be enlarged again on the next boot.
This can lead to repeated strings on such variables.

Save the original value and restore it in case of failure on
the dboot command.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
This commit is contained in:
Hector Palacios 2020-09-30 18:52:49 +02:00
parent 23b7815c17
commit 2ade93d8eb
6 changed files with 72 additions and 0 deletions

View File

@ -2,6 +2,9 @@
# U-Boot bootscript for EMMC/SD images created by Yocto.
#
# Back up environment variables
setenv ORIG_extra_bootargs ${extra_bootargs}
#
# Set device tree filename depending on the board ID (if defined)
#
@ -34,3 +37,11 @@ else
fi
setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs}
dboot linux mmc ${mmcbootdev}:${mmcpart}
# We only get here in case of an error on the dboot command.
# Undo changes to environment variables
setenv extra_bootargs ${ORIG_extra_bootargs}
setenv ORIG_extra_bootargs

View File

@ -2,6 +2,9 @@
# U-Boot bootscript for EMMC/SD images created by Yocto.
#
# Back up environment variables
setenv ORIG_extra_bootargs ${extra_bootargs}
#
# Set device tree filename depending on the board ID (if defined)
#
@ -64,3 +67,11 @@ else
fi
setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs}
dboot linux mmc ${mmcbootdev}:${mmcpart}
# We only get here in case of an error on the dboot command.
# Undo changes to environment variables
setenv extra_bootargs ${ORIG_extra_bootargs}
setenv ORIG_extra_bootargs

View File

@ -2,6 +2,9 @@
# U-Boot bootscript for NAND images created by Yocto.
#
# Back up environment variables
setenv ORIG_extra_bootargs ${extra_bootargs}
#
# Set device tree filename depending on the board ID (if defined)
#
@ -28,3 +31,11 @@ else
fi
setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs}
dboot linux nand ${mtdbootpart}
# We only get here in case of an error on the dboot command.
# Undo changes to environment variables
setenv extra_bootargs ${ORIG_extra_bootargs}
setenv ORIG_extra_bootargs

View File

@ -2,6 +2,9 @@
# U-Boot bootscript for NAND images created by Yocto.
#
# Back up environment variables
setenv ORIG_extra_bootargs ${extra_bootargs}
#
# Set device tree filename depending on the board ID (if defined)
#
@ -28,3 +31,11 @@ else
fi
setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs}
dboot linux nand ${mtdbootpart}
# We only get here in case of an error on the dboot command.
# Undo changes to environment variables
setenv extra_bootargs ${ORIG_extra_bootargs}
setenv ORIG_extra_bootargs

View File

@ -2,6 +2,10 @@
# U-Boot bootscript for EMMC/SD images created by Yocto.
#
# Back up environment variables
setenv ORIG_overlays ${overlays}
setenv ORIG_extra_bootargs ${extra_bootargs}
# Set SOC type to "imx8mn" if not already defined by U-Boot
if test ! -n "${soc_type}"; then
setenv soc_type "imx8mn"
@ -54,3 +58,13 @@ else
fi
setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs}
dboot linux mmc ${mmcbootdev}:${mmcpart}
# We only get here in case of an error on the dboot command.
# Undo changes to environment variables
setenv overlays ${ORIG_overlays}
setenv ORIG_overlays
setenv extra_bootargs ${ORIG_extra_bootargs}
setenv ORIG_extra_bootargs

View File

@ -2,6 +2,10 @@
# U-Boot bootscript for EMMC/SD images created by Yocto.
#
# Back up environment variables
setenv ORIG_overlays ${overlays}
setenv ORIG_extra_bootargs ${extra_bootargs}
# Set SOC type to "imx8qxp" if not already defined by U-Boot
if test ! -n "${soc_type}"; then
setenv soc_type "imx8qxp"
@ -57,3 +61,13 @@ else
fi
setenv extra_bootargs fbcon=logo-pos:center ${extra_bootargs}
dboot linux mmc ${mmcbootdev}:${mmcpart}
# We only get here in case of an error on the dboot command.
# Undo changes to environment variables
setenv overlays ${ORIG_overlays}
setenv ORIG_overlays
setenv extra_bootargs ${ORIG_extra_bootargs}
setenv ORIG_extra_bootargs