BPI-R2 Ethernet MAC address

Hello BPI Team, and everyone who developing it. I try both Ubuntu image and LEDE image. And they all have same problem: The MAC address of eth0 and eth1 are random. I know that I can change it in “Network Connections”(Ubuntu) or “/etc/config/network”(LEDE). But for some reason it don’t work as my thought.

LEDE

I try the LEDE image first. I Want use R2 as a high performant rother and NAS. Then I try BPI-R2 LEDE source code for hardware NAT. But when I want to use it as main rother formally. I saw the network name in my windows is “Network 14”. The “Network 2” to “Network 13” are not the same MAC address. But I have just two rother. One is daily use, other is that BPI-R2. Then I try to add “option macaddr *********” in “/etc/config/network”. It success! “IP a” show that MAC address is change. But network didn’t work at the same time.

I Use wireshark get the package. It actually send package with the MAC address which I set. But it just can’t get any package. of course no DHCP, no ARP, no anything.

Ubuntu

Just not long ago. I saw BPI-R2 new image : ubuntu 16.04 V1.2.1 BT and WIFI AP mode are working fine 2017-11-27 and I install it in to emmc today. It works. Then I mark down the MAC address both eth0 and eth1. reboot. And Surprise! Not the same MAC address.

I try enter my MAC address in “Cloned MAC address” “Wired connection 1”. Save and reconnect it. It works! Then I change the language and reboot (I know it does’t need reboot, I just type it and press enter (QAQ) ). When it boot finish, the MAC address change again. The profile change to new one call “Wired connection 3”.

So, How can I do? Can anyone fix it? Or just I have this problem? Maybe this problem is not important for you. But not me. The network which i am use now have account-MAC bind. I need a stable MAC.(In Chinese is: 锐捷MAC绑定 :confused:)

Forget my poor English please. :anguished:

have you tried the search? :slight_smile:

for debian/ubuntu there is a way to set the mac:

no idea for lede…

Thanks for your information, I will checkk this problem, and will update you if I have any clue.

Isn’t it common practice to set the MAC address in u-boot before even starting the kernel? Then it’s more like a board property than an OS configuration setting. I never set it for multiple ports though :thinking:

I would be surprised if this currently is happening: If both are invalid and CONFIG_NET_RANDOM_ETHADDR is defined, a random,locally-assigned MAC is written to eth_device->enetaddr.

Thanks frank-w. I will try.:grinning:

Your guys are welcome! Thanks a lot! :grinning: But for some reason, I will not login here in next 3 week (or maybe 4). I am look forward to see R2 become better.

how to do that? using uEnv.txt? then it must not be done for every OS system-specific

can you make a step-by-step to set the eth-adress(es) in uboot?

@BitMaster I tried setting ethaddr and eth1addr in u-boot, but it didn’t work. You should able to set these environment variables in u-boot to set the MAC address of Linux’s eth0 and eth1 interfaces.

However, it seems ethaddr (but not eth1addr) is already set on my BPI-R2 and isn’t working. ethaddr was set to some kind of default address under the “MediaTek Inc., TAIWAN” OUI:

BPI-R2> env print ethaddr
ethaddr=00:0C:E7:11:22:33

I tried manually setting both environment variables, but I could not affect the MAC address used in linux To test you can run the following commands at the u-boot console (-f is needed to overwrite the existing ethaddr):

setenv -f ethaddr 02:8B:03:50:76:01
setenv eth1addr 02:8B:03:50:76:02
boot

To save it to persistent storage you can do:

setenv -f ethaddr 02:8B:03:50:76:01
setenv eth1addr 02:8B:03:50:76:02
saveenv

Maybe u-boot needs a driver for this to work or something?

It looks like mtk_eth_soc in Linux tries to read the MAC address which in turn tries to read the MAC address from the device tree. Maybe you can just set the MAC address in the device tree itself, though that sounds difficult.

1 Like

Have you used a actual uboot?

There is a fix for eth in uboot from nov 30th:

Probably not, I’ve been using the recent images of LEDE and Ubuntu, but haven’t paid attention to what version of u-boot is included. I haven’t tried building BPI-R2-bsp yet, I will soon.

You can download the actual uboot from my gdrive

https://drive.google.com/drive/mobile/folders/1WLWAR1FC-rF4n2SgFecBlU1ym_XKqAR_/15Y5Y3NAOwg_IMmN3k6hdb7pAQj9oTVTl?usp=sharing&sort=13&direction=a

You can update it using bpi-update or like this: http://www.fw-web.de/dokuwiki/doku.php?id=en/bpi-r2/uboot#update_uboot

this patch fixed the uboot load code issue which cannot download image via tftp protocol sometimes.

1 Like

if the problem exists in current uboot,are there fixes for this?

it is not an issue since mac address is from dts not uboot, thanks.

How do i set mac in dts? Is’nt there an uboot-way?

you can refer to below discussion, thanks. http://zedboard.com/content/passing-mac-address-kernel-device-tree-blob

in that thread there must be added a entry to ethernet@xxxxx

local-mac-address = [00 0a 35 00 00 01];

i’ve found in mt7623.dtsi only 1 ethernet-section, is that eth0 or eth1?

as i see in curent kernel there are lan and wan both mapped to eth0:

4: wan@eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default0
5: lan0@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP0
6: lan1@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state 0

is that right? i supposed wan is a separate nic (eth1) and the lan-ports on eth0

this is on 4.4.70 (without dsa):

5: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKN0
6: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qle0

it seems that both nics are in same controller:

root@bpi-r2:~# find /sys/devices/platform/ -name 'eth0'
/sys/devices/platform/1b100000.ethernet/net/eth0
root@bpi-r2:~# find /sys/devices/platform/ -name 'eth1'
/sys/devices/platform/1b100000.ethernet/net/eth1

found nothing how they separated and why here 2 devices created

Ethernet-dts-entry is different…

4.4.70:

eth: ethernet@1b100000 {
		compatible = "mediatek,mt7623-eth";
		reg = <0 0x1b100000 0 0x20000>;
		interrupts = <GIC_SPI 200 IRQ_TYPE_LEVEL_LOW>,
			     <GIC_SPI 199 IRQ_TYPE_LEVEL_LOW>,
			     <GIC_SPI 198 IRQ_TYPE_LEVEL_LOW>;
		clocks = <&topckgen CLK_TOP_ETHIF_SEL>,
			 <&clk26m>,
			 <&clk26m>,
			 <&clk26m>,
			 <&apmixedsys CLK_APMIXED_TRGPLL>,
			 <&ethsys CLK_ETHSYS_ESW>,
			 <&ethsys CLK_ETHSYS_GP2>,
			 <&ethsys CLK_ETHSYS_GP1>,
			 <&clk26m>,
			 <&clk26m>,
			 <&clk26m>,
			 <&clk26m>,
			 <&clk26m>;
		clock-names = "ethif", "eth1pll", "eth2pll",
			      "sgmipll", "trgpll", "esw", "gp2",
			      "gp1", "gp0", "sgmii_tx250m",
			      "sgmii_rx250m", "sgmii_cdr_ref",
			      "sgmii_cdr_fb";
		power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>;
		resets = <&watchdog MT2701_TOPRGU_ETHDMA_RST>;
		reset-names = "eth";
		mediatek,ethsys = <&ethsys>;
            mediatek,pctl = <&syscfg_pctl_a>;
		mediatek,switch = <&gsw>;
		#reset-cells = <1>;
		#address-cells = <1>;
		#size-cells = <0>;
		status = "disabled";
	};

	gsw: gswsys@1b100000 {
		compatible = "mediatek,mt7623-gsw",
			     "mediatek,mt2701-gsw";
		mediatek,ethsys = <&ethsys>;
		status = "disabled";
};

4.14 (last part):

reset-names = "fe", "gmac", "ppe";
power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>; 
mediatek,ethsys = <&ethsys>; 
mediatek,pctl = <&syscfg_pctl_a>;
#address-cells = <1>;
#size-cells = <0>;
status = "disabled";

as you see in 4.4.70 there is a additional line +section

mediatek,switch = <&gsw>;

This will raise the question about lan/wan-isolation again…

Looked in schematics,but it’s not clear…on last page i see in block-diagram,that lan+wan goes over the 7530 switch…on the page with the switch only lan-ports are listed (1-4)

Hi

I’ve tried the command ifconfig ethx hw ether 00:11:22:33:44:55 on both lede and ubuntu, it works. Can you please have a try?

i can also change mac with ifconfig hw ether…so i’m doing it currently (/etc/network/interfaces): http://www.fw-web.de/dokuwiki/doku.php?id=en/bpi-r2/software

but if the right way to do it is in dts…i want to set both interfaces in uboot, because then i have not recompile kernel and its independend from runnnig system

the way with “hwaddress ether” does not work in debian 9 (stretch), here you can do that with

iface lan0 inet static
  address 192.168.0.10
  netmask 255.255.255.0
  gateway 192.168.0.5
#  pre-up ip link set $IFACE up
  pre-up ip link set $IFACE address 02:01:02:03:04:08 up
  post-down ip link set $IFACE down

in /etc/network/interfaces