From: Lei Wen Date: Wed, 13 Oct 2010 03:07:21 +0000 (+0800) Subject: env_mmc: fix cannot save env issue X-Git-Tag: v2010.12-rc1~107 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e79f48393dd919079b34f37957c933f8e75c164d;p=u-boot env_mmc: fix cannot save env issue The env change its implementation after this log, while env mmc didn't change it immediately, which cause issue. Follow to the new style to fix it. commit ea882baf9c17cd142c99e3ff640d3ab01daa5cec Author: Wolfgang Denk Date: Sun Jun 20 23:33:59 2010 +0200 New implementation for internal handling of environment variables. Signed-off-by: Lei Wen --- diff --git a/common/env_mmc.c b/common/env_mmc.c index cc288d487c..dcab994e5d 100644 --- a/common/env_mmc.c +++ b/common/env_mmc.c @@ -29,6 +29,7 @@ #include #include #include +#include /* references to names in env_common.c */ extern uchar default_environment[]; @@ -96,13 +97,23 @@ inline int write_env(struct mmc *mmc, unsigned long size, int saveenv(void) { + env_t env_new; + ssize_t len; + char *res; struct mmc *mmc = find_mmc_device(CONFIG_SYS_MMC_ENV_DEV); if (init_mmc_for_env(mmc)) return 1; + res = (char *)&env_new.data; + len = hexport('\0', &res, ENV_SIZE); + if (len < 0) { + error("Cannot export environment: errno = %d\n", errno); + return 1; + } + env_new.crc = crc32(0, env_new.data, ENV_SIZE); printf("Writing to MMC(%d)... ", CONFIG_SYS_MMC_ENV_DEV); - if (write_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, env_ptr)) { + if (write_env(mmc, CONFIG_ENV_SIZE, CONFIG_ENV_OFFSET, (u_char *)&env_new)) { puts("failed\n"); return 1; }