MAC-address increment in dts

Hi
I´m working on a dts file for Asus 4G-AX56, Asus 4G-AX56 not yet supported

One MAC address is printed on the router and the same stored in the "factory" partition.
This is the LAN MAC-address. The WAN MAC is incremented with 1 and WiFi 802.11ax/b/g/n is incremented with 2.
WiFi 802.11ac/ax/n has it´s own MAC-address in "factory".

How do I increment MAC-addresses in the dts file?
I have tried with mac-address-increment = <(1)>; but it is not working.

		partition@1e0000 {
			label = "factory";
			reg = <0x1e0000 0x100000>;
			read-only;
			nvmem-layout {
				compatible = "fixed-layout";
				#address-cells = <1>;
				#size-cells = <1>;

				eeprom_factory_0: eeprom@0 {
					reg = <0x0 0xe00>;
				};

				macaddr_factory_4: macaddr@4 {
					reg = <0x4 0x6>;
				};

				precal_factory_e10: precal@e10 {
					reg = <0xe10 0x19c10>;
				};
			};
		};

......

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

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

	nvmem-cells = <&macaddr_factory_4>;
	nvmem-cell-names = "mac-address";
	mac-address-increment = <(1)>;
};

you can use the local-mac-address in dts ..

local-mac-address = [000000000000];

or do it in 02_network ...

add to aliases section of dts

label-mac-device = &macaddr_factory_4;

then in 02_network

asus,ax56)
           label_mac=$(get_mac_label_dt)
		   lan_mac=$(macaddr_add $label_mac 1)
		   wan_mac=$(macaddr_add $label_mac 2)
         ;;

There seems to be this file:

build_dir/target-mipsel_24kc_musl/linux-ramips_mt7621/base-files/.pkgdir/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac

Can it be used somehow?

Then this:

				macaddr_factory_4: macaddr@4 {
					compatible = "mac-base";     <---
					reg = <0x4 0x6>;
					#nvmem-cell-cells = <1>;     <---
				};
...
&gmac0 {
	nvmem-cells = <&macaddr_factory_4 0>;     <---
	nvmem-cell-names = "mac-address";
};

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

	nvmem-cells = <&macaddr_factory_4 1>;     <---
	nvmem-cell-names = "mac-address";
};
2 Likes

B.T.W I suppose the MAC stored in flash is same as the one on the sticker. Should it be used for LAN or WAN?

This worked!

	aliases {
		led-boot = &led_power;
		led-failsafe = &led_power;
		led-running = &led_power;
		led-upgrade = &led_power;
		label-mac-device = &gmac0;    <--- delete
	};
......

		partition@80000 {
			label = "u-boot-env";
			reg = <0x80000 0x60000>;
		};

		partition@e0000 {
			label = "nvram";
			reg = <0xe0000 0x100000>;
			read-only;
		};

		partition@1e0000 {
			label = "factory";
			reg = <0x1e0000 0x100000>;
			read-only;
			nvmem-layout {
				compatible = "fixed-layout";
				#address-cells = <1>;
				#size-cells = <1>;

				eeprom_factory_0: eeprom@0 {
					reg = <0x0 0xe00>;
				};

				macaddr_factory_4: macaddr@4 {
					compatible = "mac-base";     <---
					reg = <0x4 0x6>;
					#nvmem-cell-cells = <1>;     <--- added #
				};
......

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

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

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

Now I just need to clarify how the OEM sw assign the MAC addresses.
Without assigning anything to the WiFi, 802.11ax/b/g/n get the same as LAN and WiFi 802.11ac/ax/n get +4.

2 Likes

Yes, the MAC address stored in the factory partition is the same as printed on the sticker.