diff mbox

[U-Boot,RFC] try to merge different i.MX environment

Message ID 1392390415-25620-1-git-send-email-sbabic@denx.de
State Superseded
Delegated to: Stefano Babic
Headers show

Commit Message

Stefano Babic Feb. 14, 2014, 3:06 p.m. UTC
Signed-off-by: Stefano Babic <sbabic@denx.de>
CC: Fabio Estevam <fabio.estevam@freescale.com>
CC: Otavio Salvador <otavio@ossystems.com.br>
CC: Marek Vasut <marex@denx.de>
CC: Leo Sartre <lsartre@adeneo-embedded.com>
CC: Jon Nettleton <jon.nettleton@gmail.com>
CC: Eric Nelson <eric.nelson@boundarydevices.com>
CC: b18965@freescale.com

Hi everybody,

the current built-in environment in most i.MX boards is very similar.
Even if I always thought that the default environemt is something
that the user want always customize, I see from all you submitters
the not hidden desire to have such a common default environment for
all boards. At least, for i.MX boards.
Checking in the board configuration files, I see at least the following
boards that hase "quite" the same built-in environment:

	mx23evk
	mx23_olinuxino
	mx28evk
	mx51evk
	mx53evk
	mx53loco
	mx53smd
	mx6qarm2
	mx6slevk
	mx6qsabre* (all of them)
	wandboard
	cgtqmx6eval
	hummingbird
	udoo

and I am sure, I have missed some of them. The default environment is
quite the same, and CONFIG_EXTRA_ENV_SETTINGS is more or less a cut&paste
from another board. There are inconsistency and each fix must be repeated
for all boards.

I will try to address this issue. Maybe can we find a common built-in environment,
that all other boards can simply include instead of redefining ?
I want to try to find some useful blocks, that we can reuse for each board (mmc, nand, net,..).

Then each board could simply define something like:


+#include <configs/default_env.h>
#define CONFIG_EXTRA_ENV_SETTINGS \
	CONFIG_BOARD_EXTRA_ENV_SETTINGS \
	CONFIG_COMMON_SCRIPTS \
	CONFIG_BOOTCOMMAND

Where CONFIG_BOARD_EXTRA_ENV_SETTINGS still contains  extra defines specific for the board

This patch is only a proposal: it is not complete and it want not to be. It is for me only a way to start the discussion: how can we make order in the big mess of built-in environment ?

Comments ?

Best regards,
Stefano Babic

---
 include/configs/cgtqmx6eval.h     |   62 +++++------------
 include/configs/default_env.h     |  133 +++++++++++++++++++++++++++++++++++++
 include/configs/hummingboard.h    |   80 +---------------------
 include/configs/mx23_olinuxino.h  |   90 +++++--------------------
 include/configs/mx6sabre_common.h |  119 ++++-----------------------------
 include/configs/sandbox.h         |   30 ++++++++-
 include/configs/wandboard.h       |   97 ++++-----------------------
 7 files changed, 221 insertions(+), 390 deletions(-)
 create mode 100644 include/configs/default_env.h

Comments

Otavio Salvador Feb. 14, 2014, 3:24 p.m. UTC | #1
Hello Stefano,

before anything I'd like to thank you for this as it does need to be
improved and it needs to be shared to avoid same fix to be done
everywhere.

On Fri, Feb 14, 2014 at 1:06 PM, Stefano Babic <sbabic@denx.de> wrote:
> Signed-off-by: Stefano Babic <sbabic@denx.de>
> CC: Fabio Estevam <fabio.estevam@freescale.com>
> CC: Otavio Salvador <otavio@ossystems.com.br>
> CC: Marek Vasut <marex@denx.de>
> CC: Leo Sartre <lsartre@adeneo-embedded.com>
> CC: Jon Nettleton <jon.nettleton@gmail.com>
> CC: Eric Nelson <eric.nelson@boundarydevices.com>
> CC: b18965@freescale.com
>
> Hi everybody,
>
> the current built-in environment in most i.MX boards is very similar.
> Even if I always thought that the default environemt is something
> that the user want always customize, I see from all you submitters
> the not hidden desire to have such a common default environment for
> all boards. At least, for i.MX boards.
> Checking in the board configuration files, I see at least the following
> boards that hase "quite" the same built-in environment:
...

Fully agreed. This is especially important with the common distro
environment in mind.

...
> diff --git a/include/configs/default_env.h b/include/configs/default_env.h
> new file mode 100644
> index 0000000..b898156
> --- /dev/null
> +++ b/include/configs/default_env.h

I'd prefer this to be named

default_env_imx.h

> @@ -0,0 +1,133 @@
> +
> +#ifndef _DEFAULT_ENV_H
> +#define _DEFAULT_ENV_H
> +
> +#ifdef CONFIG_PREFIX_IMAGE
> +#define CONFIG_BOOT_SUFFIX "z"
> +#define CONFIG_DEFIMAGE        "zimage"

zImage

> +#else
> +#define CONFIG_BOOT_SUFFIX
> +#define CONFIG_DEFIMAGE        "uImage"
> +#endif
> +
> +#ifndef MMC_SCRIPT_FILESYSTEM
> +#define MMC_SCRIPT_FILESYSTEM fat
> +#endif

We could move to generic filesystem and avoid this.

> +#ifndef CONFIG_DEFAULT_FDT_FILE
> +#define CONFIG_DEFAULT_FDT_FILE
> +#endif
> +
> +#ifndef MMC_WRITE_OFFSET
> +#define MMC_WRITE_OFFSET 0x2
> +#endif
> +
> +#ifdef CONFIG_SUPPORT_EMMC_BOOT
> +#define EMMC_ENV \
> +       "update_emmc_firmware=" \
> +               "if test ${ip_dyn} = yes; then " \
> +                       "setenv get_cmd dhcp; " \
> +               "else " \
> +                       "setenv get_cmd tftp; " \
> +               "fi; " \
> +               "if ${get_cmd} ${update_sd_firmware_filename}; then " \
> +                       "if mmc dev ${emmcdev} && " \
> +                               "mmc open ${emmcdev} 1; then "  \

This must to be adapter with Tom's work in emmc; I think this just fails now...

> +                               "setexpr fw_sz ${filesize} / 0x200; " \
> +                               "setexpr fw_sz ${fw_sz} + 1; "  \
> +                               "mmc write ${loadaddr} " __stringify(MMC_WRITE_OFFSET) " ${fw_sz}; " \
> +                               "mmc close ${emmcdev} 1; " \
> +                       "fi; "  \
> +               "fi\0"
> +#else
> +#define EMMC_ENV ""
> +#endif
> +
> +#define CONFIG_COMMON_SCRIPTS \
> +       "bootscript=echo Running bootscript from mmc ...; " \
> +               "source\0" \
> +       "script=boot.scr\0" \
> +       "image=" CONFIG_DEFIMAGE "\0" \
> +       "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
> +       "fdt_addr=0x18000000\0" \

This must to be set by SoC type; so we don't need to re-define it in
every board. This also need to be overridable in case we have a board
with reduced memory.

> +       "console=" CONFIG_CONSOLE_DEV "\0" \
> +       "fdt_high=0xffffffff\0"   \
> +       "initrd_high=0xffffffff\0" \
> +       "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
> +       "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
> +       "mmcroot=" CONFIG_MMCROOT " rootwait rw\0" \
> +       "update_sd_firmware=" \
> +               "if test ${ip_dyn} = yes; then " \
> +                       "setenv get_cmd dhcp; " \
> +               "else " \
> +                       "setenv get_cmd tftp; " \
> +               "fi; " \
> +               "if mmc dev ${mmcdev}; then "   \
> +                       "if ${get_cmd} ${update_sd_firmware_filename}; then " \
> +                               "setexpr fw_sz ${filesize} / 0x200; " \
> +                               "setexpr fw_sz ${fw_sz} + 1; "  \
> +                               "mmc write ${loadaddr} " __stringify(MMC_WRITE_OFFSET) " ${fw_sz}; " \
> +                       "fi; "  \
> +               "fi\0" \
> +       "mmcargs=setenv bootargs console=${console},${baudrate} " \
> +               "root=${mmcroot}\0" \
> +       "loadbootscript=" \
> +               __stringify(MMC_SCRIPT_FILESYSTEM)"load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
> +       "loadimage=" \
> +               __stringify(MMC_SCRIPT_FILESYSTEM)"load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
> +       "loadfdt=" \
> +               __stringify(MMC_SCRIPT_FILESYSTEM) "load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
> +       "mmcboot=echo Booting from mmc ...; " \
> +               "run mmcargs; " \
> +               "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
> +                       "if run loadfdt; then " \
> +                               "boot" CONFIG_BOOT_SUFFIX " ${loadaddr} - ${fdt_addr}; " \
> +                       "else " \
> +                               "if test ${boot_fdt} = try; then " \
> +                                       "boot" CONFIG_BOOT_SUFFIX "; " \
> +                               "else " \
> +                                       "echo WARN: Cannot load the DT; " \
> +                               "fi; " \
> +                       "fi; " \
> +               "else " \
> +                       "boot" CONFIG_BOOT_SUFFIX "; " \
> +               "fi;\0" \
> +       "netargs=setenv bootargs console=${console},${baudrate} " \
> +               "root=/dev/nfs " \
> +               "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
> +       "netboot=echo Booting from net ...; " \

netboot and mmc might be split; some board may don't have ethernet or mmc.

> +               "run netargs; " \
> +               "if test ${ip_dyn} = yes; then " \
> +                       "setenv get_cmd dhcp; " \
> +               "else " \
> +                       "setenv get_cmd tftp; " \
> +               "fi; " \
> +               "${get_cmd} ${image}; " \
> +               "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
> +                       "if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
> +                               "boot" CONFIG_BOOT_SUFFIX " ${loadaddr} - ${fdt_addr}; " \
> +                       "else " \
> +                               "if test ${boot_fdt} = try; then " \
> +                                       "boot" CONFIG_BOOT_SUFFIX "; " \
> +                               "else " \
> +                                       "echo WARN: Cannot load the DT; " \
> +                               "fi; " \
> +                       "fi; " \
> +               "else " \
> +                       "boot" CONFIG_BOOT_SUFFIX "; " \
> +               "fi;\0"
> +
> +#define CONFIG_BOOTCOMMAND \
> +       "mmc dev ${mmcdev};" \
> +       "if mmc rescan; then " \
> +               "if run loadbootscript; then " \
> +               "run bootscript; " \
> +               "else " \
> +                       "if run loadimage; then " \
> +                               "run mmcboot; " \
> +                       "else run netboot; " \
> +                       "fi; " \
> +               "fi; " \
> +       "else run netboot; fi"
> +
> +#endif
> diff --git a/include/configs/hummingboard.h b/include/configs/hummingboard.h
> index ac65620..5c00c4b 100644
> --- a/include/configs/hummingboard.h
> +++ b/include/configs/hummingboard.h
> @@ -90,93 +90,19 @@
>  #define CONFIG_DEFAULT_FDT_FILE                "imx6dl-hummingboard.dtb"
>  #endif
>
> -#define CONFIG_EXTRA_ENV_SETTINGS \
> -       "script=boot.scr\0" \
> -       "image=zImage\0" \
> +#define CONFIG_PREFIX_IMAGE z
> +
> +#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \
>         "console=ttymxc0\0" \
>         "splashpos=m,m\0" \
>         "fdt_high=0xffffffff\0" \
>         "initrd_high=0xffffffff\0" \
> -       "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
>         "fdt_addr=0x18000000\0" \
>         "boot_fdt=try\0" \
>         "ip_dyn=yes\0" \
>         "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
>         "mmcpart=1\0" \
>         "mmcroot=/dev/mmcblk0p2 rootwait rw\0" \
> -       "update_sd_firmware_filename=u-boot.imx\0" \
> -       "update_sd_firmware=" \
> -               "if test ${ip_dyn} = yes; then " \
> -                       "setenv get_cmd dhcp; " \
> -               "else " \
> -                       "setenv get_cmd tftp; " \
> -               "fi; " \
> -               "if mmc dev ${mmcdev}; then "   \
> -                       "if ${get_cmd} ${update_sd_firmware_filename}; then " \
> -                               "setexpr fw_sz ${filesize} / 0x200; " \
> -                               "setexpr fw_sz ${fw_sz} + 1; "  \
> -                               "mmc write ${loadaddr} 0x2 ${fw_sz}; " \
> -                       "fi; "  \
> -               "fi\0" \
> -       "mmcargs=setenv bootargs console=${console},${baudrate} " \
> -               "root=${mmcroot}\0" \
> -       "loadbootscript=" \
> -               "fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
> -       "bootscript=echo Running bootscript from mmc ...; " \
> -               "source\0" \
> -       "loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
> -       "loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
> -       "mmcboot=echo Booting from mmc ...; " \
> -               "run mmcargs; " \
> -               "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
> -                       "if run loadfdt; then " \
> -                               "bootz ${loadaddr} - ${fdt_addr}; " \
> -                       "else " \
> -                               "if test ${boot_fdt} = try; then " \
> -                                       "bootz; " \
> -                               "else " \
> -                                       "echo WARN: Cannot load the DT; " \
> -                               "fi; " \
> -                       "fi; " \
> -               "else " \
> -                       "bootz; " \
> -               "fi;\0" \
> -       "netargs=setenv bootargs console=${console},${baudrate} " \
> -               "root=/dev/nfs " \
> -       "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
> -               "netboot=echo Booting from net ...; " \
> -               "run netargs; " \
> -               "if test ${ip_dyn} = yes; then " \
> -                       "setenv get_cmd dhcp; " \
> -               "else " \
> -                       "setenv get_cmd tftp; " \
> -               "fi; " \
> -               "${get_cmd} ${image}; " \
> -               "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
> -                       "if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
> -                               "bootz ${loadaddr} - ${fdt_addr}; " \
> -                       "else " \
> -                               "if test ${boot_fdt} = try; then " \
> -                                       "bootz; " \
> -                               "else " \
> -                                       "echo WARN: Cannot load the DT; " \
> -                               "fi; " \
> -                       "fi; " \
> -               "else " \
> -                       "bootz; " \
> -               "fi;\0"
> -
> -#define CONFIG_BOOTCOMMAND \
> -          "mmc dev ${mmcdev}; if mmc rescan; then " \
> -                  "if run loadbootscript; then " \
> -                          "run bootscript; " \
> -                  "else " \
> -                          "if run loadimage; then " \
> -                                  "run mmcboot; " \
> -                          "else run netboot; " \
> -                          "fi; " \
> -                  "fi; " \
> -          "else run netboot; fi"
>
>  /* Miscellaneous configurable options */
>  #define CONFIG_SYS_LONGHELP
> diff --git a/include/configs/mx23_olinuxino.h b/include/configs/mx23_olinuxino.h
> index e377fea..08df31d 100644
> --- a/include/configs/mx23_olinuxino.h
> +++ b/include/configs/mx23_olinuxino.h
> @@ -71,9 +71,17 @@
>  #define CONFIG_LOADADDR                0x42000000
>  #define CONFIG_SYS_LOAD_ADDR   CONFIG_LOADADDR
>
> -/* Extra Environment */
> -#define CONFIG_EXTRA_ENV_SETTINGS \
> -       "update_sd_firmware_filename=u-boot.sd\0" \
> +#define CONFIG_DEFAULT_FDT_FILE "imx23-olinuxino.dtb"
> +#define MMC_WRITE_OFFSET 0x800
> +
> +#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \
> +       "boot_fdt=try\0" \
> +       "ip_dyn=yes\0" \
> +       "mmcdev=0\0" \
> +       "mmcpart=2\0" \
> +       "mmcroot=/dev/mmcblk0p3 rw rootwait\0" \
> +       "console=ttyAMA0\0" \
> +       "fdt_addr=0x41000000\0" \

I think this can reuse the common setting.

...

Basically I do like this idea and I would like to help in getting it
as good and as flexible as possible; this reduces a lot the
maintenance burden and easy customization to all of us.

Regards,
Dennis Gilmore Feb. 14, 2014, 4:14 p.m. UTC | #2
On Fri, 14 Feb 2014 16:06:55 +0100
Stefano Babic <sbabic@denx.de> wrote:

> Signed-off-by: Stefano Babic <sbabic@denx.de>
> CC: Fabio Estevam <fabio.estevam@freescale.com>
> CC: Otavio Salvador <otavio@ossystems.com.br>
> CC: Marek Vasut <marex@denx.de>
> CC: Leo Sartre <lsartre@adeneo-embedded.com>
> CC: Jon Nettleton <jon.nettleton@gmail.com>
> CC: Eric Nelson <eric.nelson@boundarydevices.com>
> CC: b18965@freescale.com
> 
> Hi everybody,
> 
> the current built-in environment in most i.MX boards is very similar.
> Even if I always thought that the default environemt is something
> that the user want always customize, I see from all you submitters
> the not hidden desire to have such a common default environment for
> all boards. At least, for i.MX boards.
> Checking in the board configuration files, I see at least the
> following boards that hase "quite" the same built-in environment:
> 

I'm working on building a common set environment based on the work by
Stephen Warren for tegra, that would provide for a very usable
experience.

Its the next step forward from the distro config options. Id rather us
get a solution that works across the board than something different per
soc family. looking at how tegra is being done should provide a solid
guide.

Dennis
Wolfgang Denk Feb. 14, 2014, 4:35 p.m. UTC | #3
Dear Stefano Babic,

In message <1392390415-25620-1-git-send-email-sbabic@denx.de> you wrote:
>
> +#define CONFIG_PREFIX_IMAGE "z" 
> +#define CONFIG_MMCROOT	"/dev/mmcblk0p1"
> +#define CONFIG_CONSOLE_DEV "ttymxc1"
> +
> +#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \

Please keep in mind that all new CONFIG_ setting must be properly
documented in the README.

Best regards,

Wolfgang Denk
Stefano Babic Feb. 15, 2014, 11:57 a.m. UTC | #4
Hi Dennis,

On 14/02/2014 17:14, Dennis Gilmore wrote:
> On Fri, 14 Feb 2014 16:06:55 +0100
> Stefano Babic <sbabic@denx.de> wrote:
> 
>> Signed-off-by: Stefano Babic <sbabic@denx.de>
>> CC: Fabio Estevam <fabio.estevam@freescale.com>
>> CC: Otavio Salvador <otavio@ossystems.com.br>
>> CC: Marek Vasut <marex@denx.de>
>> CC: Leo Sartre <lsartre@adeneo-embedded.com>
>> CC: Jon Nettleton <jon.nettleton@gmail.com>
>> CC: Eric Nelson <eric.nelson@boundarydevices.com>
>> CC: b18965@freescale.com
>>
>> Hi everybody,
>>
>> the current built-in environment in most i.MX boards is very similar.
>> Even if I always thought that the default environemt is something
>> that the user want always customize, I see from all you submitters
>> the not hidden desire to have such a common default environment for
>> all boards. At least, for i.MX boards.
>> Checking in the board configuration files, I see at least the
>> following boards that hase "quite" the same built-in environment:
>>
> 
> I'm working on building a common set environment based on the work by
> Stephen Warren for tegra, that would provide for a very usable
> experience.
> 
> Its the next step forward from the distro config options. Id rather us
> get a solution that works across the board than something different per
> soc family.

Fully agree. I will check again tegra-common-post.h. As far as I have
understood, the built-in environment for Tegra sets a minimal set of
rules and scripts that allow to load a full environment from another
script stored on a media (mmc or usb). This is also a good statement,
because the environment is not so fine defined and let easy customization.

> looking at how tegra is being done should provide a solid
> guide.

Thanks,
Stefano
Stefano Babic Feb. 16, 2014, 4:40 p.m. UTC | #5
Hi Otavio,

On 14/02/2014 16:24, Otavio Salvador wrote:

> 
> Fully agreed. This is especially important with the common distro
> environment in mind.

Right - we should also take care of Dennis' efforts in this direction.

> 
> ...
>> diff --git a/include/configs/default_env.h b/include/configs/default_env.h
>> new file mode 100644
>> index 0000000..b898156
>> --- /dev/null
>> +++ b/include/configs/default_env.h
> 
> I'd prefer this to be named
> 
> default_env_imx.h

Agree.

> 
> We could move to generic filesystem and avoid this.

Agree.

> 
>> +#ifndef CONFIG_DEFAULT_FDT_FILE
>> +#define CONFIG_DEFAULT_FDT_FILE
>> +#endif
>> +
>> +#ifndef MMC_WRITE_OFFSET
>> +#define MMC_WRITE_OFFSET 0x2
>> +#endif
>> +
>> +#ifdef CONFIG_SUPPORT_EMMC_BOOT
>> +#define EMMC_ENV \
>> +       "update_emmc_firmware=" \
>> +               "if test ${ip_dyn} = yes; then " \
>> +                       "setenv get_cmd dhcp; " \
>> +               "else " \
>> +                       "setenv get_cmd tftp; " \
>> +               "fi; " \
>> +               "if ${get_cmd} ${update_sd_firmware_filename}; then " \
>> +                       "if mmc dev ${emmcdev} && " \
>> +                               "mmc open ${emmcdev} 1; then "  \
> 
> This must to be adapter with Tom's work in emmc; I think this just fails now...

Ok, I will take a look. We could also drop at the moment EMMC_ENV and
put it again after Tom's patches are in.

> 
>> +                               "setexpr fw_sz ${filesize} / 0x200; " \
>> +                               "setexpr fw_sz ${fw_sz} + 1; "  \
>> +                               "mmc write ${loadaddr} " __stringify(MMC_WRITE_OFFSET) " ${fw_sz}; " \
>> +                               "mmc close ${emmcdev} 1; " \
>> +                       "fi; "  \
>> +               "fi\0"
>> +#else
>> +#define EMMC_ENV ""
>> +#endif
>> +
>> +#define CONFIG_COMMON_SCRIPTS \
>> +       "bootscript=echo Running bootscript from mmc ...; " \
>> +               "source\0" \
>> +       "script=boot.scr\0" \
>> +       "image=" CONFIG_DEFIMAGE "\0" \
>> +       "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
>> +       "fdt_addr=0x18000000\0" \
> 
> This must to be set by SoC type; so we don't need to re-define it in
> every board. This also need to be overridable in case we have a board
> with reduced memory.
> 

Fully agree. I think, after making order to  the built-in environment,
we could go on and factorize also a lot of defines that are SOC common.
Without reinventing the wheel, we can do as Stephen (Warren) prepared
for Tegra.

We can have:
- config file with built-in environment
- config with defines related to the SOC
- board configuration file that includes the first two.

>> +       "console=" CONFIG_CONSOLE_DEV "\0" \
>> +       "fdt_high=0xffffffff\0"   \
>> +       "initrd_high=0xffffffff\0" \
>> +       "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
>> +       "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
>> +       "mmcroot=" CONFIG_MMCROOT " rootwait rw\0" \
>> +       "update_sd_firmware=" \
>> +               "if test ${ip_dyn} = yes; then " \
>> +                       "setenv get_cmd dhcp; " \
>> +               "else " \
>> +                       "setenv get_cmd tftp; " \
>> +               "fi; " \
>> +               "if mmc dev ${mmcdev}; then "   \
>> +                       "if ${get_cmd} ${update_sd_firmware_filename}; then " \
>> +                               "setexpr fw_sz ${filesize} / 0x200; " \
>> +                               "setexpr fw_sz ${fw_sz} + 1; "  \
>> +                               "mmc write ${loadaddr} " __stringify(MMC_WRITE_OFFSET) " ${fw_sz}; " \
>> +                       "fi; "  \
>> +               "fi\0" \
>> +       "mmcargs=setenv bootargs console=${console},${baudrate} " \
>> +               "root=${mmcroot}\0" \
>> +       "loadbootscript=" \
>> +               __stringify(MMC_SCRIPT_FILESYSTEM)"load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
>> +       "loadimage=" \
>> +               __stringify(MMC_SCRIPT_FILESYSTEM)"load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
>> +       "loadfdt=" \
>> +               __stringify(MMC_SCRIPT_FILESYSTEM) "load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
>> +       "mmcboot=echo Booting from mmc ...; " \
>> +               "run mmcargs; " \
>> +               "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
>> +                       "if run loadfdt; then " \
>> +                               "boot" CONFIG_BOOT_SUFFIX " ${loadaddr} - ${fdt_addr}; " \
>> +                       "else " \
>> +                               "if test ${boot_fdt} = try; then " \
>> +                                       "boot" CONFIG_BOOT_SUFFIX "; " \
>> +                               "else " \
>> +                                       "echo WARN: Cannot load the DT; " \
>> +                               "fi; " \
>> +                       "fi; " \
>> +               "else " \
>> +                       "boot" CONFIG_BOOT_SUFFIX "; " \
>> +               "fi;\0" \
>> +       "netargs=setenv bootargs console=${console},${baudrate} " \
>> +               "root=/dev/nfs " \
>> +               "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
>> +       "netboot=echo Booting from net ...; " \
> 
> netboot and mmc might be split; some board may don't have ethernet or mmc.

Fully agree. We need also quite the same for NAND. Marek has already
prepared (he sended to me out of the list) an environment for NAND based
boards (m28evk and m52evk). I will try to merge all together and see
what's happen. My hope is that we can find a common set of scripts/rules
for the environment that can be used directly by the boards.

> 
>> +               "run netargs; " \
>> +               "if test ${ip_dyn} = yes; then " \
>> +                       "setenv get_cmd dhcp; " \
>> +               "else " \
>> +                       "setenv get_cmd tftp; " \
>> +               "fi; " \
>> +               "${get_cmd} ${image}; " \
>> +               "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
>> +                       "if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
>> +                               "boot" CONFIG_BOOT_SUFFIX " ${loadaddr} - ${fdt_addr}; " \
>> +                       "else " \
>> +                               "if test ${boot_fdt} = try; then " \
>> +                                       "boot" CONFIG_BOOT_SUFFIX "; " \
>> +                               "else " \
>> +                                       "echo WARN: Cannot load the DT; " \
>> +                               "fi; " \
>> +                       "fi; " \
>> +               "else " \
>> +                       "boot" CONFIG_BOOT_SUFFIX "; " \
>> +               "fi;\0"
>> +
>> +#define CONFIG_BOOTCOMMAND \
>> +       "mmc dev ${mmcdev};" \
>> +       "if mmc rescan; then " \
>> +               "if run loadbootscript; then " \
>> +               "run bootscript; " \
>> +               "else " \
>> +                       "if run loadimage; then " \
>> +                               "run mmcboot; " \
>> +                       "else run netboot; " \
>> +                       "fi; " \
>> +               "fi; " \
>> +       "else run netboot; fi"

Or we can do as it is done in include/configs/tegra-common-post.h

>> +#endif
>> diff --git a/include/configs/hummingboard.h b/include/configs/hummingboard.h
>> index ac65620..5c00c4b 100644
>> --- a/include/configs/hummingboard.h
>> +++ b/include/configs/hummingboard.h

I think the sense is clear - we can try first to concentrate on the
common file (default_env_imx.h), and then we can move the boards to use it.


>> @@ -90,93 +90,19 @@
>>  #define CONFIG_DEFAULT_FDT_FILE                "imx6dl-hummingboard.dtb"
>>  #endif
>>
>> -#define CONFIG_EXTRA_ENV_SETTINGS \
>> -       "script=boot.scr\0" \
>> -       "image=zImage\0" \
>> +#define CONFIG_PREFIX_IMAGE z
>> +
>> +#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \
>>         "console=ttymxc0\0" \
>>         "splashpos=m,m\0" \
>>         "fdt_high=0xffffffff\0" \
>>         "initrd_high=0xffffffff\0" \
>> -       "fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
>>         "fdt_addr=0x18000000\0" \
>>         "boot_fdt=try\0" \
>>         "ip_dyn=yes\0" \
>>         "mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
>>         "mmcpart=1\0" \
>>         "mmcroot=/dev/mmcblk0p2 rootwait rw\0" \
>> -       "update_sd_firmware_filename=u-boot.imx\0" \
>> -       "update_sd_firmware=" \
>> -               "if test ${ip_dyn} = yes; then " \
>> -                       "setenv get_cmd dhcp; " \
>> -               "else " \
>> -                       "setenv get_cmd tftp; " \
>> -               "fi; " \
>> -               "if mmc dev ${mmcdev}; then "   \
>> -                       "if ${get_cmd} ${update_sd_firmware_filename}; then " \
>> -                               "setexpr fw_sz ${filesize} / 0x200; " \
>> -                               "setexpr fw_sz ${fw_sz} + 1; "  \
>> -                               "mmc write ${loadaddr} 0x2 ${fw_sz}; " \
>> -                       "fi; "  \
>> -               "fi\0" \
>> -       "mmcargs=setenv bootargs console=${console},${baudrate} " \
>> -               "root=${mmcroot}\0" \
>> -       "loadbootscript=" \
>> -               "fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
>> -       "bootscript=echo Running bootscript from mmc ...; " \
>> -               "source\0" \
>> -       "loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
>> -       "loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
>> -       "mmcboot=echo Booting from mmc ...; " \
>> -               "run mmcargs; " \
>> -               "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
>> -                       "if run loadfdt; then " \
>> -                               "bootz ${loadaddr} - ${fdt_addr}; " \
>> -                       "else " \
>> -                               "if test ${boot_fdt} = try; then " \
>> -                                       "bootz; " \
>> -                               "else " \
>> -                                       "echo WARN: Cannot load the DT; " \
>> -                               "fi; " \
>> -                       "fi; " \
>> -               "else " \
>> -                       "bootz; " \
>> -               "fi;\0" \
>> -       "netargs=setenv bootargs console=${console},${baudrate} " \
>> -               "root=/dev/nfs " \
>> -       "ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
>> -               "netboot=echo Booting from net ...; " \
>> -               "run netargs; " \
>> -               "if test ${ip_dyn} = yes; then " \
>> -                       "setenv get_cmd dhcp; " \
>> -               "else " \
>> -                       "setenv get_cmd tftp; " \
>> -               "fi; " \
>> -               "${get_cmd} ${image}; " \
>> -               "if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
>> -                       "if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
>> -                               "bootz ${loadaddr} - ${fdt_addr}; " \
>> -                       "else " \
>> -                               "if test ${boot_fdt} = try; then " \
>> -                                       "bootz; " \
>> -                               "else " \
>> -                                       "echo WARN: Cannot load the DT; " \
>> -                               "fi; " \
>> -                       "fi; " \
>> -               "else " \
>> -                       "bootz; " \
>> -               "fi;\0"
>> -
>> -#define CONFIG_BOOTCOMMAND \
>> -          "mmc dev ${mmcdev}; if mmc rescan; then " \
>> -                  "if run loadbootscript; then " \
>> -                          "run bootscript; " \
>> -                  "else " \
>> -                          "if run loadimage; then " \
>> -                                  "run mmcboot; " \
>> -                          "else run netboot; " \
>> -                          "fi; " \
>> -                  "fi; " \
>> -          "else run netboot; fi"
>>
>>  /* Miscellaneous configurable options */
>>  #define CONFIG_SYS_LONGHELP
>> diff --git a/include/configs/mx23_olinuxino.h b/include/configs/mx23_olinuxino.h
>> index e377fea..08df31d 100644
>> --- a/include/configs/mx23_olinuxino.h
>> +++ b/include/configs/mx23_olinuxino.h
>> @@ -71,9 +71,17 @@
>>  #define CONFIG_LOADADDR                0x42000000
>>  #define CONFIG_SYS_LOAD_ADDR   CONFIG_LOADADDR
>>
>> -/* Extra Environment */
>> -#define CONFIG_EXTRA_ENV_SETTINGS \
>> -       "update_sd_firmware_filename=u-boot.sd\0" \
>> +#define CONFIG_DEFAULT_FDT_FILE "imx23-olinuxino.dtb"
>> +#define MMC_WRITE_OFFSET 0x800
>> +
>> +#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \
>> +       "boot_fdt=try\0" \
>> +       "ip_dyn=yes\0" \
>> +       "mmcdev=0\0" \
>> +       "mmcpart=2\0" \
>> +       "mmcroot=/dev/mmcblk0p3 rw rootwait\0" \
>> +       "console=ttyAMA0\0" \
>> +       "fdt_addr=0x41000000\0" \
> 
> I think this can reuse the common setting.

Do you mean only for fdt_addr ? Yes, agree.

> Basically I do like this idea and I would like to help in getting it
> as good and as flexible as possible; this reduces a lot the
> maintenance burden and easy customization to all of us.

Fully agree.

Regards,
Stefano Babic
Tom Rini Feb. 18, 2014, 5:11 p.m. UTC | #6
On Sat, Feb 15, 2014 at 12:57:43PM +0100, Stefano Babic wrote:
> Hi Dennis,
> 
> On 14/02/2014 17:14, Dennis Gilmore wrote:
> > On Fri, 14 Feb 2014 16:06:55 +0100
> > Stefano Babic <sbabic@denx.de> wrote:
> > 
> >> Signed-off-by: Stefano Babic <sbabic@denx.de>
> >> CC: Fabio Estevam <fabio.estevam@freescale.com>
> >> CC: Otavio Salvador <otavio@ossystems.com.br>
> >> CC: Marek Vasut <marex@denx.de>
> >> CC: Leo Sartre <lsartre@adeneo-embedded.com>
> >> CC: Jon Nettleton <jon.nettleton@gmail.com>
> >> CC: Eric Nelson <eric.nelson@boundarydevices.com>
> >> CC: b18965@freescale.com
> >>
> >> Hi everybody,
> >>
> >> the current built-in environment in most i.MX boards is very similar.
> >> Even if I always thought that the default environemt is something
> >> that the user want always customize, I see from all you submitters
> >> the not hidden desire to have such a common default environment for
> >> all boards. At least, for i.MX boards.
> >> Checking in the board configuration files, I see at least the
> >> following boards that hase "quite" the same built-in environment:
> >>
> > 
> > I'm working on building a common set environment based on the work by
> > Stephen Warren for tegra, that would provide for a very usable
> > experience.
> > 
> > Its the next step forward from the distro config options. Id rather us
> > get a solution that works across the board than something different per
> > soc family.
> 
> Fully agree. I will check again tegra-common-post.h. As far as I have
> understood, the built-in environment for Tegra sets a minimal set of
> rules and scripts that allow to load a full environment from another
> script stored on a media (mmc or usb). This is also a good statement,
> because the environment is not so fine defined and let easy customization.

Dan has adapted the tegra form to work with the TI boards that use
ti_armv7_common.h and similar so I think we should be able to get i.MX
also using something similar.
diff mbox

Patch

diff --git a/include/configs/cgtqmx6eval.h b/include/configs/cgtqmx6eval.h
index b189bf1..4fe8a58 100644
--- a/include/configs/cgtqmx6eval.h
+++ b/include/configs/cgtqmx6eval.h
@@ -73,58 +73,26 @@ 
 
 #define CONFIG_DEFAULT_FDT_FILE "imx6q-congatec.dtb"
 
-#define CONFIG_EXTRA_ENV_SETTINGS \
-	"script=boot.scr\0" \
-	"image=zImage\0" \
-	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
-	"boot_dir=/boot\0" \
-	"console=ttymxc1\0" \
+#define CONFIG_PREFIX_IMAGE "z" 
+#define CONFIG_MMCROOT	"/dev/mmcblk0p1"
+#define CONFIG_CONSOLE_DEV "ttymxc1"
+
+#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \
 	"fdt_high=0xffffffff\0" \
 	"initrd_high=0xffffffff\0" \
 	"fdt_addr=0x18000000\0" \
 	"boot_fdt=try\0" \
 	"mmcdev=1\0" \
-	"mmcpart=1\0" \
-	"mmcroot=/dev/mmcblk0p1 rootwait rw\0" \
-	"mmcargs=setenv bootargs console=${console},${baudrate} " \
-		"root=${mmcroot}\0" \
-	"loadbootscript=" \
-		"ext2load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
-	"bootscript=echo Running bootscript from mmc ...; " \
-		"source\0" \
-	"loadimage=ext2load mmc ${mmcdev}:${mmcpart} ${loadaddr} " \
-		"${boot_dir}/${image}\0" \
-	"loadfdt=ext2load mmc ${mmcdev}:${mmcpart} ${fdt_addr} " \
-		"${boot_dir}/${fdt_file}\0" \
-	"mmcboot=echo Booting from mmc ...; " \
-		"run mmcargs; " \
-		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-			"if run loadfdt; then " \
-				"bootz ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"if test ${boot_fdt} = try; then " \
-					"bootz; " \
-				"else " \
-					"echo WARN: Cannot load the DT; " \
-				"fi; " \
-			"fi; " \
-		"else " \
-			"bootz; " \
-		"fi;\0"
-
-#define CONFIG_BOOTCOMMAND \
-	   "mmc dev ${mmcdev};" \
-	   "mmc dev ${mmcdev}; if mmc rescan; then " \
-		   "if run loadbootscript; then " \
-			   "run bootscript; " \
-		   "else " \
-			   "if run loadimage; then " \
-				   "run mmcboot; " \
-			   "else "\
-				   "echo ERR: Fail to boot from mmc; " \
-			   "fi; " \
-		   "fi; " \
-	   "else echo ERR: Fail to boot from mmc; fi"
+	"mmcpart=1\0"
+
+#define MMC_SCRIPT_FILESYSTEM ext2
+
+#include <configs/default_env.h>
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	CONFIG_BOARD_EXTRA_ENV_SETTINGS \
+	CONFIG_COMMON_SCRIPTS \
+	CONFIG_BOOTCOMMAND
 
 /* Miscellaneous configurable options */
 #define CONFIG_SYS_LONGHELP
diff --git a/include/configs/default_env.h b/include/configs/default_env.h
new file mode 100644
index 0000000..b898156
--- /dev/null
+++ b/include/configs/default_env.h
@@ -0,0 +1,133 @@ 
+
+#ifndef _DEFAULT_ENV_H
+#define _DEFAULT_ENV_H
+
+#ifdef CONFIG_PREFIX_IMAGE
+#define CONFIG_BOOT_SUFFIX "z"
+#define CONFIG_DEFIMAGE	"zimage"
+#else
+#define CONFIG_BOOT_SUFFIX
+#define CONFIG_DEFIMAGE	"uImage"
+#endif
+
+#ifndef MMC_SCRIPT_FILESYSTEM
+#define MMC_SCRIPT_FILESYSTEM fat
+#endif
+
+#ifndef CONFIG_DEFAULT_FDT_FILE 
+#define CONFIG_DEFAULT_FDT_FILE 
+#endif
+
+#ifndef MMC_WRITE_OFFSET
+#define MMC_WRITE_OFFSET 0x2
+#endif
+
+#ifdef CONFIG_SUPPORT_EMMC_BOOT
+#define EMMC_ENV \
+	"update_emmc_firmware=" \
+		"if test ${ip_dyn} = yes; then " \
+			"setenv get_cmd dhcp; " \
+		"else " \
+			"setenv get_cmd tftp; " \
+		"fi; " \
+		"if ${get_cmd} ${update_sd_firmware_filename}; then " \
+			"if mmc dev ${emmcdev} && " \
+				"mmc open ${emmcdev} 1; then "	\
+				"setexpr fw_sz ${filesize} / 0x200; " \
+				"setexpr fw_sz ${fw_sz} + 1; "	\
+				"mmc write ${loadaddr} " __stringify(MMC_WRITE_OFFSET) " ${fw_sz}; " \
+				"mmc close ${emmcdev} 1; " \
+			"fi; "	\
+		"fi\0"
+#else
+#define EMMC_ENV ""
+#endif
+
+#define CONFIG_COMMON_SCRIPTS \
+	"bootscript=echo Running bootscript from mmc ...; " \
+		"source\0" \
+	"script=boot.scr\0" \
+	"image=" CONFIG_DEFIMAGE "\0" \
+	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
+	"fdt_addr=0x18000000\0" \
+	"console=" CONFIG_CONSOLE_DEV "\0" \
+	"fdt_high=0xffffffff\0"	  \
+	"initrd_high=0xffffffff\0" \
+	"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
+	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
+	"mmcroot=" CONFIG_MMCROOT " rootwait rw\0" \
+	"update_sd_firmware=" \
+		"if test ${ip_dyn} = yes; then " \
+			"setenv get_cmd dhcp; " \
+		"else " \
+			"setenv get_cmd tftp; " \
+		"fi; " \
+		"if mmc dev ${mmcdev}; then "	\
+			"if ${get_cmd} ${update_sd_firmware_filename}; then " \
+				"setexpr fw_sz ${filesize} / 0x200; " \
+				"setexpr fw_sz ${fw_sz} + 1; "	\
+				"mmc write ${loadaddr} " __stringify(MMC_WRITE_OFFSET) " ${fw_sz}; " \
+			"fi; "	\
+		"fi\0" \
+	"mmcargs=setenv bootargs console=${console},${baudrate} " \
+		"root=${mmcroot}\0" \
+	"loadbootscript=" \
+		__stringify(MMC_SCRIPT_FILESYSTEM)"load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
+	"loadimage=" \
+		__stringify(MMC_SCRIPT_FILESYSTEM)"load mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
+	"loadfdt=" \
+		__stringify(MMC_SCRIPT_FILESYSTEM) "load mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
+	"mmcboot=echo Booting from mmc ...; " \
+		"run mmcargs; " \
+		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
+			"if run loadfdt; then " \
+				"boot" CONFIG_BOOT_SUFFIX " ${loadaddr} - ${fdt_addr}; " \
+			"else " \
+				"if test ${boot_fdt} = try; then " \
+					"boot" CONFIG_BOOT_SUFFIX "; " \
+				"else " \
+					"echo WARN: Cannot load the DT; " \
+				"fi; " \
+			"fi; " \
+		"else " \
+			"boot" CONFIG_BOOT_SUFFIX "; " \
+		"fi;\0" \
+	"netargs=setenv bootargs console=${console},${baudrate} " \
+		"root=/dev/nfs " \
+		"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
+	"netboot=echo Booting from net ...; " \
+		"run netargs; " \
+		"if test ${ip_dyn} = yes; then " \
+			"setenv get_cmd dhcp; " \
+		"else " \
+			"setenv get_cmd tftp; " \
+		"fi; " \
+		"${get_cmd} ${image}; " \
+		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
+			"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
+				"boot" CONFIG_BOOT_SUFFIX " ${loadaddr} - ${fdt_addr}; " \
+			"else " \
+				"if test ${boot_fdt} = try; then " \
+					"boot" CONFIG_BOOT_SUFFIX "; " \
+				"else " \
+					"echo WARN: Cannot load the DT; " \
+				"fi; " \
+			"fi; " \
+		"else " \
+			"boot" CONFIG_BOOT_SUFFIX "; " \
+		"fi;\0"
+
+#define CONFIG_BOOTCOMMAND \
+	"mmc dev ${mmcdev};" \
+	"if mmc rescan; then " \
+		"if run loadbootscript; then " \
+		"run bootscript; " \
+		"else " \
+			"if run loadimage; then " \
+				"run mmcboot; " \
+			"else run netboot; " \
+			"fi; " \
+		"fi; " \
+	"else run netboot; fi"
+
+#endif
diff --git a/include/configs/hummingboard.h b/include/configs/hummingboard.h
index ac65620..5c00c4b 100644
--- a/include/configs/hummingboard.h
+++ b/include/configs/hummingboard.h
@@ -90,93 +90,19 @@ 
 #define CONFIG_DEFAULT_FDT_FILE		"imx6dl-hummingboard.dtb"
 #endif
 
-#define CONFIG_EXTRA_ENV_SETTINGS \
-	"script=boot.scr\0" \
-	"image=zImage\0" \
+#define CONFIG_PREFIX_IMAGE z 
+
+#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \
 	"console=ttymxc0\0" \
 	"splashpos=m,m\0" \
 	"fdt_high=0xffffffff\0" \
 	"initrd_high=0xffffffff\0" \
-	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
 	"fdt_addr=0x18000000\0" \
 	"boot_fdt=try\0" \
 	"ip_dyn=yes\0" \
 	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
 	"mmcpart=1\0" \
 	"mmcroot=/dev/mmcblk0p2 rootwait rw\0" \
-	"update_sd_firmware_filename=u-boot.imx\0" \
-	"update_sd_firmware=" \
-		"if test ${ip_dyn} = yes; then " \
-			"setenv get_cmd dhcp; " \
-		"else " \
-			"setenv get_cmd tftp; " \
-		"fi; " \
-		"if mmc dev ${mmcdev}; then "	\
-			"if ${get_cmd} ${update_sd_firmware_filename}; then " \
-				"setexpr fw_sz ${filesize} / 0x200; " \
-				"setexpr fw_sz ${fw_sz} + 1; "	\
-				"mmc write ${loadaddr} 0x2 ${fw_sz}; " \
-			"fi; "	\
-		"fi\0" \
-	"mmcargs=setenv bootargs console=${console},${baudrate} " \
-		"root=${mmcroot}\0" \
-	"loadbootscript=" \
-		"fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
-	"bootscript=echo Running bootscript from mmc ...; " \
-		"source\0" \
-	"loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
-	"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
-	"mmcboot=echo Booting from mmc ...; " \
-		"run mmcargs; " \
-		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-			"if run loadfdt; then " \
-				"bootz ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"if test ${boot_fdt} = try; then " \
-					"bootz; " \
-				"else " \
-					"echo WARN: Cannot load the DT; " \
-				"fi; " \
-			"fi; " \
-		"else " \
-			"bootz; " \
-		"fi;\0" \
-	"netargs=setenv bootargs console=${console},${baudrate} " \
-		"root=/dev/nfs " \
-	"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
-		"netboot=echo Booting from net ...; " \
-		"run netargs; " \
-		"if test ${ip_dyn} = yes; then " \
-			"setenv get_cmd dhcp; " \
-		"else " \
-			"setenv get_cmd tftp; " \
-		"fi; " \
-		"${get_cmd} ${image}; " \
-		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-			"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
-				"bootz ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"if test ${boot_fdt} = try; then " \
-					"bootz; " \
-				"else " \
-					"echo WARN: Cannot load the DT; " \
-				"fi; " \
-			"fi; " \
-		"else " \
-			"bootz; " \
-		"fi;\0"
-
-#define CONFIG_BOOTCOMMAND \
-	   "mmc dev ${mmcdev}; if mmc rescan; then " \
-		   "if run loadbootscript; then " \
-			   "run bootscript; " \
-		   "else " \
-			   "if run loadimage; then " \
-				   "run mmcboot; " \
-			   "else run netboot; " \
-			   "fi; " \
-		   "fi; " \
-	   "else run netboot; fi"
 
 /* Miscellaneous configurable options */
 #define CONFIG_SYS_LONGHELP
diff --git a/include/configs/mx23_olinuxino.h b/include/configs/mx23_olinuxino.h
index e377fea..08df31d 100644
--- a/include/configs/mx23_olinuxino.h
+++ b/include/configs/mx23_olinuxino.h
@@ -71,9 +71,17 @@ 
 #define CONFIG_LOADADDR		0x42000000
 #define CONFIG_SYS_LOAD_ADDR	CONFIG_LOADADDR
 
-/* Extra Environment */
-#define CONFIG_EXTRA_ENV_SETTINGS \
-	"update_sd_firmware_filename=u-boot.sd\0" \
+#define CONFIG_DEFAULT_FDT_FILE "imx23-olinuxino.dtb"
+#define MMC_WRITE_OFFSET 0x800
+
+#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \
+	"boot_fdt=try\0" \
+	"ip_dyn=yes\0" \
+	"mmcdev=0\0" \
+	"mmcpart=2\0" \
+	"mmcroot=/dev/mmcblk0p3 rw rootwait\0" \
+	"console=ttyAMA0\0" \
+	"fdt_addr=0x41000000\0" \
 	"update_sd_firmware="		/* Update the SD firmware partition */ \
 		"if mmc rescan ; then "	\
 		"if tftp ${update_sd_firmware_filename} ; then " \
@@ -82,78 +90,12 @@ 
 		"mmc write ${loadaddr} 0x800 ${fw_sz} ; " \
 		"fi ; "	\
 		"fi\0" \
-	"script=boot.scr\0"	\
-	"uimage=uImage\0" \
-	"console=ttyAMA0\0" \
-	"fdt_file=imx23-olinuxino.dtb\0" \
-	"fdt_addr=0x41000000\0" \
-	"boot_fdt=try\0" \
-	"ip_dyn=yes\0" \
-	"mmcdev=0\0" \
-	"mmcpart=2\0" \
-	"mmcroot=/dev/mmcblk0p3 rw rootwait\0" \
-	"mmcargs=setenv bootargs console=${console},${baudrate} " \
-		"root=${mmcroot}\0" \
-	"loadbootscript="  \
-		"fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
-	"bootscript=echo Running bootscript from mmc ...; "	\
-		"source\0" \
-	"loaduimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${uimage}\0" \
-	"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
-	"mmcboot=echo Booting from mmc ...; " \
-		"run mmcargs; " \
-		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-			"if run loadfdt; then " \
-				"bootm ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"if test ${boot_fdt} = try; then " \
-					"bootm; " \
-				"else " \
-					"echo WARN: Cannot load the DT; " \
-				"fi; " \
-			"fi; " \
-		"else " \
-			"bootm; " \
-		"fi;\0" \
-	"netargs=setenv bootargs console=${console},${baudrate} " \
-		"root=/dev/nfs " \
-		"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
-	"netboot=echo Booting from net ...; " \
-		"usb start; " \
-		"run netargs; "	\
-		"if test ${ip_dyn} = yes; then " \
-			"setenv get_cmd dhcp; " \
-		"else " \
-			"setenv get_cmd tftp; " \
-		"fi; " \
-		"${get_cmd} ${uimage}; " \
-		"if test ${boot_fdt} = yes; then " \
-			"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
-				"bootm ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"if test ${boot_fdt} = try; then " \
-					"bootm; " \
-				"else " \
-					"echo WARN: Cannot load the DT; " \
-				"fi;" \
-			"fi; " \
-		"else " \
-			"bootm; " \
-		"fi;\0"
-
-#define CONFIG_BOOTCOMMAND \
-	"mmc dev ${mmcdev}; if mmc rescan; then " \
-		"if run loadbootscript; then " \
-			"run bootscript; " \
-		"else " \
-			"if run loaduimage; then " \
-				"run mmcboot; " \
-			"else run netboot; " \
-			"fi; " \
-		"fi; " \
-	"else run netboot; fi"
-
+	
 /* The rest of the configuration is shared */
 #include <configs/mxs.h>
 
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	CONFIG_COMMON_SCRIPTS \
+	CONFIG_BOARD_EXTRA_ENV_SETTINGS \
+	CONFIG_BOOTCOMMAND
 #endif /* __CONFIGS_MX23_OLINUXINO_H__ */
diff --git a/include/configs/mx6sabre_common.h b/include/configs/mx6sabre_common.h
index 4efcebf..e7bb467 100644
--- a/include/configs/mx6sabre_common.h
+++ b/include/configs/mx6sabre_common.h
@@ -95,115 +95,22 @@ 
 #define CONFIG_LOADADDR                        0x12000000
 #define CONFIG_SYS_TEXT_BASE           0x17800000
 
-#ifdef CONFIG_SUPPORT_EMMC_BOOT
-#define EMMC_ENV \
-	"emmcdev=2\0" \
-	"update_emmc_firmware=" \
-		"if test ${ip_dyn} = yes; then " \
-			"setenv get_cmd dhcp; " \
-		"else " \
-			"setenv get_cmd tftp; " \
-		"fi; " \
-		"if ${get_cmd} ${update_sd_firmware_filename}; then " \
-			"if mmc dev ${emmcdev} && " \
-				"mmc open ${emmcdev} 1; then "	\
-				"setexpr fw_sz ${filesize} / 0x200; " \
-				"setexpr fw_sz ${fw_sz} + 1; "	\
-				"mmc write ${loadaddr} 0x2 ${fw_sz}; " \
-				"mmc close ${emmcdev} 1; " \
-			"fi; "	\
-		"fi\0"
-#else
-#define EMMC_ENV ""
-#endif
-
-#define CONFIG_EXTRA_ENV_SETTINGS \
-	"script=boot.scr\0" \
-	"image=zImage\0" \
-	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
+#define CONFIG_PREFIX_IMAGE "z" 
+#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \
+	"fdt_high=0xffffffff\0" \
+	"initrd_high=0xffffffff\0" \
 	"fdt_addr=0x18000000\0" \
 	"boot_fdt=try\0" \
-	"ip_dyn=yes\0" \
-	"console=" CONFIG_CONSOLE_DEV "\0" \
-	"fdt_high=0xffffffff\0"	  \
-	"initrd_high=0xffffffff\0" \
-	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
 	"mmcpart=1\0" \
-	"mmcroot=" CONFIG_MMCROOT " rootwait rw\0" \
-	"update_sd_firmware=" \
-		"if test ${ip_dyn} = yes; then " \
-			"setenv get_cmd dhcp; " \
-		"else " \
-			"setenv get_cmd tftp; " \
-		"fi; " \
-		"if mmc dev ${mmcdev}; then "	\
-			"if ${get_cmd} ${update_sd_firmware_filename}; then " \
-				"setexpr fw_sz ${filesize} / 0x200; " \
-				"setexpr fw_sz ${fw_sz} + 1; "	\
-				"mmc write ${loadaddr} 0x2 ${fw_sz}; " \
-			"fi; "	\
-		"fi\0" \
-	EMMC_ENV	  \
-	"mmcargs=setenv bootargs console=${console},${baudrate} " \
-		"root=${mmcroot}\0" \
-	"loadbootscript=" \
-		"fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
-	"bootscript=echo Running bootscript from mmc ...; " \
-		"source\0" \
-	"loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
-	"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
-	"mmcboot=echo Booting from mmc ...; " \
-		"run mmcargs; " \
-		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-			"if run loadfdt; then " \
-				"bootz ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"if test ${boot_fdt} = try; then " \
-					"bootz; " \
-				"else " \
-					"echo WARN: Cannot load the DT; " \
-				"fi; " \
-			"fi; " \
-		"else " \
-			"bootz; " \
-		"fi;\0" \
-	"netargs=setenv bootargs console=${console},${baudrate} " \
-		"root=/dev/nfs " \
-		"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
-	"netboot=echo Booting from net ...; " \
-		"run netargs; " \
-		"if test ${ip_dyn} = yes; then " \
-			"setenv get_cmd dhcp; " \
-		"else " \
-			"setenv get_cmd tftp; " \
-		"fi; " \
-		"${get_cmd} ${image}; " \
-		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-			"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
-				"bootz ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"if test ${boot_fdt} = try; then " \
-					"bootz; " \
-				"else " \
-					"echo WARN: Cannot load the DT; " \
-				"fi; " \
-			"fi; " \
-		"else " \
-			"bootz; " \
-		"fi;\0"
-
-#define CONFIG_BOOTCOMMAND \
-	"mmc dev ${mmcdev};" \
-	"if mmc rescan; then " \
-		"if run loadbootscript; then " \
-		"run bootscript; " \
-		"else " \
-			"if run loadimage; then " \
-				"run mmcboot; " \
-			"else run netboot; " \
-			"fi; " \
-		"fi; " \
-	"else run netboot; fi"
+	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0"
+
+#include <configs/default_env.h>
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	CONFIG_COMMON_SCRIPTS \
+	CONFIG_BOARD_EXTRA_ENV_SETTINGS \
+	EMMC_ENV \
+	CONFIG_BOOTCOMMAND
+
 
 #define CONFIG_ARP_TIMEOUT     200UL
 
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index a6d5582..3951485 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -120,9 +120,6 @@ 
 
 #define CONFIG_BOOTARGS ""
 
-#define CONFIG_EXTRA_ENV_SETTINGS	"stdin=serial\0" \
-					"stdout=serial\0" \
-					"stderr=serial\0"
 
 #define CONFIG_GZIP_COMPRESSED
 #define CONFIG_BZIP2
@@ -131,4 +128,31 @@ 
 
 #define CONFIG_TPM_TIS_SANDBOX
 
+#include <configs/default_env.h>
+
+#define CONFIG_CONSOLE_DEV	"ttymxc1"
+#define CONFIG_MMCROOT	"/dev/mmcblk0p1" 
+#define CONFIG_SYS_MMC_ENV_DEV 0
+#define CONFIG_PREFIX_IMAGE
+
+#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \
+	"stdin=serial\0" \
+	"stdout=serial\0" \
+	"stderr=serial\0" \
+	"console=ttymxc1\0" \
+	"fdt_high=0xffffffff\0" \
+	"initrd_high=0xffffffff\0" \
+	"fdt_addr=0x18000000\0" \
+	"boot_fdt=try\0" \
+	"mmcdev=1\0" \
+	"mmcpart=1\0"
+
+#include <configs/default_env.h>
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	CONFIG_BOARD_EXTRA_ENV_SETTINGS \
+	CONFIG_COMMON_SCRIPTS \
+	CONFIG_BOOTCOMMAND
+
+
 #endif
diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h
index 3488472..85c9807 100644
--- a/include/configs/wandboard.h
+++ b/include/configs/wandboard.h
@@ -106,93 +106,24 @@ 
 #define CONFIG_DEFAULT_FDT_FILE		"imx6q-wandboard.dtb"
 #endif
 
-#define CONFIG_EXTRA_ENV_SETTINGS \
-	"script=boot.scr\0" \
-	"image=zImage\0" \
-	"console=ttymxc0\0" \
-	"splashpos=m,m\0" \
+
+#define CONFIG_PREFIX_IMAGE "z"
+#define CONFIG_MMCROOT	"/dev/mmcblk0p1"
+#define CONFIG_CONSOLE_DEV "ttymxc0"
+
+#define CONFIG_BOARD_EXTRA_ENV_SETTINGS \
 	"fdt_high=0xffffffff\0" \
 	"initrd_high=0xffffffff\0" \
-	"fdt_file=" CONFIG_DEFAULT_FDT_FILE "\0" \
 	"fdt_addr=0x18000000\0" \
 	"boot_fdt=try\0" \
-	"ip_dyn=yes\0" \
-	"mmcdev=" __stringify(CONFIG_SYS_MMC_ENV_DEV) "\0" \
-	"mmcpart=1\0" \
-	"mmcroot=/dev/mmcblk0p2 rootwait rw\0" \
-	"update_sd_firmware_filename=u-boot.imx\0" \
-	"update_sd_firmware=" \
-		"if test ${ip_dyn} = yes; then " \
-			"setenv get_cmd dhcp; " \
-		"else " \
-			"setenv get_cmd tftp; " \
-		"fi; " \
-		"if mmc dev ${mmcdev}; then "	\
-			"if ${get_cmd} ${update_sd_firmware_filename}; then " \
-				"setexpr fw_sz ${filesize} / 0x200; " \
-				"setexpr fw_sz ${fw_sz} + 1; "	\
-				"mmc write ${loadaddr} 0x2 ${fw_sz}; " \
-			"fi; "	\
-		"fi\0" \
-	"mmcargs=setenv bootargs console=${console},${baudrate} " \
-		"root=${mmcroot}\0" \
-	"loadbootscript=" \
-		"fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${script};\0" \
-	"bootscript=echo Running bootscript from mmc ...; " \
-		"source\0" \
-	"loadimage=fatload mmc ${mmcdev}:${mmcpart} ${loadaddr} ${image}\0" \
-	"loadfdt=fatload mmc ${mmcdev}:${mmcpart} ${fdt_addr} ${fdt_file}\0" \
-	"mmcboot=echo Booting from mmc ...; " \
-		"run mmcargs; " \
-		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-			"if run loadfdt; then " \
-				"bootz ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"if test ${boot_fdt} = try; then " \
-					"bootz; " \
-				"else " \
-					"echo WARN: Cannot load the DT; " \
-				"fi; " \
-			"fi; " \
-		"else " \
-			"bootz; " \
-		"fi;\0" \
-	"netargs=setenv bootargs console=${console},${baudrate} " \
-		"root=/dev/nfs " \
-	"ip=dhcp nfsroot=${serverip}:${nfsroot},v3,tcp\0" \
-		"netboot=echo Booting from net ...; " \
-		"run netargs; " \
-		"if test ${ip_dyn} = yes; then " \
-			"setenv get_cmd dhcp; " \
-		"else " \
-			"setenv get_cmd tftp; " \
-		"fi; " \
-		"${get_cmd} ${image}; " \
-		"if test ${boot_fdt} = yes || test ${boot_fdt} = try; then " \
-			"if ${get_cmd} ${fdt_addr} ${fdt_file}; then " \
-				"bootz ${loadaddr} - ${fdt_addr}; " \
-			"else " \
-				"if test ${boot_fdt} = try; then " \
-					"bootz; " \
-				"else " \
-					"echo WARN: Cannot load the DT; " \
-				"fi; " \
-			"fi; " \
-		"else " \
-			"bootz; " \
-		"fi;\0"
-
-#define CONFIG_BOOTCOMMAND \
-	   "mmc dev ${mmcdev}; if mmc rescan; then " \
-		   "if run loadbootscript; then " \
-			   "run bootscript; " \
-		   "else " \
-			   "if run loadimage; then " \
-				   "run mmcboot; " \
-			   "else run netboot; " \
-			   "fi; " \
-		   "fi; " \
-	   "else run netboot; fi"
+	"mmcpart=1\0"
+
+#include <configs/default_env.h>
+
+#define CONFIG_EXTRA_ENV_SETTINGS \
+	CONFIG_BOARD_EXTRA_ENV_SETTINGS \
+	CONFIG_COMMON_SCRIPTS \
+	CONFIG_BOOTCOMMAND
 
 /* Miscellaneous configurable options */
 #define CONFIG_SYS_LONGHELP