Skip to contentSkip to conversation

what's the uboot way to pass eth*addr to linux ?

U-Boot Philippe De Muyter 5 participants 12 messages Feb 19, 2010 – Mar 5, 2010

lore
Share & tools
lore
#0 lore raw

Hello

I have a problem : my (coldfire) linux kernel does not reuse the mac addresses known by u-boot as ethaddr and eth1addr.

I have read doc/README.enetaddr, that states :

struct bd_info [...]
are temporary copies of the MAC address only for the purpose of passing this information to an OS kernel we are about to boot.

but I see no field in bd_info that could be set before booting linux.

I thought that the address of the environment zone could be given to linux, but I do not see where either.

So what's the recommended/supported way to inform the kernel of the mac addresses of all the ethernet interfaces ?

Philippe

#1 lore raw

Hi Philippe!

May be it is a little bit tricky but you can just read the u-boot environment from you Linux driver and use the "ethaddr" variable. I did the same for osk5912

2010/2/19 Philippe De Muyter <[email protected]>

Quoted 26 lines

Hello

I have a problem : my (coldfire) linux kernel does not reuse the mac addresses known by u-boot as ethaddr and eth1addr.

I have read doc/README.enetaddr, that states :

struct bd_info [...]
are temporary copies of the MAC address only for the purpose of passing this information to an OS kernel we are about to boot.

but I see no field in bd_info that could be set before booting linux.

I thought that the address of the environment zone could be given to linux, but I do not see where either.

So what's the recommended/supported way to inform the kernel of the mac addresses of all the ethernet interfaces ?

Philippe
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#2 lore raw

Hi Maxim,

Quoted 5 lines · Maxim Podbereznyi

Hi Philippe!

May be it is a little bit tricky but you can just read the u-boot environment from you Linux driver and use the "ethaddr" variable. I did the same for osk5912

Thanks, but I need something more straightforward. The ethernet driver in linux must know the mac address at startup to be able to have root on nfs.

Previously, the mac addresses were stored in the bd_info struct, but that has been removed, but alas not replaced by a common mechanism for all architectures.

Philippe

#3 lore raw

Dear Philippe De Muyter,

Quoted 4 lines · In message <[email protected]> you wrote:

Previously, the mac addresses were stored in the bd_info struct, but that has been removed, but alas not replaced by a common mechanism for all architectures.

Complain about this to the Linux architecture maintainers - there have been many and longf discussions about this before.

Today we consider the device tree to be the Right Thing (TM) to pass such information to the kernel, and more and more architectures use this method.

As long as it's not available for your architecture, the most straightforward way is to pass an "ethaddr=..." argument on the kernel command line. Drivers can pick it up easily there. Just don't expect that such Linux driver code will be accepted for mainline.

#4 lore raw

Hello Wolfgang,

Quoted 10 lines · Wolfgang Denk

Dear Philippe De Muyter,

Quoted 4 lines · In message <[email protected]> you wrote:

Previously, the mac addresses were stored in the bd_info struct, but that has been removed, but alas not replaced by a common mechanism for all architectures.

Complain about this to the Linux architecture maintainers - there have been many and longf discussions about this before.

Do you mean lkml or some other mailing list or individual ?

Quoted 4 lines

Today we consider the device tree to be the Right Thing (TM) to pass such information to the kernel, and more and more architectures use this method.

AFAIK, device trees are powerpc-specific and my board is coldfire based.

Quoted 5 lines

As long as it's not available for your architecture, the most straightforward way is to pass an "ethaddr=..." argument on the kernel command line. Drivers can pick it up easily there. Just don't expect that such Linux driver code will be accepted for mainline.

I don't like that method because it can easily be forgotten by someone changing bootargs for some other reason. IMO bootargs should only be used for configuration choices.

I'd rather go for an additional parameter given by u-boot to linux with the address of the used u-boot environment, passed the same way that the address of bd_info is given to linux (for coldfire's, that's on the stack)

Philippe

#5 lore raw

Dear Philippe De Muyter,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 3 lines

Complain about this to the Linux architecture maintainers - there have been many and longf discussions about this before.

Do you mean lkml or some other mailing list or individual ?

I had especially the ARM list and RMK in mind.

Quoted 5 lines
Quoted 3 lines

Today we consider the device tree to be the Right Thing (TM) to pass such information to the kernel, and more and more architectures use this method.

AFAIK, device trees are powerpc-specific and my board is coldfire based.

Several other architecture use the device tree as well, and more are following. For example, an adaption for ARM is on the way right now.

Quoted 8 lines
Quoted 4 lines

As long as it's not available for your architecture, the most straightforward way is to pass an "ethaddr=..." argument on the kernel command line. Drivers can pick it up easily there. Just don't expect that such Linux driver code will be accepted for mainline.

I don't like that method because it can easily be forgotten by someone changing bootargs for some other reason. IMO bootargs should only be used for configuration choices.

Well, that's mostly a matter of taste. At least it's an architecutre independent, standardized way to pass information.

Quoted 3 lines

I'd rather go for an additional parameter given by u-boot to linux with the address of the used u-boot environment, passed the same way that the address of bd_info is given to linux (for coldfire's, that's on the stack)

i. e. you create yet another, non-standard solution - exactly what you complained about originally.

Best regards,

Wolfgang Denk

Signature · 6 lines
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
Humanity has the  stars  in  its  future,  and  that  future  is  too
important  to be lost under the burden of juvenile folly and ignorant
superstition.                                          - Isaac Asimov
#6 lore raw
In reply to Philippe De Muyter
Quoted 9 lines · On Saturday 20 February 2010 04:37:17 Philippe De Muyter wrote:
Quoted 5 lines · Maxim Podbereznyi

Hi Philippe!

May be it is a little bit tricky but you can just read the u-boot environment from you Linux driver and use the "ethaddr" variable. I did the same for osk5912

Thanks, but I need something more straightforward. The ethernet driver in linux must know the mac address at startup to be able to have root on nfs.

a small static initramfs would take care of this just fine
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100305/25715b0e/attachment.pgp

#7 lore raw
In reply to Maxim Podbereznyi

Hi Maxim,

Quoted 5 lines · Maxim Podbereznyi

Hi Philippe!

May be it is a little bit tricky but you can just read the u-boot environment from you Linux driver and use the "ethaddr" variable. I did the same for osk5912

Sorry, I replied too fast, It seems that I misunderstood your answer. How do you access the U-boot environment from the linux driver ? Is there a linux kernel library function to retrieve one element of a U-boot environment ? Does U-boot tell linux where the U-boot environment resides in memory ?

Philippe

#8 lore raw

Hi!

Well, I know nothing about coldfire but for osk5912 it is well known where all partitions reside on the flash. You can find it the u-boot config file for coldfire.

The code for MontaVista with kernel 2.4:

static int nicGetMacAddress(u8* macaddr)

{
    int ret = 0;

    if (check_mem_region(FLASH_PARAM_
ADDR, FLASH_PARAM_SIZE)) {
      printk("enc28j60: flash memory already in use\n");
      return ENXIO;
    }
    else {
      unsigned long base = FLASH_PARAM_ADDR;
      unsigned long size = FLASH_PARAM_SIZE;
      void *vbase;
      unsigned char *sf = NULL;
      int res;
      int i;
      char *endptr;

      res = request_mem_region(base, size, "enc28j60-flash");
      if (!res) {
        printk("enc28j60: flash memory mapping failed\n");
        return ENXIO;
      }
      vbase = ioremap(base, size);
      if (!vbase) {
        printk("enc28j60: flash memory ioremap failed\n");
        return ENOMEM;
      }
      sf = (char *)vbase;

      endptr = fw_getenv(sf, "ethaddr");
      if (endptr)
      for (i=0; i<6; i++) { // IPv4
        unsigned long tmp;
        char *str = endptr+1;
        tmp = enc28_strtoul(str, &endptr, 16);
        *macaddr++ = tmp;
      }
      else {
        printk("enc28j60: no ethaddr variable in u-boot environment");
        ret = EINVAL;
      }

      iounmap(vbase);
      release_resource(res);
    }

    return ret;
}

Hope you can easily adapt it to your kernel!

2010/2/20 Philippe De Muyter <[email protected]>

Quoted 18 lines

Hi Maxim,

Quoted 4 lines · Maxim Podbereznyi

Hi Philippe!

May be it is a little bit tricky but you can just read the u-boot environment from you Linux driver and use the "ethaddr" variable. I did

the

Quoted 1 line

same for osk5912

Sorry, I replied too fast, It seems that I misunderstood your answer. How do you access the U-boot environment from the linux driver ? Is there a linux kernel library function to retrieve one element of a U-boot environment ? Does U-boot tell linux where the U-boot environment resides in memory ?

Philippe

#9 lore raw

Hi Maxim,

Quoted 5 lines · Maxim Podbereznyi

The code for MontaVista with kernel 2.4:

static int nicGetMacAddress(u8* macaddr)
{

[...]

Quoted 1 line
      endptr = fw_getenv(sf, "ethaddr");

[...]

Quoted 3 lines

}

Hope you can easily adapt it to your kernel!

So the library fucntion to retrieve the value of a u-boot environment variable is 'fw_getenv'. I do not have that function in my linux sources.

Philippe

#10 lore raw

Hi Philippe,

Quoted 13 lines · Philippe De Muyter

Hi Maxim,

Quoted 5 lines · Maxim Podbereznyi

The code for MontaVista with kernel 2.4:

static int nicGetMacAddress(u8* macaddr)
{

[...]

Quoted 1 line
      endptr = fw_getenv(sf, "ethaddr");

[...]

Quoted 2 lines

}

Quoted 9 lines
Quoted 1 line

Hope you can easily adapt it to your kernel!

So the library fucntion to retrieve the value of a u-boot environment variable is 'fw_getenv'. I do not have that function in my linux sources.

It's a tool in the U-boot source tree.

Philippe

regards,
Ben

#11 lore raw
In reply to Philippe De Muyter

Dear Philippe De Muyter,

Quoted 5 lines · In message <[email protected]> you wrote:
Quoted 2 lines

Hope you can easily adapt it to your kernel!

So the library fucntion to retrieve the value of a u-boot environment variable is 'fw_getenv'. I do not have that function in my linux sources.

Did I not already point you to tools/env/* ?

Best regards,

Wolfgang Denk

Signature · 5 lines
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
Without freedom of choice there is no creativity.
	-- Kirk, "The return of the Archons", stardate 3157.4