Skip to main content

MAC Address

Factory MAC Address​

Each board leaves the factory with a unique Ethernet MAC address stored in the U-Boot environment as the ethaddr variable.

warning

Flashing an image overwrites the U-Boot environment, so the factory MAC address is lost. After flashing, the board uses the MAC address programmed in the SoC OTP memory. If the OTP memory is blank, a random MAC address is generated at every boot.

Before flashing the board for the first time, write down the factory MAC address. Use one of the following methods:

  • In the U-Boot console (stop autoboot over the Serial Connection):

    U-Boot console
    printenv ethaddr
  • In Linux:

    Linux shell on the board
    cat /sys/class/net/end0/address

Program the MAC Address to OTP​

To keep the same MAC address regardless of the flashed image, program it to the SoC OTP (one-time programmable) memory. U-Boot reads it from OTP at every boot and passes it to Linux in the device tree.

danger

Programming OTP memory is irreversible. The MAC address can be programmed only once and cannot be changed or erased afterwards. Double-check the address before burning it.

Use the factory MAC address recorded earlier, an address from an OUI range assigned to your organization, or a locally administered address (second least significant bit of the first byte set, e.g. 02:xx:xx:xx:xx:xx).

The MAC address is stored in two eFuse customer data words, programmed with the MediaTek ewriter tool by field index:

Fieldewriter indexContentExample (e2:53:1d:aa:c9:1d)
C_DAT1238MAC address bytes 0 to 3e2531daa
C_DAT2239MAC address bytes 4 and 5, 0000c91d0000

Each field is written as exactly 4 bytes (8 hex digits), in the same order as the MAC address.

caution

Do not write the C_DAT0 field (index 237). It is reserved for the MediaTek rollback index.

Prepare the Image​

The ewriter tool and the eFuse programming power control are available only in images built with the NDA extension. Build and flash an image with the nda.yml configuration, as described in the Image Configurations and Build the Image sections.

Run all commands below in the board's Linux shell as root.

Check the eFuse Fields​

Make sure that both fields are blank:

Linux shell on the board
ewriter 0 238 4
ewriter 0 239 4

Expected output for each field:

efuse hex:
00000000
status code = 0, which means "eFuse is ok."

Burn the MAC Address​

Enable the eFuse programming power supply:

Linux shell on the board
echo 1 > /sys/devices/platform/fsource/state
cat /sys/devices/platform/fsource/state

The cat command must print enabled. Then write both fields, for example for MAC address e2:53:1d:aa:c9:1d:

Linux shell on the board
ewriter 1 238 4 e2531daa
ewriter 1 239 4 c91d0000

Each command must end with status code = 0, which means "eFuse is ok.". Disable the eFuse programming power supply:

Linux shell on the board
echo 0 > /sys/devices/platform/fsource/state

Verify the MAC Address​

Read the fields back:

Linux shell on the board
ewriter 0 238 4
ewriter 0 239 4
xxd -s 0x514 -l 6 /sys/devices/platform/soc/11f20000.efuse/nvmem0/nvmem

Expected output of the xxd command:

00000514: e253 1daa c91d .S....

Reboot the board and check that the interface uses the programmed address:

Linux shell on the board
cat /sys/class/net/end0/address

The address stays the same after every reboot and after flashing a new image.