Duplicate MAC Addresses and Serial Numbers

Uboot is already installed, it’s what loads Ubuntu for you. Personally I would ignore uboot and use either option 1 or 2 that I put above. Both of them work from within Ubuntu


Method 1 not working, i try many times, many methods.
Method 2
$sudo fw_setenv ethaddr “00:15:18:01:81:32”
without mistakes but without results

Method 3 i don have this device :confused:!

after restart i have another mac, next restart next mac


Can you have a try with another MAC address? like “10:14:18:01:81:33”

Good luck!

i know, i have 10 working mac on another devices, not work on khadas, 98:84:96:26:86:A1

Hey, seems that found out a mistake you ran:

You forgot the ethaddr as below:


Good luck!

my bad, work! Thx for all.

1 Like

That method works (I used USB-TTL for that) for Ethernet (wired cable). What about setting MAC addresses for Wifi and Bluetooth?

Hardcoding Bluetooth MAC address I assume is critically important because otherwise after every reboot need to pair devices once again… :frowning:

Using the bionic 4.9 images when i try to use

sudo fw_setenv ethaddr “00:00:00:00:01:01”

it sets the ethaddr variable, which i can check with fw_printenv. But it doesnt change the MAC address for the VIM even after reboot. The MAC appears to be set from the kernel command line, as can be seen from the dmseg output where it includes mac=98:aa:fc:60:45:94. This is the mac address that always appears from ifconfig. Any ideas?

Ive get everything else working to set the MAC based on CPU serial number so can get unique MAC addresses for all my VIMs on first boot - script is as follows in case anyone else wants it:


if [ ! -f $FLAG ]; then
#First boot so sort out MAC Address
echo “First boot, so fixing MAC Address”

cpuid=$(grep Serial /proc/cpuinfo | cut -d: -f2 | sed ‘s/^[ \t]//;s/[ \t]$//’)
macAdd=$(echo $cpuid | sed -e ‘s/(.)/\L\1/’ | sed 's/^(…)(…)(…)(…)(…).$/02:\1:\2:\3:\4:\5/’)
echo "Setting MAC to: " $macAdd
fw_setenv ethaddr $macAdd

#create flag file so it won’t run the next boot
touch $FLAG

exit 0

1 Like

Any advice on this? Still struggling to get this working

sudo fw_setenv ethaddr “00:00:00:00:01:01” sets the variable but doesnt change the MAC address on boot

reading around it looks like the config is stored /etc/fw_env.config which currently has

/dev/env 0x0 0x10000

Im out of ideas!

@numbqq please confirm and figure out a solution.

Hi, Birty:
Have you tried another MAC Address, as I just found some address not work.

Good day!

Hi @Gouwa yeah - have tried other MAC addresses - that one will work if i set it in


with the line

hwaddress ether 00:00:00:00:01:01

so its a working MAC.

thank you!

Hello @birty

Sorry for the late reply.

Please update your uboot repo.

Try to setup custom ethernet mac address:

$ sudo fw_setenv custom_ethmac "02:34:6b:33:11:22"



Thanks @numbqq - works perfectly :slight_smile:

any advice on where to put that file so that can get it to run on first boot like the resize2fs script? Can i add it to the filesystem in the fenix/archives directories? Still trying to read my way through the fenix scripts - much easier now they have been refactored thought!

I’m working on it, I will add it to Fenix…


even better - great support as always - thank you!!

@numbqq just had a thought - the script above uses the upper end of the serial number, you could get unlucky and get chips with the same number at the top and so end up with the same mac. So should probably use the lower end or even better take a md5sum and use that to generate the mac from so we guarantee it is unique i.e.

macAdd=$(echo $CPUID|md5sum|sed ‘s/^(…)(…)(…)(…)(…).*$/02:\1:\2:\3:\4:\5/’)


Hello @birty

You don’t need to generate the MAC address.

For VIM2, the MAC address is exist in OPT, and it’s unique.

For VIM1, there is no default MAC address.But when bootup the u-boot will generate a random MAC address, so we can use it, we can pass it to kernel and save it to a file /boot/env.txt. You can also edit the file to change the MAC address. The /boot/env.txt is like this:

khadas@Khadas:~$ cat /boot/env.txt 

You can modify custom_ethmac to change the MAC address.

Please refer to Fenix for details.


1 Like

Thanks @numbqq - will be trying with a new image this weekend!

edit: all up and running - thank you!!


4 posts were split to a new topic: Bluetooth Keyboard Issue

Another working solution for Ubuntu 22.04 that does not require U-boot