[SOLVED] rock64: MAC address always randomized

This is for ARMv8 based devices

[SOLVED] rock64: MAC address always randomized

Postby Isgar » Tue Sep 25, 2018 10:55 pm

Hi,

I would like to define a static mac address for my rock64. Unfortunately, modifying the boot.txt like in the wiki does not help. My boot.txt has:
$this->bbcode_second_pass_code('', 'setenv macaddr 81 66 53 24 e9 77
')
I also tried:
$this->bbcode_second_pass_code('', 'setenv bootargs console=ttyS2,1500000 mac_addr=81:66:53:24:e9:77
')
no success, random MAC on every start

$this->bbcode_second_pass_code('', '
In: serial@ff130000
Out: serial@ff130000
Err: serial@ff130000
Model: Rockchip RK3328 EVB
Net:
Warning: ethernet@ff540000 (eth0) using random MAC address - 1e:5a:5a:69:a5:28
eth0: ethernet@ff540000
Hit any key to stop autoboot: 0
switch to partitions #0, OK
mmc0(part 0) is current device
Scanning mmc 0:1...
Found U-Boot script /boot.scr
')

I am booting from eMMC if that makes a difference. The random MAC address is assigned even before boot.scr is read.
Any idea?

Edit:

Interestingly, the actual mac address seems to be even different to the one in the log.

journalctl shows this:
$this->bbcode_second_pass_code('', '
Sep 14 22:08:05 alarm systemd-udevd[595]: link_config: autonegotiation is unset or enabled, the speed and duplex are not writable.
Sep 14 22:08:05 alarm systemd-udevd[595]: link_config: could not get ethtool features for eth0
Sep 14 22:08:05 alarm systemd-udevd[595]: Could not set offload features of eth0: Device or resource busy
Sep 14 22:08:05 alarm systemd-udevd[595]: Could not generate persistent MAC address for eth0: No such file or directory
')

I am also using the systemd-tool initramfs hook for remote root cryptsetup unlock, but I think it was randomized even with the default setup as described in the wiki.
Last edited by Isgar on Fri Oct 05, 2018 6:36 pm, edited 1 time in total.
Isgar
 
Posts: 15
Joined: Thu Sep 04, 2014 10:45 pm

Re: rock64: MAC address always randomized

Postby TheSaint » Wed Sep 26, 2018 1:42 am

Have you run the ./mkscr after $this->bbcode_second_pass_code('', 'setenv bootargs "console=ttyS2,1500000 mac_addr=81:66:53:24:e9:77"')
NOTE the statement is quote enclosed
TheSaint
 
Posts: 346
Joined: Mon Jul 23, 2018 7:57 am

Re: rock64: MAC address always randomized

Postby Isgar » Wed Sep 26, 2018 6:44 am

Yes, I ran mkscr every time after modifying boot.txt.

I dont think enclosing is necessary, as other options like root= are working. Will try it anyway.
Isgar
 
Posts: 15
Joined: Thu Sep 04, 2014 10:45 pm

Re: rock64: MAC address always randomized

Postby summers » Wed Sep 26, 2018 10:11 am

OK - there are two things that use the mac address; uboot for it its getting information of the net, e.g. a tftp boot, or net console.

Then the kernel, when it brings up linux.

These two are separate, although uboot is usually fairly good at passing on its setting, I'm note quite sure how in the device tree world, think it may set it in the chosen node - but also seems possible to pass it almost on the kernel command line ...

Anyway my uboot that need it set do it by setting the variable "ethaddr", and usually that is saved in the environment variables. Now as you use distro set up in uboot (thats the boot.scr bit ...) often those don't allow saving of variables, as you can do most things in boot.scr - but yes its too late for setting the ethernet mac in uboot.

Alas can't see how you set the linux kernel mac address from the command line, think its different for each network driver.
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: rock64: MAC address always randomized

Postby Isgar » Fri Oct 05, 2018 6:34 pm

Using setenv ethaddr xx:xx:xx:xx:xx:xx worked :)

Thank you very much!

It would be very helpful if somebody can update the Rock64 Wiki to use this instead of macaddr
Isgar
 
Posts: 15
Joined: Thu Sep 04, 2014 10:45 pm

Re: [SOLVED] rock64: MAC address always randomized

Postby summers » Mon Oct 08, 2018 12:13 pm

Actually checking the distributed boot.txt: https://archlinuxarm.org/packages/aarch64/uboot-rock64/files/boot.txt

it has
$this->bbcode_second_pass_code('', 'setenv macaddr da 19 c8 7a 6d f4
fdt set /ethernet@ff540000 local-mac-address "[${macaddr}]"')

So you can see it is just setting the mac address in the device tree. The device tree is just used by the kernel. So if this isn't setting the mac address in linux when it boots, then the setting of the device tree is wrong ...
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm

Re: [SOLVED] rock64: MAC address always randomized

Postby Isgar » Mon Oct 08, 2018 8:37 pm

Ok i take it back...

Turned out that the mac address (and others i tried) i used in the beginning was invalid - with ethaddr it was actually giving me an error about that so i changed it. Macaddr didnt say anything, and i forgot to recheck after i was finally happy that it worked.

Feeling a bit dumb now :P
Isgar
 
Posts: 15
Joined: Thu Sep 04, 2014 10:45 pm

Re: [SOLVED] rock64: MAC address always randomized

Postby summers » Tue Oct 09, 2018 9:17 am

No reason to feel dumb, its always a bit confusing that uboot has an ethernet mac adddress set by:
$this->bbcode_second_pass_code('', 'setenv ethaddr 12:34:56:78:9A:BC')
And the kernel has an ethernet mac address set in the device tree. And that uboot is usually good at passing information like this across.

And doesn't help that it isn't really documented anywhere ...
summers
 
Posts: 984
Joined: Sat Sep 06, 2014 12:56 pm


Return to ARMv8 Devices

Who is online

Users browsing this forum: No registered users and 6 guests