Assign static mac to second ethernet

I am using an iMX6 Solo in the evaluation board.
IN my application I have to use two ethernet. One is default ethernet and second i am adding using SPI ethernet.
I have used the ENC28J60 module with SPI interface. I had add below code in device-tree file.

/* Colibri SSP */
&ecspi4 {
	enc28j60x0: enc28j60x@0 {
		compatible = "microchip,enc28j60";
		reg = <0>;
	//	clocks = <&clk16m>;
		interrupt-parent = <&gpio3>;
		interrupts = <27 0x2>;
		spi-max-frequency = <10000000>;
		status = "okay";
	};
	/* To keep the CAN controller enabled by default,
	 * disable conflicting spidev. This spidev device
	 * enables with the devicetree overlay.
	 */
	spidev0: spidev@0 {
		status = "disabled";
	};
};

My second ethernet is working. but the problem is the MAC address is changed in every boot.
How can I assign static mac to this interface?

Hi Brijesh,

Have you tried adding optional property local-mac-address or mac-address in device tree node

 /* Colibri SSP */
 &ecspi4 {
     enc28j60x0: enc28j60x@0 {
         compatible = "microchip,enc28j60";
         reg = <0>;
     //    clocks = <&clk16m>;
         interrupt-parent = <&gpio3>;
         interrupts = <27 0x2>;
         spi-max-frequency = <10000000>;
         local-mac-address = [aa ee 03 04 01 02];
         status = "okay";
     };
     /* To keep the CAN controller enabled by default,
      * disable conflicting spidev. This spidev device
      * enables with the devicetree overlay.
      */
     spidev0: spidev@0 {
         status = "disabled";
     };
 };

Let me know if that works for you.

Best Regards

Ritesh Kumar

Hi

I had tried this but still mac address change at every boot.

Hi Brijesh,

We do not have hardware to test, ideally as per documentation this should be enough to set MAC.
Another method you can try from systemd-networkd setting the MAC.

/etc/systemd/network/00-eth1.link
    
[Match]
Interface=eth1

[Link]
MACAddress=aa:ee:03:04:01:02

Reference link below

https://wiki.archlinux.org/index.php/MAC_address_spoofing

Best Regards

Ritesh Kumar