zephyr: bt: hci: ipm_stm32wb: public identity mac address is not applied
Describe the bug When trying the bluetooth examples for STM32WB55RG on two different nucleo_wb55rg boards, I noticed that the MAC address was the same for both:
EDIT: I found this “bug” when trying to setup MAC addresses on 2 nucleo_wb55 boards. I wanted to use the public MAC address either the one generated by STM’s or the ones I can get through my company public mac addresses range. Using random addresses is not really an option here because we need MAC address filtering in our applications.
02:80:E1:00:00:00
To Reproduce
#build a Bluetooth example, peripheral_hr for example:
cd ~/zephyrproject/zephyr/samples/bluetooth/peripheral_hr/
west build -p always -b nucleo_wb55rg && west flash
The 2 boards prints the same MAC address: Board 1:
*** Booting Zephyr OS build zephyr-v3.5.0-233-g9ac852549610 ***
[00:00:00.216,000] <inf> bt_hci_core: Identity: 02:80:E1:00:00:00 (public)
[00:00:00.216,000] <inf> bt_hci_core: HCI: version 5.0 (0x09) revision 0x0026, manufacturer 0x0030
[00:00:00.217,000] <inf> bt_hci_core: LMP: version 5.0 (0x09) subver 0x2126
Bluetooth initialized
Advertising successfully started
Board 2:
*** Booting Zephyr OS build zephyr-v3.5.0-233-g9ac852549610 ***
[00:00:00.216,000] <inf> bt_hci_core: Identity: 02:80:E1:00:00:00 (public)
[00:00:00.216,000] <inf> bt_hci_core: HCI: version 5.0 (0x09) revision 0x0026, manufacturer 0x0030
[00:00:00.217,000] <inf> bt_hci_core: LMP: version 5.0 (0x09) subver 0x2126
Bluetooth initialized
Advertising successfully started
Possible root of the issue The hci_core->common_init() function issues a HCI reset, which I believe disgards the previous configuration done by ipm_stm32wb->bt_ipm_open()->bt_ipm_ble_init()->bt_imp_set_addr() by resetting the M0 coprocessor. I don’t know if all the settings set prior to hci_core->common_init() are affected, but it could be the case.
Possible fix Add BT_QUIRK_NO_RESET to the bt_hci_driver in ipm_stm32wb.c Is there a way to add this quirk using another method that I’m not aware of ?
static const struct bt_hci_driver drv = {
.name = "BT IPM",
.bus = BT_HCI_DRIVER_BUS_IPM,
.open = bt_ipm_open,
#ifdef CONFIG_BT_HCI_HOST
.close = bt_ipm_close,
#endif
.send = bt_ipm_send,
.quirks = BT_QUIRK_NO_RESET, //---> Add this driver quirk
};
static int _bt_ipm_init(void)
{
...
}
New output with this change, the MAC address are unique for 2 different boards running the same sample (peripheral_hr).
Board 1:
*** Booting Zephyr OS build zephyr-v3.5.0-233-g9ac852549610 ***
[00:00:00.215,000] <inf> bt_hci_core: Identity: 80:E1:26:1B:A1:E9 (public)
[00:00:00.215,000] <inf> bt_hci_core: HCI: version 5.0 (0x09) revision 0x0026, manufacturer 0x0030
[00:00:00.215,000] <inf> bt_hci_core: LMP: version 5.0 (0x09) subver 0x2126
Bluetooth initialized
Advertising successfully started
Board 2:
*** Booting Zephyr OS build zephyr-v3.5.0-233-g9ac852549610 ***
[00:00:00.215,000] <inf> bt_hci_core: Identity: 80:E1:26:01:AB:7C (public)
[00:00:00.215,000] <inf> bt_hci_core: HCI: version 5.0 (0x09) revision 0x0026, manufacturer 0x0030
[00:00:00.215,000] <inf> bt_hci_core: LMP: version 5.0 (0x09) subver 0x2126
Bluetooth initialized
Advertising successfully started
Expected behavior A config is available to select the public static mac address generated by STMicroElectronics when the IPM hci driver is loaded.
Impact All stm32wb boards have the same MAC address which prevents differentiating them.
Environment (please complete the following information):
- OS: Xubuntu 22.04 x64
- Version: Zephyr RTOS V3.5.0-233
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 15 (7 by maintainers)
Issue is clear, STM32WB HCI driver must be reworked in order to give an unique address using “setup” function Assigning a public address is clearly feasible. A solution will be provided by mid-September
Related issue to MAC address setting on the WB55, I’ve tried setting up my company’s public MAC address on the nucleo_wb55rg board without success yet:
Tentative was the following:
I tried modifying my public MAC address using and the settings API in the “samples/bluetooth/peripheral” example with small modifications:
Use the CONFIG_BT_SETTING to load “bt/id” key and initialized the bluetooth driver then add the public address setting update function using the settings API:
The sample outputs the correctly setup address 28:36:13:A0:BE:EF, so reading from NVS is not an issue.
But unfortunately, a scan with NRF Connect shows the following MAC:
Furthermore, even if I apply the BT_QUIRKS_NO_RESET that fixed loading the public address derived from STM’s chip unique ID I still get STM’s public address and not my company’s one.
My guess is that the HCI command to update the loaded identity address is not being sent to the M0 core, therefore not updating the MAC address that shows up in NRF Connect.
I tried to validate my theory and tried the send ACI command used in bt_ipm_set_addr() but in the commit_settings of the subsys/bluetooth/host/settings.c:
After flashing the sample the MAC/identity is now correct in NRF connect !
I don’t have a clear idea on the best way to integrate such a procedure in the bluetooth stack since I had to modify both the subsys settings loading and the ipm HCI driver.
But I’m only trying to program my company’s public bluetooth addresses in the SOC.