[U-Boot] [RFC] try to merge different i.MX environment
Stefano Babic
sbabic at denx.de
Sun Feb 16 17:40:53 CET 2014
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
--
=====================================================================
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================
More information about the U-Boot
mailing list