zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.84k stars 6.6k forks source link

BT HCI Raw on STM32WB55RG #46075

Closed sebachm94 closed 2 years ago

sebachm94 commented 2 years ago

Describe the bug Hi, I need to do some Direct Test Mode for BT and I tried to build Zephyr hci_raw module to run one of prepared example from Zephyr: /zephyr/samples/bluetooth/hci_uart/. It seems that there are some kind of dependencies and it's impossible to build HCI_Raw on STM32WB55RG. I used sources and configuration from example and tried to build it, but it failed while linking, due to undefined references to: 'bt_hci_cmd_create' and 'bt_hci_cmd_send_sync' in /zephyr/drivers/bluetooth/hci/ipm_stm32wb.c, looks like this driver depends on HCI Core, which excludes HCI Raw. I wasn't able to use other drivers too (maybe my configuration for other drivers wasn't full - I tried: CONFIG_BT_H4 instead of CONFIG_BT_STM32_IPM, which is taken by default). Is there any possibility to build HCI Raw with STM32WB55RG and run Direct Test Mode?

To Reproduce Build example: /zephyr/samples/bluetooth/hci_uart/ on STM32WB55RG.

Expected behavior I can build and run HCI Raw module on WB55RG.

erwango commented 2 years ago

See https://docs.zephyrproject.org/latest/connectivity/bluetooth/bluetooth-arch.html

Using ble on stm32wb involves a Host-only build. This configuration is not compatible with hci_* samples which are only compatible with respective controller builds.

The configuration you need involves a new type of host build, which would transport hci packets from usart to existing ipm_stm32wb driver. A kind of transparent host build.

erwango commented 2 years ago

@sebachm94 For my information, one question: In your 'Direct Test Mode for BT', do you intent to test anything else than the BLE controller and RF subsytem ? In a pure transparent mode application, HCI messages would go from UART to HCI Zephyr driver and quite a little of Zephyr comes into play. For that purpose, a STM32Cube sample application is already provided in STM32WB STM32Cube package, cf https://github.com/STMicroelectronics/STM32CubeWB/tree/master/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode Isn't it sufficient for your need ? you should be able to use https://github.com/STMicroelectronics/STM32CubeWB/tree/master/Projects/P-NUCLEO-WB55.Nucleo/Applications/BLE/BLE_TransparentMode which

sebachm94 commented 2 years ago

Hi @erwango, thank you for your answer! This STM32Cube sample application could be the option for us. We are considering to use it, I will let you know if that would be sufficient for us.