Ethernet MAC address

Every time I build a new image, I get a new MAC address, so DHCP issues a new IP address.
It would be nice if you could have a persistent address, or to be able to set it manually during the build.

There are lots of ways to achieve this. The simplest method is to set and save the environment variable in u-boot, e.g.

Warning: ethernet@4070000 (eth0) using random MAC address - 86:27:15:cb:f9:b5
eth0: ethernet@4070000
Hit any key to stop autoboot:  0 
cv180x_c906# 
cv180x_c906# setenv ethaddr aa:bb:cc:dd:11:22
cv180x_c906# saveenv
Saving Environment to NAND... Erasing NAND...
Erasing at 0x880000 -- 100% complete.
Writing to NAND... OK
OK
cv180x_c906# printenv ethaddr 
ethaddr=aa:bb:cc:dd:11:22
1 Like

Thanks. Is there a way to set this when I write the SD card or build a new image?
I also want to disable the Console writing to tty0.

1 Like

You might consider setting the default MAC in u-boot-2021.10/include/configs/cv180x-asic.h e.g.

diff --git a/u-boot-2021.10/include/configs/cv180x-asic.h b/u-boot-2021.10/include/configs/cv180x-asic.h
index 20d842ab3..fed89aa23 100644
--- a/u-boot-2021.10/include/configs/cv180x-asic.h
+++ b/u-boot-2021.10/include/configs/cv180x-asic.h
@@ -256,6 +256,7 @@
        #endif
 
        #define CONFIG_EXTRA_ENV_SETTINGS       \
+               "ethaddr=aa:bb:cc:dd:11:22\0" \
                "netdev=eth0\0"         \
                "consoledev=" CONSOLEDEV  \
                "baudrate=115200\0" \

Another effective method is to set in /etc/network/interfaces.

2 Likes