[U-Boot] environment in NAND

Arno Steffen arno.steffen at googlemail.com
Wed Sep 7 11:34:14 CEST 2011


2011/9/7 Wolfgang Wegner <wolfgang at leila.ping.de>:
> Hi Arno,
>
> On Wed, Sep 07, 2011 at 08:20:22AM +0200, Arno Steffen wrote:
>> Hi Marek and Wolfgang, Thanks for your answers.
>> I kept already one sector space for bad blocks, so 1st environment is
>> at c.0000, 2nd at 10.0000. Blocksize is 2.0000 (so 1 block left).
>> Maybe I have to announce uboot, that there is one block more
>> available. But how, in wich defininition? I can declare size (which is
>> just 8k) and blocksize (128k), but not block number ?!?
>> I found that this below more or less relates to environment: Maybe I
>> miss something here? Some look redundant to me. I adopted this from
>> another board included in uboot, just changed size,location and
>> redundancy.
>>
>> #define CONFIG_ENV_SIZE                       (8 << 10)       /* 8 KiB */
>> #define CONFIG_SYS_MALLOC_LEN         (CONFIG_ENV_SIZE + (128 << 10))
>> #define CONFIG_SYS_GBL_DATA_SIZE      128     /* bytes reserved for */
>>
>> #define SMNAND_ENV_OFFSET             0x0C0000 /* environment starts here */
>>
>> #define CONFIG_SYS_ENV_SECT_SIZE      boot_flash_sec
>> #define CONFIG_ENV_OFFSET             boot_flash_off
>> #define CONFIG_ENV_ADDR                       boot_flash_env_addr
>>
>> #define CONFIG_SYS_REDUNDAND_ENVIRONMENT
>> #define CONFIG_ENV_OFFSET_REDUND      0x100000
>> #define CONFIG_ENV_SIZE_REDUND                (CONFIG_ENV_SIZE)
>
> this is my adapted openrd configuration:
> #define CONFIG_ENV_IS_IN_NAND           1
> #define CONFIG_ENV_SECT_SIZE            0x20000 /* 128K */
>
> #define CONFIG_ENV_SIZE                 0x20000 /* 128k */
> #define CONFIG_ENV_ADDR                 0x60000
> #define CONFIG_ENV_OFFSET               0x60000 /* env starts here */
> #define CONFIG_ENV_RANGE                (6 * CONFIG_ENV_SIZE)
> #define CONFIG_ENV_OFFSET_REDUND        (CONFIG_ENV_OFFSET + CONFIG_ENV_RANGE)
>
> It is too long ago I made this modification, so I am not sure (but of
> course hope so) that CONFIG_ENV_SIZE_REDUND does not have to be
> explicitly specified.
>
> Concerning your hint about making CONFIG_ENV_SIZE smaller: there
> is a comment in the original openrd_base.h config file
> /*
>  * max 4k env size is enough, but in case of nand
>  * it has to be rounded to sector size
>  */
> and I simply adhered to it. It is not clear to me if this is really
> a requirement or just made for convenience (having overview over the
> flash usage layout).
>
> Up to now, I did not have any problems with this setup on something
> like 100+ boards.
>
> Best regards,
> Wolfgang
>
>

You are right:
./include/environment.h:# if defined(CONFIG_ENV_ADDR_REDUND) &&
!defined(CONFIG_ENV_SIZE_REDUND)
./include/environment.h:#  define CONFIG_ENV_SIZE_REDUND	CONFIG_ENV_SIZE
If it is not defined it assumes the size is same.

It is not necessary to round up. I see a message from uboot, that env
size is smaller than a sector and a the complete sector will be
erased.
See log below. (From my understanding every change is a complete erase
and rewrite, as it all happens in just one sector).

But again, how did you managed this with bad blocks?

"# save
Saving Environment to NAND...
Erasing Nand...
Warning: Erase size 0x00002000 smaller than one erase block 0x00020000
         Erasing 0x00020000 instead
Skipping bad block at  0x000c0000

Writing to Nand... FAILED!"

So from what I observe is, that neither e0000 (next block) is erased
nor written.

Best regards
Arno


More information about the U-Boot mailing list