[U-Boot-Users] reading ethaddr from env

Wolfgang Denk wd at denx.de
Thu Feb 24 23:49:50 CET 2005


In message <20050223100142.GA3003 at 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.




More information about the U-Boot mailing list