From mboxrd@z Thu Jan 1 00:00:00 1970 From: Scott Wood Date: Fri, 27 Jan 2012 15:46:07 -0600 Subject: [U-Boot] Question regarding NAND environment In-Reply-To: <4F218EA3.2000509@logicpd.com> References: <4F2187F4.1000503@logicpd.com> <4F218D07.8060204@freescale.com> <4F218EA3.2000509@logicpd.com> Message-ID: <4F231B1F.7010008@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 01/26/2012 11:34 AM, Peter Barada wrote: > On 01/26/2012 12:27 PM, Scott Wood wrote: >> Why are two copies insufficient for that? > Two copies are sufficient, if none of the blocks ever go bad. > > To simplify things, suppose the environment is the same size as a block > and you have only two blocks (and two copies) to hold the environment. > If one block goes bad then there is a window between when the one > remaining block is erased and written with the environment that if power > fails then there is no environment in NAND. It seems unlikely, but possible I guess. Currently I don't think we dynamically mark blocks bad at all in U-Boot, except in things like ubi and yaffs. > To solve this I can crank up the number of blocks to three which allows > one block to go bad and still at all times have one good copy of the > environment in NAND. But looking at writeenv(), it stops as soon as > either nand_write fails, or one copy of the environment is written. So > it could make sense to modify writeenv to write as many copies of the > environment that fit into CONFIG_ENV_RANGE, and have readenv read out > copies and verify them until it finds one good one. This isn't what CONFIG_ENV_RANGE is about. I think it would make more sense to change REDUND to support more than two copies (each with their own range). Probably better to never update the environment in the field -- source a script in an ubi partition instead. -Scott