Duplicate Bluetooth MAC addresses

Which system do you use? Android, Ubuntu, OOWOW or others?

Android

Which version of system do you use? Khadas official images, self built images, or others?

Self build based on v230621, modified to allow USB peripheral without prompt

Please describe your issue below:

We currently have a lot (around 20) VIM4s in service, they are running an in-house Android application which connect to an iPad over Bluetooth Low Energy. We’ve noticed a bug where the iPads will see multiple VIM4s advertising as a singular device, and making it impossible to know definitively which device the iPad is connecting to. We’ve tracking this down to some devices sharing a Bluetooth MAC address, which is included in the BLE advertising packets, and the iPad is unable to distinguish between different physical devices.

This isn’t a one off case, we’ve observed a handful of devices each sharing the same MAC address. My understanding is that Bluetooth MAC addresses should be unique to each device, but that some manufacturers do not follow this standard. These MAC address collisions are seriously harming our use case for the VIM4 because we’re unable to rely on being able to connect to the correct device.

Does anybody have any suggestions on how to resolve this? Even if we can trick Android into thinking the chip has a different MAC address, or if there’s a way to hijack the lower level advertising packet from the application layer? Are there places in the Android OS where we can modify the value? Is there a way to change it from U Boot?

I don’t work with android so keep that in mind.

Try this.
Connect ttl device to linux debug port.
Space bar to stop uboot
Then at the prompt enter the command below.

Watch the screen and look for the exact name of the interface and replace that in the uboot commands

=> setenv <<eth1>addr > xx:xx:xx:xx

=> saveenv
1 Like

Thanks for this suggestion, unfortunately I don’t have the connector to try serial debugging at the moment but I could get a hold of one.

I had seen this command from a few other threads changes the ethernet MAC address, whereas I am specifically looking to change the Bluetooth Address.

@sqrtc View Bluetooth device address changes in the settings application. If the device is restored to its factory settings, the Bluetooth device address will also change after the settings are applied. The Bluetooth device address is randomly assigned. So you can try restoring the factory settings and see if the Bluetooth device address has changed on your end?

Hi @goenjoy. Thanks for this answer. The Bluetooth address does change when I reset the device which is helpful to know.

I currently have around 20 devices setup and configured, not in easy reach to reset and start again. Is there any other method to updating the MAC address without having to wipe each device?

@sqrtc Even if it is randomly assigned, the probability is almost non-existent. Can you take screenshots of the same address and take a look? How many other duplicates are there?

In addition, if you want to achieve uniqueness in your application, the final solution is to use Ethernet’s MAC Addr, which will be more reliable.

@goenjoy I was also surprised about the collisions. Attached are photos from two different devices, but I have observed this specific MAC address on at least 4 devices, including the one I reset earlier to generate a different MAC address.

I am using BLE in my application on the VIM4, so I’m under the assumption that the Ethernet MAC address wouldn’t be any use in this situation,


@sqrtc This is strange, as it is a random allocation, we are powerless. It can only be changed by restoring the factory settings. Perhaps you can filter out this special address in the application.

@goenjoy If it is generated randomly when the OS is initialised, there must be a file or config somewhere deep in the OS with this MAC Address. If it is changeable by factory reset, it must be changeable by other means. I have previously located this file at data/misc/bluedroid/bt_config.conf

[Info]
FileSource = Empty
TimeCreated = 2023-07-04 17:21:14

[Metrics]
Salt256Bit = 1e7d4b00422a3dd98d7c59773f5ee7f66c00e6cdf66969d8a297e01ab2f5c0a6

[Adapter]
Address = 22:22:aa:6d:bf:fa
LE_LOCAL_KEY_IRK = 3952e1963430a22b43351e1d74e65ce5
LE_LOCAL_KEY_IR = a63c0ff3172c14a70c6259d2d34d4e37
LE_LOCAL_KEY_DHK = 99eb19c68a1b0d1cc198fd7834511073
LE_LOCAL_KEY_ER = 0b6084af492a74b5636508a2e3cc068d
ScanMode = 1
DiscoveryTimeout = 120
Name = CON1

Changing the device name in the Android settings updates the name in the file, however changing either the name or address in the file doesn’t have any effect.

There is also the settings CLI. settings get secure bluetooth_address will return 22:22:aa:6d:bf:fa, trying to set the BT address like settings put secure bluetooth_address 22:22:F4:51:21:97 will return the updated BT address but has no effect on the device.

@sqrtc

C:\Users\25348>adb connect 192.168.30.224
connected to 192.168.30.224:5555

C:\Users\25348>adb root

C:\Users\25348>adb connect 192.168.30.224
connected to 192.168.30.224:5555

C:\Users\25348>adb remount
remount succeeded

C:\Users\25348>adb shell
VIM4:/ #
VIM4:/ # getprop persist.service.bdroid.bdaddr
22:22:be:a4:cb:c5
VIM4:/ #
VIM4:/ # setprop persist.service.bdroid.bdaddr 22:22:be:a4:cb:c8
VIM4:/ # getprop persist.service.bdroid.bdaddr
22:22:be:a4:cb:c8
VIM4:/ # rm /data/misc/bluedroid/bt_config.conf
VIM4:/ # reboot
C:\Users\25348>adb connect 192.168.30.224
connected to 192.168.30.224:5555

C:\Users\25348>adb shell
VIM4:/ $ su
VIM4:/ #
VIM4:/ # settings get secure bluetooth_address
22:22:BE:A4:CB:C8
VIM4:/ #