milkv-duo / duo-buildroot-sdk

Milk-V Duo Official buildroot SDK
411 stars 174 forks source link

Enable the config file for aic8800 #111

Closed LevitatingBusinessMan closed 5 months ago

LevitatingBusinessMan commented 5 months ago

Currently there's no way to configure the mac address used by aic8800 even though various methods are coded in.

The current default behavior uses hardcoded default mac address of which the last two bytes are randomized on each boot.

This causes some networking issues, for instance a new DHCP lease is requested on each startup and it's near impossible to assign a static ip from a dhcp server.

This issue has been discussed on the forums.

One could use a script to modify the wlan0 device and change the address but this isn't optimal.

Within the aic8800 sourcecode is a previously unused configuration parser. I slightly modified en re-enabled it. It needed modification because the first implementation relied on request_firmware, however there already existsa wrapper called rwnx_request_firmware_common in rwnx_platform.c that can load a firmware from the disk or via request_firmware.

I also had to slightly alter the login around setting the mac address.

However the behavior should remain exactly the same without the presence of the config file.

I also tried applying this efuse patch but the driver was unable to request the permanent hardware mac address from the efuses. However if in the future this is possible, then the efuse mac address will overwrite the one in the configuration because the check for this is done later.

To make use of this new change one can create a file /mnt/system/firmware/aic8800/rwxn_settings.ini . Within it, the address can be configured like so:

MAC_ADDR=aa:bb:cc:dd:ee:ff

It could also be interesting to look at how the RockPi-S handles the wlan mac address.

Another preferred method could be to save a random mac address to a file in /var/run on the first boot and continue using it. This will ensure that each Duo has a different but persistent mac address without configuration. Please let me know what you think of this.