Setting MAC address on iMX6ULL
From SomLabs Wiki
Setting MAC address on iMX6ULL
Contents
This article describes a couple of methods to set the board MAC address and avoid the assignment its random value after device reboot.
Setting MAC address in systemd-networkd service files
The systemd-networkd interface configuration is stored in the *.network files within the /etc/systemd/network directory. To assign a MAC address to the chosen interface a new configuration file should be created (if it does not exist already). For the eth0 interface a file named 25-eth.network may be created with the following content:
[Match] Name=eth0 [Link] MACAddress=fe:51:11:6c:62:e8 [Network] DHCP=ipv4
This file will assign the given address to the eth0 interface and enable the DHCP client for IPv4 address setting. More information may be found on the systemd-networkd service documentation.
U-Boot env variable
The default U-Boot configuration generates a random MAC address for the ETH interface. This behavior may be changed by adding a new env variable to the U-Boot. The environment variables are stored in one of the following files:
U-boot 2022.04 or later
- StarSBC-6ULL board/somlabs/starsbc-6ull/starsbc-6ull.env
- StarSOM-6ULL board/somlabs/starsom-6ull/starsom-6ull.env
- VisionSOM-6ULL board/somlabs/visionsom-6ull/visionsom-6ull.env
Older u-boot versions
- StarSBC-6ULL include/configs/starsbc_6ull.h
- StarSOM-6ULL include/configs/starsom_6ull.h
- VisionSOM-6ULL include/configs/visionsom_6ull.h
A new MAC address may be set by adding the following variable:
ethaddr=fe:51:11:6c:62:e8
Linux device tree file
A MAC address may be defined in the dtb file used by the Linux kernel. The address definition should be added in the device tree source in the following section:
&fec1 { local-mac-address = [ 70 b3 d5 1a 70 06 ]; }
This code configures given MAC address for the fec1 interface.
To prevent overwriting this value by u-boot, a random address generation should be disabled in the bootloader defconfig:
- StarSBC-6ULL configs/starsbc_6ull_defconfig
- StarSOM-6ULL configs/starsom_6ull_defconfig
- VisionSOM-6ULL configs/visionsom_6ull_defconfig
CONFIG_NET_RANDOM_ETHADDR=n
Processor OTP memory
NOTE! The described operation may be performed only once and cannot be reversed! |
The iMX6ULL processor has an OTP memory area that is used by default to store the permanent MAC address. The registers responsible for this are described in the Reference Manual:
- OTP Bank4 Word2 (MAC Address) (OCOTP_MAC0)
- OTP Bank4 Word3 (MAC Address) (OCOTP_MAC1)
- OTP Bank4 Word4 (MAC Address) (OCOTP_MAC2)
This area may be written from the U-Boot console by executing the following commands. In this example the fe:51:11:6c:62:e8 address is stored in OTP:
fuse prog 4 2 0x116c62e8 fuse prog 4 3 0xfe51