From: Wolfgang Denk Date: Thu, 24 Feb 2005 23:49:50 +0100 Subject: [U-Boot-Users] reading ethaddr from env In-Reply-To: Your message of "Wed, 23 Feb 2005 11:01:42 +0100." <20050223100142.GA3003@nabla101> Message-ID: <20050224224955.25547C1430@atlas.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 In message <20050223100142.GA3003@nabla101> you wrote: > > When u-boot starts and try to read the ethaddr, (lib_arm/board.c at 296), > the parameter tmp used in the function getenv_r is pointing to the gd->bd > structure, so the execution of this function corrupts the data stored in > it. You are wrong. "tmp" is a local array, declared in line 294: 294 uchar tmp[64]; 295 296 i = getenv_r ("ethaddr", tmp, sizeof (tmp)); > I've found a "dirty" workaround of this problem rising the size of tmp > buffer: What exactly is your problem? > /* uchar tmp[64]; */ > uchar tmp[128]; > > i = getenv_r ("ethaddr", tmp, sizeof (tmp)); Why do you think that 64 bytes should be insufficient to store the MAC address? > As you can see the tmp buffer is pointing to the gd->bd plus 4. At least this is what the debugger claims. > Any hints ? I cannot reproduce this problem here. WHat do you get when you use printf() to display the addresses _before_ calling getenv_r()? Best regards, Wolfgang Denk -- See us @ Embedded World, Nuremberg, Feb 22 - 24, Hall 10.0 Booth 310 Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de As a general rule, the freedom of any people can be judged by the volume of their laughter.