From f080c4fb894c5cb4a72ffae0894ed2e24c51c2d1 Mon Sep 17 00:00:00 2001 From: Dmitrii Sharshakov Date: Mon, 16 Jun 2025 18:17:35 +0200 Subject: [PATCH] snippets: add hci-uart-native-sim Enable connecting native sim to a physical board running hci_uart without usage of Bumble or other intermediary steps, but rather using common h4 hardware driver. Most commonly used port is USB CDC-ACM, as by default for most nRF boards. Signed-off-by: Dmitrii Sharshakov --- snippets/hci-uart-native-sim/README.rst | 15 +++++++++++ .../hci-uart-native-sim.conf | 8 ++++++ .../hci-uart-native-sim.overlay | 27 +++++++++++++++++++ snippets/hci-uart-native-sim/snippet.yml | 4 +++ 4 files changed, 54 insertions(+) create mode 100644 snippets/hci-uart-native-sim/README.rst create mode 100644 snippets/hci-uart-native-sim/hci-uart-native-sim.conf create mode 100644 snippets/hci-uart-native-sim/hci-uart-native-sim.overlay create mode 100644 snippets/hci-uart-native-sim/snippet.yml diff --git a/snippets/hci-uart-native-sim/README.rst b/snippets/hci-uart-native-sim/README.rst new file mode 100644 index 00000000000..c4e2b671178 --- /dev/null +++ b/snippets/hci-uart-native-sim/README.rst @@ -0,0 +1,15 @@ +.. _snippet-hci-uart-native-sim: + +Native Simulator support for hci_uart Snippet (hci-uart-native-sim) +################################################################### + +.. code-block:: console + + west build -S hci-uart-native-sim [...] + +Overview +******** + +This snippet allows to use hci_uart connected to the host computer +with the Native Simulator. It is useful for testing with a real +Bluetooth controller, such as a device running Zephyr. diff --git a/snippets/hci-uart-native-sim/hci-uart-native-sim.conf b/snippets/hci-uart-native-sim/hci-uart-native-sim.conf new file mode 100644 index 00000000000..ac8005441af --- /dev/null +++ b/snippets/hci-uart-native-sim/hci-uart-native-sim.conf @@ -0,0 +1,8 @@ +# zephyr,native-tty-uart has a high load order +CONFIG_BT_HCI_INIT_PRIORITY=55 + +CONFIG_BT_BUF_EVT_RX_SIZE=255 +CONFIG_BT_BUF_ACL_RX_SIZE=255 +CONFIG_BT_BUF_ACL_TX_SIZE=251 +CONFIG_BT_BUF_CMD_TX_SIZE=255 +CONFIG_BT_CTLR_SCAN_DATA_LEN_MAX=191 diff --git a/snippets/hci-uart-native-sim/hci-uart-native-sim.overlay b/snippets/hci-uart-native-sim/hci-uart-native-sim.overlay new file mode 100644 index 00000000000..fb1d5d648fb --- /dev/null +++ b/snippets/hci-uart-native-sim/hci-uart-native-sim.overlay @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2025 Dmitrii Sharshakov + * + * SPDX-License-Identifier: Apache-2.0 + */ + +&bt_hci_userchan { + status = "disabled"; +}; + +/ { + chosen { + zephyr,bt-hci = &bt_hci_uart; + }; + + hci_uart: hci_uart { + compatible = "zephyr,native-tty-uart"; + status = "okay"; + current-speed = <2000000>; + serial-port = "/dev/ttyACM0"; + + bt_hci_uart: bt_hci_uart { + compatible = "zephyr,bt-hci-uart"; + status = "okay"; + }; + }; +}; diff --git a/snippets/hci-uart-native-sim/snippet.yml b/snippets/hci-uart-native-sim/snippet.yml new file mode 100644 index 00000000000..dece9e83651 --- /dev/null +++ b/snippets/hci-uart-native-sim/snippet.yml @@ -0,0 +1,4 @@ +name: hci-uart-native-sim +append: + EXTRA_CONF_FILE: hci-uart-native-sim.conf + EXTRA_DTC_OVERLAY_FILE: hci-uart-native-sim.overlay