diff mbox

[U-Boot,3/7] sunxi: Enable UBI and NAND support

Message ID 6c44b7aa93af6ffd76d4d0bee5713f087e082c62.1478621974.git-series.maxime.ripard@free-electrons.com
State Superseded
Delegated to: Hans de Goede
Headers show

Commit Message

Maxime Ripard Nov. 8, 2016, 4:21 p.m. UTC
From: Hans de Goede <hdegoede@redhat.com>

Enable the NAND and UBI support in the configuration header so that we can
(finally) use it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
---
 include/configs/sunxi-common.h | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

Comments

Boris Brezillon Nov. 8, 2016, 4:27 p.m. UTC | #1
On Tue,  8 Nov 2016 17:21:13 +0100
Maxime Ripard <maxime.ripard@free-electrons.com> wrote:

> From: Hans de Goede <hdegoede@redhat.com>
> 
> Enable the NAND and UBI support in the configuration header so that we can
> (finally) use it.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  include/configs/sunxi-common.h | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 8363414828fa..1733767ba53b 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -129,9 +129,23 @@
>  #define CONFIG_SERIAL_TAG
>  
>  #ifdef CONFIG_NAND_SUNXI
> +#define CONFIG_SYS_NAND_U_BOOT_OFFS	(8 << 20) /* 8 MiB */


>  #define CONFIG_SYS_NAND_MAX_ECCPOS 1664
>  #define CONFIG_SYS_NAND_ONFI_DETECTION
>  #define CONFIG_SYS_MAX_NAND_DEVICE 8
> +
> +/* Requirements for UBI */
> +#define CONFIG_RBTREE
> +#define CONFIG_LZO
> +#define CONFIG_CMD_MTDPARTS
> +#define CONFIG_CMD_UBI
> +#define CONFIG_CMD_UBIFS
> +#define CONFIG_MTD_DEVICE
> +
> +#define CONFIG_MTD_PARTITIONS
> +
> +#define CONFIG_CMD_NAND
> +#define CONFIG_CMD_NAND_TRIMFFS
>  #endif
>  
>  #ifdef CONFIG_SPL_SPI_SUNXI
> @@ -143,7 +157,14 @@
>  #define CONFIG_GENERIC_MMC
>  #define CONFIG_MMC_SUNXI
>  #define CONFIG_MMC_SUNXI_SLOT		0
> -#define CONFIG_ENV_IS_IN_MMC
> +#endif
> +
> +#if defined(CONFIG_ENV_IS_IN_NAND)
> +#define CONFIG_ENV_OFFSET			0xc00000
> +#define CONFIG_ENV_SIZE				0x400000
> +#elif defined(CONFIG_ENV_IS_IN_MMC)
> +#define CONFIG_ENV_OFFSET			(544 << 10) /* (8 + 24 + 512) KiB */
> +#define CONFIG_ENV_SIZE				(128 << 10) /* 128 KiB */
>  #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
>  #endif
>  
> @@ -175,9 +196,6 @@
>  
>  #define CONFIG_SYS_MONITOR_LEN		(768 << 10)	/* 768 KiB */
>  
> -#define CONFIG_ENV_OFFSET		(544 << 10) /* (8 + 24 + 512) KiB */
> -#define CONFIG_ENV_SIZE			(128 << 10)	/* 128 KiB */
> -
>  #define CONFIG_FAT_WRITE	/* enable write access */
>  
>  #define CONFIG_SPL_FRAMEWORK
Boris Brezillon Nov. 8, 2016, 4:27 p.m. UTC | #2
On Tue,  8 Nov 2016 17:21:13 +0100
Maxime Ripard <maxime.ripard@free-electrons.com> wrote:

> From: Hans de Goede <hdegoede@redhat.com>
> 
> Enable the NAND and UBI support in the configuration header so that we can
> (finally) use it.
> 
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  include/configs/sunxi-common.h | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
> 
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 8363414828fa..1733767ba53b 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -129,9 +129,23 @@
>  #define CONFIG_SERIAL_TAG
>  
>  #ifdef CONFIG_NAND_SUNXI
> +#define CONFIG_SYS_NAND_U_BOOT_OFFS	(8 << 20) /* 8 MiB */

Can we make this configurable through Kconfig?

>  #define CONFIG_SYS_NAND_MAX_ECCPOS 1664
>  #define CONFIG_SYS_NAND_ONFI_DETECTION
>  #define CONFIG_SYS_MAX_NAND_DEVICE 8
> +
> +/* Requirements for UBI */
> +#define CONFIG_RBTREE
> +#define CONFIG_LZO
> +#define CONFIG_CMD_MTDPARTS
> +#define CONFIG_CMD_UBI
> +#define CONFIG_CMD_UBIFS
> +#define CONFIG_MTD_DEVICE
> +
> +#define CONFIG_MTD_PARTITIONS
> +
> +#define CONFIG_CMD_NAND
> +#define CONFIG_CMD_NAND_TRIMFFS
>  #endif
>  
>  #ifdef CONFIG_SPL_SPI_SUNXI
> @@ -143,7 +157,14 @@
>  #define CONFIG_GENERIC_MMC
>  #define CONFIG_MMC_SUNXI
>  #define CONFIG_MMC_SUNXI_SLOT		0
> -#define CONFIG_ENV_IS_IN_MMC
> +#endif
> +
> +#if defined(CONFIG_ENV_IS_IN_NAND)
> +#define CONFIG_ENV_OFFSET			0xc00000
> +#define CONFIG_ENV_SIZE				0x400000

Ditto.

> +#elif defined(CONFIG_ENV_IS_IN_MMC)
> +#define CONFIG_ENV_OFFSET			(544 << 10) /* (8 + 24 + 512) KiB */
> +#define CONFIG_ENV_SIZE				(128 << 10) /* 128 KiB */
>  #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
>  #endif
>  
> @@ -175,9 +196,6 @@
>  
>  #define CONFIG_SYS_MONITOR_LEN		(768 << 10)	/* 768 KiB */
>  
> -#define CONFIG_ENV_OFFSET		(544 << 10) /* (8 + 24 + 512) KiB */
> -#define CONFIG_ENV_SIZE			(128 << 10)	/* 128 KiB */
> -
>  #define CONFIG_FAT_WRITE	/* enable write access */
>  
>  #define CONFIG_SPL_FRAMEWORK
Maxime Ripard Nov. 9, 2016, 2:32 p.m. UTC | #3
Hi Boris,

On Tue, Nov 08, 2016 at 05:27:48PM +0100, Boris Brezillon wrote:
> On Tue,  8 Nov 2016 17:21:13 +0100
> Maxime Ripard <maxime.ripard@free-electrons.com> wrote:
> 
> > From: Hans de Goede <hdegoede@redhat.com>
> > 
> > Enable the NAND and UBI support in the configuration header so that we can
> > (finally) use it.
> > 
> > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > ---
> >  include/configs/sunxi-common.h | 26 ++++++++++++++++++++++----
> >  1 file changed, 22 insertions(+), 4 deletions(-)
> > 
> > diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> > index 8363414828fa..1733767ba53b 100644
> > --- a/include/configs/sunxi-common.h
> > +++ b/include/configs/sunxi-common.h
> > @@ -129,9 +129,23 @@
> >  #define CONFIG_SERIAL_TAG
> >  
> >  #ifdef CONFIG_NAND_SUNXI
> > +#define CONFIG_SYS_NAND_U_BOOT_OFFS	(8 << 20) /* 8 MiB */
> 
> Can we make this configurable through Kconfig?

Is there a need for that? AFAIK, everyone in U-Boot defines it there
(and converting everyone to Kconfig for all the CONFIG_SYS_NAND
options is going to be painful).

Thanks!
Maxime
Boris Brezillon Nov. 9, 2016, 2:57 p.m. UTC | #4
On Wed, 9 Nov 2016 15:32:37 +0100
Maxime Ripard <maxime.ripard@free-electrons.com> wrote:

> Hi Boris,
> 
> On Tue, Nov 08, 2016 at 05:27:48PM +0100, Boris Brezillon wrote:
> > On Tue,  8 Nov 2016 17:21:13 +0100
> > Maxime Ripard <maxime.ripard@free-electrons.com> wrote:
> >   
> > > From: Hans de Goede <hdegoede@redhat.com>
> > > 
> > > Enable the NAND and UBI support in the configuration header so that we can
> > > (finally) use it.
> > > 
> > > Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> > > Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> > > ---
> > >  include/configs/sunxi-common.h | 26 ++++++++++++++++++++++----
> > >  1 file changed, 22 insertions(+), 4 deletions(-)
> > > 
> > > diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> > > index 8363414828fa..1733767ba53b 100644
> > > --- a/include/configs/sunxi-common.h
> > > +++ b/include/configs/sunxi-common.h
> > > @@ -129,9 +129,23 @@
> > >  #define CONFIG_SERIAL_TAG
> > >  
> > >  #ifdef CONFIG_NAND_SUNXI
> > > +#define CONFIG_SYS_NAND_U_BOOT_OFFS	(8 << 20) /* 8 MiB */  
> > 
> > Can we make this configurable through Kconfig?  
> 
> Is there a need for that?

Yes, I think so, since each board has a different kind of NAND (with
possibly different eraseblock size) and I'm not sure this is always
acceptable to lose 8MiB of storage for the SPL images (especially for
small SLC NANDs).

> AFAIK, everyone in U-Boot defines it there
> (and converting everyone to Kconfig for all the CONFIG_SYS_NAND
> options is going to be painful).

It already exists: enable the SYS_NAND_U_BOOT_LOCATIONS Kconfig
option, and you should see the SYS_NAND_U_BOOT_OFFS and
SYS_NAND_U_BOOT_OFFS_REDUND ones.

> 
> Thanks!
> Maxime
>
Hans de Goede Nov. 14, 2016, 11:18 a.m. UTC | #5
Hi,

On 08-11-16 17:21, Maxime Ripard wrote:
> From: Hans de Goede <hdegoede@redhat.com>
>
> Enable the NAND and UBI support in the configuration header so that we can
> (finally) use it.
>
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
> ---
>  include/configs/sunxi-common.h | 26 ++++++++++++++++++++++----
>  1 file changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 8363414828fa..1733767ba53b 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -129,9 +129,23 @@
>  #define CONFIG_SERIAL_TAG
>
>  #ifdef CONFIG_NAND_SUNXI
> +#define CONFIG_SYS_NAND_U_BOOT_OFFS	(8 << 20) /* 8 MiB */

As Boris already said, please put this in Kconfig.

>  #define CONFIG_SYS_NAND_MAX_ECCPOS 1664
>  #define CONFIG_SYS_NAND_ONFI_DETECTION
>  #define CONFIG_SYS_MAX_NAND_DEVICE 8
> +
> +/* Requirements for UBI */
> +#define CONFIG_RBTREE
> +#define CONFIG_LZO
> +#define CONFIG_CMD_MTDPARTS
> +#define CONFIG_CMD_UBI
> +#define CONFIG_CMD_UBIFS
> +#define CONFIG_MTD_DEVICE
> +
> +#define CONFIG_MTD_PARTITIONS
> +
> +#define CONFIG_CMD_NAND
> +#define CONFIG_CMD_NAND_TRIMFFS
>  #endif
>
>  #ifdef CONFIG_SPL_SPI_SUNXI
> @@ -143,7 +157,14 @@
>  #define CONFIG_GENERIC_MMC
>  #define CONFIG_MMC_SUNXI
>  #define CONFIG_MMC_SUNXI_SLOT		0
> -#define CONFIG_ENV_IS_IN_MMC
> +#endif
> +
> +#if defined(CONFIG_ENV_IS_IN_NAND)
> +#define CONFIG_ENV_OFFSET			0xc00000
> +#define CONFIG_ENV_SIZE				0x400000
> +#elif defined(CONFIG_ENV_IS_IN_MMC)
> +#define CONFIG_ENV_OFFSET			(544 << 10) /* (8 + 24 + 512) KiB */
> +#define CONFIG_ENV_SIZE				(128 << 10) /* 128 KiB */
>  #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
>  #endif
>

I would greatly prefer putting the env in an UBI partition,
I thought that we had agreed on doing that ?

Regards,

Hans



> @@ -175,9 +196,6 @@
>
>  #define CONFIG_SYS_MONITOR_LEN		(768 << 10)	/* 768 KiB */
>
> -#define CONFIG_ENV_OFFSET		(544 << 10) /* (8 + 24 + 512) KiB */
> -#define CONFIG_ENV_SIZE			(128 << 10)	/* 128 KiB */
> -
>  #define CONFIG_FAT_WRITE	/* enable write access */
>
>  #define CONFIG_SPL_FRAMEWORK
>
Maxime Ripard Nov. 14, 2016, 2:09 p.m. UTC | #6
Hi,

On Mon, Nov 14, 2016 at 12:18:06PM +0100, Hans de Goede wrote:
> >  #ifdef CONFIG_SPL_SPI_SUNXI
> > @@ -143,7 +157,14 @@
> >  #define CONFIG_GENERIC_MMC
> >  #define CONFIG_MMC_SUNXI
> >  #define CONFIG_MMC_SUNXI_SLOT		0
> > -#define CONFIG_ENV_IS_IN_MMC
> > +#endif
> > +
> > +#if defined(CONFIG_ENV_IS_IN_NAND)
> > +#define CONFIG_ENV_OFFSET			0xc00000
> > +#define CONFIG_ENV_SIZE				0x400000
> > +#elif defined(CONFIG_ENV_IS_IN_MMC)
> > +#define CONFIG_ENV_OFFSET			(544 << 10) /* (8 + 24 + 512) KiB */
> > +#define CONFIG_ENV_SIZE				(128 << 10) /* 128 KiB */
> >  #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
> >  #endif
> > 
> 
> I would greatly prefer putting the env in an UBI partition,
> I thought that we had agreed on doing that ?

That was mentionned a few times, but I didn't remember having a final
decision. I'm not really sure that putting the environment in UBI
would be a good idea.

Attaching the UBI volume takes a very significant time. Doing so
before the user can see that something is happening in the system
feels pretty bad.

Maxime
Hans de Goede Nov. 14, 2016, 2:12 p.m. UTC | #7
Hi,

On 14-11-16 15:09, Maxime Ripard wrote:
> Hi,
>
> On Mon, Nov 14, 2016 at 12:18:06PM +0100, Hans de Goede wrote:
>>>  #ifdef CONFIG_SPL_SPI_SUNXI
>>> @@ -143,7 +157,14 @@
>>>  #define CONFIG_GENERIC_MMC
>>>  #define CONFIG_MMC_SUNXI
>>>  #define CONFIG_MMC_SUNXI_SLOT		0
>>> -#define CONFIG_ENV_IS_IN_MMC
>>> +#endif
>>> +
>>> +#if defined(CONFIG_ENV_IS_IN_NAND)
>>> +#define CONFIG_ENV_OFFSET			0xc00000
>>> +#define CONFIG_ENV_SIZE				0x400000
>>> +#elif defined(CONFIG_ENV_IS_IN_MMC)
>>> +#define CONFIG_ENV_OFFSET			(544 << 10) /* (8 + 24 + 512) KiB */
>>> +#define CONFIG_ENV_SIZE				(128 << 10) /* 128 KiB */
>>>  #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
>>>  #endif
>>>
>>
>> I would greatly prefer putting the env in an UBI partition,
>> I thought that we had agreed on doing that ?
>
> That was mentionned a few times, but I didn't remember having a final
> decision. I'm not really sure that putting the environment in UBI
> would be a good idea.
>
> Attaching the UBI volume takes a very significant time. Doing so
> before the user can see that something is happening in the system
> feels pretty bad.

So maybe we need to print a message before doing so ?

We really need bad-block management for the environment, AFAICT
the current non UBI implementation does not even have a backup ?

Regards,

Hans
Maxime Ripard Nov. 14, 2016, 2:12 p.m. UTC | #8
On Mon, Nov 14, 2016 at 12:18:06PM +0100, Hans de Goede wrote:
> >  #ifdef CONFIG_SPL_SPI_SUNXI
> > @@ -143,7 +157,14 @@
> >  #define CONFIG_GENERIC_MMC
> >  #define CONFIG_MMC_SUNXI
> >  #define CONFIG_MMC_SUNXI_SLOT		0
> > -#define CONFIG_ENV_IS_IN_MMC
> > +#endif
> > +
> > +#if defined(CONFIG_ENV_IS_IN_NAND)
> > +#define CONFIG_ENV_OFFSET			0xc00000
> > +#define CONFIG_ENV_SIZE				0x400000
> > +#elif defined(CONFIG_ENV_IS_IN_MMC)
> > +#define CONFIG_ENV_OFFSET			(544 << 10) /* (8 + 24 + 512) KiB */
> > +#define CONFIG_ENV_SIZE				(128 << 10) /* 128 KiB */
> >  #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
> >  #endif

Oh, and this part is broken. It relies on the fact that all board
define ENV_IS_IN_MMC (which they should), while obviously they
don't. I'm not exactly sure about what the proper fix would be.

Maxime
Hans de Goede Nov. 14, 2016, 2:21 p.m. UTC | #9
Hi,

On 14-11-16 15:12, Maxime Ripard wrote:
> On Mon, Nov 14, 2016 at 12:18:06PM +0100, Hans de Goede wrote:
>>>  #ifdef CONFIG_SPL_SPI_SUNXI
>>> @@ -143,7 +157,14 @@
>>>  #define CONFIG_GENERIC_MMC
>>>  #define CONFIG_MMC_SUNXI
>>>  #define CONFIG_MMC_SUNXI_SLOT		0
>>> -#define CONFIG_ENV_IS_IN_MMC
>>> +#endif
>>> +
>>> +#if defined(CONFIG_ENV_IS_IN_NAND)
>>> +#define CONFIG_ENV_OFFSET			0xc00000
>>> +#define CONFIG_ENV_SIZE				0x400000
>>> +#elif defined(CONFIG_ENV_IS_IN_MMC)
>>> +#define CONFIG_ENV_OFFSET			(544 << 10) /* (8 + 24 + 512) KiB */
>>> +#define CONFIG_ENV_SIZE				(128 << 10) /* 128 KiB */
>>>  #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
>>>  #endif
>
> Oh, and this part is broken. It relies on the fact that all board
> define ENV_IS_IN_MMC (which they should), while obviously they
> don't. I'm not exactly sure about what the proper fix would be.

Yes, this has been a known problem for a while, but never
became an issue due to lack of NAND support.

My preferred way for dealing with this be would for the
environment code in u-boot allowing to build in multiple
back-ends and use spl_boot_device() which then would need
to loose its spl prefix. For the CHIP devices I'm sure
you can come up with a simpler fix since those don't
have an sdcard-slot. But for other boards this will be
necessary as we really don't want to have separate
nand and mmc u-boot.bin files.

Anyways this is something for whomever will take over
as sunxi custodian from me. Maybe someone from free-electrons
can co-maintain with Jagan ?

Regards,

Hans
Tom Rini Nov. 14, 2016, 5:03 p.m. UTC | #10
On Mon, Nov 14, 2016 at 03:21:41PM +0100, Hans de Goede wrote:
> Hi,
> 
> On 14-11-16 15:12, Maxime Ripard wrote:
> >On Mon, Nov 14, 2016 at 12:18:06PM +0100, Hans de Goede wrote:
> >>> #ifdef CONFIG_SPL_SPI_SUNXI
> >>>@@ -143,7 +157,14 @@
> >>> #define CONFIG_GENERIC_MMC
> >>> #define CONFIG_MMC_SUNXI
> >>> #define CONFIG_MMC_SUNXI_SLOT		0
> >>>-#define CONFIG_ENV_IS_IN_MMC
> >>>+#endif
> >>>+
> >>>+#if defined(CONFIG_ENV_IS_IN_NAND)
> >>>+#define CONFIG_ENV_OFFSET			0xc00000
> >>>+#define CONFIG_ENV_SIZE				0x400000
> >>>+#elif defined(CONFIG_ENV_IS_IN_MMC)
> >>>+#define CONFIG_ENV_OFFSET			(544 << 10) /* (8 + 24 + 512) KiB */
> >>>+#define CONFIG_ENV_SIZE				(128 << 10) /* 128 KiB */
> >>> #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
> >>> #endif
> >
> >Oh, and this part is broken. It relies on the fact that all board
> >define ENV_IS_IN_MMC (which they should), while obviously they
> >don't. I'm not exactly sure about what the proper fix would be.
> 
> Yes, this has been a known problem for a while, but never
> became an issue due to lack of NAND support.
> 
> My preferred way for dealing with this be would for the
> environment code in u-boot allowing to build in multiple
> back-ends and use spl_boot_device() which then would need
> to loose its spl prefix. For the CHIP devices I'm sure
> you can come up with a simpler fix since those don't
> have an sdcard-slot. But for other boards this will be
> necessary as we really don't want to have separate
> nand and mmc u-boot.bin files.
> 
> Anyways this is something for whomever will take over
> as sunxi custodian from me. Maybe someone from free-electrons
> can co-maintain with Jagan ?

I would really like to see the co-maintainer model continue here, if
possible, yes.  Thanks!
Maxime Ripard Nov. 17, 2016, 10:27 p.m. UTC | #11
On Mon, Nov 14, 2016 at 03:21:41PM +0100, Hans de Goede wrote:
> Hi,
> 
> On 14-11-16 15:12, Maxime Ripard wrote:
> > On Mon, Nov 14, 2016 at 12:18:06PM +0100, Hans de Goede wrote:
> > > >  #ifdef CONFIG_SPL_SPI_SUNXI
> > > > @@ -143,7 +157,14 @@
> > > >  #define CONFIG_GENERIC_MMC
> > > >  #define CONFIG_MMC_SUNXI
> > > >  #define CONFIG_MMC_SUNXI_SLOT		0
> > > > -#define CONFIG_ENV_IS_IN_MMC
> > > > +#endif
> > > > +
> > > > +#if defined(CONFIG_ENV_IS_IN_NAND)
> > > > +#define CONFIG_ENV_OFFSET			0xc00000
> > > > +#define CONFIG_ENV_SIZE				0x400000
> > > > +#elif defined(CONFIG_ENV_IS_IN_MMC)
> > > > +#define CONFIG_ENV_OFFSET			(544 << 10) /* (8 + 24 + 512) KiB */
> > > > +#define CONFIG_ENV_SIZE				(128 << 10) /* 128 KiB */
> > > >  #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
> > > >  #endif
> > 
> > Oh, and this part is broken. It relies on the fact that all board
> > define ENV_IS_IN_MMC (which they should), while obviously they
> > don't. I'm not exactly sure about what the proper fix would be.
> 
> Yes, this has been a known problem for a while, but never
> became an issue due to lack of NAND support.
> 
> My preferred way for dealing with this be would for the
> environment code in u-boot allowing to build in multiple
> back-ends and use spl_boot_device() which then would need
> to loose its spl prefix. For the CHIP devices I'm sure
> you can come up with a simpler fix since those don't
> have an sdcard-slot. But for other boards this will be
> necessary as we really don't want to have separate
> nand and mmc u-boot.bin files.

Ack, thanks.

> Anyways this is something for whomever will take over as sunxi
> custodian from me. Maybe someone from free-electrons can co-maintain
> with Jagan ?

Yes, that would make a lot of sense. I'll discuss this internally, and
do the interim while we come up with someone.

Maxime
diff mbox

Patch

diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 8363414828fa..1733767ba53b 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -129,9 +129,23 @@ 
 #define CONFIG_SERIAL_TAG
 
 #ifdef CONFIG_NAND_SUNXI
+#define CONFIG_SYS_NAND_U_BOOT_OFFS	(8 << 20) /* 8 MiB */
 #define CONFIG_SYS_NAND_MAX_ECCPOS 1664
 #define CONFIG_SYS_NAND_ONFI_DETECTION
 #define CONFIG_SYS_MAX_NAND_DEVICE 8
+
+/* Requirements for UBI */
+#define CONFIG_RBTREE
+#define CONFIG_LZO
+#define CONFIG_CMD_MTDPARTS
+#define CONFIG_CMD_UBI
+#define CONFIG_CMD_UBIFS
+#define CONFIG_MTD_DEVICE
+
+#define CONFIG_MTD_PARTITIONS
+
+#define CONFIG_CMD_NAND
+#define CONFIG_CMD_NAND_TRIMFFS
 #endif
 
 #ifdef CONFIG_SPL_SPI_SUNXI
@@ -143,7 +157,14 @@ 
 #define CONFIG_GENERIC_MMC
 #define CONFIG_MMC_SUNXI
 #define CONFIG_MMC_SUNXI_SLOT		0
-#define CONFIG_ENV_IS_IN_MMC
+#endif
+
+#if defined(CONFIG_ENV_IS_IN_NAND)
+#define CONFIG_ENV_OFFSET			0xc00000
+#define CONFIG_ENV_SIZE				0x400000
+#elif defined(CONFIG_ENV_IS_IN_MMC)
+#define CONFIG_ENV_OFFSET			(544 << 10) /* (8 + 24 + 512) KiB */
+#define CONFIG_ENV_SIZE				(128 << 10) /* 128 KiB */
 #define CONFIG_SYS_MMC_ENV_DEV		0	/* first detected MMC controller */
 #endif
 
@@ -175,9 +196,6 @@ 
 
 #define CONFIG_SYS_MONITOR_LEN		(768 << 10)	/* 768 KiB */
 
-#define CONFIG_ENV_OFFSET		(544 << 10) /* (8 + 24 + 512) KiB */
-#define CONFIG_ENV_SIZE			(128 << 10)	/* 128 KiB */
-
 #define CONFIG_FAT_WRITE	/* enable write access */
 
 #define CONFIG_SPL_FRAMEWORK