diff mbox

[U-Boot] env_init() for mmc

Message ID d1f8e367-1f0a-b33e-ba4e-adaebd33834c@ti.com
State Not Applicable
Delegated to: Jaehoon Chung
Headers show

Commit Message

Jean-Jacques Hiblot March 30, 2017, 9:06 a.m. UTC
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:



>
> York
>
> ________________________________________
> From: Jaehoon Chung <jh80.chung@samsung.com>
> Sent: Wednesday, March 29, 2017 9:49 PM
> To: york sun
> Cc: u-boot@lists.denx.de
> Subject: Re: env_init() for mmc
>
> Hi York,
>
> On 03/23/2017 07:58 AM, york sun wrote:
>> Jaehoon,
>>
>> I noticed the env_init() returns default environmental variable for SPL
>> build. I wonder if you can make some change to use the actual variables?
>> I am having some trouble to get the saved variable during SPL boot.
> Which trouble do you have for getting saved variable?
> If you can share in more detail, it's helpful to me. And I'm finding the solution for it.
> Now, i have a more free time than before.. :)
>
> Best Regards,
> Jaehoon Chung
>
>> York
>>
>>
>>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot

Comments

York Sun March 30, 2017, 3:19 p.m. UTC | #1
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
diff mbox

Patch

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;
  }