Device tree mac-address-increment not working as expected

Hello,

I'm working on a pull request to add support for our DPT-Module V1 (https://www.dptechnics.com/docs/openwrtmodule_datasheet_rev3.pdf). This device was previously in the ar71xx support branch and must now be ported to ath79. I have about everything working, except the MAC address assignment. We use the following MAC scheme:

  • WiFi = sticker MAC
  • LAN = sticker MAC - 1
  • WAN = sticker MAC + 1

The sticker MAC is read from a factory partition and this is working well for WiFi. The problem however is with the ethernet. Following is the relevant DTS snippet:

&eth0 {
	status = "okay";

	nvmem-cells = <&macaddr_factory>;
	nvmem-cell-names = "mac-address";
        mac-address-increment = <1>;

	gmac-config {
		device = <&gmac>;
		switch-phy-addr-swap = <0>;
		switch-phy-swap = <0>;
	};
};

&eth1 {
	status = "okay";

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

There are two strange things:

  • eth0 in the DTS is actually eth1 on boot. This is the actual WAN port and is working as such (I added eth1 as WAN in 02_network).
  • While eth1 in the DTS (this is eth0 when booted) has the sticker MAC -1 as expected. eth0 in the DTS (this is eth1 when booted) has the sticker MAC + 2.

I have tried every possible combination of numbers but it's always wrong. Can somebody point me in the right direction?

Kind regards,
Daan

Ok, I just fixed the issue after a day of searching. I was working on 22.03.2 which did not yet have this patch: https://github.com/openwrt/openwrt/blob/master/target/linux/generic/pending-5.10/684-of_net-do-mac-address-increment-only-once.patch

Turns out that on AR9331 devices the PHY probing is actually deferred, and this caused the system to increment twice.

Ok, new issue. I need to have a blocksize of 32k for this device. I have the following device definition:

define Device/dptechnics_dpt-module-v1
  $(Device/tplink-16mlzma)
  SOC := ar9331
  BLOCKSIZE := 32k
  DEVICE_VENDOR := DPTechnics
  DEVICE_MODEL := DPT-Module v1
  DEVICE_PACKAGES := kmod-usb-core kmod-usb2
  SUPPORTED_DEVICES += dptechnics-dpt-module-v1
  KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | uImage lzma
  IMAGE_SIZE := 16192k
  TPLINK_HWID := 0xD0000101
endef
TARGET_DEVICES += dptechnics_dpt-module-v1

The blocksize however is still 64k:

cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00010000 00010000 "u-boot"
mtd1: 00008000 00010000 "dpt-persistent"
mtd2: 00008000 00010000 "dpt-factory"
mtd3: 00fd0000 00010000 "firmware"
mtd4: 00221d55 00010000 "kernel"
mtd5: 00dae2a8 00010000 "rootfs"
mtd6: 00a80000 00010000 "rootfs_data"
mtd7: 00010000 00010000 "art"

Do I need to set something in the DTS file? My physical chip can support 4k/32k/64k blocksize.