Patchwork [U-Boot] omap3_beagle: enable the use of a plain text file named uEnv.txt instead of boot.scr

login
register
mail settings
Submitter Alexander Holler
Date Jan. 24, 2011, 11:08 p.m.
Message ID <1295910529-27454-1-git-send-email-holler@ahsoftware.de>
Download mbox | patch
Permalink /patch/80286/
State Superseded
Delegated to: Sandeep Paulraj
Headers show

Comments

Alexander Holler - Jan. 24, 2011, 11:08 p.m.
Using the new env import command it is possible to use plain text files instead
of script-images. Plain text files are much easier to handle.

E.g. If your boot.scr contains the following:
-----------------------------------
setenv dvimode 1024x768-16@60
run loaduimage
run mmcboot
-----------------------------------
you could create a file named uEnv.txt and use that instead of boot.scr:
-----------------------------------
dvimode=1024x768-16@60
uenvcmd=run loaduimage; run mmcboot
-----------------------------------
The variable uenvcmd (if existent) will be executed (using run) after uEnv.txt
was loaded. If uenvcmd doesn't exist the default boot sequence will be started,
therefore you could just use
-----------------------------------
dvimode=1024x768-16@60
-----------------------------------
as uEnv.txt because loaduimage and mmcboot is part of the default boot sequence.

For backwards compatibility the use of boot.scr is still supported.

Signed-off-by: Alexander Holler <holler@ahsoftware.de>
---
 include/configs/omap3_beagle.h |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)
Jason Kridner - Feb. 4, 2011, 5:41 p.m.
On Mon, Jan 24, 2011 at 6:08 PM, Alexander Holler <holler@ahsoftware.de> wrote:
> Using the new env import command it is possible to use plain text files instead
> of script-images. Plain text files are much easier to handle.

I agree this has been a frequent concern of BeagleBoard users.  I
would like to see this patch get accepted.

>
> E.g. If your boot.scr contains the following:
> -----------------------------------
> setenv dvimode 1024x768-16@60
> run loaduimage
> run mmcboot
> -----------------------------------
> you could create a file named uEnv.txt and use that instead of boot.scr:
> -----------------------------------
> dvimode=1024x768-16@60
> uenvcmd=run loaduimage; run mmcboot
> -----------------------------------
> The variable uenvcmd (if existent) will be executed (using run) after uEnv.txt
> was loaded. If uenvcmd doesn't exist the default boot sequence will be started,
> therefore you could just use
> -----------------------------------
> dvimode=1024x768-16@60
> -----------------------------------
> as uEnv.txt because loaduimage and mmcboot is part of the default boot sequence.
>
> For backwards compatibility the use of boot.scr is still supported.
>
> Signed-off-by: Alexander Holler <holler@ahsoftware.de>
> ---
>  include/configs/omap3_beagle.h |   25 ++++++++++++++++++++-----
>  1 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
> index 5cfa4cb..0214c7f 100644
> --- a/include/configs/omap3_beagle.h
> +++ b/include/configs/omap3_beagle.h
> @@ -218,6 +218,9 @@
>        "loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr\0" \
>        "bootscript=echo Running bootscript from mmc ...; " \
>                "source ${loadaddr}\0" \
> +       "loadbootenv=fatload mmc ${mmcdev} ${loadaddr} uEnv.txt\0" \
> +       "importbootenv=echo Importing environment from mmc ...; " \
> +               "env import -t $loadaddr $filesize\0" \
>        "loaduimage=fatload mmc ${mmcdev} ${loadaddr} uImage\0" \
>        "mmcboot=echo Booting from mmc ...; " \
>                "run mmcargs; " \
> @@ -229,12 +232,24 @@
>
>  #define CONFIG_BOOTCOMMAND \
>        "if mmc rescan ${mmcdev}; then " \
> -               "if run loadbootscript; then " \
> -                       "run bootscript; " \
> +               "if run loadbootenv; then " \
> +                       "run importbootenv;" \
> +                       "if test -n $uenvcmd; then " \
> +                               "echo Running uenvcmd ...;run uenvcmd;" \
> +                       "else " \

I believe the code would be cleaner without this else clause.  You
could simply put the test for the boot environment variable loaded out
of uEnv.txt ahead of the test for loading boot.scr.  The running of
uenvcmd should prevent any other boot operations from occurring if it
succeeds, so you can leave out the else entirely and just close the if
statement.  I think the end result is the same, but the code would be
more readable, less nested, and each edit wouldn't impact the rest of
the bootcmd.  I made a patch that did this, but I have some
dependencies on commands that I haven't yet got accepted.[1]

[1] http://gitorious.org/beagleboard-validation/u-boot/blobs/dcbcbcded81e92a30081663371e2bd458ecccaba/include/configs/omap3_beagle.h

> +                               "if run loaduimage; then " \
> +                                       "run mmcboot; " \
> +                               "else run nandboot; " \
> +                               "fi; " \
> +                       "fi; " \
>                "else " \
> -                       "if run loaduimage; then " \
> -                               "run mmcboot; " \
> -                       "else run nandboot; " \
> +                       "if run loadbootscript; then " \
> +                               "run bootscript; " \
> +                       "else " \
> +                               "if run loaduimage; then " \
> +                                       "run mmcboot; " \
> +                               "else run nandboot; " \
> +                               "fi; " \
>                        "fi; " \
>                "fi; " \
>        "else run nandboot; fi"
> --
> 1.7.2.2
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>

Patch

diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index 5cfa4cb..0214c7f 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -218,6 +218,9 @@ 
 	"loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr\0" \
 	"bootscript=echo Running bootscript from mmc ...; " \
 		"source ${loadaddr}\0" \
+	"loadbootenv=fatload mmc ${mmcdev} ${loadaddr} uEnv.txt\0" \
+	"importbootenv=echo Importing environment from mmc ...; " \
+		"env import -t $loadaddr $filesize\0" \
 	"loaduimage=fatload mmc ${mmcdev} ${loadaddr} uImage\0" \
 	"mmcboot=echo Booting from mmc ...; " \
 		"run mmcargs; " \
@@ -229,12 +232,24 @@ 
 
 #define CONFIG_BOOTCOMMAND \
 	"if mmc rescan ${mmcdev}; then " \
-		"if run loadbootscript; then " \
-			"run bootscript; " \
+		"if run loadbootenv; then " \
+			"run importbootenv;" \
+			"if test -n $uenvcmd; then " \
+				"echo Running uenvcmd ...;run uenvcmd;" \
+			"else " \
+				"if run loaduimage; then " \
+					"run mmcboot; " \
+				"else run nandboot; " \
+				"fi; " \
+			"fi; " \
 		"else " \
-			"if run loaduimage; then " \
-				"run mmcboot; " \
-			"else run nandboot; " \
+			"if run loadbootscript; then " \
+				"run bootscript; " \
+			"else " \
+				"if run loaduimage; then " \
+					"run mmcboot; " \
+				"else run nandboot; " \
+				"fi; " \
 			"fi; " \
 		"fi; " \
 	"else run nandboot; fi"