[U-Boot] ethernet: ROM MAC address vs env variable MAC address

Prabhakar Kushwaha prabhakar.kushwaha at nxp.com
Wed Nov 8 12:02:55 UTC 2017


Hi All, 

I am seeing following type of code for MAC address write for a network device.

net/eth-uclass.c  eth_post_probe()   or net/eth_legacy.c eth_write_hwaddr()

	eth_env_get_enetaddr_by_index("eth", dev->seq, env_enetaddr);
	if (!is_zero_ethaddr(env_enetaddr)) {
		if (!is_zero_ethaddr(pdata->enetaddr) &&
		    memcmp(pdata->enetaddr, env_enetaddr, ARP_HLEN)) {
			printf("\nWarning: %s MAC addresses don't match:\n",
			       dev->name);
			printf("Address in ROM is          %pM\n",
			       pdata->enetaddr);
			printf("Address in environment is  %pM\n",
			       env_enetaddr);
		}

		/* Override the ROM MAC address */
		memcpy(pdata->enetaddr, env_enetaddr, ARP_HLEN);

Why ROM MAC address getting overwritten by environment env MAC address.  
MAC address is something unique and assigned to a particular device. So one should never change its MAC address.

Please suggest. 

Regards,
Prabhakar



More information about the U-Boot mailing list