[U-Boot] [PATCH v3 2/2] env_nand.c: support falling back to redundant env when writing

Phil Sutter phil.sutter at viprinet.com
Fri Jul 19 12:09:43 CEST 2013


Hi,

On Wed, Jul 17, 2013 at 05:25:31PM -0500, Scott Wood wrote:
> On 06/26/2013 01:25:26 PM, Phil Sutter wrote:
> > Without this patch, when the currently chosen environment to be  
> > written
> > has bad blocks, saveenv fails completely. Instead, when there is
> > redundant environment fall back to the other copy. Environment reading
> > needs no adjustment, as the fallback logic for incomplete writes  
> > applies
> > to this case as well.
> > 
> > Signed-off-by: Phil Sutter <phil.sutter at viprinet.com>
> > ---
> >  common/env_nand.c | 105  
> > ++++++++++++++++++++++++------------------------------
> >  1 file changed, 46 insertions(+), 59 deletions(-)
> 
> Missing description of changes since v2
> 
> > -#else /* ! CONFIG_ENV_OFFSET_REDUND */
> > +
> > +static unsigned char env_flags;
> 
> env_nand.c:193:22: warning: 'env_flags' defined but not used
> [-Wunused-variable]
> 
> (when CONFIG_ENV_OFFSET_REDUND is not defined)
> 
> >  int saveenv(void)
> >  {
> >  	int	ret = 0;
> >  	ALLOC_CACHE_ALIGN_BUFFER(env_t, env_new, 1);
> >  	ssize_t	len;
> >  	char	*res;
> > +	int	env_idx;
> >  	nand_erase_options_t nand_erase_options;
> > +	static const struct env_location location[] = {
> > +		{
> > +			.name = "NAND",
> > +			.erase_opts = &nand_erase_options,
> > +			.offset = CONFIG_ENV_OFFSET,
> > +		},
> > +#ifdef CONFIG_ENV_OFFSET_REDUND
> > +		{
> > +			.name = "redundant NAND",
> > +			.erase_opts = &nand_erase_options,
> > +			.offset = CONFIG_ENV_OFFSET_REDUND,
> > +		},
> > +#endif
> > +	};
> > +
> 
> env_nand.c:206:4: error: initializer element is not constant
> env_nand.c:206:4: error: (near initialization for  
> 'location[0].erase_opts')
> 
> You could make nand_erase_options static, or you could use code to  
> assign
> that field.
> 
> Is this code untested, or did you accidentally send an old version?

Yes, indeed. My apologies for not having tested this, seems like a
combination of too much belief in your builtin parser and failure of
mine.

Corrected version which incorporates your suggestions and tries to solve
the issue above in a cleaner way follows. And yes, this time it has even
been tested.

Greetings, 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


More information about the U-Boot mailing list