Patchwork [U-Boot] ARM: vexpress: Extend default boot sequence to load script from MMC

login
register
mail settings
Submitter Jon Medhurst (Tixy)
Date Nov. 29, 2011, 1:46 p.m.
Message ID <1322574376.4500.34.camel@linaro1>
Download mbox | patch
Permalink /patch/128289/
State Changes Requested
Delegated to: Tom Rini
Headers show

Comments

Jon Medhurst (Tixy) - Nov. 29, 2011, 1:46 p.m.
Extend the default boot sequence on Versatile Express to load a boot
script from MMC.

Signed-off-by: Jon Medhurst <jon.medhurst@linaro.org>

---
 include/configs/vexpress_common.h |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
Ryan Harkin - Nov. 29, 2011, 4:04 p.m.
On Tue, 2011-11-29 at 13:46 +0000, Jon Medhurst (Tixy) wrote:
> Extend the default boot sequence on Versatile Express to load a boot
> script from MMC.
> 
> Signed-off-by: Jon Medhurst <jon.medhurst@linaro.org>

Acked-by: Ryan Harkin <ryan.harkin@linaro.org>

> 
> ---
>  include/configs/vexpress_common.h |   20 ++++++++++++++++++--
>  1 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/include/configs/vexpress_common.h b/include/configs/vexpress_common.h
> index a4ae5a8..d56f19d 100644
> --- a/include/configs/vexpress_common.h
> +++ b/include/configs/vexpress_common.h
> @@ -178,6 +178,8 @@
>  #define CONFIG_CMD_SAVEENV
>  #define CONFIG_NET_MULTI
>  #define CONFIG_CMD_RUN
> +#define CONFIG_CMD_BOOTD
> +#define CONFIG_CMD_ECHO
>  
>  #define CONFIG_CMD_FAT
>  #define CONFIG_DOS_PARTITION		1
> @@ -226,7 +228,14 @@
>  #define CONFIG_SYS_INIT_SP_ADDR		CONFIG_SYS_GBL_DATA_OFFSET
>  
>  /* Basic environment settings */
> -#define CONFIG_BOOTCOMMAND		"run bootflash;"
> +#define CONFIG_BOOTCOMMAND \
> +	"if mmc rescan ${mmcdev}; then " \
> +		"if run loadbootscript; then " \
> +			"run bootscript; " \
> +		"fi; " \
> +	"fi; " \
> +	"run bootflash;"
> +
>  #ifdef CONFIG_VEXPRESS_ORIGINAL_MEMORY_MAP
>  #define CONFIG_PLATFORM_ENV_SETTINGS \
>  		"loadaddr=0x80008000\0" \
> @@ -258,7 +267,12 @@
>  			"devtmpfs.mount=0  vmalloc=256M\0" \
>  		"bootflash=run flashargs; " \
>  			"cp ${ramdisk_addr} ${ramdisk_addr_r} ${maxramdisk}; " \
> -			"bootm ${kernel_addr} ${ramdisk_addr_r}\0"
> +			"bootm ${kernel_addr} ${ramdisk_addr_r}\0" \
> +		"mmcdev=0\0" \
> +		"bootscr=boot.scr\0" \
> +		"loadbootscript=fatload mmc ${mmcdev} ${loadaddr} ${bootscr}\0" \
> +		"bootscript=echo Running bootscript from mmc ...; " \
> +			"source ${loadaddr}\0"
>  
>  /* FLASH and environment organization */
>  #define PHYS_FLASH_SIZE			0x04000000	/* 64MB */
> @@ -305,6 +319,8 @@
>  #define CONFIG_SYS_PROMPT		"VExpress# "
>  #define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + \
>  					sizeof(CONFIG_SYS_PROMPT) + 16)
> +#define CONFIG_SYS_HUSH_PARSER
> +#define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
>  #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE /* Boot args buffer */
>  #define CONFIG_CMD_SOURCE
>  #define CONFIG_SYS_LONGHELP
Tom Rini - Nov. 29, 2011, 8:46 p.m.
On Tue, Nov 29, 2011 at 6:46 AM, Jon Medhurst (Tixy)
<jon.medhurst@linaro.org> wrote:
> Extend the default boot sequence on Versatile Express to load a boot
> script from MMC.
>
> Signed-off-by: Jon Medhurst <jon.medhurst@linaro.org>

Is there any interest in defining a common 'fancy' boot command?  Over
on beagleboard (and a few other eval boards) we are (or will be)
doing, roughly:
Is there mmc? {
  Can we load a bootscript? {
    load it, do it
  }
  Can we load uEnv.txt? {
    Did it set 'uenvcmd'? {
      Run it
    }
  }
  Did we load the kernel? {
    bootm it
  }
}
Try nand.

And it's not hard to replace NAND with "whatever flash the board sets"
Jon Medhurst (Tixy) - Nov. 30, 2011, 8:32 a.m.
On Tue, 2011-11-29 at 13:46 -0700, Tom Rini wrote:
> On Tue, Nov 29, 2011 at 6:46 AM, Jon Medhurst (Tixy)
> <jon.medhurst@linaro.org> wrote:
> > Extend the default boot sequence on Versatile Express to load a boot
> > script from MMC.
> >
> > Signed-off-by: Jon Medhurst <jon.medhurst@linaro.org>
> 
> Is there any interest in defining a common 'fancy' boot command?  Over
> on beagleboard (and a few other eval boards) we are (or will be)
> doing, roughly:
> Is there mmc? {
>   Can we load a bootscript? {
>     load it, do it
>   }
>   Can we load uEnv.txt? {
>     Did it set 'uenvcmd'? {
>       Run it
>     }
>   }
>   Did we load the kernel? {
>     bootm it
>   }
> }
> Try nand.
> 
> And it's not hard to replace NAND with "whatever flash the board sets"

It could make sense. However, the combinations of boot methods could get
quite big, e.g. do we include pxeboot, tftp?

If everything was included in the common 'fancy boot' then some boards
would have to define boot methods (or stubs) for things they weren't
interested in. And, conversely, if fancy boot didn't include everything,
then other people would need to extend it. 

I came across this issue with my patch. I wanted to look for a common
pattern to copy for my boot command. I was tempted by those which
included other options but then realised we didn't currently have a use
for them, and if I added them there would be more testing and
maintenance required.

So perhaps the number of boards interested in the common function would
be very small?
Tom Rini - Nov. 30, 2011, 2:51 p.m.
On Wed, Nov 30, 2011 at 1:32 AM, Jon Medhurst (Tixy)
<jon.medhurst@linaro.org> wrote:
> On Tue, 2011-11-29 at 13:46 -0700, Tom Rini wrote:
>> On Tue, Nov 29, 2011 at 6:46 AM, Jon Medhurst (Tixy)
>> <jon.medhurst@linaro.org> wrote:
>> > Extend the default boot sequence on Versatile Express to load a boot
>> > script from MMC.
>> >
>> > Signed-off-by: Jon Medhurst <jon.medhurst@linaro.org>
>>
>> Is there any interest in defining a common 'fancy' boot command?  Over
>> on beagleboard (and a few other eval boards) we are (or will be)
>> doing, roughly:
>> Is there mmc? {
>>   Can we load a bootscript? {
>>     load it, do it
>>   }
>>   Can we load uEnv.txt? {
>>     Did it set 'uenvcmd'? {
>>       Run it
>>     }
>>   }
>>   Did we load the kernel? {
>>     bootm it
>>   }
>> }
>> Try nand.
>>
>> And it's not hard to replace NAND with "whatever flash the board sets"
>
> It could make sense. However, the combinations of boot methods could get
> quite big, e.g. do we include pxeboot, tftp?

Well, maybe we define some blocks (TRY_MMC, TRY_ENET, TRY_NAND,
TRY_SPI, ...) ...

> If everything was included in the common 'fancy boot' then some boards
> would have to define boot methods (or stubs) for things they weren't
> interested in. And, conversely, if fancy boot didn't include everything,
> then other people would need to extend it.

... provide a few examples of the blocks strung together and have
people string up what they need themselves, so long as it's an
otherwise good idea to have complex default boot methods?
Jon Medhurst (Tixy) - Nov. 30, 2011, 3:19 p.m.
On Wed, 2011-11-30 at 07:51 -0700, Tom Rini wrote:
> On Wed, Nov 30, 2011 at 1:32 AM, Jon Medhurst (Tixy)
> <jon.medhurst@linaro.org> wrote:
> > On Tue, 2011-11-29 at 13:46 -0700, Tom Rini wrote:
> >> On Tue, Nov 29, 2011 at 6:46 AM, Jon Medhurst (Tixy)
> >> <jon.medhurst@linaro.org> wrote:
> >> > Extend the default boot sequence on Versatile Express to load a boot
> >> > script from MMC.
> >> >
> >> > Signed-off-by: Jon Medhurst <jon.medhurst@linaro.org>
> >>
> >> Is there any interest in defining a common 'fancy' boot command?  Over
> >> on beagleboard (and a few other eval boards) we are (or will be)
> >> doing, roughly:
> >> Is there mmc? {
> >>   Can we load a bootscript? {
> >>     load it, do it
> >>   }
> >>   Can we load uEnv.txt? {
> >>     Did it set 'uenvcmd'? {
> >>       Run it
> >>     }
> >>   }
> >>   Did we load the kernel? {
> >>     bootm it
> >>   }
> >> }
> >> Try nand.
> >>
> >> And it's not hard to replace NAND with "whatever flash the board sets"
> >
> > It could make sense. However, the combinations of boot methods could get
> > quite big, e.g. do we include pxeboot, tftp?
> 
> Well, maybe we define some blocks (TRY_MMC, TRY_ENET, TRY_NAND,
> TRY_SPI, ...) ...
> 
> > If everything was included in the common 'fancy boot' then some boards
> > would have to define boot methods (or stubs) for things they weren't
> > interested in. And, conversely, if fancy boot didn't include everything,
> > then other people would need to extend it.
> 
> ... provide a few examples of the blocks strung together and have
> people string up what they need themselves, so long as it's an
> otherwise good idea to have complex default boot methods?

If something like this was planned for BeagleBoard anyway, then perhaps
it could written in terms of these TRY_MMC etc. macros (which seem like
a reasonable idea to me). Then a working prototype could be posted as an
RFC for others to comment on? I suspect at the moment there's not many
people reading this 'vexpress' thread ;-)
Tom Rini - Nov. 30, 2011, 3:46 p.m.
On Wed, Nov 30, 2011 at 8:19 AM, Jon Medhurst (Tixy)
<jon.medhurst@linaro.org> wrote:
> On Wed, 2011-11-30 at 07:51 -0700, Tom Rini wrote:
>> On Wed, Nov 30, 2011 at 1:32 AM, Jon Medhurst (Tixy)
>> <jon.medhurst@linaro.org> wrote:
>> > On Tue, 2011-11-29 at 13:46 -0700, Tom Rini wrote:
>> >> On Tue, Nov 29, 2011 at 6:46 AM, Jon Medhurst (Tixy)
>> >> <jon.medhurst@linaro.org> wrote:
>> >> > Extend the default boot sequence on Versatile Express to load a boot
>> >> > script from MMC.
>> >> >
>> >> > Signed-off-by: Jon Medhurst <jon.medhurst@linaro.org>
>> >>
>> >> Is there any interest in defining a common 'fancy' boot command?  Over
>> >> on beagleboard (and a few other eval boards) we are (or will be)
>> >> doing, roughly:
>> >> Is there mmc? {
>> >>   Can we load a bootscript? {
>> >>     load it, do it
>> >>   }
>> >>   Can we load uEnv.txt? {
>> >>     Did it set 'uenvcmd'? {
>> >>       Run it
>> >>     }
>> >>   }
>> >>   Did we load the kernel? {
>> >>     bootm it
>> >>   }
>> >> }
>> >> Try nand.
>> >>
>> >> And it's not hard to replace NAND with "whatever flash the board sets"
>> >
>> > It could make sense. However, the combinations of boot methods could get
>> > quite big, e.g. do we include pxeboot, tftp?
>>
>> Well, maybe we define some blocks (TRY_MMC, TRY_ENET, TRY_NAND,
>> TRY_SPI, ...) ...
>>
>> > If everything was included in the common 'fancy boot' then some boards
>> > would have to define boot methods (or stubs) for things they weren't
>> > interested in. And, conversely, if fancy boot didn't include everything,
>> > then other people would need to extend it.
>>
>> ... provide a few examples of the blocks strung together and have
>> people string up what they need themselves, so long as it's an
>> otherwise good idea to have complex default boot methods?
>
> If something like this was planned for BeagleBoard anyway, then perhaps
> it could written in terms of these TRY_MMC etc. macros (which seem like
> a reasonable idea to me). Then a working prototype could be posted as an
> RFC for others to comment on? I suspect at the moment there's not many
> people reading this 'vexpress' thread ;-)

Note that beagleboard already has the switch logic, but I see your
point, and it's on my TODO list, hopefully in time for v2012.03 tho.

Patch

diff --git a/include/configs/vexpress_common.h b/include/configs/vexpress_common.h
index a4ae5a8..d56f19d 100644
--- a/include/configs/vexpress_common.h
+++ b/include/configs/vexpress_common.h
@@ -178,6 +178,8 @@ 
 #define CONFIG_CMD_SAVEENV
 #define CONFIG_NET_MULTI
 #define CONFIG_CMD_RUN
+#define CONFIG_CMD_BOOTD
+#define CONFIG_CMD_ECHO
 
 #define CONFIG_CMD_FAT
 #define CONFIG_DOS_PARTITION		1
@@ -226,7 +228,14 @@ 
 #define CONFIG_SYS_INIT_SP_ADDR		CONFIG_SYS_GBL_DATA_OFFSET
 
 /* Basic environment settings */
-#define CONFIG_BOOTCOMMAND		"run bootflash;"
+#define CONFIG_BOOTCOMMAND \
+	"if mmc rescan ${mmcdev}; then " \
+		"if run loadbootscript; then " \
+			"run bootscript; " \
+		"fi; " \
+	"fi; " \
+	"run bootflash;"
+
 #ifdef CONFIG_VEXPRESS_ORIGINAL_MEMORY_MAP
 #define CONFIG_PLATFORM_ENV_SETTINGS \
 		"loadaddr=0x80008000\0" \
@@ -258,7 +267,12 @@ 
 			"devtmpfs.mount=0  vmalloc=256M\0" \
 		"bootflash=run flashargs; " \
 			"cp ${ramdisk_addr} ${ramdisk_addr_r} ${maxramdisk}; " \
-			"bootm ${kernel_addr} ${ramdisk_addr_r}\0"
+			"bootm ${kernel_addr} ${ramdisk_addr_r}\0" \
+		"mmcdev=0\0" \
+		"bootscr=boot.scr\0" \
+		"loadbootscript=fatload mmc ${mmcdev} ${loadaddr} ${bootscr}\0" \
+		"bootscript=echo Running bootscript from mmc ...; " \
+			"source ${loadaddr}\0"
 
 /* FLASH and environment organization */
 #define PHYS_FLASH_SIZE			0x04000000	/* 64MB */
@@ -305,6 +319,8 @@ 
 #define CONFIG_SYS_PROMPT		"VExpress# "
 #define CONFIG_SYS_PBSIZE		(CONFIG_SYS_CBSIZE + \
 					sizeof(CONFIG_SYS_PROMPT) + 16)
+#define CONFIG_SYS_HUSH_PARSER
+#define CONFIG_SYS_PROMPT_HUSH_PS2	"> "
 #define CONFIG_SYS_BARGSIZE		CONFIG_SYS_CBSIZE /* Boot args buffer */
 #define CONFIG_CMD_SOURCE
 #define CONFIG_SYS_LONGHELP