Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth: Convert HCI drivers to use a proper Zephyr driver API #72323

Merged
merged 30 commits into from
Jun 11, 2024

Conversation

jhedberg
Copy link
Member

@jhedberg jhedberg commented May 5, 2024

Current status:

  • Create a base binding and API definition
  • Update the host to support new HCI driver instances
  • Update h4.c
  • Update native controller HCI driver
  • Fix samples/bluetooth/hci_uart_async/ to work with the new driver model
  • Fix bsim to work both with native and UART-based controllers (right now CI is failing)
  • Figure out what to do with bt_read_static_addr(). Taken care of by Bluetooth: Simplify Kconfig options and interface between the host and controller #72580
  • Figure out what to do with BT_HAS_HCI_VS, BT_HCI_VS and BT_HCI_VS_EXT (perhaps DTS properties?). Some preparation in Bluetooth: Simplify Kconfig options and interface between the host and controller #72580.
  • Fix controller unit tests: no devicetree available for unit_testing "board" right now: Bluetooth: controller: Add BT_CTLR_HCI Kconfig option #72871
  • Update ipc.c
  • Update userchan.c
  • Update h5.c
  • Update hci_ambiq.c (and associated DT binding)
  • Remove hci_b91.c: Bluetooth: drivers: Remove unmaintained B91 HCI driver #73289
  • Update hci_esp32.c
  • Update hci_psoc6_bless.c (and associated DT binding)
  • Update hci_spi_st.c (and associated DT binding)
  • Update hci_stm32wba.c
  • Update ipm_stm32wb.c (and associated DT binding)
  • Update spi.c
  • Update hci_da1469x.c
  • Update hci_nxp.c
  • Update slz_hci.c
  • Update documentation, especially stuff regarding /chosen properties
  • Make it possible for nrf52_bsim to use also UART for HCI
  • Update various apps under samples/ and tests/ that use the legacy HCI driver API
  • Get rid of the Kconfig choice section for HCI drivers
  • Get rid of BT_NO_DRIVER
  • Deprecate the old API
  • Lots of testing
    • bsim with virtual driver (hci_driver.c)
    • ipc.c tested in CI
    • Test on hardware with virtual bus (i.e. combined build)
    • Test on hardware with IPC (i.e. split build)
    • Test on hardware with UART (i.e. split build)
    • userchan.c
    • Test with an OoT driver (e.g. NCS)

Right now the host hci_core.c uses #if DT_HAS_CHOSEN(zephyr_bt_hci) to separate the new-style HCI drivers from the legacy HCI driver support. The old API has been deprecated, but will only be removed after a deprecation period.

The following drivers depend on "west blobs", so they're not covered by CI, but were manually compile tested:

What this PR doesn't try to tackle:

  • Find a solution for and fix driver dependencies on host HCI command sending APIs, which are e.g. not available with HCI_RAW.
    #if defined(CONFIG_BT_HCI_RAW)
    struct bt_hci_cmd_hdr hdr;
    hdr.opcode = sys_cpu_to_le16(HCI_VSC_UPDATE_NVDS_CFG_CMD_OPCODE);
    hdr.param_len = HCI_VSC_UPDATE_NVDS_CFG_CMD_LENGTH;
    buf = bt_buf_get_tx(BT_BUF_CMD, K_NO_WAIT, &hdr, sizeof(hdr));
    if (!buf) {
    return -ENOBUFS;
    }
    net_buf_add_mem(buf, &am_devices_cooper_nvds[0], HCI_VSC_UPDATE_NVDS_CFG_CMD_LENGTH);
    ret = bt_send(buf);
    if (!ret) {
    /* Give some time to make NVDS take effect in BLE controller */
    k_sleep(K_MSEC(5));
    /* Need to send reset command to make the NVDS take effect */
    hdr.opcode = sys_cpu_to_le16(BT_HCI_OP_RESET);
    hdr.param_len = 0;
    buf = bt_buf_get_tx(BT_BUF_CMD, K_NO_WAIT, &hdr, sizeof(hdr));
    if (!buf) {
    return -ENOBUFS;
    }
    ret = bt_send(buf);
    }
    #else
    uint8_t *p;
    buf = bt_hci_cmd_create(HCI_VSC_UPDATE_NVDS_CFG_CMD_OPCODE,
    HCI_VSC_UPDATE_NVDS_CFG_CMD_LENGTH);
    if (!buf) {
    return -ENOBUFS;
    }
    p = net_buf_add(buf, HCI_VSC_UPDATE_NVDS_CFG_CMD_LENGTH);
    memcpy(p, &am_devices_cooper_nvds[0], HCI_VSC_UPDATE_NVDS_CFG_CMD_LENGTH);
    ret = bt_hci_cmd_send_sync(HCI_VSC_UPDATE_NVDS_CFG_CMD_OPCODE, buf, NULL);
    if (!ret) {
    /* Give some time to make NVDS take effect in BLE controller */
    k_sleep(K_MSEC(5));
    }
    #endif /* defined(CONFIG_BT_HCI_RAW) */
  • Decide what to do with BT_HCI_ACL_FLOW_CONTROL currently referencing specific HCI drivers
  • net_buf allocations by drivers. Drivers should own their own memory rather than calling into the host side to do these allocations.
  • Making the HCI driver API support system calls. This is related to the above first point. We also can't have the driver make direct calls using the recv callback to the host, rather there needs to be another mechanism for the host to fetch data from the driver.

Fixes #51503

@jhedberg jhedberg force-pushed the bt_hci_driver branch 2 times, most recently from 7bebbc5 to a841b2a Compare May 5, 2024 16:06
@jhedberg jhedberg force-pushed the bt_hci_driver branch 4 times, most recently from 4f65c0e to 94a0e38 Compare May 6, 2024 08:56
@jhedberg jhedberg requested a review from aescolar May 6, 2024 13:21
@jhedberg jhedberg force-pushed the bt_hci_driver branch 10 times, most recently from cb2bbdb to a963844 Compare May 13, 2024 10:08
@jhedberg jhedberg force-pushed the bt_hci_driver branch 2 times, most recently from 0ae93c5 to 54bde20 Compare May 13, 2024 13:22
bjarki-andreasen pushed a commit to bjarki-andreasen/sdk-zephyr that referenced this pull request Sep 30, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
bjarki-andreasen pushed a commit to bjarki-andreasen/sdk-zephyr that referenced this pull request Oct 1, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
bjarki-andreasen pushed a commit to bjarki-andreasen/sdk-zephyr that referenced this pull request Oct 1, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
bjarki-andreasen pushed a commit to bjarki-andreasen/sdk-zephyr that referenced this pull request Oct 1, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
bjarki-andreasen pushed a commit to bjarki-andreasen/sdk-zephyr that referenced this pull request Oct 4, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
bjarki-andreasen pushed a commit to bjarki-andreasen/sdk-zephyr that referenced this pull request Oct 4, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
bjarki-andreasen pushed a commit to bjarki-andreasen/sdk-zephyr that referenced this pull request Oct 4, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
rlubos pushed a commit to rlubos/sdk-zephyr that referenced this pull request Oct 22, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit 25e8625)
rlubos pushed a commit to rlubos/sdk-zephyr that referenced this pull request Oct 22, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit 25e8625)
rlubos pushed a commit to rlubos/sdk-zephyr that referenced this pull request Oct 22, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit 25e8625)
rlubos pushed a commit to rlubos/sdk-zephyr that referenced this pull request Oct 22, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit 25e8625)
rlubos pushed a commit to rlubos/sdk-zephyr that referenced this pull request Oct 22, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit 25e8625)
rlubos pushed a commit to rlubos/sdk-zephyr that referenced this pull request Oct 23, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit 25e8625)
rlubos pushed a commit to rlubos/sdk-zephyr that referenced this pull request Oct 24, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit 25e8625)
rlubos pushed a commit to rlubos/sdk-zephyr that referenced this pull request Oct 24, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit 25e8625)
jukkar pushed a commit to jukkar/sdk-zephyr that referenced this pull request Dec 5, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit 25e8625)
(cherry picked from commit 8b26afd)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Dec 30, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Dec 30, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Dec 30, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Dec 30, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Dec 30, 2024
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Jan 3, 2025
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Jan 3, 2025
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Jan 7, 2025
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Jan 8, 2025
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Jan 8, 2025
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Jan 8, 2025
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Jan 8, 2025
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Jan 10, 2025
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
anangl pushed a commit to anangl/sdk-zephyr that referenced this pull request Jan 10, 2025
The nRF54H20 supports a Bluetooth controller.
The HCI driver interface has changed upstream in
zephyrproject-rtos/zephyr#72323
so now we need to add it to device tree.

Signed-off-by: Rubin Gerritsen <[email protected]>
(cherry picked from commit f47a9b8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bluetooth: HCI drivers should be first-class Zephyr drivers (driver API, DTS, etc)