[U-Boot] [PATCH] Make flash protection work, when the environment is in EEPROM

Jon Smirl jonsmirl at gmail.com
Sat Mar 21 21:08:34 CET 2009


On Sat, Mar 21, 2009 at 3:52 PM, Wolfgang Denk <wd at denx.de> wrote:
> Dear Jon,
>
> In message <20090321135934.12464.65400.stgit at localhost> you wrote:
>> From: Eric Schumann <E.Schumann at phytec.de>
>>
>> On the pcm030 the environment is located in the onboard EEPROM. But we want
>> to handle flash sector protection in a safe manner. So we must read the
>> unlock environment variable from EEPROM instead from flash.
>>
>> This patch is required as long the evironment is saved into the EEPROM.
>>
>> Signed-off-by: Eric Schumann <E.Schumann at phytec.de>
>> Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
>> ---
>>  0 files changed, 0 insertions(+), 0 deletions(-)
>>
>> diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
>> index 391d169..1436131 100644
>> --- a/drivers/mtd/cfi_flash.c
>> +++ b/drivers/mtd/cfi_flash.c
>> @@ -2009,7 +2009,9 @@ unsigned long flash_init (void)
>>  #endif
>>
>>  #ifdef CONFIG_SYS_FLASH_PROTECTION
>> -     char *s = getenv("unlock");
>> +     /* read environment from EEPROM */
>> +     char s[4];
>> +     getenv_r ("unlock", s, sizeof(s));
>>  #endif
>
> This patch doesn't really make sense to me. The flash_init() code  is
> only  being  run  after  relocation  to  RAM, so standard getenv() is
> supposed to work, and there should be no reason why we would have  to
> fall back on getenv_r().

I didn't write these, these are the Phytex pcm030 board support
patches from Pengutronix that have never been submitted to mainline.
They're all working on my hardware but of course there may be better
ways to do things.

My guess is getenv() returns a pointer to the environment variable,
not a copy of the environment variable. getenv_r() returns a copy. How
can you return a pointer to the variable if the variable is in
something not directly addressable like EEPROM?  Does
getenv("unlock"); do what you want when the environment is in EEPROM?

>
> Please explain which issues you are observing.
>
>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
> "Who is the oldest inhabitant of this village?"
> "We haven't got one; we had one, but he died three weeks ago."
>



-- 
Jon Smirl
jonsmirl at gmail.com


More information about the U-Boot mailing list