
On Wed, Jun 30, 2010 at 5:41 PM, Wolfgang Denk wd@denx.de wrote:
Dear Ben Gardiner,
In message 1277933528-8335-1-git-send-email-bengardiner@nanometrics.ca you wrote:
This is a re-submission of the patch by Harald Welte laforge@openmoko.org with minor modifications for rebase and changes as suggested by Scott Wood scottwood@freescale.com [1] [2].
This patch enables the environment partition to have a run-time dynamic location (offset) in the NAND flash. The reason for this is simply that all NAND flashes have factory-default bad blocks, and a fixed compile time offset would mean that sometimes the environment partition would live inside factory bad blocks. Since the number of factory default blocks can be quite high (easily 1.3MBytes in current standard components), it is not economic to keep that many spare blocks inside the environment partition.
With this patch and CONFIG_ENV_OFFSET_OOB enabled, the location of the environment partition is stored in the out-of-band (OOB) data of the first block in flash. Since the first block is where most systems boot from, the vendors guarantee that the first block is not a factory default block.
Does this work with redundant environment in NAND?
Currently the use of CONFIG_ENV_OFFSET_OOB and CONFIG_ENV_OFFSET_REDUND is disabled. I think it could work when the env is in its own NAND partition (i.e. !ENV_IS_EMBEDDED and !CONFIG_NAND_ENV_DST).
We could require that the redundant env is CONFIG_ENV_SIZE after the offset specified in the OOB or that two offsets are store in the OOB area. The latter requires that the OOB size is large enough to store two offsets. The former requires that CONFIG_ENV_SIZE is a multiple of the erase block size and perhaps additional skip-if-bad-block behaviour.
Furthermore, to implement env.oob compatibility with redundant environments I believe that the use of the CONFIG_ENV_OFFSET_REDUND macro needs to be split into a 'use redundant env' macro and a 'value of redundant env offset' macro so that we don't have to redefine CONFIG_ENV_OFFSET_REDUND. For instance, I would change saveenv in env_nand.c to look something like:
---
#ifdef CONFIG_USE_ENV_REDUND int saveenv(void) { ... ret = writeenv(CONFIG_ENV_OFFSET_REDUND, (u_char *) env_ptr);
---
I see that compatibility of this feature with redundant environments would definitely increase its utility. Can I put that into a second patch series and leave this patch as-is to be considered for inclusion? Would you prefer that I re-spin this patch into a series that includes support for redundant environment?
Best Regards, Ben Gardiner