[SOLVED] Why are MAC adresses regenerated at reboot?

Started by vinczo, January 05, 2017, 05:17:16 PM

Previous topic - Next topic

vinczo

Hi,

I am working on Olinuxino-RT5350F chip with OpenWRT firmware.
I have the following interfaces:
br-lan
eth0
eth0.1
eth0.2
lo
wlan0

I realised that after each reboot the MAC adress is regenerated for eth0, vlans (eth0.1,eth0.2) and wlan0.
There is only br-lan that keeps the same MAC adress after each reboot.

However, if I reflash the chip (with the same OpenWRT firmware), the MAC adress is changed for all interfaces br-lan included.

Note, that when I say MAC adress is changed, it is the full MAC adress that is changed  (Organisationally Unique Identifier included)!

Any insight would be very helpful,
Thanks in advance,

Vince

zgyarmati

 The MAC addresses of the wlan0 and the eth0 interfaces (theoretically at least) are set by the first bytes of the 'factory' flash partition, and as a fallback, if those values are not set, the driver generates random MAC address at each boot.
It seems that those bytes on the flash are not set in the Olimex provided images (which would be the ideal case). This issue also affects me as well, but i haven't really dig into this, i'll post my findings if any...
--<br />Zoltan Gyarmati

LubOlimex

As zgyarmati suggested, by default we don't set any MAC in the eeprom so MAC addressing is controlled by the OpenWRT Linux.

There are different methods to achieve what you want. One less obvious method that might be easier for production would be again using the rt5350f_factory.eeprom and set the MAC address for each board. Open the latest eeprom with e hex editor and type desired MAC address. Refer to this picture on where to edit: http://i.imgur.com/RNUw7LW.jpg

Find the pdf guide that can be used to understand the eeprom content here: https://github.com/OLIMEX/OLINUXINO/raw/master/SOFTWARE/RT5350F/Prebuilt%20images/mtd2%20recovery/RT307x_RT357x-EEPROM_Content_V1.62.pdf

When the file is ready follow the same procedure to update the eeprom as suggested here: https://github.com/OLIMEX/OLINUXINO/blob/master/SOFTWARE/RT5350F/Prebuilt%20images/mtd2%20recovery/README.md

Other than the method described above refer to the "more legit" practices proposed by OpenWRT community. There are several wiki articles on the subject, for example this one: https://wiki.openwrt.org/doc/uci/dhcp – I also recommend you to check on the OpenWRT forums for more user experience.

Best regards,
Lub/OLIMEX
Technical support and documentation manager at Olimex

zgyarmati

Some supplemental notes:

1. It's also possible to flash this value with an SPI programmer, as described here: https://www.olimex.com/wiki/RT5350F-OLinuXino#Upload_prebuilt_images_using_programmer_tool (might be better in a production run)

2. A MAC address contains 6 octets (while on the screenshot 8 is highlighted), so enough to set the 4:9 bytes

3. The value set on the factory partition sets both the eth0 and the wlan0 MAC address to the same value.
--<br />Zoltan Gyarmati

Syd

Hi,

I contacted an industrialist, the latter told me that they were installing and integrating EEPROMs containing a Mac address of type SPI or I2C.

I went on a 25AA02E48I component containing a single MAC address issued by MicroChip.

In the of_get_mac_address_mtd function, the address is searched in the DTS ( with mtd-mac-address keyword).



int of_get_mac_address_mtd(struct device_node *np, void *mac)



We find it (on offset 0x4) :

   
        ethernet@10100000 {
                mtd-mac-address = <&factory 0x4>;
        };



And the reference factory was define for a partition ( wifi eeprom ).


    factory: partition@40000 {
            label = "factory";
            reg = <0x40000 0x10000>;
            read-only;
    };


So , i search to change eeprom reference on another SPI flash like 25AAE48I (with offset 0xfa).

But, i didn't find good way , or drivers for it.

need few help ... thx  ;D




Syd


Ok, i try a simple issu :

here, we need to active the Kernel misc module for AT25 eeprom.



                        m25p80@1 {
                            #address-cells = <1>;
                            #size-cells = <1>;
                            compatible = "at25";
                            reg = <1>;
                            linux,modalias = "m25p80", "at25";
                            spi-max-frequency = <1000000>;

                            at25,byte-len = <0x100>;
                            at25,addr-mode = <1>;
                            at25,page-size = <16>;
                        };




and read Mac address on eeprom with script for the Wireless config :




NEWMAC==$(hexdump -C -s 250 -n 6 /sys/bus/spi/devices/spi32766.1/eeprom | awk  'NR==1 {  printf $2":"$3":"$4":"$5":"$6":"$7"\n" }')

logger "Applying random MAC address to WAN (${NEWMAC})..."

uci set network.wan.macaddr=${NEWMAC}
uci commit network