This is an automated email from the ASF dual-hosted git repository.
GUIDINGLI pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new b5db91fe0da boards/sim: Add zblue configuration
b5db91fe0da is described below
commit b5db91fe0daa00ec54357fbfc4d33931fb22bfb8
Author: Kai Cheng <[email protected]>
AuthorDate: Thu Nov 5 14:07:41 2026 +0800
boards/sim: Add zblue configuration
Add sim:zblue for the Zephyr Bluetooth host in apps
(wireless/bluetooth/zblue): a Bluetooth controller of the host is
attached with CONFIG_SIM_HCISOCKET and exposed as /dev/ttyHCI0 through
CONFIG_UART_BTH4, and the zblue_peripheral example is enabled.
CONFIG_DEV_URANDOM provides the entropy for the host cryptography and
CONFIG_TLS_NELEM the thread-specific data used by the porting layer.
Document the application and the configuration.
Build it in CI with CMake, and not on macOS: it needs the Linux
HCI socket and ELF section start/stop symbols.
Signed-off-by: Kai Cheng <[email protected]>
---
.../applications/wireless/zblue/index.rst | 80 +++++++++++++++++++
.../platforms/sim/sim/boards/sim/index.rst | 22 ++++++
boards/sim/sim/sim/configs/zblue/defconfig | 90 ++++++++++++++++++++++
tools/ci/testlist/sim-03.dat | 4 +
4 files changed, 196 insertions(+)
diff --git a/Documentation/applications/wireless/zblue/index.rst
b/Documentation/applications/wireless/zblue/index.rst
new file mode 100644
index 00000000000..44ae763184e
--- /dev/null
+++ b/Documentation/applications/wireless/zblue/index.rst
@@ -0,0 +1,80 @@
+=======================================================
+``zblue`` Zephyr Bluetooth host in userspace
+=======================================================
+
+This application builds the Bluetooth host of the `Zephyr project
+<https://github.com/zephyrproject-rtos/zephyr>`_ as a userspace library. The
+Zephyr source is downloaded from a Zephyr release tag and is used without
+modification; only a small porting layer in ``apps/wireless/bluetooth/zblue``
+is NuttX code.
+
+It is an optional stack. The NuttX Bluetooth stack
+(``wireless/bluetooth``, ``net/bluetooth``) and NimBLE stay available; only
+one host can be enabled at a time.
+
+Applications use the Zephyr Bluetooth API (``<zephyr/bluetooth/...>``) as
+documented by Zephyr.
+
+Only the simulator is supported for now. On other targets the initialized
+iterable RAM sections of the host (``net_buf`` pools) need support in the
+board linker scripts, which is not there yet.
+
+Configuration
+-------------
+
+``CONFIG_ZBLUE``
+ Enables the stack. It needs ``CONFIG_UART_BTH4``: the host talks to the
+ controller through ``/dev/ttyHCIx``, so any driver registered with
+ ``bt_driver_register()`` can be used.
+
+``CONFIG_ZBLUE_REF``
+ Zephyr release tag to download, for example ``v4.5.0``.
+
+``CONFIG_ZBLUE_CONF``
+ Zephyr configuration fragment with the ``CONFIG_BT_*`` options, relative
+ to the application directory (default ``zblue.conf``). The options are
+ the original Zephyr ones. They are resolved with the Zephyr Kconfig
+ after download and do not appear in the NuttX menuconfig.
+
+``CONFIG_ZBLUE_HCI_DEVICE``
+ HCI device, default ``/dev/ttyHCI0``.
+
+``CONFIG_ZBLUE_THREAD_PRIORITY``
+ Zephyr cooperative priorities are mapped above this NuttX priority,
+ preemptive priorities below it.
+
+Cryptography uses the PSA API of Mbed TLS (``apps/crypto/mbedtls``); the
+options the host needs are selected automatically and
+``CONFIG_MBEDTLS_MINIMAL`` is enabled by default. Mbed TLS needs an entropy
+source, e.g. ``CONFIG_DEV_URANDOM`` on the simulator or the hardware random
+number generator of the board.
+
+Download and build requirements: ``curl``, ``tar`` and ``python3``.
+
+Updating the Zephyr release
+---------------------------
+
+Change ``CONFIG_ZBLUE_REF`` and remove the ``zephyr`` directory and the
+downloaded archive (``make distclean``). Fixes to the Zephyr host itself are
+made in Zephyr, not here.
+
+Porting layer
+-------------
+
+* Zephyr kernel services used by the host (threads, semaphores, mutexes,
+ queues, memory slabs, work queues, timeouts) are implemented on POSIX
+ threads, without NuttX internal interfaces.
+* Zephyr cooperative threads are serialized with one lock that is
+ released only while a thread blocks; ``k_sched_lock()`` takes the same
+ lock.
+* Iterable sections (``BT_CONN_CB_DEFINE()``, ``BT_GATT_SERVICE_DEFINE()``,
+ ...) are collected by the linker without changes to the board linker
+ script. Entries of a type are in link order.
+* ``SYS_INIT()`` functions run before ``bt_enable()`` starts the host.
+
+Example
+-------
+
+``CONFIG_ZBLUE_PERIPHERAL_EXAMPLE`` builds ``zblue_peripheral``: it
+advertises as ``CONFIG_BT_DEVICE_NAME`` and accepts connections, with the
+GAP and GATT services. See the ``sim:zblue`` configuration of the simulator.
diff --git a/Documentation/platforms/sim/sim/boards/sim/index.rst
b/Documentation/platforms/sim/sim/boards/sim/index.rst
index 7ae0729a708..59b61fbc5b0 100644
--- a/Documentation/platforms/sim/sim/boards/sim/index.rst
+++ b/Documentation/platforms/sim/sim/boards/sim/index.rst
@@ -1007,6 +1007,28 @@ At this point you should be able to detect a "nimble"
BLE device when scanning
for BLE devices. You can use nRFConnect Android application from Nordic to
connect and inspect exposed GATT services.
+zblue
+-----
+
+The Zephyr Bluetooth host (:doc:`/applications/wireless/zblue/index`) in
+userspace, on a Bluetooth controller of the host attached with
+``CONFIG_SIM_HCISOCKET`` and exposed as ``/dev/ttyHCI0``. The controller is
+taken over with the HCI user channel, so it must be down on the host and the
+simulator needs ``CAP_NET_ADMIN``:
+
+.. code:: console
+
+ $ sudo hciconfig hci0 down
+ $ sudo ./nuttx --bt-dev=hci0
+ nsh> zblue_peripheral &
+ zblue: Bluetooth ready, identity P:00:1A:7D:DA:71:11
+ zblue: advertising as "NuttX zblue"
+
+A central can then scan for "NuttX zblue", connect and read the GAP and GATT
+services, for example ``gatttool -i hci1 -b <address> --primary`` from a
+second adapter. ``CONFIG_DEV_URANDOM`` provides the entropy for the host
+cryptography; it is not suitable for a real device.
+
nsh
---
diff --git a/boards/sim/sim/sim/configs/zblue/defconfig
b/boards/sim/sim/sim/configs/zblue/defconfig
new file mode 100644
index 00000000000..f377b76632e
--- /dev/null
+++ b/boards/sim/sim/sim/configs/zblue/defconfig
@@ -0,0 +1,90 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed
.config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that
includes your
+# modifications.
+#
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+CONFIG_ARCH="sim"
+CONFIG_ARCH_BOARD="sim"
+CONFIG_ARCH_BOARD_SIM=y
+CONFIG_ARCH_CHIP="sim"
+CONFIG_ARCH_SIM=y
+CONFIG_BOARDCTL_APP_SYMTAB=y
+CONFIG_BOARDCTL_POWEROFF=y
+CONFIG_BOARD_LOOPSPERMSEC=0
+CONFIG_BOOT_RUNFROMEXTSRAM=y
+CONFIG_BUILTIN=y
+CONFIG_COVERAGE_ALL=y
+CONFIG_COVERAGE_TOOLCHAIN=y
+CONFIG_DEBUG_ASSERTIONS=y
+CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y
+CONFIG_DEBUG_FEATURES=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DEV_GPIO=y
+CONFIG_DEV_LOOP=y
+CONFIG_DEV_URANDOM=y
+CONFIG_DRIVERS_BLUETOOTH=y
+CONFIG_DRIVERS_WIRELESS=y
+CONFIG_ETC_FATDEVNO=2
+CONFIG_ETC_ROMFS=y
+CONFIG_ETC_ROMFSDEVNO=1
+CONFIG_EXAMPLES_GPIO=y
+CONFIG_EXAMPLES_HELLO=y
+CONFIG_EXPERIMENTAL=y
+CONFIG_FAT_LCNAMES=y
+CONFIG_FAT_LFN=y
+CONFIG_FS_BINFS=y
+CONFIG_FS_FAT=y
+CONFIG_FS_HOSTFS=y
+CONFIG_FS_LINKS=y
+CONFIG_FS_PROCFS=y
+CONFIG_FS_RAMMAP=y
+CONFIG_FS_ROMFS=y
+CONFIG_GPIO_LOWER_HALF=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_IDLETHREAD_STACKSIZE=4096
+CONFIG_INIT_ENTRYPOINT="init_main"
+CONFIG_IOEXPANDER=y
+CONFIG_IOEXPANDER_DUMMY=y
+CONFIG_LIBC_ENVPATH=y
+CONFIG_LIBC_EXECFUNCS=y
+CONFIG_LIBC_LOCALE=y
+CONFIG_LIBC_LOCALE_CATALOG=y
+CONFIG_LIBC_LOCALE_GETTEXT=y
+CONFIG_LIBC_MAX_EXITFUNS=1
+CONFIG_LIBC_NUMBERED_ARGS=y
+CONFIG_NDEBUG=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILE_APPS=y
+CONFIG_NSH_READLINE=y
+CONFIG_PATH_INITIAL="/bin"
+CONFIG_PIPES=y
+CONFIG_PSEUDOFS_ATTRIBUTES=y
+CONFIG_PSEUDOFS_FILE=y
+CONFIG_READLINE_CMD_HISTORY=y
+CONFIG_READLINE_EDIT_EMACS=y
+CONFIG_READLINE_TABCOMPLETION=y
+CONFIG_RTC=y
+CONFIG_RTC_ARCH=y
+CONFIG_RTC_DRIVER=y
+CONFIG_SCHED_BACKTRACE=y
+CONFIG_SCHED_CHILD_STATUS=y
+CONFIG_SCHED_EVENTS=y
+CONFIG_SCHED_HAVE_PARENT=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SIM_HCISOCKET=y
+CONFIG_SIM_HOSTFS=y
+CONFIG_SIM_WALLTIME_SIGNAL=y
+CONFIG_START_MONTH=6
+CONFIG_START_YEAR=2008
+CONFIG_SYSTEM_DUMPSTACK=y
+CONFIG_SYSTEM_GCOV=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_NXINIT=y
+CONFIG_TESTING_OSTEST=y
+CONFIG_TLS_NELEM=4
+CONFIG_UART_BTH4=y
+CONFIG_ZBLUE=y
+CONFIG_ZBLUE_PERIPHERAL_EXAMPLE=y
diff --git a/tools/ci/testlist/sim-03.dat b/tools/ci/testlist/sim-03.dat
index 88456bd1973..575a9730e6f 100644
--- a/tools/ci/testlist/sim-03.dat
+++ b/tools/ci/testlist/sim-03.dat
@@ -24,6 +24,9 @@
-Darwin,sim:usbdev
-Darwin,sim:usbhost
+# zblue needs the Linux HCI socket and ELF section start/stop symbols
+-Darwin,sim:zblue
+
# Boards build by CMake
CMake,sim:ostest
CMake,sim:ostest_oneholder
@@ -51,3 +54,4 @@ CMake,sim:userfs
CMake,sim:usrsocktest
CMake,sim:ustream
CMake,sim:vncserver
+CMake,sim:zblue