public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Phil Sutter <phil.sutter@viprinet.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/4] env_nand.c: support falling back to redundant env when writing
Date: Thu, 20 Dec 2012 22:28:39 +0100	[thread overview]
Message-ID: <20121220212839.GJ22029@philter.vipri.net> (raw)
In-Reply-To: <1355267552.16025.0@snotra>

On Tue, Dec 11, 2012 at 05:12:32PM -0600, Scott Wood wrote:
> On 12/10/2012 07:41:43 AM, Phil Sutter wrote:
> > On Fri, Dec 07, 2012 at 11:38:11AM -0600, Scott Wood wrote:
> > > On 12/07/2012 10:58:53 AM, Phil Sutter wrote:
> > > > Hmm. Does not look like CONFIG_ENV_OFFSET_OOB is used to select  
> > the
> > > > block(s) within the erase page to save the environment. Looking at
> > > > common/env_nand.c:318, the environment offset saved in the OOB  
> > seems
> > > > to
> > > > be in erase page unit.
> > >
> > > I'm not sure what you mean by "block(s) within the erase page" --
> > > blocks are the unit of erasing, and of bad block marking.
> > 
> > Not always, at least not with NAND flash. Erase pages are mostly  
> > bigger
> > than write pages (or "blocks"). In my case, flash consists of 0x800
> > bytes write pages and 0x2000 bytes erase pages.
> 
> Erase blocks are larger than write pages, yes.  I've never heard erase  
> blocks called "pages" or write pages called "blocks" -- but my main  
> point is that the unit of erasing and the unit of badness are the same.

Ah, OK. Please excuse my humble nomenclature, I never cared enough to
sort out what is called what. Of course, this is not the best basis for
a discussion about these things.

But getting back to the topic: The assumption of blocks getting bad, not
pages within a block means that for any kind of bad block prevention,
multiple blocks need to be used. Although I'm honestly speaking not
really sure why this needs to be like that. Maybe the bad page marking
would disappear when erasing the block it belongs to?

> > > The block to hold the environment is stored in the OOB of block  
> > zero,
> > > which is usually guaranteed to not be bad.
> > 
> > Erase or write block? Note that every write block has it's own OOB.
> 
> "block" means "erase block".
> 
> Every write page has its own OOB, but it is erase blocks that are  
> marked bad.  Typically the block can be marked bad in either the first  
> or the second page of the erase block.

Interesting. I had the impression of pages being marked bad and the
block's badness being taken from whether it contains bad pages. Probably
the 'nand markbad' command tricked me.

> > > > On the other hand, I could not find code that alters this setting
> > > > based
> > > > on bad blocks found or whatever. This seems to simply be an
> > > > alternative
> > > > to setting CONFIG_ENV_OFFSET at build-time.
> > >
> > > It is set by the "nand env.oob" command.  It is currently a manual
> > > process (or rather, automation is left to the user's board  
> > preparation
> > > process rather than being built into U-Boot), as U-Boot wouldn't  
> > know
> > > how to give back unused blocks to other purposes.
> > 
> > So that assumes that any block initially identified 'good' will ever
> > turn 'bad' later on?
> 
> We don't currently have any mechanism for that to happen with the  
> environment -- which could be another good reason to have real  
> redundancy that doesn't get crippled from day one by having one copy  
> land on a factory bad block.  Of course, that requires someone to  
> implement support for redundant environment combined with  
> CONFIG_ENV_OFFSET_OOB.

Well, as long as CONFIG_ENV_OFFSET_REDUND supported falling back to the
other copy in case of error there would be a working system in three of
four cases instead of only one.

> Maybe a better option is to implement support for storing the  
> environment in ubi, although usually if your environment is in NAND  
> that means your U-Boot image is in NAND, so you have the same problem  
> there.  Maybe you could have an SPL that contains ubi support, that  
> fits in the guaranteed-good first block.
> 
> Do you have any data on how often a block might go bad that wasn't  
> factory-bad, to what extent reads versus writes matter, and whether  
> there is anything special about block zero beyond not being factory-bad?

No, sadly not. I'd guess this information depends on what hardware being
used specifically. But I suppose block zero being prone to becoming
worn just like any other block, although it not being erased as often
should help a lot.

Assuming a certain number of erase cycles after each block is worn out
and given the fact that CONFIG_ENV_OFFSET_REDUND has always both blocks
written (unless power failure occurs), they would turn bad at the same
time and therefore rendering the environment useless with or without
fallback. :)

Best wishes, Phil

-- 
Viprinet Europe GmbH
Mainzer Str. 43
55411 Bingen am Rhein
Germany

Phone/Zentrale:               +49 6721 49030-0
Direct line/Durchwahl:        +49 6721 49030-134
Fax:                          +49 6721 49030-109

phil.sutter at viprinet.com
http://www.viprinet.com

Registered office/Sitz der Gesellschaft: Bingen am Rhein, Germany
Commercial register/Handelsregister: Amtsgericht Mainz HRB44090
CEO/Gesch?ftsf?hrer: Simon Kissel

  reply	other threads:[~2012-12-20 21:28 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-21 12:59 [U-Boot] [PATCH 1/4] Optimized nand_read_buf for kirkwood Phil Sutter
2012-11-21 12:59 ` [U-Boot] [PATCH 2/4] env_nand.c: support falling back to redundant env when writing Phil Sutter
2012-11-27 22:04   ` Scott Wood
2012-11-28 21:06     ` Phil Sutter
2012-12-06 18:18       ` Scott Wood
2012-12-07 11:53         ` Phil Sutter
2012-12-07 16:58           ` Phil Sutter
2012-12-07 17:38             ` Scott Wood
2012-12-10 13:41               ` Phil Sutter
2012-12-11 23:12                 ` Scott Wood
2012-12-20 21:28                   ` Phil Sutter [this message]
2012-12-20 21:41                     ` Scott Wood
2012-12-21 10:34                       ` Phil Sutter
2012-12-22  2:29                         ` Scott Wood
2012-11-21 12:59 ` [U-Boot] [PATCH 3/4] env_nand.c: do warn only if really no valid environment could be loaded Phil Sutter
2012-11-27 22:06   ` Scott Wood
2012-11-27 22:07     ` Scott Wood
2013-02-20  0:33   ` Scott Wood
2012-11-21 12:59 ` [U-Boot] [PATCH 4/4] common/env_nand.c: calculate crc only when readenv was OK Phil Sutter
2012-11-26  3:46 ` [U-Boot] [PATCH 1/4] Optimized nand_read_buf for kirkwood Prafulla Wadaskar
2012-11-26 10:29   ` Phil Sutter
2012-11-26 10:33     ` Phil Sutter
2012-11-26 23:39       ` Scott Wood
2012-12-20  6:44         ` Prafulla Wadaskar
2012-12-20 10:55           ` Phil Sutter
2013-02-21 17:21 ` [U-Boot] Version 2 of Kirkwood and env_nand improvements Phil Sutter
2013-02-21 17:21   ` [U-Boot] [PATCHv2 1/4] Optimized nand_read_buf for kirkwood (V3) Phil Sutter
2013-02-23  1:26     ` Scott Wood
2013-02-21 17:21   ` [U-Boot] [PATCHv2 2/4] env_nand.c: support falling back to redundant env when writing Phil Sutter
2013-02-23  1:32     ` Scott Wood
2013-02-21 17:21   ` [U-Boot] [PATCHv2 3/4] env_nand.c: clarify log messages when env reading fails Phil Sutter
2013-02-23  1:59     ` Scott Wood
2013-02-25  9:39       ` Phil Sutter
2013-02-25 22:40         ` Scott Wood
2013-02-21 17:21   ` [U-Boot] [PATCHv2 4/4] common/env_nand.c: calculate crc only when readenv was OK Phil Sutter
2013-02-23  2:00     ` Scott Wood
2013-06-26 18:25   ` [U-Boot] Version 3 of Kirkwood and env_nand improvements Phil Sutter
2013-06-26 18:25     ` [U-Boot] [PATCH v3 1/2] Optimized nand_read_buf for kirkwood Phil Sutter
2013-06-27 10:02       ` Albert ARIBAUD
2013-08-19 23:29       ` [U-Boot] [U-Boot,v3,1/2] " Scott Wood
2013-06-26 18:25     ` [U-Boot] [PATCH v3 2/2] env_nand.c: support falling back to redundant env when writing Phil Sutter
2013-07-17 22:25       ` Scott Wood
2013-07-19 10:09         ` Phil Sutter
2013-07-19 10:20           ` [U-Boot] [PATCH] " Phil Sutter
2013-07-19 10:30             ` Phil Sutter
2013-08-22 22:50             ` [U-Boot] " Scott Wood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121220212839.GJ22029@philter.vipri.net \
    --to=phil.sutter@viprinet.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox