Read or change nRF51 mac address on Zephyr

Our project uses a Raspberry Pi compute module 3 connected via UART to 2 nRF51822. I'll go through what is working and than describe the issues I'm having

What's going on without issues:

  • The 2 nRF51822 are running project Zephyr HCI_UART sample with a very small change to blink an LED.
  • The Raspberry Pi is running the latest Jessie (from Mar/2017) with Kernel 4.4
  • I compiled both blueZ 5.43 and 5.44 (they have different tools) without issues.
  • Attach the modules btattach -B /dev/ttyAMA0 -S 115200 -P h4 and I can see communication on btmon
  • Check hciconfig and I can data being transmitted/received to/from the module
  • btmgmt --index 0 and call static-addr FF:22:33:44:55:FF I get Static address successfully set and then power on. All good.
  • I call le-obb and it shows the address as the LE Device Address: FF:22:33:44:55:FF
  • I call find -l and I can see it finding BT devices around.
  • Checking systemctl status bluetooth and bluetoothd -v it's all up and running and it's running the one from bluez 5.44

The issue:

The BD address is always 00:00:00:00:00 and this seems to have implications on tools like bluetoothctland others.

I'm basically trying every tool every command line I can find on Google (e.g. this link) to set the address and there's always errors.

  • Invoking hciconfig always returns the address as BD Address: 00:00:00:00:00:00
  • Invoking bdaddr I get Manufacturer: internal use (65535). Device address: 00:00:00:00:00:00 (XEROX CORPORATION)
  • Trying to change the address via bdaddr bdaddr -i hci0 FF:22:33:44:55:FF I get, Unsupported manufacturer
  • trying to use hciattach to connect instead of btattach and passing a bdaddr param, it connects but the address is still 00
  • bluetoothctl show or bluetoothctl list returns empty.
  • bluetoothctl show gives No default controller available and show 0 or show hci0 gives Controller 0 not available

As per "Raju" on the comments section of the nRF5x support within the Zephyr Project RTOS blog post it seems that it seems that there's some issue on mapping the address on Zephyr, but I'm not sure if that is my issue or something unrelated.

I've tried to find on the source code of Zephyr anything related to the bd address, how to set it, or how to change it, and I couldn't find anything. If needed I can recompile it with extras flags, or include some params, extra protocol. But I'm really running out of options here.

Any help will be deeply appreciated.

  • Valid observation. We have our own OUI acquired from IEEE that we should use at the final product. But for now, just something that works would be great.

  • Hi,

    The code that set random address from FICR on the nRF5x devices in not included in the hci_uart example, only on host + controller samples. If you want to use random addresses, you can patch the sample code with this code that ge and set the random values from FICR. You can also set a public address the same way, if you have acquired one from IEEE.

    Best regards,


  • Hi, thanks for pointing it out the direction of the code. But the issue here is the public address. It's always zero on the linux host which causes issues. We do have a address space from IEEE. How can I set it using the hci_uart?

  • If you are not getting any adapter when calling bluetoothctl show or bluetoothctl list that means bluetoothd was not able to initialize your interface.

    The lack of a public address is expected here, but bluez should still set a random or static address when starting (depending on your config). Try manually running bluetoothd with debug (-d) and see if you get any error.

    Had a similar issue on a different linux host and my problem was because bluez was failing to generate a random address (bt_crypto_new was returning an error). Investigating further, my issue was because my kernel was missin CRYPTO_USER, so I just enabled the following configs:


    After rebuilding my kernel with the additional options, bluez was able to generate a random address and successfully initialize the interface:

    root@hikey:~# bluetoothctl show
    [NEW] Controller C5:62:65:D2:5C:3E hikey #1 [default]
  • This readme has a link to a patch that helped me with the BD Address issue: First I could not completely run diretcly the patch, but then I made the changes manually. There were some folder names wrong also I think that's because of versions of zephyr. hope that helps.