PINE64
Debian: MAC address keeps changing on every reboot - Printable Version

+- PINE64 (https://forum.pine64.org)
+-- Forum: ROCK64 (https://forum.pine64.org/forumdisplay.php?fid=85)
+--- Forum: Linux on Rock64 (https://forum.pine64.org/forumdisplay.php?fid=88)
+--- Thread: Debian: MAC address keeps changing on every reboot (/showthread.php?tid=4972)

Pages: 1 2


Debian: MAC address keeps changing on every reboot - rontant - 08-19-2017

My router DHCP server is unable to assign a fixed IP address to Rock 64 running ayufan's Debian Jessie because the MAC address keeps changing after every reboot. 

In the file /etc/network/interfaces.d/eth0 , I tried to add a line "hwaddress ether 00:11:22:33:44:55"  after "iface eth0 inet dhcp" line, rebooted the Rock, but it has no effect.

I really need this fixed IP address assignment using the router DHCP to do port forwarding, etc. can any kind soul please help me?

Thanks in advance

Update: Using "dmesg | tail" command, I found some errors. It looks like something is broken here.

[   16.107739] systemd-journald[284]: Received request to flush runtime journal from PID 1
[   16.677610] rk_gmac-dwmac ff540000.eth: rk_get_eth_addr: rk_vendor_read eth mac address failed (6)
[   16.684179] rk_gmac-dwmac ff540000.eth: rk_get_eth_addr: generate random eth mac address: 46:dc:5a:a0:be:8a
[   17.087857] rk_gmac-dwmac ff540000.eth: rk_get_eth_addr: mac address: 46:dc:5a:a0:be:8a
[   17.092156] eth0: device MAC address 46:dc:5a:a0:be:8a
[   19.975103] rk_gmac-dwmac ff550000.eth: rk_get_eth_addr: mac address: 46:dc:5a:a0:be:8a
[   19.987574] eth1: device MAC address 46:dc:5a:a0:be:8a
[   21.159028] rk_gmac-dwmac ff540000.eth eth0: Link is Up - 1Gbps/Full - flow control rx/tx
[   24.618565] tty_port_close_start: tty->count = 1 port count = 2.


RE: Debian: MAC address keeps changing on every reboot - dlu - 08-19-2017

You can try a script in /etc/network/if-pre-up.d that changes the mac via ip link set ...


RE: Debian: MAC address keeps changing on every reboot - rontant - 08-19-2017

(08-19-2017, 01:04 PM)dlu Wrote: You can try a script in /etc/network/if-pre-up.d that changes the mac via ip link set ...

Thanks but it doesn't help. Google search on this topic brought up several past threads about this similar issue with Pine A64 as well. Fortunately, the workaround was found by hardcoding the MAC address on /boot/uEnv.txt but this only applies to Pine A64. Rock 64 doesn't have this file.


RE: Debian: MAC address keeps changing on every reboot - ayufan - 08-19-2017

Clear SPI flash. Run `dd if=/dev/zero of=/dev/mtd3` and restart. From now on address should be persisted.


RE: Debian: MAC address keeps changing on every reboot - MarkHaysHarris777 - 08-19-2017

Just for grins and other computer science reasons, you might want to backup the original spi_flash bytes before you wipe it out !

mkdir  spi_flash

cd spi_flash

sudo  dd  if=/dev/mtd3  of=spi_flash.org

That should create a file called  spi_flash.org  size 262144;   


Shy

I wanted to compare the SPI flash from the pre production boards vs the production boards.


RE: Debian: MAC address keeps changing on every reboot - rontant - 08-19-2017

(08-19-2017, 07:45 PM)ayufan Wrote: Clear SPI flash. Run `dd if=/dev/zero of=/dev/mtd3` and restart. From now on address should be persisted.

Yes, it works!!! It took two reboots for it to take effect after running `dd if=/dev/zero of=/dev/mtd3` Thanks ayufan. You are the best!  Smile


RE: Debian: MAC address keeps changing on every reboot - MarkHaysHarris777 - 08-19-2017

btw,  there is no difference between the pre production boards and the production boards ;  SPI flash defaults to the same hexdump  FFFF FFFF FFFF FFFF FFFF FFFF FFFF ...

So, wiping the SPI flash from /dev/null  fills it with zeros rather than 1's ...

Dodgy


RE: Debian: MAC address keeps changing on every reboot - rontant - 08-19-2017

Here is my hexdump now after clearing the SPI

rock64@rock64:~$ sudo dd if=/dev/mtd3 of=spi_flash.hex
512+0 records in
512+0 records out
262144 bytes (262 kB) copied, 0.106056 s, 2.5 MB/s
rock64@rock64:~$ hexdump -c spi_flash.hex
0000000 D V K R 002 \0 \0 \0 001 \0 001 \0 @ \0 � �
0000010 003 \0 \0 \0 006\0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
0000400 202 c � e � � \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000410 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
000fff0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 002 \0 \0 \0
0010000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
0040000


RE: Debian: MAC address keeps changing on every reboot - KnReLe - 08-19-2017

Yes zeroing out this memory worked. The stable MAC address appears at 0x400-0x405 from what I can see here.


RE: Debian: MAC address keeps changing on every reboot - dlu - 08-20-2017

Can someone explain the solution please?

- If the mac address resides in the "SPI flash", then 00:...:00 and FF:...:FF are both invalid addresses. Which software part corrected the zeroes, and why didn't it correct the FFs?
- Where does the new value for the stable mac address come from? Is it the same code path as seen in rontants loglines (random_ether_addr in rk_get_eth_addr)? Or somewhere else?