Duplicate wireless MAC address on Colibri iMX6ULL WiFi interfaces mlan0 and uap0

Our application uses WiFi Access Point/AP mode (on uap0 interface) Station/STA mode (on mlan0 interface) simultaneously.

Sometimes this works, but other times I notice that the MAC address of the mlan0 and uap0 interfaces are the same, and this causes all kinds of confusion with the software and unreliable wifi networking. Usually the MAC addresses only differ by 2 in the 2nd last octet, but when this bug occurs the addresses are exactly the same:

:~# ip -c a
...
4: mlan0: <NO-CARRIER,BROADCAST,MULTICAST,DYNAMIC,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether dc:f5:05:11:39:35 brd ff:ff:ff:ff:ff:ff
5: uap0: <BROADCAST,MULTICAST,DYNAMIC,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether dc:f5:05:11:39:35 brd ff:ff:ff:ff:ff:ff
    inet 192.168.9.10/24 brd 192.168.9.255 scope global uap0
       valid_lft forever preferred_lft forever
    inet6 fe80::def5:5ff:fe11:3935/64 scope link 
       valid_lft forever preferred_lft forever

One way to trigger this bug is to restart hostapd (systemctl restart hostapd), or to mannually take the uap0 interface up and down (ip link set dev uap0 down && sleep 2 && ip link set dev uap0 up).

Questions:

  1. How are these MAC addresses being assigned? Is it by the mwifiex driver?
  2. What is the solution to this problem? i.e. how to prevent this happening?
  3. Is there a way to recover once this issue is detected? (changing the MAC address did not seem to work for me, probably because hostapd is using the wrong one that it read at start and restarting hostapd causes the wrong/duplicate MAC to be set for uap0)

Hardware/OS details:

  • Toradex Colibri iMX6ULL 512MB V1.1A
  • Custom carrier board (similar to Iris)
  • BSP 3
  • Kernel version: 4.14.170-3.0.4+gbaa6c24240a4 #1 SMP Fri May 26 01:16:37 UTC 2023
  • mwifiex details:
:~# modinfo mwifiex | grep version
version:        1.0
description:    Marvell WiFi-Ex Driver version 1.0
version:        backported from Linux (v5.4.27-0-g585e0cc08069) using backports v5.4.27-1-0-gf6e8852f
srcversion:     F6DEC1EF0118FF52DA370FC
vermagic:       4.14.170-3.0.4+gbaa6c24240a4 SMP mod_unload modversions ARMv7 p2v8

hostAPD configuaration:

:~# cat /etc/hostapd.conf
interface=uap0
ssid=my_ap
hw_mode=g
channel=3
own_ip_addr=192.168.9.10
wpa=2
wpa_passphrase=mypassword
wpa_key_mgmt=WPA-PSK
:~# cat /etc/systemd/network/hostapd.network
[Match]
Name=uap0
[Network]
Address=192.168.22.33/24
DHCPServer=yes

Crickets! Does anyone have any ideas?

I have now tried the same thing using the latest version of Toradex software and an Iris Carrier board (V1.1B), with the same result. Here is the output of tdx-info:

Software summary
------------------------------------------------------------
Bootloader:               U-Boot
Kernel version:           6.1.55-6.4.0+git.d23900f974e0 #1 SMP Sat Sep 23 09:11:13 UTC 2023
Kernel command line:      user_debug=30 ubi.mtd=ubi root=ubi0:rootfs rw rootfstype=ubifs ubi.fm_autoconvert=1 console=tty1 console=ttymxc0,115200n8 consoleblank=0 video=mxsfb:640x480M-16@60
Distro name:              NAME="TDX Wayland with XWayland Upstream"
Distro version:           VERSION_ID=6.4.0-build.8
Hostname:                 colibri-imx6ull-14938994
------------------------------------------------------------

Hardware info
------------------------------------------------------------
HW model:                 Toradex Colibri iMX6ULL 512MB on Colibri Evaluation Board V3
Toradex version:          0040 V1.1A
Serial number:            14938994
Processor arch:           armv7l
------------------------------------------------------------

Please help, this is a serious issue!