From: Wolfgang Denk Date: Mon, 23 Mar 2009 09:15:32 +0100 Subject: [U-Boot] [PATCH] Make flash protection work, when the environment is in EEPROM In-Reply-To: <9e4733910903222001h54568fao2f96dcbdc8925df5@mail.gmail.com> References: <20090321135934.12464.65400.stgit@localhost> <20090321195213.17AA7832E406@gemini.denx.de> <9e4733910903211308v63878fabx19f3327371db56c6@mail.gmail.com> <20090321202405.A557B832E406@gemini.denx.de> <20090322225904.GD20099@pengutronix.de> <9e4733910903222001h54568fao2f96dcbdc8925df5@mail.gmail.com> Message-ID: <20090323081532.4560A832E406@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear Jon, in message <9e4733910903222001h54568fao2f96dcbdc8925df5@mail.gmail.com> you wrote: > > >> > getenv("unlock"); do what you want when the environment is in EEPROM? > >> > >> getenv() always works that way, no matter which actual media is used > >> for the persistent storage of the environment. > > > > This is not quite true. In the PPC init sequence flash_init() is called > > before env_relocate() and thus getenv is not available in flash_init(). I see. You are right. > > Please note that this was just a quick way for us to make things work > > and I never considered this a fix for mainline. > > What is your fix for mainline? We cannot run env_relocate() before flash_init(), as (with environ- ment stored in flash) we need an initialized flash memory to do so. Consequently, we indeed have to use getenv_r() instead of getenv(). Stefan, will you pick up the original patch, please: http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/56275 Hm, you might want to change "char s[4];" into "char s[256];" or similar, though, to make buffer overflows less likely. 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 I used to be indecisive, now I'm not sure.