Set Ethernet MAC Address from EEPROM in U-Boot (i.MX6ULL)

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set Ethernet MAC Address from EEPROM in U-Boot (i.MX6ULL)

Jump to solution
1,722 Views
daneduplooy
Contributor III

How would one set the Ethernet MAC address in U-Boot from an I2C EEPROM (AT24MAC402 / i.MX6ULL)?

0 Kudos
1 Solution
1,687 Views
daneduplooy
Contributor III

nvmem-cells should be under &fec1 (not under mdio), then it works.

Also,

CONFIG_I2C_EEPROM=y
CONFIG_SYS_I2C_EEPROM_ADDR=0x58
CONFIG_NVMEM=y
CONFIG_DM_RTC=y // For NVMEM, otherwise compile error

and

        eth0_addr: eth-mac-addr@9A { /* 9A is the address in the EEPROM */
            reg = <0x9A 0x06>;
        };

View solution in original post

0 Kudos
3 Replies
1,688 Views
daneduplooy
Contributor III

nvmem-cells should be under &fec1 (not under mdio), then it works.

Also,

CONFIG_I2C_EEPROM=y
CONFIG_SYS_I2C_EEPROM_ADDR=0x58
CONFIG_NVMEM=y
CONFIG_DM_RTC=y // For NVMEM, otherwise compile error

and

        eth0_addr: eth-mac-addr@9A { /* 9A is the address in the EEPROM */
            reg = <0x9A 0x06>;
        };
0 Kudos
1,707 Views
daneduplooy
Contributor III

Hi, thanks for the response.

I am partly asking regarding the "best" way to do this; I have seen some implementations apparently just using the device tree, like so:

&i2c2 {
	clock-frequency = <100000>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_i2c2>;
	status = "okay";

    eeprom@58 {
        compatible = "atmel,24mac402";
        pagesize = <256>;
        read-only;
        reg = <0x58>;
        #address-cells = <1>;
        #size-cells = <1>;

        eth0_addr: eth-mac-addr@9A {
            reg = <0x0 0x06>;
        };
	};
};

&fec1 { /* ENET1 */
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_enet1>;
	phy-mode = "rmii";
	phy-handle = <&ethphy0>;
	status = "okay";

	mdio {
		#address-cells = <1>;
		#size-cells = <0>;

		nvmem-cells = <&eth0_addr>;
		nvmem-cell-names = "mac-address";

		ethphy0: ethernet-phy@0 {
            /* compatible = "ethernet-phy-ieee802.3-c22"; */
			reg = <0>; /* PHY Address 0 */
			/* max-speed = <100>;
			clocks = <&clks IMX6UL_CLK_ENET_REF>;
			clock-names = "rmii-ref"; */
		};
	};
};

I am not exactly sure what "nvem-cells" are though, and whether these possibly only apply to the kernel.

I can read the EEPROM from the U-Boot prompt, so it is getting initialised correctly via the Device Tree.

 

Or should I rather be implementing this using the C code, such as the library you have linked? Could you assist with the C code to set the Ethernet MAC address?

 

Thanks!

0 Kudos
1,713 Views
Bio_TICFSL
NXP TechSupport
NXP TechSupport

Hello,

No, the ethernet has its own driver for setting the MAC. for I2C driver please check:

https://github.com/u-boot/u-boot/blob/master/cmd/eeprom.c

 

Regards

 

 

0 Kudos