
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@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