The command to lock the MAC address: echo "pre-up ifconfig eth0 hw ether whatever:mac:address" >> /etc/network/interfaces
works for ethernet (eth0), but does not work for the wlan0 interface: echo "pre-up ifconfig wlan0 hw ether some:other:MAC:address" >> /etc/network/interfaces
It always gets a new MAC anyway, which is a bit annoying. How to fix this?
I can’t find what is bringing up the wlan0 interface. It’s not in /etc/network/interfaces . I’ve tried adding scripts to if-pre-up.d to change the MAC address, but it always fails on boot because there is no wlan0 that early on the boot . I did find a pretty ugly way to get the MAC to be the same. I used the script below and invoked it with /etc/init.d/S99User . The trick to it is to wait until wlan0 is up so we can take it back down and reassign the MAC and bring it back up. It also brings up wpa_supplicant once the MAC is figured out. There should be a better way, but damned if I can find it."
[root@milkv-duo]~# cat /mnt/system/sma.sh
#! /bin/sh
sleep 15
ifconfig wlan0 down
# Set the new MAC address
ifconfig wlan0 hw ether 78:01:86:75:30:9F
# Bring up the interface
ifconfig wlan0 up
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
and add to /etc/init.d/S99user
if [ -f $SYSTEMPATH/sma.sh ]; then
usleep 30000
. $SYSTEMPATH/sma.sh &
fi
If someone from milkv could tell us what is bringing up wlan0, this would be over in no time… What the point of open source if there is little communication?
Loading the aic8800 driver is what brings up wlan0 the interface.
Loading said driver is done by duo-init.sh.
I am not sure if you all are facing the same issue but my mac address changes with every boot. I think that might be a bug in the driver, I am going to experiment with updating the driver with that from radxa.
I think setting up the device beforehand via /etc/network/interfaces could work.
Edit: You can easily deduce this by reading the kernel log. The aic8800 prints a bunch of debug lines starting with AICWFDBG.
Loading a config file for the firmware is disabled here:
This causes the module to use a default mac address here instead.
There is also this code here, where it again reverts to the default mac because a call to rwnx_send_get_macaddr_req fails to get an efuse mac address (it returns an empty mac).
There is also CONFIG_USE_COSTUMER_MAC which is seemingly used by the RockPi-S to set a mac. This is worth looking into further.
Basically the RockPi-S has all of their code for generating the mac here:
The default mac address itself can be found here:
It is 88:00:33:77:10:99.
However the last two bytes are random on each boot. I am not sure where or why this is done yet. I know the last bit is XOR’d with the device index but that should’t be random.
With this patch I you can create a file /mnt/system/firmware/aic8800/rwnx_settings.ini and place your mac address in it:
MAC_ADDR=...
If you don’t place this file the driver just reverts to the default behaviour of a random mac.
I am also going to look into if there’s an efuse that can be used to get the actual permanent mac address. If I can’t get that to work I will see if carbonfix will merge this.