[U-Boot] [PATCH] nitrogen6x : Use generic distro configuration
Fabien Lahoudere
fabien.lahoudere at collabora.co.uk
Tue Jun 28 17:37:55 CEST 2016
On 28/06/16 12:58, Sjoerd Simons wrote:
> On Fri, 2016-06-24 at 17:59 +0200, Fabien Lahoudere wrote:
>> In order to simplify the use of various images on various media
>> for nitrogen6x, the configuration of the board must follow the
>> generic distro configuration (doc/README.distro).
>>
>> In order to boot your old rootfs, move your kernel and your device
>> tree in /boot/. Then create /boot/extlinux/extlinux.conf with for
>> example:
>>
>> default Buildroot
>>
>> label Buildroot
>> kernel /boot/zImage
>> append console=ttymxc1,115200 root=/dev/mmcblk0p1 rootwait rw
>> fdtdir /boot
>>
>> Signed-off-by: Fabien Lahoudere <fabien.lahoudere at collabora.co.uk>
>> ---
>>
>> diff --git a/include/configs/mx6_common.h
>> b/include/configs/mx6_common.h
>> index fb49322..75cbc84 100644
>> --- a/include/configs/mx6_common.h
>> +++ b/include/configs/mx6_common.h
>> @@ -58,6 +58,12 @@
>> #endif
>> #endif
>> #define CONFIG_SYS_LOAD_ADDR CONFIG_LOADADDR
>> +#ifndef CONFIG_FDTADDR
>> +#define CONFIG_FDTADDR 0x18000000
>> +#endif
>> +#ifndef CONFIG_RAMDISKADDR
>> +#define CONFIG_RAMDISKADDR 0x13000000
>> +#endif
>>
>> /* allow to overwrite serial and ethaddr */
>> #define CONFIG_ENV_OVERWRITE
>> @@ -93,4 +99,26 @@
>> #define CONFIG_CMD_FUSE
>> #define CONFIG_MXC_OCOTP
>>
>> +#ifdef CONFIG_DISTRO_DEFAULTS
>> +#include <config_distro_defaults.h>
>
> Why a configure option for using the default distro options rather then
> just always using them?
>
> Note that you can use the defaults without enforcing distro_bootcmd
> usage. (Though it would be good to get some consistent boot setup on
> all the mx6 devices ofcourse)
Because #include <config_distro_defaults.h> need
CONFIG_DISTRO_DEFAULTS=y else it does not compile.
And keeping this configure option will let the end user chose u-boot
behaviour without having an heavy env.
>
>> +#ifndef CONFIG_FDTFILE
>> +#define CONFIG_FDTFILE "undefined"
>> +#endif
>
> Not having an fdt is bad when using distro boot commands, probably
> better to error here.
>
Ok. I agree and I will fix this.
>> +#include <config_distro_bootcmd.h>
>> +
>> +#define CONFIG_EXTRA_ENV_SETTINGS \
>> + "fdtfile=" CONFIG_FDTFILE "\0" \
>> + "fdt_addr_r=" __stringify(CONFIG_FDTADDR) "\0" \
>> + "fdt_addr=" __stringify(CONFIG_FDTADDR) "\0" \
>> + "kernel_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \
>> + "pxefile_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \
>> + "scriptaddr=" __stringify(CONFIG_LOADADDR) "\0" \
>> + "ramdisk_addr_r=" __stringify(CONFIG_RAMDISKADDR) "\0" \
>> + "ramdiskaddr=" __stringify(CONFIG_RAMDISKADDR) "\0" \
>> + BOOTENV
>> +
>> +#endif
>> +
>> #endif
>> diff --git a/include/configs/nitrogen6x.h
>> b/include/configs/nitrogen6x.h
>> index b651eb3..33658b0 100644
>> --- a/include/configs/nitrogen6x.h
>> +++ b/include/configs/nitrogen6x.h
>> @@ -10,8 +10,6 @@
>> #ifndef __CONFIG_H
>> #define __CONFIG_H
>>
>> -#include "mx6_common.h"
>> -
>> #define CONFIG_MACH_TYPE 3769
>>
>> /* Size of malloc() pool */
>> @@ -38,9 +36,9 @@
>> /* I2C Configs */
>> #define CONFIG_SYS_I2C
>> #define CONFIG_SYS_I2C_MXC
>> -#define CONFIG_SYS_I2C_MXC_I2C1 /* enable I2C bus 1
>> */
>> -#define CONFIG_SYS_I2C_MXC_I2C2 /* enable I2C bus 2
>> */
>> -#define CONFIG_SYS_I2C_MXC_I2C3 /* enable I2C bus 3
>> */
>> +#define CONFIG_SYS_I2C_MXC_I2C1 /* enable I2C bus 1 */
>> +#define CONFIG_SYS_I2C_MXC_I2C2 /* enable I2C bus 2 */
>> +#define CONFIG_SYS_I2C_MXC_I2C3 /* enable I2C bus 3 */
>> #define CONFIG_SYS_I2C_SPEED 100000
>> #define CONFIG_I2C_EDID
>>
>> @@ -113,159 +111,22 @@
>>
>> #define CONFIG_PREBOOT ""
>>
>> -#ifdef CONFIG_CMD_SATA
>> -#define CONFIG_DRIVE_SATA "sata "
>> -#else
>> -#define CONFIG_DRIVE_SATA
>> -#endif
>> -
>> -#ifdef CONFIG_CMD_MMC
>> -#define CONFIG_DRIVE_MMC "mmc "
>> -#else
>> -#define CONFIG_DRIVE_MMC
>> -#endif
>> -
>> -#ifdef CONFIG_USB_STORAGE
>> -#define CONFIG_DRIVE_USB "usb "
>> +#if defined(CONFIG_SABRELITE)
>> +#define CONFIG_FDTFILE "imx6q-sabrelite.dtb"
>> #else
>> -#define CONFIG_DRIVE_USB
>> +#define CONFIG_FDTFILE "imx6q-nitrogen6x.dtb"
>> #endif
>>
>> -#define CONFIG_DRIVE_TYPES CONFIG_DRIVE_SATA CONFIG_DRIVE_MMC
>> CONFIG_DRIVE_USB
>> -#define CONFIG_UMSDEVS CONFIG_DRIVE_SATA CONFIG_DRIVE_MMC
>> -
>> -#if defined(CONFIG_SABRELITE)
>> -#define CONFIG_EXTRA_ENV_SETTINGS \
>> - "script=boot.scr\0" \
>> - "uimage=uImage\0" \
>> - "console=ttymxc1\0" \
>> - "fdt_high=0xffffffff\0" \
>> - "initrd_high=0xffffffff\0" \
>> - "fdt_file=imx6q-sabrelite.dtb\0" \
>> - "fdt_addr=0x18000000\0" \
>> - "boot_fdt=try\0" \
>> - "ip_dyn=yes\0" \
>> - "mmcdevs=0 1\0" \
>> - "mmcpart=1\0" \
>> - "mmcroot=/dev/mmcblk0p2 rootwait rw\0" \
>> - "mmcargs=setenv bootargs console=${console},${baudrate} " \
>> - "root=${mmcroot}\0" \
>> - "loadbootscript=" \
>> - "load mmc ${mmcdev}:${mmcpart} ${loadaddr}
>> ${script};\0" \
>> - "bootscript=echo Running bootscript from mmc ...; " \
>> - "source\0" \
>> - "loaduimage=load mmc ${mmcdev}:${mmcpart} ${loadaddr}
>> ${uimage}\0" \
>> - "loadfdt=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 " \
>> - "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 ...; " \
>> - "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 || test ${boot_fdt} =
>> try; 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 BOOT_TARGET_DEVICES(func) \
>> + func(MMC, mmc, 0) \
>> + func(MMC, mmc, 1) \
>> + func(SATA, sata, 0) \
>> + func(USB, usb, 0) \
>> + func(PXE, pxe, na) \
>> + func(DHCP, dhcp, na)
>
> You probably don't want to toss out all the legacy boot stuff. See
> commit bc3199fd1875f89e9e1fb2af45665c4a718217b9 for an example of how
> to integrate older hardcoded boot commands with the distro boot
> commands.
>
> Do take special care about the ordering, It's probably undesirable to
> have attempts for network booting happening before e.g. trying to do an
> upgrade.
>
Yes I see the commit but the problem with the nitrogen6x.h is that there
is two different env. So if we add LEGACY_MMC, we need to redefine
mmcboot depending on what board is used. The goal is to simplify so I
prefer not to add this legacy stuff.
I you think it is mandatory, I can add it and redefine mmcboot if necessary.
More information about the U-Boot
mailing list