[U-Boot] [RFC] try to merge different i.MX environment
Otavio Salvador
otavio at ossystems.com.br
Fri Feb 14 16:24:33 CET 2014
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 at denx.de> wrote:
> Signed-off-by: Stefano Babic <sbabic at denx.de>
> CC: Fabio Estevam <fabio.estevam at freescale.com>
> CC: Otavio Salvador <otavio at ossystems.com.br>
> CC: Marek Vasut <marex at denx.de>
> CC: Leo Sartre <lsartre at adeneo-embedded.com>
> CC: Jon Nettleton <jon.nettleton at gmail.com>
> CC: Eric Nelson <eric.nelson at boundarydevices.com>
> CC: b18965 at 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,
--
Otavio Salvador O.S. Systems
http://www.ossystems.com.br http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750
More information about the U-Boot
mailing list