Make my MAC address static/fixed using EEPROM

Started by chargrilled, January 03, 2015, 02:06:16 PM

Previous topic - Next topic

chargrilled

Hi all,

OK so pretty much what the subject says. 

I have an A20-OLinuXIno-LIME2 which I really do like however I would like to have a couple more and have them use DHCP reservations.  The only issue is the MAC address is being generated on each boot.

At this point I would like to quote part of the LIME2 "feature" list - "2KB EEPROM for MAC address storage and more"

Having looked though this forum and others I am very confused.  How exactly do I use the EEPROM (on I2C-1 0x50-0x57) to configure the MAC for the Linux kernel to us?  What if I bought some MAC addresses how do I get the board to use them??

I am open to other suggestions on how to fix the MAC address as long as the MAC address is not stored on SD/USB/SATA device etc.  So other hardware options are OK as long as I can clone the Linux setup and the boards all retain their own MACs.

Thanks

nickvanalst

I would be very interested in this as well.

We are using the SOM with our own board, so we will need to probably integrate the EEPROM our self.
But it would be nice to have some general direction of how it should be implemented!


chargrilled

Thanks progmetalbg.

Little irritating that the Lime2 doesnt have a SID and there isnt a jumper to let us burn one.  hey I still love the board  :).

So if I want to use a single image for multiple boards I guess the only real option is to stop the eth0 coming up on boot (upsets some corporate networks and security teams that audit MACs).  Then on boot read the EEPROM - if blank generate a MAC in one area of the EEPROM and then use that to bring up the eth0.

ejsanyo

I successfully made MAC address static by editing /etc/network/interfaces like this:
auto eth0
iface eth0 inet dhcp
hwaddress ether xx:xx:xx:xx:xx:xx

Where "xx" is your MAC

sylvain

#5
Hello

There's some interesting infos in https://www.olimex.com/forum/index.php?topic=1900.0 but I've still hasn't found a clear explanation on when and how we should read the MAC from EEPROM and configure it in the network interface.

I have previously used /etc/network/interfaces to set the MAC on OLinuXinos without EEPROM, it it works ok, but that means the MAC is bound to a file in the SD card instead a being bound to the hardware, and this is not how it should be done.

Assuming EEPROM contains the MAC address, and that I want the network interface to be properly configured before DHCP starts:

  • Should it be done with U-Boot reading the MAC from EEPROM? Can it be done with simple config parameters, or does that require to modify U-Boot sources?
  • Can the network driver module do it without rewriting it?
  • Should it be done during the Linux boot process, via a systemd script reading from EEPROM when the interface is enabled? If so, what script presently controls the random allocation of the MAC, and how should it be modified?
  • Should it be done in the rc.local after having disabled network during boot, and only enabling eth0 at the very end (not optimal for NTP to be up and running ASAP)?

I'm willing to try stuff, but some general directions would be appreciated :)

JohnS

Has been discussed at length on linux-sunxi ML with code.

John

sylvain

Hello John

Are those the relevant threads?
https://groups.google.com/forum/#!msg/linux-sunxi/Ze3fshafW-w/ytnIuwjY8rAJ
https://groups.google.com/forum/#!msg/linux-sunxi/98l-zeEtEZY/bVlxkenTAwAJ
https://groups.google.com/forum/#!msg/linux-sunxi/fKvYiCtfils/430rdeQKCQAJ
https://groups.google.com/forum/#!msg/linux-sunxi/QA2FC8rd3q8/1yRssXQKCQAJ

Is the recommended solution for now to rebuild uboot ourselves using those experimental patches?

Would loading the MAC address in uBoot automagically disable the random generation of a new one during boot?

Thanks

JohnS

I use the ML so I got them as email and don't use those groups.

As I was happy for the devs to change the code I didn't argue and will get whatever they did when getting newer code.

If you don't like what they did then be sure to tell them with reasons.

John

SR-Digitronic

When I understand that patch correctly, you need mainline U-Boot, which makes it unusable when you have to boot from NAND.

You can always manually set a MAC address with an initramfs init script with help of busybox's i2cget and ip command:
ETH0MAC=$(printf %x:%x:%x:%x:%x:%x `i2cget -y -f 1 0x50 0x16` `i2cget -y -f 1 0x50 0x17` `i2cget -y -f 1 0x50 0x18` `i2cget -y -f 1 0x50 0x19` `i2cget -y -f 1 0x50 0x1A` `i2cget -y -f 1 0x50 0x1B`)
if test "${ETH0MAC}" != "ff:ff:ff:ff:ff:ff"; then
    ip link set dev eth0 address ${ETH0MAC}
fi


You can also use a for loop and calculate the addresses, but for that you have to enable math support in your shell. In my case this made sense, since I already had a custom init script for making NAND read only with help of overlayfs.