diff mbox

[U-Boot,PATCHv7,6/7] igep00x0: UBIize

Message ID 20160117031603.GG28493@localhost.localdomain
State Awaiting Upstream
Delegated to: Heiko Schocher
Headers show

Commit Message

Ladislav Michl Jan. 17, 2016, 3:16 a.m. UTC
Convert IGEP board to use UBI volumes for U-Boot, its environment and
kernel. With exception of first four sectors read by SoC boot
ROM whole NAND is UBI managed. As code is too big now, drop
CONFIG_SPL_EXT_SUPPORT to make it fit.

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
---
 include/configs/omap3_igep00x0.h | 80 ++++++++++++++++++++++------------------
 1 file changed, 45 insertions(+), 35 deletions(-)

Comments

Heiko Schocher Jan. 21, 2016, 6:07 a.m. UTC | #1
Hello Ladislav,

Am 17.01.2016 um 04:16 schrieb Ladislav Michl:
> Convert IGEP board to use UBI volumes for U-Boot, its environment and
> kernel. With exception of first four sectors read by SoC boot
> ROM whole NAND is UBI managed. As code is too big now, drop
> CONFIG_SPL_EXT_SUPPORT to make it fit.
>
> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
> ---
>   include/configs/omap3_igep00x0.h | 80 ++++++++++++++++++++++------------------
>   1 file changed, 45 insertions(+), 35 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
>
> diff --git a/include/configs/omap3_igep00x0.h b/include/configs/omap3_igep00x0.h
> index 5da6cfd..9afbcbe 100644
> --- a/include/configs/omap3_igep00x0.h
> +++ b/include/configs/omap3_igep00x0.h
> @@ -74,6 +74,8 @@
>   #define CONFIG_CMD_CACHE
>   #ifdef CONFIG_BOOT_ONENAND
>   #define CONFIG_CMD_ONENAND	/* ONENAND support		*/
> +#else
> +#define CONFIG_CMD_UBI
>   #endif
>   #define CONFIG_CMD_DHCP
>   #define CONFIG_CMD_PING
> @@ -86,6 +88,10 @@
>   	"stdout=serial\0" \
>   	"stderr=serial\0"
>
> +#define ENV_MTD_SETTINGS \
> +	"mtdids=nand0=gpmc-nand.0\0" \
> +	"mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
> +
>   #define MEM_LAYOUT_SETTINGS \
>   	DEFAULT_LINUX_BOOT_ENV \
>   	"scriptaddr=0x87E00000\0" \
> @@ -96,36 +102,15 @@
>
>   #include <config_distro_bootcmd.h>
>
> -
>   #define CONFIG_EXTRA_ENV_SETTINGS \
>   	ENV_DEVICE_SETTINGS \
> +	ENV_MTD_SETTINGS \
>   	MEM_LAYOUT_SETTINGS \
>   	BOOTENV
>
>   #endif
>
>   /*
> - * FLASH and environment organization
> - */
> -
> -#ifdef CONFIG_BOOT_ONENAND
> -#define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
> -
> -#define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
> -
> -#define CONFIG_ENV_IS_IN_ONENAND	1
> -#define CONFIG_ENV_SIZE			(512 << 10) /* Total Size Environment */
> -#define CONFIG_ENV_ADDR			ONENAND_ENV_OFFSET
> -#endif
> -
> -#ifdef CONFIG_NAND
> -#define CONFIG_ENV_OFFSET		0x260000 /* environment starts here */
> -#define CONFIG_ENV_IS_IN_NAND	        1
> -#define CONFIG_ENV_SIZE			(512 << 10) /* Total Size Environment */
> -#define CONFIG_ENV_ADDR			NAND_ENV_OFFSET
> -#endif
> -
> -/*
>    * SMSC911x Ethernet
>    */
>   #if defined(CONFIG_CMD_NET)
> @@ -134,19 +119,50 @@
>   #define CONFIG_SMC911X_BASE		0x2C000000
>   #endif /* (CONFIG_CMD_NET) */
>
> +/*
> + * FLASH and environment organization
> + */
> +#ifdef CONFIG_NAND
> +#define CONFIG_SPL_UBI			1
> +#define CONFIG_SPL_UBI_MAX_VOL_LEBS	256
> +#define CONFIG_SPL_UBI_MAX_PEB_SIZE	(256*1024)
> +#define CONFIG_SPL_UBI_MAX_PEBS		4096
> +#define CONFIG_SPL_UBI_VOL_IDS		8
> +#define CONFIG_SPL_UBI_LOAD_MONITOR_ID	0
> +#define CONFIG_SPL_UBI_LOAD_KERNEL_ID	3
> +#define CONFIG_SPL_UBI_LOAD_ARGS_ID	4
> +#define CONFIG_SPL_UBI_PEB_OFFSET	4
> +#define CONFIG_SPL_UBI_VID_OFFSET	512
> +#define CONFIG_SPL_UBI_LEB_START	2048
> +#define CONFIG_SPL_UBI_INFO_ADDR	0x88080000
> +
> +#define CONFIG_ENV_IS_IN_UBI		1
> +#define CONFIG_ENV_UBI_PART		"UBI"
> +#define CONFIG_ENV_UBI_VOLUME		"config"
> +#define CONFIG_ENV_UBI_VOLUME_REDUND	"config_r"
> +#define CONFIG_UBI_SILENCE_MSG		1
> +#define CONFIG_UBIFS_SILENCE_MSG	1
> +#else
> +#define CONFIG_ENV_IS_NOWHERE
> +#endif
> +#define CONFIG_ENV_SIZE			(32*1024)
> +
> +#define CONFIG_RBTREE
> +#define CONFIG_MTD_PARTITIONS
> +#define MTDIDS_DEFAULT			"nand0=gpmc-nand.0"
> +#define MTDPARTS_DEFAULT		"mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
> +
>   /* OneNAND boot config */
>   #ifdef CONFIG_BOOT_ONENAND
>   #define CONFIG_SPL_ONENAND_SUPPORT
> -#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
>   #define CONFIG_SYS_ONENAND_PAGE_SIZE	2048
> -#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
> -#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
> -	(512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
> -
> +#define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
> +#define CONFIG_SYS_ONENAND_U_BOOT_OFFS	0x80000
>   #endif
>
>   /* NAND boot config */
>   #ifdef CONFIG_NAND
> +#define CONFIG_SPL_NAND_SUPPORT
>   #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
>   #define CONFIG_SYS_NAND_5_ADDR_CYCLE
>   #define CONFIG_SYS_NAND_PAGE_COUNT	64
> @@ -166,14 +182,8 @@
>   #define CONFIG_NAND_OMAP_ECCSCHEME	OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
>   #define CONFIG_NAND_OMAP_GPMC
>   #define CONFIG_BCH
> -
> -#define CONFIG_SYS_NAND_U_BOOT_OFFS	0x80000
> -/* NAND: SPL falcon mode configs */
> -#ifdef CONFIG_SPL_OS_BOOT
> -#define CONFIG_CMD_SPL_NAND_OFS		0x240000
> -#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS	0x280000
> -#define CONFIG_CMD_SPL_WRITE_SIZE	0x2000
> -#endif
>   #endif
>
> +#undef CONFIG_SPL_EXT_SUPPORT
> +
>   #endif /* __IGEP00X0_H */
>
Enric Balletbo Serra Jan. 22, 2016, 10:35 p.m. UTC | #2
Hi Ladis,

Many thanks for your work on this, see some comments below ...

2016-01-21 7:07 GMT+01:00 Heiko Schocher <hs@denx.de>:
> Hello Ladislav,
>
> Am 17.01.2016 um 04:16 schrieb Ladislav Michl:
>>
>> Convert IGEP board to use UBI volumes for U-Boot, its environment and
>> kernel. With exception of first four sectors read by SoC boot
>> ROM whole NAND is UBI managed. As code is too big now, drop
>> CONFIG_SPL_EXT_SUPPORT to make it fit.
>>
>> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
>> ---
>>   include/configs/omap3_igep00x0.h | 80
>> ++++++++++++++++++++++------------------
>>   1 file changed, 45 insertions(+), 35 deletions(-)
>
>
> Reviewed-by: Heiko Schocher <hs@denx.de>
>
> bye,
> Heiko
>
>>
>> diff --git a/include/configs/omap3_igep00x0.h
>> b/include/configs/omap3_igep00x0.h
>> index 5da6cfd..9afbcbe 100644
>> --- a/include/configs/omap3_igep00x0.h
>> +++ b/include/configs/omap3_igep00x0.h
>> @@ -74,6 +74,8 @@
>>   #define CONFIG_CMD_CACHE
>>   #ifdef CONFIG_BOOT_ONENAND
>>   #define CONFIG_CMD_ONENAND    /* ONENAND support              */
>> +#else
>> +#define CONFIG_CMD_UBI
>>   #endif
>>   #define CONFIG_CMD_DHCP
>>   #define CONFIG_CMD_PING
>> @@ -86,6 +88,10 @@
>>         "stdout=serial\0" \
>>         "stderr=serial\0"
>>
>> +#define ENV_MTD_SETTINGS \
>> +       "mtdids=nand0=gpmc-nand.0\0" \
>> +       "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
>> +

I think this should be protected by CONFIG_BOOT_NAND, if is defined
CONFIG_BOOT_ONENAND the ENV_MTD_SETTINGS are wrong.

Also, as we're changing the memory map, I'd like to change the
reserved space for SPL to 2M instead of 512k, so we cover all NAND
block sizes from (64KB to 512KB)

>>   #define MEM_LAYOUT_SETTINGS \
>>         DEFAULT_LINUX_BOOT_ENV \
>>         "scriptaddr=0x87E00000\0" \
>> @@ -96,36 +102,15 @@
>>
>>   #include <config_distro_bootcmd.h>
>>
>> -
>>   #define CONFIG_EXTRA_ENV_SETTINGS \
>>         ENV_DEVICE_SETTINGS \
>> +       ENV_MTD_SETTINGS \
>>         MEM_LAYOUT_SETTINGS \
>>         BOOTENV
>>
>>   #endif
>>
>>   /*
>> - * FLASH and environment organization
>> - */
>> -
>> -#ifdef CONFIG_BOOT_ONENAND
>> -#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
>> -
>> -#define ONENAND_ENV_OFFSET             0x260000 /* environment starts
>> here */
>> -
>> -#define CONFIG_ENV_IS_IN_ONENAND       1
>> -#define CONFIG_ENV_SIZE                        (512 << 10) /* Total Size
>> Environment */
>> -#define CONFIG_ENV_ADDR                        ONENAND_ENV_OFFSET
>> -#endif
>> -
>> -#ifdef CONFIG_NAND
>> -#define CONFIG_ENV_OFFSET              0x260000 /* environment starts
>> here */
>> -#define CONFIG_ENV_IS_IN_NAND          1
>> -#define CONFIG_ENV_SIZE                        (512 << 10) /* Total Size
>> Environment */
>> -#define CONFIG_ENV_ADDR                        NAND_ENV_OFFSET
>> -#endif
>> -
>> -/*
>>    * SMSC911x Ethernet
>>    */
>>   #if defined(CONFIG_CMD_NET)
>> @@ -134,19 +119,50 @@
>>   #define CONFIG_SMC911X_BASE           0x2C000000
>>   #endif /* (CONFIG_CMD_NET) */
>>
>> +/*
>> + * FLASH and environment organization
>> + */
>> +#ifdef CONFIG_NAND
>> +#define CONFIG_SPL_UBI                 1
>> +#define CONFIG_SPL_UBI_MAX_VOL_LEBS    256
>> +#define CONFIG_SPL_UBI_MAX_PEB_SIZE    (256*1024)
>> +#define CONFIG_SPL_UBI_MAX_PEBS                4096
>> +#define CONFIG_SPL_UBI_VOL_IDS         8
>> +#define CONFIG_SPL_UBI_LOAD_MONITOR_ID 0
>> +#define CONFIG_SPL_UBI_LOAD_KERNEL_ID  3
>> +#define CONFIG_SPL_UBI_LOAD_ARGS_ID    4
>> +#define CONFIG_SPL_UBI_PEB_OFFSET      4
>> +#define CONFIG_SPL_UBI_VID_OFFSET      512
>> +#define CONFIG_SPL_UBI_LEB_START       2048
>> +#define CONFIG_SPL_UBI_INFO_ADDR       0x88080000
>> +
>> +#define CONFIG_ENV_IS_IN_UBI           1
>> +#define CONFIG_ENV_UBI_PART            "UBI"
>> +#define CONFIG_ENV_UBI_VOLUME          "config"
>> +#define CONFIG_ENV_UBI_VOLUME_REDUND   "config_r"
>> +#define CONFIG_UBI_SILENCE_MSG         1
>> +#define CONFIG_UBIFS_SILENCE_MSG       1
>> +#else
>> +#define CONFIG_ENV_IS_NOWHERE
>> +#endif
>> +#define CONFIG_ENV_SIZE                        (32*1024)
>> +
>> +#define CONFIG_RBTREE
>> +#define CONFIG_MTD_PARTITIONS
>> +#define MTDIDS_DEFAULT                 "nand0=gpmc-nand.0"
>> +#define MTDPARTS_DEFAULT
>> "mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
>> +

Same comment as above.

>>   /* OneNAND boot config */
>>   #ifdef CONFIG_BOOT_ONENAND
>>   #define CONFIG_SPL_ONENAND_SUPPORT
>> -#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
>>   #define CONFIG_SYS_ONENAND_PAGE_SIZE  2048
>> -#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
>> -#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
>> -       (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
>> -
>> +#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
>> +#define CONFIG_SYS_ONENAND_U_BOOT_OFFS 0x80000
>>   #endif
>>
>>   /* NAND boot config */
>>   #ifdef CONFIG_NAND
>> +#define CONFIG_SPL_NAND_SUPPORT
>>   #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
>>   #define CONFIG_SYS_NAND_5_ADDR_CYCLE
>>   #define CONFIG_SYS_NAND_PAGE_COUNT    64
>> @@ -166,14 +182,8 @@
>>   #define CONFIG_NAND_OMAP_ECCSCHEME    OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
>>   #define CONFIG_NAND_OMAP_GPMC
>>   #define CONFIG_BCH
>> -
>> -#define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
>> -/* NAND: SPL falcon mode configs */
>> -#ifdef CONFIG_SPL_OS_BOOT
>> -#define CONFIG_CMD_SPL_NAND_OFS                0x240000
>> -#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS        0x280000
>> -#define CONFIG_CMD_SPL_WRITE_SIZE      0x2000
>> -#endif
>>   #endif
>>
>> +#undef CONFIG_SPL_EXT_SUPPORT
>> +
>>   #endif /* __IGEP00X0_H */
>>
>

About the new layout you propose the following, right?

volume 0 is u-boot.img, 1 and 2 env, 3 kernel, 4 FDT, 5 rootfs (ubifs)

It's not possible load the kernel and the FDT from the rootfs directly, right?

BTW, I created the 5 volumes and copied the files to every volume but
I get following errors, do you know what I am missing?

U-Boot SPL 2016.01-00358-g4efe05f (Jan 22 2016 - 17:16:04)
Trying to boot from NAND
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 3
UBI warning: Failed
Loading Linux failed, falling back to U-Boot.
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: LEB 0 of 1 is missing
UBI warning: Failed to load volume 0
UBI warning: Failed
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

Thanks,
Enric

> --
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Ladislav Michl Jan. 24, 2016, 1:44 p.m. UTC | #3
Hi Enric,

On Fri, Jan 22, 2016 at 11:35:49PM +0100, Enric Balletbo Serra wrote:
[...]
> > Am 17.01.2016 um 04:16 schrieb Ladislav Michl:
[...]
> >> +#define ENV_MTD_SETTINGS \
> >> +       "mtdids=nand0=gpmc-nand.0\0" \
> >> +       "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
> >> +
> 
> I think this should be protected by CONFIG_BOOT_NAND, if is defined
> CONFIG_BOOT_ONENAND the ENV_MTD_SETTINGS are wrong.

Ah, right! I'll do that in next version. Btw, I hope to have OneNAND
board version too, so I would be able to test that as well.

> Also, as we're changing the memory map, I'd like to change the
> reserved space for SPL to 2M instead of 512k, so we cover all NAND
> block sizes from (64KB to 512KB)

What if we do that dynamically? It is not problem in U-Boot as we are
already running FDT fixup, so adding one more shouldn't hurt too much.
And we need to run 'spl export' anyway to fixup RAM size, so it is not
problem for falcon mode, too.

[...] 
> About the new layout you propose the following, right?
> 
> volume 0 is u-boot.img, 1 and 2 env, 3 kernel, 4 FDT, 5 rootfs (ubifs)

Yes, that's right. U-Boot does not care about volumes above 4, it is purely
Linux thing, but I'm using it that way (and somewhere in distant future I'd
like to run database directly on top of UBI volume)

> It's not possible load the kernel and the FDT from the rootfs directly, right?

UBIFS will certainly not fit into SPL size.

> BTW, I created the 5 volumes and copied the files to every volume but
> I get following errors, do you know what I am missing?
> 
> U-Boot SPL 2016.01-00358-g4efe05f (Jan 22 2016 - 17:16:04)
> Trying to boot from NAND
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 3
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 3
> UBI warning: Failed
> Loading Linux failed, falling back to U-Boot.
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 0
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 0
> UBI warning: Failed
> SPL: failed to boot from all boot devices
> ### ERROR ### Please RESET the board ###

I've never seen that. How did you copy files into volumes? Btw, I haven't
tried doing that using U-Boot, but did:
$ ubiformat /dev/mtd1 -f root.ubi
(where root.ubi is product of PTXdist build)
Later I used f.e. 
$ ubiupdatevol /dev/ubi0_0 u-boot.img
to load files into volumes.

	ladis
Heiko Schocher Jan. 25, 2016, 6:39 a.m. UTC | #4
Hello Enric, Ladislav,

Am 22.01.2016 um 23:35 schrieb Enric Balletbo Serra:
> Hi Ladis,
>
> Many thanks for your work on this, see some comments below ...

Sorry, pull request is sent with this patch, see:

http://lists.denx.de/pipermail/u-boot/2016-January/239855.html

@Ladislav: Please send changes in a follow up patch, thanks!


> 2016-01-21 7:07 GMT+01:00 Heiko Schocher <hs@denx.de>:
>> Hello Ladislav,
>>
>> Am 17.01.2016 um 04:16 schrieb Ladislav Michl:
>>>
>>> Convert IGEP board to use UBI volumes for U-Boot, its environment and
>>> kernel. With exception of first four sectors read by SoC boot
>>> ROM whole NAND is UBI managed. As code is too big now, drop
>>> CONFIG_SPL_EXT_SUPPORT to make it fit.
>>>
>>> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
>>> ---
>>>    include/configs/omap3_igep00x0.h | 80
>>> ++++++++++++++++++++++------------------
>>>    1 file changed, 45 insertions(+), 35 deletions(-)
>>
>>
>> Reviewed-by: Heiko Schocher <hs@denx.de>
>>
>> bye,
>> Heiko
>>
>>>
>>> diff --git a/include/configs/omap3_igep00x0.h
>>> b/include/configs/omap3_igep00x0.h
>>> index 5da6cfd..9afbcbe 100644
>>> --- a/include/configs/omap3_igep00x0.h
>>> +++ b/include/configs/omap3_igep00x0.h
>>> @@ -74,6 +74,8 @@
>>>    #define CONFIG_CMD_CACHE
>>>    #ifdef CONFIG_BOOT_ONENAND
>>>    #define CONFIG_CMD_ONENAND    /* ONENAND support              */
>>> +#else
>>> +#define CONFIG_CMD_UBI
>>>    #endif
>>>    #define CONFIG_CMD_DHCP
>>>    #define CONFIG_CMD_PING
>>> @@ -86,6 +88,10 @@
>>>          "stdout=serial\0" \
>>>          "stderr=serial\0"
>>>
>>> +#define ENV_MTD_SETTINGS \
>>> +       "mtdids=nand0=gpmc-nand.0\0" \
>>> +       "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
>>> +
>
> I think this should be protected by CONFIG_BOOT_NAND, if is defined
> CONFIG_BOOT_ONENAND the ENV_MTD_SETTINGS are wrong.

Good point ...

> Also, as we're changing the memory map, I'd like to change the
> reserved space for SPL to 2M instead of 512k, so we cover all NAND
> block sizes from (64KB to 512KB)

I do not understand this, but I have no details about the hw ...

>>>    #define MEM_LAYOUT_SETTINGS \
>>>          DEFAULT_LINUX_BOOT_ENV \
>>>          "scriptaddr=0x87E00000\0" \
>>> @@ -96,36 +102,15 @@
>>>
>>>    #include <config_distro_bootcmd.h>
>>>
>>> -
>>>    #define CONFIG_EXTRA_ENV_SETTINGS \
>>>          ENV_DEVICE_SETTINGS \
>>> +       ENV_MTD_SETTINGS \
>>>          MEM_LAYOUT_SETTINGS \
>>>          BOOTENV
>>>
>>>    #endif
>>>
>>>    /*
>>> - * FLASH and environment organization
>>> - */
>>> -
>>> -#ifdef CONFIG_BOOT_ONENAND
>>> -#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
>>> -
>>> -#define ONENAND_ENV_OFFSET             0x260000 /* environment starts
>>> here */
>>> -
>>> -#define CONFIG_ENV_IS_IN_ONENAND       1
>>> -#define CONFIG_ENV_SIZE                        (512 << 10) /* Total Size
>>> Environment */
>>> -#define CONFIG_ENV_ADDR                        ONENAND_ENV_OFFSET
>>> -#endif
>>> -
>>> -#ifdef CONFIG_NAND
>>> -#define CONFIG_ENV_OFFSET              0x260000 /* environment starts
>>> here */
>>> -#define CONFIG_ENV_IS_IN_NAND          1
>>> -#define CONFIG_ENV_SIZE                        (512 << 10) /* Total Size
>>> Environment */
>>> -#define CONFIG_ENV_ADDR                        NAND_ENV_OFFSET
>>> -#endif
>>> -
>>> -/*
>>>     * SMSC911x Ethernet
>>>     */
>>>    #if defined(CONFIG_CMD_NET)
>>> @@ -134,19 +119,50 @@
>>>    #define CONFIG_SMC911X_BASE           0x2C000000
>>>    #endif /* (CONFIG_CMD_NET) */
>>>
>>> +/*
>>> + * FLASH and environment organization
>>> + */
>>> +#ifdef CONFIG_NAND
>>> +#define CONFIG_SPL_UBI                 1
>>> +#define CONFIG_SPL_UBI_MAX_VOL_LEBS    256
>>> +#define CONFIG_SPL_UBI_MAX_PEB_SIZE    (256*1024)
>>> +#define CONFIG_SPL_UBI_MAX_PEBS                4096
>>> +#define CONFIG_SPL_UBI_VOL_IDS         8
>>> +#define CONFIG_SPL_UBI_LOAD_MONITOR_ID 0
>>> +#define CONFIG_SPL_UBI_LOAD_KERNEL_ID  3
>>> +#define CONFIG_SPL_UBI_LOAD_ARGS_ID    4
>>> +#define CONFIG_SPL_UBI_PEB_OFFSET      4
>>> +#define CONFIG_SPL_UBI_VID_OFFSET      512
>>> +#define CONFIG_SPL_UBI_LEB_START       2048
>>> +#define CONFIG_SPL_UBI_INFO_ADDR       0x88080000
>>> +
>>> +#define CONFIG_ENV_IS_IN_UBI           1
>>> +#define CONFIG_ENV_UBI_PART            "UBI"
>>> +#define CONFIG_ENV_UBI_VOLUME          "config"
>>> +#define CONFIG_ENV_UBI_VOLUME_REDUND   "config_r"
>>> +#define CONFIG_UBI_SILENCE_MSG         1
>>> +#define CONFIG_UBIFS_SILENCE_MSG       1
>>> +#else
>>> +#define CONFIG_ENV_IS_NOWHERE
>>> +#endif
>>> +#define CONFIG_ENV_SIZE                        (32*1024)
>>> +
>>> +#define CONFIG_RBTREE
>>> +#define CONFIG_MTD_PARTITIONS
>>> +#define MTDIDS_DEFAULT                 "nand0=gpmc-nand.0"
>>> +#define MTDPARTS_DEFAULT
>>> "mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
>>> +
>
> Same comment as above.
>
>>>    /* OneNAND boot config */
>>>    #ifdef CONFIG_BOOT_ONENAND
>>>    #define CONFIG_SPL_ONENAND_SUPPORT
>>> -#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
>>>    #define CONFIG_SYS_ONENAND_PAGE_SIZE  2048
>>> -#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
>>> -#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
>>> -       (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
>>> -
>>> +#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
>>> +#define CONFIG_SYS_ONENAND_U_BOOT_OFFS 0x80000
>>>    #endif
>>>
>>>    /* NAND boot config */
>>>    #ifdef CONFIG_NAND
>>> +#define CONFIG_SPL_NAND_SUPPORT
>>>    #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
>>>    #define CONFIG_SYS_NAND_5_ADDR_CYCLE
>>>    #define CONFIG_SYS_NAND_PAGE_COUNT    64
>>> @@ -166,14 +182,8 @@
>>>    #define CONFIG_NAND_OMAP_ECCSCHEME    OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
>>>    #define CONFIG_NAND_OMAP_GPMC
>>>    #define CONFIG_BCH
>>> -
>>> -#define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
>>> -/* NAND: SPL falcon mode configs */
>>> -#ifdef CONFIG_SPL_OS_BOOT
>>> -#define CONFIG_CMD_SPL_NAND_OFS                0x240000
>>> -#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS        0x280000
>>> -#define CONFIG_CMD_SPL_WRITE_SIZE      0x2000
>>> -#endif
>>>    #endif
>>>
>>> +#undef CONFIG_SPL_EXT_SUPPORT
>>> +
>>>    #endif /* __IGEP00X0_H */
>>>
>>
>
> About the new layout you propose the following, right?
>
> volume 0 is u-boot.img, 1 and 2 env, 3 kernel, 4 FDT, 5 rootfs (ubifs)
>
> It's not possible load the kernel and the FDT from the rootfs directly, right?

That would be nice, but for this we need UBIFS support in SPL.
Patches are welcome ;-)

> BTW, I created the 5 volumes and copied the files to every volume but
> I get following errors, do you know what I am missing?
>
> U-Boot SPL 2016.01-00358-g4efe05f (Jan 22 2016 - 17:16:04)
> Trying to boot from NAND
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 3
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 3
> UBI warning: Failed
> Loading Linux failed, falling back to U-Boot.
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 0
> UBI warning: LEB 0 of 1 is missing
> UBI warning: Failed to load volume 0
> UBI warning: Failed
> SPL: failed to boot from all boot devices
> ### ERROR ### Please RESET the board ###
>
> Thanks,
> Enric

bye,
Heiko
Enric Balletbo Serra Jan. 25, 2016, 7:26 a.m. UTC | #5
Hi,

2016-01-25 7:39 GMT+01:00 Heiko Schocher <hs@denx.de>:
> Hello Enric, Ladislav,
>
> Am 22.01.2016 um 23:35 schrieb Enric Balletbo Serra:
>>
>> Hi Ladis,
>>
>> Many thanks for your work on this, see some comments below ...
>
>
> Sorry, pull request is sent with this patch, see:
>
> http://lists.denx.de/pipermail/u-boot/2016-January/239855.html
>
> @Ladislav: Please send changes in a follow up patch, thanks!
>
>
>
>> 2016-01-21 7:07 GMT+01:00 Heiko Schocher <hs@denx.de>:
>>>
>>> Hello Ladislav,
>>>
>>> Am 17.01.2016 um 04:16 schrieb Ladislav Michl:
>>>>
>>>>
>>>> Convert IGEP board to use UBI volumes for U-Boot, its environment and
>>>> kernel. With exception of first four sectors read by SoC boot
>>>> ROM whole NAND is UBI managed. As code is too big now, drop
>>>> CONFIG_SPL_EXT_SUPPORT to make it fit.
>>>>
>>>> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
>>>> ---
>>>>    include/configs/omap3_igep00x0.h | 80
>>>> ++++++++++++++++++++++------------------
>>>>    1 file changed, 45 insertions(+), 35 deletions(-)
>>>
>>>
>>>
>>> Reviewed-by: Heiko Schocher <hs@denx.de>
>>>
>>> bye,
>>> Heiko
>>>
>>>>
>>>> diff --git a/include/configs/omap3_igep00x0.h
>>>> b/include/configs/omap3_igep00x0.h
>>>> index 5da6cfd..9afbcbe 100644
>>>> --- a/include/configs/omap3_igep00x0.h
>>>> +++ b/include/configs/omap3_igep00x0.h
>>>> @@ -74,6 +74,8 @@
>>>>    #define CONFIG_CMD_CACHE
>>>>    #ifdef CONFIG_BOOT_ONENAND
>>>>    #define CONFIG_CMD_ONENAND    /* ONENAND support              */
>>>> +#else
>>>> +#define CONFIG_CMD_UBI
>>>>    #endif
>>>>    #define CONFIG_CMD_DHCP
>>>>    #define CONFIG_CMD_PING
>>>> @@ -86,6 +88,10 @@
>>>>          "stdout=serial\0" \
>>>>          "stderr=serial\0"
>>>>
>>>> +#define ENV_MTD_SETTINGS \
>>>> +       "mtdids=nand0=gpmc-nand.0\0" \
>>>> +       "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
>>>> +
>>
>>
>> I think this should be protected by CONFIG_BOOT_NAND, if is defined
>> CONFIG_BOOT_ONENAND the ENV_MTD_SETTINGS are wrong.
>
>
> Good point ...
>
>> Also, as we're changing the memory map, I'd like to change the
>> reserved space for SPL to 2M instead of 512k, so we cover all NAND
>> block sizes from (64KB to 512KB)
>
>
> I do not understand this, but I have no details about the hw ...
>

The ROM boot on OMAP reads the first 4 blocks searching for the SPL,
in production is a practice flash the SPL 4 times. OneNAND/NAND
devices can have different block sizes and the OMAP ROM boot supports
block sizes from 64KB to 512K. For IGEP boards in particular, at least
there are boards that have block size of 128K and 256K. What I would
meant here is set as default the mtdparts variable to reserve 2M for
SPL, just to cover all the cases.

mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0


>
>>>>    #define MEM_LAYOUT_SETTINGS \
>>>>          DEFAULT_LINUX_BOOT_ENV \
>>>>          "scriptaddr=0x87E00000\0" \
>>>> @@ -96,36 +102,15 @@
>>>>
>>>>    #include <config_distro_bootcmd.h>
>>>>
>>>> -
>>>>    #define CONFIG_EXTRA_ENV_SETTINGS \
>>>>          ENV_DEVICE_SETTINGS \
>>>> +       ENV_MTD_SETTINGS \
>>>>          MEM_LAYOUT_SETTINGS \
>>>>          BOOTENV
>>>>
>>>>    #endif
>>>>
>>>>    /*
>>>> - * FLASH and environment organization
>>>> - */
>>>> -
>>>> -#ifdef CONFIG_BOOT_ONENAND
>>>> -#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
>>>> -
>>>> -#define ONENAND_ENV_OFFSET             0x260000 /* environment starts
>>>> here */
>>>> -
>>>> -#define CONFIG_ENV_IS_IN_ONENAND       1
>>>> -#define CONFIG_ENV_SIZE                        (512 << 10) /* Total
>>>> Size
>>>> Environment */
>>>> -#define CONFIG_ENV_ADDR                        ONENAND_ENV_OFFSET
>>>> -#endif
>>>> -
>>>> -#ifdef CONFIG_NAND
>>>> -#define CONFIG_ENV_OFFSET              0x260000 /* environment starts
>>>> here */
>>>> -#define CONFIG_ENV_IS_IN_NAND          1
>>>> -#define CONFIG_ENV_SIZE                        (512 << 10) /* Total
>>>> Size
>>>> Environment */
>>>> -#define CONFIG_ENV_ADDR                        NAND_ENV_OFFSET
>>>> -#endif
>>>> -
>>>> -/*
>>>>     * SMSC911x Ethernet
>>>>     */
>>>>    #if defined(CONFIG_CMD_NET)
>>>> @@ -134,19 +119,50 @@
>>>>    #define CONFIG_SMC911X_BASE           0x2C000000
>>>>    #endif /* (CONFIG_CMD_NET) */
>>>>
>>>> +/*
>>>> + * FLASH and environment organization
>>>> + */
>>>> +#ifdef CONFIG_NAND
>>>> +#define CONFIG_SPL_UBI                 1
>>>> +#define CONFIG_SPL_UBI_MAX_VOL_LEBS    256
>>>> +#define CONFIG_SPL_UBI_MAX_PEB_SIZE    (256*1024)
>>>> +#define CONFIG_SPL_UBI_MAX_PEBS                4096
>>>> +#define CONFIG_SPL_UBI_VOL_IDS         8
>>>> +#define CONFIG_SPL_UBI_LOAD_MONITOR_ID 0
>>>> +#define CONFIG_SPL_UBI_LOAD_KERNEL_ID  3
>>>> +#define CONFIG_SPL_UBI_LOAD_ARGS_ID    4
>>>> +#define CONFIG_SPL_UBI_PEB_OFFSET      4
>>>> +#define CONFIG_SPL_UBI_VID_OFFSET      512
>>>> +#define CONFIG_SPL_UBI_LEB_START       2048
>>>> +#define CONFIG_SPL_UBI_INFO_ADDR       0x88080000
>>>> +
>>>> +#define CONFIG_ENV_IS_IN_UBI           1
>>>> +#define CONFIG_ENV_UBI_PART            "UBI"
>>>> +#define CONFIG_ENV_UBI_VOLUME          "config"
>>>> +#define CONFIG_ENV_UBI_VOLUME_REDUND   "config_r"
>>>> +#define CONFIG_UBI_SILENCE_MSG         1
>>>> +#define CONFIG_UBIFS_SILENCE_MSG       1
>>>> +#else
>>>> +#define CONFIG_ENV_IS_NOWHERE
>>>> +#endif
>>>> +#define CONFIG_ENV_SIZE                        (32*1024)
>>>> +
>>>> +#define CONFIG_RBTREE
>>>> +#define CONFIG_MTD_PARTITIONS
>>>> +#define MTDIDS_DEFAULT                 "nand0=gpmc-nand.0"
>>>> +#define MTDPARTS_DEFAULT
>>>> "mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
>>>> +
>>
>>
>> Same comment as above.
>>
>>>>    /* OneNAND boot config */
>>>>    #ifdef CONFIG_BOOT_ONENAND
>>>>    #define CONFIG_SPL_ONENAND_SUPPORT
>>>> -#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
>>>>    #define CONFIG_SYS_ONENAND_PAGE_SIZE  2048
>>>> -#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
>>>> -#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
>>>> -       (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
>>>> -
>>>> +#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
>>>> +#define CONFIG_SYS_ONENAND_U_BOOT_OFFS 0x80000
>>>>    #endif
>>>>
>>>>    /* NAND boot config */
>>>>    #ifdef CONFIG_NAND
>>>> +#define CONFIG_SPL_NAND_SUPPORT
>>>>    #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
>>>>    #define CONFIG_SYS_NAND_5_ADDR_CYCLE
>>>>    #define CONFIG_SYS_NAND_PAGE_COUNT    64
>>>> @@ -166,14 +182,8 @@
>>>>    #define CONFIG_NAND_OMAP_ECCSCHEME
>>>> OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
>>>>    #define CONFIG_NAND_OMAP_GPMC
>>>>    #define CONFIG_BCH
>>>> -
>>>> -#define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
>>>> -/* NAND: SPL falcon mode configs */
>>>> -#ifdef CONFIG_SPL_OS_BOOT
>>>> -#define CONFIG_CMD_SPL_NAND_OFS                0x240000
>>>> -#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS        0x280000
>>>> -#define CONFIG_CMD_SPL_WRITE_SIZE      0x2000
>>>> -#endif
>>>>    #endif
>>>>
>>>> +#undef CONFIG_SPL_EXT_SUPPORT
>>>> +
>>>>    #endif /* __IGEP00X0_H */
>>>>
>>>
>>
>> About the new layout you propose the following, right?
>>
>> volume 0 is u-boot.img, 1 and 2 env, 3 kernel, 4 FDT, 5 rootfs (ubifs)
>>
>> It's not possible load the kernel and the FDT from the rootfs directly,
>> right?
>
>
> That would be nice, but for this we need UBIFS support in SPL.
> Patches are welcome ;-)
>

Hehe, yes, I think the problem is fit the ubifs into the SPL size.

>> BTW, I created the 5 volumes and copied the files to every volume but
>> I get following errors, do you know what I am missing?
>>
>> U-Boot SPL 2016.01-00358-g4efe05f (Jan 22 2016 - 17:16:04)
>> Trying to boot from NAND
>> UBI warning: LEB 0 of 1 is missing
>> UBI warning: Failed to load volume 3
>> UBI warning: LEB 0 of 1 is missing
>> UBI warning: Failed to load volume 3
>> UBI warning: Failed
>> Loading Linux failed, falling back to U-Boot.
>> UBI warning: LEB 0 of 1 is missing
>> UBI warning: Failed to load volume 0
>> UBI warning: LEB 0 of 1 is missing
>> UBI warning: Failed to load volume 0
>> UBI warning: Failed
>> SPL: failed to boot from all boot devices
>> ### ERROR ### Please RESET the board ###
>>
>> Thanks,
>> Enric
>
>
> bye,
> Heiko
>
> --
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Heiko Schocher Jan. 25, 2016, 8:13 a.m. UTC | #6
Hello Enric,

Am 25.01.2016 um 08:26 schrieb Enric Balletbo Serra:
> Hi,
>
> 2016-01-25 7:39 GMT+01:00 Heiko Schocher <hs@denx.de>:
>> Hello Enric, Ladislav,
>>
>> Am 22.01.2016 um 23:35 schrieb Enric Balletbo Serra:
>>>
>>> Hi Ladis,
>>>
>>> Many thanks for your work on this, see some comments below ...
>>
>>
>> Sorry, pull request is sent with this patch, see:
>>
>> http://lists.denx.de/pipermail/u-boot/2016-January/239855.html
>>
>> @Ladislav: Please send changes in a follow up patch, thanks!
>>
>>
>>
>>> 2016-01-21 7:07 GMT+01:00 Heiko Schocher <hs@denx.de>:
>>>>
>>>> Hello Ladislav,
>>>>
>>>> Am 17.01.2016 um 04:16 schrieb Ladislav Michl:
>>>>>
>>>>>
>>>>> Convert IGEP board to use UBI volumes for U-Boot, its environment and
>>>>> kernel. With exception of first four sectors read by SoC boot
>>>>> ROM whole NAND is UBI managed. As code is too big now, drop
>>>>> CONFIG_SPL_EXT_SUPPORT to make it fit.
>>>>>
>>>>> Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
>>>>> ---
>>>>>     include/configs/omap3_igep00x0.h | 80
>>>>> ++++++++++++++++++++++------------------
>>>>>     1 file changed, 45 insertions(+), 35 deletions(-)
>>>>
>>>>
>>>>
>>>> Reviewed-by: Heiko Schocher <hs@denx.de>
>>>>
>>>> bye,
>>>> Heiko
>>>>
>>>>>
>>>>> diff --git a/include/configs/omap3_igep00x0.h
>>>>> b/include/configs/omap3_igep00x0.h
>>>>> index 5da6cfd..9afbcbe 100644
>>>>> --- a/include/configs/omap3_igep00x0.h
>>>>> +++ b/include/configs/omap3_igep00x0.h
>>>>> @@ -74,6 +74,8 @@
>>>>>     #define CONFIG_CMD_CACHE
>>>>>     #ifdef CONFIG_BOOT_ONENAND
>>>>>     #define CONFIG_CMD_ONENAND    /* ONENAND support              */
>>>>> +#else
>>>>> +#define CONFIG_CMD_UBI
>>>>>     #endif
>>>>>     #define CONFIG_CMD_DHCP
>>>>>     #define CONFIG_CMD_PING
>>>>> @@ -86,6 +88,10 @@
>>>>>           "stdout=serial\0" \
>>>>>           "stderr=serial\0"
>>>>>
>>>>> +#define ENV_MTD_SETTINGS \
>>>>> +       "mtdids=nand0=gpmc-nand.0\0" \
>>>>> +       "mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
>>>>> +
>>>
>>>
>>> I think this should be protected by CONFIG_BOOT_NAND, if is defined
>>> CONFIG_BOOT_ONENAND the ENV_MTD_SETTINGS are wrong.
>>
>>
>> Good point ...
>>
>>> Also, as we're changing the memory map, I'd like to change the
>>> reserved space for SPL to 2M instead of 512k, so we cover all NAND
>>> block sizes from (64KB to 512KB)
>>
>>
>> I do not understand this, but I have no details about the hw ...
>>
>
> The ROM boot on OMAP reads the first 4 blocks searching for the SPL,
> in production is a practice flash the SPL 4 times. OneNAND/NAND
> devices can have different block sizes and the OMAP ROM boot supports
> block sizes from 64KB to 512K. For IGEP boards in particular, at least
> there are boards that have block size of 128K and 256K. What I would
> meant here is set as default the mtdparts variable to reserve 2M for
> SPL, just to cover all the cases.

Thanks for the explanation.

> mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0
>
>
>>
>>>>>     #define MEM_LAYOUT_SETTINGS \
>>>>>           DEFAULT_LINUX_BOOT_ENV \
>>>>>           "scriptaddr=0x87E00000\0" \
>>>>> @@ -96,36 +102,15 @@
>>>>>
>>>>>     #include <config_distro_bootcmd.h>
>>>>>
>>>>> -
>>>>>     #define CONFIG_EXTRA_ENV_SETTINGS \
>>>>>           ENV_DEVICE_SETTINGS \
>>>>> +       ENV_MTD_SETTINGS \
>>>>>           MEM_LAYOUT_SETTINGS \
>>>>>           BOOTENV
>>>>>
>>>>>     #endif
>>>>>
>>>>>     /*
>>>>> - * FLASH and environment organization
>>>>> - */
>>>>> -
>>>>> -#ifdef CONFIG_BOOT_ONENAND
>>>>> -#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
>>>>> -
>>>>> -#define ONENAND_ENV_OFFSET             0x260000 /* environment starts
>>>>> here */
>>>>> -
>>>>> -#define CONFIG_ENV_IS_IN_ONENAND       1
>>>>> -#define CONFIG_ENV_SIZE                        (512 << 10) /* Total
>>>>> Size
>>>>> Environment */
>>>>> -#define CONFIG_ENV_ADDR                        ONENAND_ENV_OFFSET
>>>>> -#endif
>>>>> -
>>>>> -#ifdef CONFIG_NAND
>>>>> -#define CONFIG_ENV_OFFSET              0x260000 /* environment starts
>>>>> here */
>>>>> -#define CONFIG_ENV_IS_IN_NAND          1
>>>>> -#define CONFIG_ENV_SIZE                        (512 << 10) /* Total
>>>>> Size
>>>>> Environment */
>>>>> -#define CONFIG_ENV_ADDR                        NAND_ENV_OFFSET
>>>>> -#endif
>>>>> -
>>>>> -/*
>>>>>      * SMSC911x Ethernet
>>>>>      */
>>>>>     #if defined(CONFIG_CMD_NET)
>>>>> @@ -134,19 +119,50 @@
>>>>>     #define CONFIG_SMC911X_BASE           0x2C000000
>>>>>     #endif /* (CONFIG_CMD_NET) */
>>>>>
>>>>> +/*
>>>>> + * FLASH and environment organization
>>>>> + */
>>>>> +#ifdef CONFIG_NAND
>>>>> +#define CONFIG_SPL_UBI                 1
>>>>> +#define CONFIG_SPL_UBI_MAX_VOL_LEBS    256
>>>>> +#define CONFIG_SPL_UBI_MAX_PEB_SIZE    (256*1024)
>>>>> +#define CONFIG_SPL_UBI_MAX_PEBS                4096
>>>>> +#define CONFIG_SPL_UBI_VOL_IDS         8
>>>>> +#define CONFIG_SPL_UBI_LOAD_MONITOR_ID 0
>>>>> +#define CONFIG_SPL_UBI_LOAD_KERNEL_ID  3
>>>>> +#define CONFIG_SPL_UBI_LOAD_ARGS_ID    4
>>>>> +#define CONFIG_SPL_UBI_PEB_OFFSET      4
>>>>> +#define CONFIG_SPL_UBI_VID_OFFSET      512
>>>>> +#define CONFIG_SPL_UBI_LEB_START       2048
>>>>> +#define CONFIG_SPL_UBI_INFO_ADDR       0x88080000
>>>>> +
>>>>> +#define CONFIG_ENV_IS_IN_UBI           1
>>>>> +#define CONFIG_ENV_UBI_PART            "UBI"
>>>>> +#define CONFIG_ENV_UBI_VOLUME          "config"
>>>>> +#define CONFIG_ENV_UBI_VOLUME_REDUND   "config_r"
>>>>> +#define CONFIG_UBI_SILENCE_MSG         1
>>>>> +#define CONFIG_UBIFS_SILENCE_MSG       1
>>>>> +#else
>>>>> +#define CONFIG_ENV_IS_NOWHERE
>>>>> +#endif
>>>>> +#define CONFIG_ENV_SIZE                        (32*1024)
>>>>> +
>>>>> +#define CONFIG_RBTREE
>>>>> +#define CONFIG_MTD_PARTITIONS
>>>>> +#define MTDIDS_DEFAULT                 "nand0=gpmc-nand.0"
>>>>> +#define MTDPARTS_DEFAULT
>>>>> "mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
>>>>> +
>>>
>>>
>>> Same comment as above.
>>>
>>>>>     /* OneNAND boot config */
>>>>>     #ifdef CONFIG_BOOT_ONENAND
>>>>>     #define CONFIG_SPL_ONENAND_SUPPORT
>>>>> -#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
>>>>>     #define CONFIG_SYS_ONENAND_PAGE_SIZE  2048
>>>>> -#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
>>>>> -#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
>>>>> -       (512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
>>>>> -
>>>>> +#define CONFIG_SYS_ONENAND_BASE                ONENAND_MAP
>>>>> +#define CONFIG_SYS_ONENAND_U_BOOT_OFFS 0x80000
>>>>>     #endif
>>>>>
>>>>>     /* NAND boot config */
>>>>>     #ifdef CONFIG_NAND
>>>>> +#define CONFIG_SPL_NAND_SUPPORT
>>>>>     #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
>>>>>     #define CONFIG_SYS_NAND_5_ADDR_CYCLE
>>>>>     #define CONFIG_SYS_NAND_PAGE_COUNT    64
>>>>> @@ -166,14 +182,8 @@
>>>>>     #define CONFIG_NAND_OMAP_ECCSCHEME
>>>>> OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
>>>>>     #define CONFIG_NAND_OMAP_GPMC
>>>>>     #define CONFIG_BCH
>>>>> -
>>>>> -#define CONFIG_SYS_NAND_U_BOOT_OFFS    0x80000
>>>>> -/* NAND: SPL falcon mode configs */
>>>>> -#ifdef CONFIG_SPL_OS_BOOT
>>>>> -#define CONFIG_CMD_SPL_NAND_OFS                0x240000
>>>>> -#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS        0x280000
>>>>> -#define CONFIG_CMD_SPL_WRITE_SIZE      0x2000
>>>>> -#endif
>>>>>     #endif
>>>>>
>>>>> +#undef CONFIG_SPL_EXT_SUPPORT
>>>>> +
>>>>>     #endif /* __IGEP00X0_H */
>>>>>
>>>>
>>>
>>> About the new layout you propose the following, right?
>>>
>>> volume 0 is u-boot.img, 1 and 2 env, 3 kernel, 4 FDT, 5 rootfs (ubifs)
>>>
>>> It's not possible load the kernel and the FDT from the rootfs directly,
>>> right?
>>
>>
>> That would be nice, but for this we need UBIFS support in SPL.
>> Patches are welcome ;-)
>>
>
> Hehe, yes, I think the problem is fit the ubifs into the SPL size.

Yes, maybe ...

bye,
Heiko
>
>>> BTW, I created the 5 volumes and copied the files to every volume but
>>> I get following errors, do you know what I am missing?
>>>
>>> U-Boot SPL 2016.01-00358-g4efe05f (Jan 22 2016 - 17:16:04)
>>> Trying to boot from NAND
>>> UBI warning: LEB 0 of 1 is missing
>>> UBI warning: Failed to load volume 3
>>> UBI warning: LEB 0 of 1 is missing
>>> UBI warning: Failed to load volume 3
>>> UBI warning: Failed
>>> Loading Linux failed, falling back to U-Boot.
>>> UBI warning: LEB 0 of 1 is missing
>>> UBI warning: Failed to load volume 0
>>> UBI warning: LEB 0 of 1 is missing
>>> UBI warning: Failed to load volume 0
>>> UBI warning: Failed
>>> SPL: failed to boot from all boot devices
>>> ### ERROR ### Please RESET the board ###
>>>
>>> Thanks,
>>> Enric
>>
>>
>> bye,
>> Heiko
>>
>> --
>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
>
Tom Rini Jan. 25, 2016, 3:13 p.m. UTC | #7
On Mon, Jan 25, 2016 at 07:39:10AM +0100, Heiko Schocher wrote:
> Hello Enric, Ladislav,
> 
> Am 22.01.2016 um 23:35 schrieb Enric Balletbo Serra:
> >Hi Ladis,
> >
> >Many thanks for your work on this, see some comments below ...
> 
> Sorry, pull request is sent with this patch, see:
> 
> http://lists.denx.de/pipermail/u-boot/2016-January/239855.html

Note that the PR there just lists one patch...

> @Ladislav: Please send changes in a follow up patch, thanks!

No, sorry.  I had intentionally not yet grabbed the PR there yet since I
didn't want this series in until Enric had ack'd them as it's a behavior
change and he is listed as the maintainer.  You grabbed them a bit too
early, sorry!
Heiko Schocher Jan. 25, 2016, 3:35 p.m. UTC | #8
Hello Tom,

Am 25.01.2016 um 16:13 schrieb Tom Rini:
> On Mon, Jan 25, 2016 at 07:39:10AM +0100, Heiko Schocher wrote:
>> Hello Enric, Ladislav,
>>
>> Am 22.01.2016 um 23:35 schrieb Enric Balletbo Serra:
>>> Hi Ladis,
>>>
>>> Many thanks for your work on this, see some comments below ...
>>
>> Sorry, pull request is sent with this patch, see:
>>
>> http://lists.denx.de/pipermail/u-boot/2016-January/239855.html
>
> Note that the PR there just lists one patch...

wrong link, sorry.

>> @Ladislav: Please send changes in a follow up patch, thanks!
>
> No, sorry.  I had intentionally not yet grabbed the PR there yet since I
> didn't want this series in until Enric had ack'd them as it's a behavior
> change and he is listed as the maintainer.  You grabbed them a bit too
> early, sorry!

Ups, sorry (may I was to happy for having UBI support in SPL)

Ok, so I wait for a new version for this patch.

bye,
Heiko
Ladislav Michl Jan. 25, 2016, 3:56 p.m. UTC | #9
Hi Enric,

On Mon, Jan 25, 2016 at 08:26:23AM +0100, Enric Balletbo Serra wrote:
> The ROM boot on OMAP reads the first 4 blocks searching for the SPL,
> in production is a practice flash the SPL 4 times. OneNAND/NAND
> devices can have different block sizes and the OMAP ROM boot supports
> block sizes from 64KB to 512K. For IGEP boards in particular, at least
> there are boards that have block size of 128K and 256K. What I would
> meant here is set as default the mtdparts variable to reserve 2M for
> SPL, just to cover all the cases.
> 
> mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0

So far there was no ack or nack to yesterday's proposal making that
dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks,
only mtd needs fixed offset. So I'd like to see this offset calculated as
4*block_size, not some "worst case" value...

	ladis
Enric Balletbo Serra Jan. 25, 2016, 4:56 p.m. UTC | #10
Hi Ladis,

2016-01-25 16:56 GMT+01:00 Ladislav Michl <ladis@linux-mips.org>:
> Hi Enric,
>
> On Mon, Jan 25, 2016 at 08:26:23AM +0100, Enric Balletbo Serra wrote:
>> The ROM boot on OMAP reads the first 4 blocks searching for the SPL,
>> in production is a practice flash the SPL 4 times. OneNAND/NAND
>> devices can have different block sizes and the OMAP ROM boot supports
>> block sizes from 64KB to 512K. For IGEP boards in particular, at least
>> there are boards that have block size of 128K and 256K. What I would
>> meant here is set as default the mtdparts variable to reserve 2M for
>> SPL, just to cover all the cases.
>>
>> mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0
>
> So far there was no ack or nack to yesterday's proposal making that
> dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks,
> only mtd needs fixed offset. So I'd like to see this offset calculated as
> 4*block_size, not some "worst case" value...
>
>         ladis

Your proposal looks good to me.
Heiko Schocher April 13, 2016, 5:19 a.m. UTC | #11
Hello Enric,

Am 25.01.2016 um 17:56 schrieb Enric Balletbo Serra:
> Hi Ladis,
>
> 2016-01-25 16:56 GMT+01:00 Ladislav Michl <ladis@linux-mips.org>:
>> Hi Enric,
>>
>> On Mon, Jan 25, 2016 at 08:26:23AM +0100, Enric Balletbo Serra wrote:
>>> The ROM boot on OMAP reads the first 4 blocks searching for the SPL,
>>> in production is a practice flash the SPL 4 times. OneNAND/NAND
>>> devices can have different block sizes and the OMAP ROM boot supports
>>> block sizes from 64KB to 512K. For IGEP boards in particular, at least
>>> there are boards that have block size of 128K and 256K. What I would
>>> meant here is set as default the mtdparts variable to reserve 2M for
>>> SPL, just to cover all the cases.
>>>
>>> mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0
>>
>> So far there was no ack or nack to yesterday's proposal making that
>> dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks,
>> only mtd needs fixed offset. So I'd like to see this offset calculated as
>> 4*block_size, not some "worst case" value...
>>
>>          ladis
>
> Your proposal looks good to me.
>

Are there any updates for this patch? The UBI SPL support is pending
for a while ...

I pushed my last (rebased to mainline) state to:

http://git.denx.de/?p=u-boot/u-boot-ubi.git;a=shortlog;h=refs/heads/ubi-spl

without the 2 igep00x0 board patches:

- [U-Boot,PATCHv7,6/7] igep00x0: UBIize
   https://patchwork.ozlabs.org/patch/569214/

- [U-Boot,PATCHv4,7/7] igep00x0: Falcon mode
   https://patchwork.ozlabs.org/patch/569215/

Could you please update your patches for the board support, so we can
push the UBI SPL support to mainline?

Thanks!

bye,
Heiko
Enric Balletbo Serra April 13, 2016, 11:39 a.m. UTC | #12
2016-04-13 7:19 GMT+02:00 Heiko Schocher <hs@denx.de>:
> Hello Enric,
>
>
> Am 25.01.2016 um 17:56 schrieb Enric Balletbo Serra:
>>
>> Hi Ladis,
>>
>> 2016-01-25 16:56 GMT+01:00 Ladislav Michl <ladis@linux-mips.org>:
>>>
>>> Hi Enric,
>>>
>>> On Mon, Jan 25, 2016 at 08:26:23AM +0100, Enric Balletbo Serra wrote:
>>>>
>>>> The ROM boot on OMAP reads the first 4 blocks searching for the SPL,
>>>> in production is a practice flash the SPL 4 times. OneNAND/NAND
>>>> devices can have different block sizes and the OMAP ROM boot supports
>>>> block sizes from 64KB to 512K. For IGEP boards in particular, at least
>>>> there are boards that have block size of 128K and 256K. What I would
>>>> meant here is set as default the mtdparts variable to reserve 2M for
>>>> SPL, just to cover all the cases.
>>>>
>>>> mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0
>>>
>>>
>>> So far there was no ack or nack to yesterday's proposal making that
>>> dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks,
>>> only mtd needs fixed offset. So I'd like to see this offset calculated as
>>> 4*block_size, not some "worst case" value...
>>>
>>>          ladis
>>
>>
>> Your proposal looks good to me.
>>
>
> Are there any updates for this patch? The UBI SPL support is pending
> for a while ...
>
> I pushed my last (rebased to mainline) state to:
>
> http://git.denx.de/?p=u-boot/u-boot-ubi.git;a=shortlog;h=refs/heads/ubi-spl
>
> without the 2 igep00x0 board patches:
>
> - [U-Boot,PATCHv7,6/7] igep00x0: UBIize
>   https://patchwork.ozlabs.org/patch/569214/
>
> - [U-Boot,PATCHv4,7/7] igep00x0: Falcon mode
>   https://patchwork.ozlabs.org/patch/569215/
>
> Could you please update your patches for the board support, so we can
> push the UBI SPL support to mainline?
>

Ladis, did you have a chance to look and solve the latest comments I did?

These patch series looks really interesting, like Heiko I would like
to see these merged.

> Thanks!
>
>
> bye,
> Heiko
> --
> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Enric Balletbo Serra April 19, 2016, 10:15 a.m. UTC | #13
Hi Ladislav,

2016-04-13 13:39 GMT+02:00 Enric Balletbo Serra <eballetbo@gmail.com>:
> 2016-04-13 7:19 GMT+02:00 Heiko Schocher <hs@denx.de>:
>> Hello Enric,
>>
>>
>> Am 25.01.2016 um 17:56 schrieb Enric Balletbo Serra:
>>>
>>> Hi Ladis,
>>>
>>> 2016-01-25 16:56 GMT+01:00 Ladislav Michl <ladis@linux-mips.org>:
>>>>
>>>> Hi Enric,
>>>>
>>>> On Mon, Jan 25, 2016 at 08:26:23AM +0100, Enric Balletbo Serra wrote:
>>>>>
>>>>> The ROM boot on OMAP reads the first 4 blocks searching for the SPL,
>>>>> in production is a practice flash the SPL 4 times. OneNAND/NAND
>>>>> devices can have different block sizes and the OMAP ROM boot supports
>>>>> block sizes from 64KB to 512K. For IGEP boards in particular, at least
>>>>> there are boards that have block size of 128K and 256K. What I would
>>>>> meant here is set as default the mtdparts variable to reserve 2M for
>>>>> SPL, just to cover all the cases.
>>>>>
>>>>> mtdparts=mtdparts=gpmc-nand.0:2m(SPL),-(UBI)\0
>>>>
>>>>
>>>> So far there was no ack or nack to yesterday's proposal making that
>>>> dynamic; Both boot ROM and ubispl code thinks in terms of eraseblocks,
>>>> only mtd needs fixed offset. So I'd like to see this offset calculated as
>>>> 4*block_size, not some "worst case" value...
>>>>
>>>>          ladis
>>>
>>>
>>> Your proposal looks good to me.
>>>
>>
>> Are there any updates for this patch? The UBI SPL support is pending
>> for a while ...
>>
>> I pushed my last (rebased to mainline) state to:
>>
>> http://git.denx.de/?p=u-boot/u-boot-ubi.git;a=shortlog;h=refs/heads/ubi-spl
>>
>> without the 2 igep00x0 board patches:
>>
>> - [U-Boot,PATCHv7,6/7] igep00x0: UBIize
>>   https://patchwork.ozlabs.org/patch/569214/
>>
>> - [U-Boot,PATCHv4,7/7] igep00x0: Falcon mode
>>   https://patchwork.ozlabs.org/patch/569215/
>>
>> Could you please update your patches for the board support, so we can
>> push the UBI SPL support to mainline?
>>
>
> Ladis, did you have a chance to look and solve the latest comments I did?
>

If you don't have enough time maybe I can pickup the patches and
finish the work, if it's ok. I'll have some time this weekend.


> These patch series looks really interesting, like Heiko I would like
> to see these merged.
>
>> Thanks!
>>
>>
>> bye,
>> Heiko
>> --
>> DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
>> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
diff mbox

Patch

diff --git a/include/configs/omap3_igep00x0.h b/include/configs/omap3_igep00x0.h
index 5da6cfd..9afbcbe 100644
--- a/include/configs/omap3_igep00x0.h
+++ b/include/configs/omap3_igep00x0.h
@@ -74,6 +74,8 @@ 
 #define CONFIG_CMD_CACHE
 #ifdef CONFIG_BOOT_ONENAND
 #define CONFIG_CMD_ONENAND	/* ONENAND support		*/
+#else
+#define CONFIG_CMD_UBI
 #endif
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_PING
@@ -86,6 +88,10 @@ 
 	"stdout=serial\0" \
 	"stderr=serial\0"
 
+#define ENV_MTD_SETTINGS \
+	"mtdids=nand0=gpmc-nand.0\0" \
+	"mtdparts=mtdparts=gpmc-nand.0:512k(SPL),-(UBI)\0"
+
 #define MEM_LAYOUT_SETTINGS \
 	DEFAULT_LINUX_BOOT_ENV \
 	"scriptaddr=0x87E00000\0" \
@@ -96,36 +102,15 @@ 
 
 #include <config_distro_bootcmd.h>
 
-
 #define CONFIG_EXTRA_ENV_SETTINGS \
 	ENV_DEVICE_SETTINGS \
+	ENV_MTD_SETTINGS \
 	MEM_LAYOUT_SETTINGS \
 	BOOTENV
 
 #endif
 
 /*
- * FLASH and environment organization
- */
-
-#ifdef CONFIG_BOOT_ONENAND
-#define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
-
-#define ONENAND_ENV_OFFSET		0x260000 /* environment starts here */
-
-#define CONFIG_ENV_IS_IN_ONENAND	1
-#define CONFIG_ENV_SIZE			(512 << 10) /* Total Size Environment */
-#define CONFIG_ENV_ADDR			ONENAND_ENV_OFFSET
-#endif
-
-#ifdef CONFIG_NAND
-#define CONFIG_ENV_OFFSET		0x260000 /* environment starts here */
-#define CONFIG_ENV_IS_IN_NAND	        1
-#define CONFIG_ENV_SIZE			(512 << 10) /* Total Size Environment */
-#define CONFIG_ENV_ADDR			NAND_ENV_OFFSET
-#endif
-
-/*
  * SMSC911x Ethernet
  */
 #if defined(CONFIG_CMD_NET)
@@ -134,19 +119,50 @@ 
 #define CONFIG_SMC911X_BASE		0x2C000000
 #endif /* (CONFIG_CMD_NET) */
 
+/*
+ * FLASH and environment organization
+ */
+#ifdef CONFIG_NAND
+#define CONFIG_SPL_UBI			1
+#define CONFIG_SPL_UBI_MAX_VOL_LEBS	256
+#define CONFIG_SPL_UBI_MAX_PEB_SIZE	(256*1024)
+#define CONFIG_SPL_UBI_MAX_PEBS		4096
+#define CONFIG_SPL_UBI_VOL_IDS		8
+#define CONFIG_SPL_UBI_LOAD_MONITOR_ID	0
+#define CONFIG_SPL_UBI_LOAD_KERNEL_ID	3
+#define CONFIG_SPL_UBI_LOAD_ARGS_ID	4
+#define CONFIG_SPL_UBI_PEB_OFFSET	4
+#define CONFIG_SPL_UBI_VID_OFFSET	512
+#define CONFIG_SPL_UBI_LEB_START	2048
+#define CONFIG_SPL_UBI_INFO_ADDR	0x88080000
+
+#define CONFIG_ENV_IS_IN_UBI		1
+#define CONFIG_ENV_UBI_PART		"UBI"
+#define CONFIG_ENV_UBI_VOLUME		"config"
+#define CONFIG_ENV_UBI_VOLUME_REDUND	"config_r"
+#define CONFIG_UBI_SILENCE_MSG		1
+#define CONFIG_UBIFS_SILENCE_MSG	1
+#else
+#define CONFIG_ENV_IS_NOWHERE
+#endif
+#define CONFIG_ENV_SIZE			(32*1024)
+
+#define CONFIG_RBTREE
+#define CONFIG_MTD_PARTITIONS
+#define MTDIDS_DEFAULT			"nand0=gpmc-nand.0"
+#define MTDPARTS_DEFAULT		"mtdparts=gpmc-nand.0:512k(SPL),-(UBI)"
+
 /* OneNAND boot config */
 #ifdef CONFIG_BOOT_ONENAND
 #define CONFIG_SPL_ONENAND_SUPPORT
-#define CONFIG_SYS_ONENAND_U_BOOT_OFFS  0x80000
 #define CONFIG_SYS_ONENAND_PAGE_SIZE	2048
-#define CONFIG_SPL_ONENAND_LOAD_ADDR    0x80000
-#define CONFIG_SPL_ONENAND_LOAD_SIZE    \
-	(512 * 1024 - CONFIG_SPL_ONENAND_LOAD_ADDR)
-
+#define CONFIG_SYS_ONENAND_BASE		ONENAND_MAP
+#define CONFIG_SYS_ONENAND_U_BOOT_OFFS	0x80000
 #endif
 
 /* NAND boot config */
 #ifdef CONFIG_NAND
+#define CONFIG_SPL_NAND_SUPPORT
 #define CONFIG_SYS_NAND_BUSWIDTH_16BIT
 #define CONFIG_SYS_NAND_5_ADDR_CYCLE
 #define CONFIG_SYS_NAND_PAGE_COUNT	64
@@ -166,14 +182,8 @@ 
 #define CONFIG_NAND_OMAP_ECCSCHEME	OMAP_ECC_BCH8_CODE_HW_DETECTION_SW
 #define CONFIG_NAND_OMAP_GPMC
 #define CONFIG_BCH
-
-#define CONFIG_SYS_NAND_U_BOOT_OFFS	0x80000
-/* NAND: SPL falcon mode configs */
-#ifdef CONFIG_SPL_OS_BOOT
-#define CONFIG_CMD_SPL_NAND_OFS		0x240000
-#define CONFIG_SYS_NAND_SPL_KERNEL_OFFS	0x280000
-#define CONFIG_CMD_SPL_WRITE_SIZE	0x2000
-#endif
 #endif
 
+#undef CONFIG_SPL_EXT_SUPPORT
+
 #endif /* __IGEP00X0_H */