[PATCH v5 0/5] net: Derive stable MAC addresses from a unique device ID

From: Alexey Charkov

Date: Wed Nov 25 2026 - 14:37:01 EST


Rockchip SoCs are shipped with a unique CPU ID in their internal OTP
memory, and Rockchip bootloaders use it to give boards which have no
dedicated storage for a MAC address a stable one anyway: they hash the CPU
ID and patch the resulting addresses into the device tree they hand over.

Kernels started without that fixup, e.g. straight from the SPL in Falcon
mode or by any other loader which does not implement Rockchip's derivation,
fall back to random MAC addresses which change on every boot.

Derive the addresses in of_get_mac_address() instead, as the last resort
after any stored address, from a "unique-id" NVMEM cell referenced by
the Ethernet controller, so that a Linux image can use the same stable
addresses regardless of the boot flow.

v5 moves the derivation out of the OTP driver following Andrew's review
of v4. The CPU ID cell keeps returning the raw CPU ID to everyone, and
the Ethernet controller references it as its unique ID rather than as
its MAC address. The derivation is picked by the compatible of the
referenced cell, as the algorithms differ between vendors: Allwinner and
Amlogic bootloaders also derive addresses from chip IDs, each in their
own way. The addresses are indexed by the controller's "ethernetN"
alias, which is how the bootloaders assign them to interfaces. Doing it
in of_net.c lets any controller with a device tree node use it,
including PCIe ones, and needs no changes to NVMEM or to the handling of
"mac-address" cells.

On the Rockchip side, the existing CPU ID cell gets a "rockchip,cpuid"
compatible. Its location comes from the cell's reg property, so no
per-SoC data is needed, and other SoCs only need the compatible on their
CPU ID cell plus the references from their Ethernet controllers.
Controllers without an "ethernetN" alias keep getting random addresses,
as they would with the bootloaders.

Patch 4 moves the RK3576 OTP cells from the deprecated direct-child
syntax into a fixed layout, as the former does not allow a compatible on
a cell.

Only RK3576 is wired up here, that being the SoC I can test on.

Cross-checked on an RK3576 board: the addresses fixed up into the FDT by
U-Boot match the ones derived from the CPU ID, and both GMACs get them
when the kernel is booted without U-Boot proper at all (via Falcon
mode). The raw CPU ID cell remains readable alongside (e.g. via sysfs).

Signed-off-by: Alexey Charkov <alchark@xxxxxxxxxxx>
---
Changes in v5:
- Moved the derivation from the rockchip-otp driver into
of_get_mac_address(), with the Ethernet controller referencing the CPU
ID as a "unique-id" NVMEM cell (Andrew)
- Indexed the addresses by the controller's "ethernetN" alias instead of
a cell argument, matching how the bootloaders assign them
- Added "unique-id" to the ethernet-controller binding
- Dropped #nvmem-cell-cells from the "rockchip,cpuid" cell
- Dropped the net change accepting longer "mac-address" cells and the
OTP post-processor
- Did not carry over Ryan's Tested-by from v4, as the implementation
changed
- Link to v4: https://patch.msgid.link/20261124-rk3576-otp-cpuid-mac-v4-0-d403b8a25113@xxxxxxxxxxx

Changes in v4:
- Dropped the NVMEM core change letting post-processing shorten the
output, as cells have a fixed size (Srinivas)
- Added a net change letting the NVMEM MAC address helpers take the
first six bytes of a longer cell instead
- Made the OTP post-processor write the address into the first six
bytes of the CPU ID cell, keeping its size
- Link to v3: https://patch.msgid.link/20261123-rk3576-otp-cpuid-mac-v3-0-40c756dcf36f@xxxxxxxxxxx

Changes in v3:
- Dropped the OTP read serialization patch, applied separately
- Replaced the SoC-specific NVMEM layout with a "rockchip,cpuid"
compatible on the existing CPU ID fixed cell, so that it works
alongside other fixed cells (Ricardo) and needs no per-SoC table (Ryan)
- Moved the derivation into the rockchip-otp driver's cell fixup hook,
which also makes the layout module unload issue moot (Sashiko)
- Made #nvmem-cell-cells required for the new compatible (Sashiko)
- Dropped the dead match data and address validity checks (Srinivas)
- Allowed MAC address indices up to 255 rather than just 0 and 1
- Added an NVMEM core change letting post-processing shorten the output
- Moved the RK3576 OTP cells into a fixed layout
- Dropped Miquel's Reviewed-by from the driver patch, as the code moved
- Link to v2: https://patch.msgid.link/20260902-rk3576-otp-cpuid-mac-v2-0-e4b7fe2ab13f@xxxxxxxxxxx

Changes in v2:
- Switched from a scope-based guard to explicit lock/unlock calls in the
OTP driver to avoid mixing styles in a function using goto error
handling (Sashiko)
- Link to v1: https://patch.msgid.link/20260901-rk3576-otp-cpuid-mac-v1-0-ea9135270fc2@xxxxxxxxxxx

---
Alexey Charkov (5):
dt-bindings: nvmem: fixed-cell: Add Rockchip CPU ID
dt-bindings: net: ethernet-controller: Allow a unique ID NVMEM cell
net: of_net: Derive MAC addresses from a unique device ID
arm64: dts: rockchip: Move RK3576 OTP cells into a fixed layout
arm64: dts: rockchip: Derive GMAC MAC addresses from OTP on RK3576

.../bindings/net/ethernet-controller.yaml | 11 ++-
.../bindings/nvmem/layouts/fixed-cell.yaml | 24 +++++
.../bindings/nvmem/layouts/fixed-layout.yaml | 5 +
arch/arm64/boot/dts/rockchip/rk3576.dtsi | 110 +++++++++++----------
net/core/of_net.c | 105 +++++++++++++++++++-
5 files changed, 200 insertions(+), 55 deletions(-)
---
base-commit: 3dd8c790a7b7027abdd568e36db5e82ffaea7c77
change-id: 20260901-rk3576-otp-cpuid-mac-3c90243d0884

Best regards,
--
Alexey Charkov <alchark@xxxxxxxxxxx>