This is a cache of https://discuss.96boards.org/t/wifi-mac-address-programming/978. It is a snapshot of the page at 2024-11-01T13:53:29.830+0000.
Wifi MAC Address Programming - DragonBoard410c - 96Boards Forum

Wifi MAC Address Programming

Hi,

The Wifi, BT MAC Addr. doesn’t seem to work on my 410c.
The board is flashed with dragonboard410c_sdcard_install_android-118.zip and steps followed from
lm80-p0436-44_set_up_wi-fi_mac_addr_dragonboard410c.pdf
android-bootloaders-v2 is the firmware used.

Observation for Wi-Fi:

  1. The Wifi MAC address is always 02:00:00:00 prior to ‘Turning On’ the Wifi.
  2. TurnOn the Wifi
  3. The MAC address is always 00:0a:f5:60:0c:04 irrespective of changes to the WCNSS_qcom_cfg.ini

Note:
a) The IP addr was read from “Settings->Wifi->Advanced” section
b) The netcfg does not exist on this image.

Would there additional steps that might have been missed out?

@SumanKumar

have you checked Qualcomm’s documentation on this matter? Please see below:

Hi Jorge,

I want to set WIFI macaddress, and I follow the document “https://developer.qualcomm.com/download/db410c/setting-wi-fi-mac-address.pdf” – “2.1 Setting the Wi-Fi MAC address on DragonBoard 410c”.

I found some strange issue for Debian version:

Setting WIFI MAC address NG: dragonboard410c_sdcard_install_debian-144.zip
Setting WIFI MAC address NG: dragonboard410c_sdcard_install_debian-110.zip
Setting WIFI MAC address OK: dragonboard410c_sdcard_install_debian-83.zip
Setting WIFI MAC address OK: dragonboard410c_sdcard_install_debian-66.zip

Please help to solve this bug.
Thanks.

@Miles, please could you share the error messages that you encounter when you follow the instructions and the output of dmesg after executing them?

It is what I seting WIFI MAC address as follows:

  1. run the command:
    linaro@linaro-alip:~$ sudo su
    root@linaro-alip:~$ ifconfig wlan0
    wlan0 Link encap:Ethernet WHaddr 02:00:a2:a6:22:40
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    Collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
    root@linaro-alip:~$ echo “8d:fd:f0:01:22:d7” > /lib/firmware/wlan/macaddr0
  2. reboot the device
    root@linaro-alip:~$ reboot
  3. check the MAC address, but it is not changed
    linaro@linaro-alip:~$ sudo su
    root@linaro-alip:~$ ifconfig wlan0
    wlan0 Link encap:Ethernet WHaddr 02:00:a2:a6:22:40
    UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
    RX packets:0 errors:0 dropped:0 overruns:0 frame:0
    TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
    Collisions:0 txqueuelen:1000
    RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
  4. check the file “/lib/firmware/wlan/macaddr0”, it is already changed
    root@linaro-alip:~$ vi /lib/firmware/wlan/macaddr0
    8d:fd:f0:01:22:d7

The MAC address should be modified after rebooting, but The Linaro Linux version 16.06 / 16.09 not.

@Miles, your MAC address has not changed across reboots so there should be no need to re-assign a new address.

Since the MAC seems to be permanent, why you need to setup a new MAC?

From the doc:
[…]
If you are running Linux based ubuntu release 15.07 or newer, your board should already be
equipped with a unique MAC address. Therefore, you should not experience a random MAC
address issue, as with prior releases. Instructions below are only relevant for those who wish to
use the DragonBoard 410c assigned MAC address.
[…]

I suspect the kernel changes that went in to address the issue of random MAC addresses after reboots might have disabled the option of setting the addresses via /lib/firmware/wlan/macaddr0.

Hi Jorge,

Why to disable the option, is it possible to recover this function to set MAC address for new release version?

Thanks.

No, I don’t think so since the system now works as expected and the work-around is no longer needed.

The MAC address is being passed by the bootloader to the kernel in the device tree using the local-mac-address property (since it is supported by the driver).

having said that I suppose you could hack the kernel to force your own mac address but I see no valid reason for doing so.

have a look at the code:

https://git.linaro.org/landing-teams/working/qualcomm/kernel.git/tree/drivers/net/wireless/ath/wcn36xx/main.c?h=release/qcomlt-4.9#n1207

Hi Jorge,

I found out that 16.06 release note
" WLAN MAC address is now set in DTB file, not in /lib/firmware/wlan/macaddr0 "
According to the description, I can modify WIFI MAC address in DTB file.
And how should I modify DTB file? could you please provide the method step by step?

Thanks.

Hi Miles,

Sorry I didnt notice your entry before going on vacation.

The firmware passes the MAC address to the kernel in the device tree but I believe you can still add the property to the device tree at the time of creating your image.

So if you follow the db410 instructions on how to build the boot image, add the following change to your kernel tree (adjusting your MAC address), generate the new image and flash it with fastboot


[jramirez@igloo kernel.git (debian-qcom-dragonboard410c-16.09-local *$)]$ git diff
diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi
index 551c12a..7cf949e 100644
--- a/arch/arm64/boot/dts/qcom/msm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi
@@ -1129,6 +1129,7 @@
 
                                        interrupts = <0 145 0>, <0 146 0>;
                                        interrupt-names = "tx", "rx";
+                                 local-mac-address = [02 00 27 60 25 28];
 
                                        qcom,state = <&apps_smsm 10>, <&apps_smsm 9>;
                                        qcom,state-names = "tx-enable", "tx-rings-empty";

then

fastboot flash boot boot-db410c.img

Does this help?

well, that would require rebuilding the dtb file, you should be able to directly modify the DTB file using “fdtput” program (on ubundu/debian you can install device-tree-compiler package to get it):

fdtput xxx.dtb /smd/pronto/wcnss/wifi -t x local-mac-address 02 00 27 60 25 28

that should do the same as above post

@ndec, cool, thanks, much better (I didnt know about that one but it makes sense it exists :slight_smile: )

Hi Jorge,

Thanks for your help, and I can modify wifi mac address successfully.

Hi ndec,

Which dtb file I should choose? And I can’t find the path “/smd/pronto/wcnss/wifi”, too.
By the way, after sending this command, I still need to generate the new image and flash it with fastboot, right?
Please help me to fix the problem.

Thanks.

if you use db410c, the DTB file is apq8016-sbc.dtb.

“/smd/pronto/wcnss/wifi” is a node in the DTB file, I don’t understand what you mean by ‘you can’t find the path’. Did the fdtput command return any error?

the second method is to let you modified the DTB file directly without having to modify (and recompile) the DTS into DTB.

Once you have modified the DTB file (with any of the above method), yes you need to rebuild the boot image and flash it.

Thanks to both.

It seems that I must rebuild kernel image if I want to change WIFI MAC address after the version OS 16.06.
It is not convenient when I write different WIFI mac address for each main board.
Is there any method not need to change kernel image?

Thanks.

just to be clear, you don’t need to rebuild the kernel image, you need to rebuild the boot image (e.g. it does not require to rebuild the kernel, that’s what I meant).

at this point there is no other option.

This forum post has triggered some more discussions internally, and we are trying to design a solution for this problem. I fully concur that the current solution is problematic. But the previous solution where MAC address was stored in a file in the root file system was also quite problematic. With the new solution the bootloader is responsible to set the MAC address which is right, we now need a mechanism so that the MAC address is stored in a place which can be read by the bootloader. There is unfortunately no persistent memory on the board beyond the eMMC, so we are likely going to dedicate an eMMC partition for that…

Hey ndec, could you comment on the current state of this?

Do I need to manually set the mac address for each board by writing out a file to /lib/firmware/wlan/macaddr0 or is it stored somewhere on the board perhaps on one of the partitions?

Thanks!

Currently if there is no MAC address in the DT then the bootloader will automatically allocate one from the local MAC address space and based on the eMMC unique ID. This is stable between reboots and there should be no problem having multiple boards on the same network.

If you want to use the stickered MAC address you can add it to the DT (part of the boot partition).

Thanks for the help danielt. I really appreciate it.