MT7621A. MAC address not read from factory

I working with development board with MT7621 module from HiLInk (HLK_7621 development board).

MAC address generating randomly during boot.
I need the MAC address to be read from the EEPROM (factory partition).

In DTS file i set:

&gmac0 {
    nvmem-cells = <&macaddr_factory_e000>;
    nvmem-cell-names = "mac-address";
};

...
        port@4 {
            status = "okay";
            label = "wan";
            nvmem-cells = <&macaddr_factory_e000>;
            nvmem-cell-names = "mac-address";
        };

&factory {
        compatible = "nvmem-cells";
        #address-cells = <1>;
        #size-cells = <1>;

        macaddr_factory_e000: macaddr@e000 {
                reg = <0xe000 0x6>;
        };

        macaddr_factory_e006: macaddr@e006 {
                reg = <0xe006 0x6>;
        };
};

I can read MAC address from factory manually:

root@OpenWrt:/# 
root@OpenWrt:/# hexdump -n 6 -s 0xe000 /dev/mtd2
000e000 d640 fb3c a502                         
000e006
root@OpenWrt:/# 
root@OpenWrt:/# 
root@OpenWrt:/# hexdump -n 6 -s 0xe006 /dev/mtd2
000e006 d640 fb3c a602                         
000e00c
root@OpenWrt:/# 

You need to use nvmem-layout instead of old binding.

ref:

1 Like

I change to "nvmem-layout" in DTS. But, this is not help me

Compiled success, but

"mtk_soc_eth 1e100000.ethernet: generated random MAC address..." 

during boot
I use openwrt version r24673-659f027e69
Kernel version: 5.15.142

The complete DTS for my board:

// SPDX-License-Identifier: GPL-2.0-or-later

#include "mt7621.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
	compatible = "vreal,areal-7621", "mediatek,mt7621-soc";
	model = "AREAL-7621A";

	keys {
		compatible = "gpio-keys";

		reset {
			label = "reset";
			gpios = <&gpio 18 GPIO_ACTIVE_HIGH>;
			linux,code = <KEY_RESTART>;
		};
	};
};

&spi0 {
	status = "okay";

	flash@0 {
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <44000000>;
		broken-flash-reset;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			partition@0 {
				label = "u-boot";
				reg = <0x0 0x30000>;
				read-only;
			};

			partition@30000 {
				label = "u-boot-env";
				reg = <0x30000 0x10000>;
				read-only;
			};

			factory: partition@40000 {
				label = "factory";
				reg = <0x40000 0x10000>;
				read-only;
				nvmem-layout {
					compatible = "fixed-layout";
					#address-cells = <1>;
					#size-cells = <1>;

					macaddr_factory_e000: macaddr@e000 {
						reg = <0xe000 0x6>;
					};
				};			
			};

			partition@50000 {
				compatible = "denx,uimage";
				label = "firmware";
				reg = <0x50000 0x1fb0000>;
			};
		};
	};
};

&gmac0 {
    nvmem-cells = <&macaddr_factory_e000>;
    nvmem-cell-names = "mac-address";
};

&ethernet {
        pinctrl-0 = <&mdio_pins>, <&rgmii1_pins>;
};

&switch0 {
	ports {
		port@0 {
			status = "okay";
			label = "lan1";
		};

		port@1 {
			status = "okay";
			label = "lan2";
		};

		port@2 {
			status = "okay";
			label = "lan3";
		};

		port@3 {
			status = "okay";
			label = "lan4";
		};

		port@4 {
			status = "okay";
			label = "wan";
			nvmem-cells = <&macaddr_factory_e000>;
			nvmem-cell-names = "mac-address";
		};
	};
};

&pcie {
	status = "okay";
	reset-gpios = <&gpio 19 GPIO_ACTIVE_LOW>, 
                  <&gpio 33 GPIO_ACTIVE_LOW>;
};

&state_default {
	gpio {
		groups = "wdt","rgmii2","sdhci";
		function = "gpio";
	};
};


&i2c {
        status = "okay";
        clock-frequency = <100000>;
        ds1307@68 {
            compatible = "ds1307";
            reg = <0x68>;
            status = "okay";
        };
        lm75@48 {
            compatible = "national,lm75";
            reg = <0x48>;
            status = "okay";
        };
        lcd0@27 {
            compatible = "hd44780";
            reg = <0x27>;
            status = "okay";
        };
};

This is what I used in the past:

&gmac0 {
	nvmem-cells = <&macaddr_factory_e000>;
	nvmem-cell-names = "mac-address";
};

&gmac1 {
	status = "okay";
	label = "wan";
	phy-handle = <&ethphy4>;

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

&factory {
	compatible = "nvmem-cells";
	#address-cells = <1>;
	#size-cells = <1>;

	macaddr_factory_e000: macaddr@e000 {
		reg = <0xe000 0x6>;
	};

	macaddr_factory_e006: macaddr@e006 {
		reg = <0xe006 0x6>;
	};
};

@ shworker
just have a look at current stuff
an example
note the parts in the SPI flash also

Your DTS is like my ( see this post: MT7621A. MAC address not read from factory - #3 by shworker ).

This is not help me. I read /sys directory and see:

root@OpenWrt:/# 
root@OpenWrt:/# ls -l /sys/firmware/devicetree/base/palmbus@1e000000/spi@b00/fla
sh@0/partitions/partition@40000/nvmem-layout/macaddr@e000/
-r--r--r--    1 root     root             4 Apr  7 10:01 #nvmem-cell-cells
-r--r--r--    1 root     root             9 Apr  7 10:01 compatible
-r--r--r--    1 root     root             8 Apr  7 10:01 name
-r--r--r--    1 root     root             4 Apr  7 10:01 phandle
-r--r--r--    1 root     root             8 Apr  7 10:01 reg
root@OpenWrt:/# 

Device tree parsed, but network driver does not get mac address from flash.

only thing I notice is to remove nvmem stuff off switch port4

		port@4 {
			status = "okay";
			label = "wan";
			nvmem-cells = <&macaddr_factory_e000>;
			nvmem-cell-names = "mac-address";
		};

Problem not in DTS.
NVMEM support turn off in kernel.
Topic is closed

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.