On 03/30/2017 02:06 AM, Jean-Jacques Hiblot wrote: > > > On 30/03/2017 06:57, york sun wrote: >> Sorry for top posting. I am using OWA which doesn't do inline reply. >> >> Jaehoon, >> >> The trouble is the env_init() returns the default environment for SPL part. >> It means whatever variables I saved doesn't get loaded during the SPL part. >> It is only available after the SPL loads the RAM version. For example, we >> have hwconfig variable to control how we want to do DDR interleaving. It is >> saved. For NOR flash boot, it has no issue. But for eMMC/SD/QSPI boot, the >> env_init() doesn't use the real variable and ignore what I saved. After >> U-Boot fully comes up, I can see the correct variable. > Hi York, > > Without more details it's difficult to conclude I had the same issue, > but I ran into something similar. > My problem was that the device were the env is stored wasn't not > initialized before accessing the environment because the boot device is > not where the env is stored. > The solution in my case was to call mmc_initialize() in the env_init(). > I haven't submitted a proper patch yet by lack of time but here is what > it looks like: > > diff --git a/common/env_ext4.c b/common/env_ext4.c > index ce748ed..54d8972 100644 > --- a/common/env_ext4.c > +++ b/common/env_ext4.c > @@ -42,6 +42,10 @@ int env_init(void) > gd->env_addr = (ulong)&default_environment[0]; > gd->env_valid = 1; > > + /* intialize the MMC sub-system if env is stored on a MMC*/ > + if (!strcmp(EXT4_ENV_INTERFACE, "mmc")) > + mmc_initialize(NULL); > + > return 0; > } > > diff --git a/common/env_fat.c b/common/env_fat.c > index 75616d4..1ed1ff6 100644 > --- a/common/env_fat.c > +++ b/common/env_fat.c > @@ -31,6 +31,10 @@ int env_init(void) > gd->env_addr = (ulong)&default_environment[0]; > gd->env_valid = 1; > > + /* intialize the MMC sub-system if env is stored on a MMC*/ > + if (!strcmp(FAT_ENV_INTERFACE, "mmc")) > + mmc_initialize(NULL); > + > return 0; > } > > diff --git a/common/env_mmc.c b/common/env_mmc.c > index af932a4..d2b1a29 100644 > --- a/common/env_mmc.c > +++ b/common/env_mmc.c > @@ -64,6 +64,11 @@ int env_init(void) > /* use default */ > gd->env_addr = (ulong)&default_environment[0]; > gd->env_valid = 1; > + /* > + * intialize the MMC sub-system. This will probe the > + * MMC controllers if not already done > + */ > + mmc_initialize(NULL); > > return 0; > } > >
That may be it. When I check env_init() in common/env_mmc.c, it simply has gd->env_addr = (ulong)&default_environment[0]; So before initializing mmc, there is no actual environmental variable loaded. Same thing happens to common/env_ext4.c, common/env_fat.c, common/env_sf.c, etc. I don't know if this was intentional. York _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot