From 2ade93d8ebcde0b882a7adfe5573f6bc1294c187 Mon Sep 17 00:00:00 2001 From: Hector Palacios Date: Wed, 30 Sep 2020 18:52:49 +0200 Subject: [PATCH] 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 --- .../u-boot/u-boot-dey/ccimx6qpsbc/boot.txt | 11 +++++++++++ .../u-boot/u-boot-dey/ccimx6sbc/boot.txt | 11 +++++++++++ .../u-boot/u-boot-dey/ccimx6ulsbc/boot.txt | 11 +++++++++++ .../u-boot/u-boot-dey/ccimx6ulstarter/boot.txt | 11 +++++++++++ .../u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt | 14 ++++++++++++++ .../recipes-bsp/u-boot/u-boot-dey/ccimx8x/boot.txt | 14 ++++++++++++++ 6 files changed, 72 insertions(+) diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt index 0af8ee3f9..67f84c604 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6qpsbc/boot.txt @@ -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 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt index 95f55ff61..d68c1bfee 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6sbc/boot.txt @@ -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 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt index 09e5b0ec1..00762b19a 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulsbc/boot.txt @@ -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 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt index 37758ec4f..daf3d707f 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx6ulstarter/boot.txt @@ -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 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt index c85d093c1..b49f6a4df 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8mn-dvk/boot.txt @@ -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 diff --git a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/boot.txt b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/boot.txt index f0fbb1a0e..875d874de 100644 --- a/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/boot.txt +++ b/meta-digi-arm/recipes-bsp/u-boot/u-boot-dey/ccimx8x/boot.txt @@ -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