Repository navigation
Conversation
|
But this portging should belong userspace, like nimble: |
| * pass through kernel objects such as FIFOs. | ||
| */ | ||
|
|
||
| struct net_buf_simple |
There was a problem hiding this comment.
netbuf provides interfaces for network byte order operations and bit-level read/write access; furthermore, when used in conjunction with TCP/IP, it ensures that there is no contention for iob resources.
| ############################################################################ | ||
| # boards/sim/sim/sim/configs/bt/defconfig | ||
| # | ||
| # Copyright (c) ByteDance Ltd. and/or its affiliates. |
There was a problem hiding this comment.
remove ALL company copyright
There was a problem hiding this comment.
is it a rewrite or a copy ? We can not remove company information without authors consent!
There was a problem hiding this comment.
the code is copied from Zephyr and adjusted by @anchao , so should drop Bytedance copyright and keep Zephyr.
There was a problem hiding this comment.
Yep, The initial version was ported from Zephyr, but all files have been adapted to support the native NuttX; the entire protocol stack utilizes NuttX kernel APIs and adheres to NuttX coding standards.
There was a problem hiding this comment.
since you are a bytedance contributor is it possible to update the license to match the rest if NuttX under ICLA or SGA for the new implemnetation
is it possible to move it to nuttx-apps
There was a problem hiding this comment.
As Xiaomi's representative, you seem perfectly comfortable with the incremental contribution model that Xiaomi benefits from in the Zephyr community. Yet when it comes to NuttX, you keep raising the bar and imposing additional barriers. Why the double standard?
There was a problem hiding this comment.
The current Nimble port in nuttx-apps calls a significant number of NuttX kernel APIs directly — APIs like k_thread_create, k_sem_, k_fifo_, various work_queue functions, and other internal kernel primitives.
This is complete nonsense. AI hallucinations, or what? Did you even verify this?
If your AI makes mistakes like these, it’s hard to have confidence in the quality of the code or any claims made about it.
There was a problem hiding this comment.
k_sem_, k_fifo_ and k_work_* are Zephyr names kept by NimBLE's mesh code, which was ported from Zephyr. It has nothing to do with nuttx porting layer.
There was a problem hiding this comment.
The new stack being proposed takes the opposite approach: it starts in the kernel where it belongs architecturally (just like TCP/IP, CAN, and other in-kernel network stacks), and then we add proper userspace access through the socket layer — the same pattern every other NuttX network subsystem follows. That's not treating Bluetooth "specially" — it's treating it consistently with the rest of the OS.
No it's not. TCP/IP, CAN and other in-kernel networks stacks occupy different OSI layers. This PR puts all OSI layers to kernel which is obviously wrong. Everything above L4-L5 that resides in the kernel is controversial. What you are proposing is equivalent to embedding HTTP, REST or CANopen into the kernel.
There was a problem hiding this comment.
Let me restate my proposal more clearly: the intention is not to keep all Bluetooth profiles in kernel space. The plan is to keep only the lower Bluetooth transport/protocol layers that need to interact closely with the network/device side in the kernel, especially L2CAP. Higher-level profiles and application-facing logic should be moved out of the kernel and maintained in libs/libbt.
So the long-term layering would be:
- kernel: controller/HCI integration, core host transport, L2CAP, and other lower-layer pieces that need kernel-side integration;
- libs/libbt: higher-level Bluetooth profiles and reusable host-stack logic;
- apps: shell commands, tools, demos, and other user-facing code.
This still follows the OSI layering principle. I am not proposing that profiles such as audio, GATT services, mesh models, or other application-level logic should permanently live in the kernel.
For the current first-stage PR, the main goal is to make the stack build and run in FLAT mode first. In FLAT mode the separation is naturally less strict, and keeping the profile code close to the stack can provide better performance and lower overhead. This is also important if we want NuttX Bluetooth to be competitive with mainstream embedded OS implementations such as Zephyr.
However, I agree that this should not become the final layout for Protected and Kernel builds. For the next stage, I plan to move the higher-level profiles into libs/libbt and keep only the necessary lower-layer kernel components in net/bt. The shell code has already been removed from this PR and will be moved to apps, so the current stack no longer contains userspace shell code.
In short, I agree with the concern about not putting all OSI layers into the kernel. My proposal is to keep L2CAP and the required lower layers in the kernel, while moving higher-level profiles to libs/libbt as part of the next-stage Protected/Kernel mode support.
| @@ -438,6 +390,7 @@ source "net/netlink/Kconfig" | |||
| source "net/tcp/Kconfig" | |||
| source "net/udp/Kconfig" | |||
| source "net/bluetooth/Kconfig" | |||
| source "net/bt/Kconfig" | |||
There was a problem hiding this comment.
but what's relationship with the original bluetooth stack? it isn't good to contain two Bluetooth stacks with the incompatible public API in the kernel space.
There was a problem hiding this comment.
The original protocol stack will be removed once we have implemented support in both the kernel and user space.
There was a problem hiding this comment.
so please finish your work in your internal git and do test before submitting the partial code to community.
There was a problem hiding this comment.
This doesn't conflict with the existing Bluetooth subsystem at all — the new stack lives under net/bt/ and is guarded by its own CONFIG_BT Kconfig option, completely independent from the legacy stack. The two can coexist and be developed in parallel.
Submitting to the community early has several benefits:
- Parallel development: The community can start testing, reviewing, and contributing fixes while we continue working on phase 2 (userspace/kernel space split). There's no need to block the initial framework on downstream work.
- Earlier feedback: The Bluetooth stack is a large piece of work — 600+ files. Getting it into the tree sooner means more eyes on the code, earlier bug discovery, and broader testing across different hardware platforms.
- Lower upstream maintenance burden: Keeping a large patch set in an internal fork and rebasing against master is painful and error-prone. Every day it stays out of tree, the merge conflict surface grows.
Asking us to fully finish phase 2 and 3 in isolation before submitting phase 1 would actually slow down the overall effort and delay the community from benefiting from a working Bluetooth stack. This is a baseline submission that gives everyone a foundation to build on — not the final product.
At this stage, the entire Bluetooth stack currently only supports flat build. Protected build and kernel build support are planned for Phase 2. Our thinking for Phase 1 is to get the full stack running with complete feature support first. I've also added flat build as a dependency under the CONFIG_BT configuration option. Once this is in place, we'll move the upper-layer profile code entirely Why flat build first?There are several benefits to this approach:
Migration PlanThe overall migration is broken down into several phases: Phase 1 (current)Submit the full-featured Bluetooth stack to the mainline so everyone can collaborate on stabilizing it together. Phase 2Provide both userspace and kernel space support: • Bluetooth profile code will move to libc. Phase 3Once the new stack fully supports NuttX's Bluetooth capabilities:
Why not do everything in one commit?A Bluetooth protocol stack is an extremely complex piece of work. It involves different profiles, different L2CAP data link layers (e.g., LE Audio and SCO), each of which may require different implementation approaches within the kernel. Supporting My initial implementation is focused on getting the full-featured stack running on NuttX with minimal resource consumption. We'll continue to invest in stabilizing and improving the framework and architecture over subsequent iterations. |
|
As AI’s code generation capability improves, ensuring code quality becomes ever more important. Before the code finish:
I reject to merge this pr. Anyway, you can send email to dev@ and ask other people opinion. |
+1 |
|
I have concerns on the code quality and compliance Please split the contribution to small chunks which can be reviewed and discussed |
My recommendation is to keep the protocol stack implementation in the kernel, and use libc to provide the userspace isolation layer for protected/kernel build modes. This way:
This approach gives us the best of both worlds — performance when we need it (flat build), and isolation when we need it (protected/kernel build) — without the drastic rewrite of moving everything to userspace. I'd suggest everyone take another look at NuttX's current Bluetooth capabilities. The reality is that many companies are choosing not to adopt NuttX precisely because of the lack of a mature Bluetooth stack. A fully functional Bluetooth host stack is no longer optional — it's a baseline requirement for most IoT products today (BLE, LE Audio, mesh, etc.). Adding a proper Bluetooth stack to the kernel is a positive step for promoting NuttX adoption. It unlocks a whole category of use cases that are currently simply not possible, and makes NuttX a viable option for a much broader range of devices. This is good for the entire ecosystem. @jerpelea @acassis @xiaoxiang781216 |
ef6e918 to
c0d36c3
Compare
Hi @anchao I think we need to evolve the NuttX BLE and although the initial BLE stack used on NuttX is the same used on Zephyr that came from Intel, I don't know if we should use the code from Zephyr. Or is it a rewrite from scratch? I think for the size of this PR and the importance of this subject, I suggest it should be better if you send first an email to the mailing list explaining your proposal/approach. I think if we use code from Zephyr, the same CVEs which affect them will affect us. And it will prevent the diversity protection (when a company uses multiple RTOSs to avoid an single hacking put down all theirs devices). |
I agree that this is an important topic and probably deserves broader discussion on the mailing list before we decide the long-term direction. I can prepare a proposal email to explain the motivation, scope, current limitation, and the To clarify the approach: this is not a rewrite from scratch. The current PR is a port/adaptation of the Zephyr Bluetooth host stack into NuttX, with a NuttX compatibility layer for kernel primitives, work queues, timeout handling, logging, settings, net_buf, iterable sections, and build integration. The reason I took this approach is that the Bluetooth stack has evolved far beyond a basic BLE host. Today, a practical Bluetooth host needs to cover much more than GAP/GATT/ATT/SMP:
Rebuilding all of this on top of the original NuttX BLE implementation would be a very large multi-year effort. Even if we start from the existing NuttX BLE code, we would still need to implement and maintain a large amount of profile About the CVE concern: I think this is a valid point. If we import or derive code from Zephyr, some vulnerabilities may also apply to the NuttX port. But I think there are also trade-offs:
So I think the main question is the trade-off between:
For the current PR, I also want to make the limitation explicit:
|
c0d36c3 to
6d6ddbb
Compare
|
6d6ddbb to
b519d24
Compare
f5e37bd to
e8ede6c
Compare
f500b39 to
6a55baa
Compare
| @@ -0,0 +1,40 @@ | |||
| # ############################################################################## | |||
| # libs/zblue/CMakeLists.txt | |||
There was a problem hiding this comment.
I still prefer zblue belong nuttx-apps.git, @raiden00pl what's your opinion?
There was a problem hiding this comment.
I won’t comment on where the Bluetooth code should be placed, but I notice this PR consists entirely of code—where are the tests? Since we already have the BSWorld simulation testing system, and it’s now supported in the default CI pipeline, we really should add corresponding Bluetooth tests for this PR. Otherwise, how can we ensure the stability of such an extensive set of fixes? Although BR/EDR is not yet supported, the vast majority of LE (Low Energy) functionality can certainly be tested.
There was a problem hiding this comment.
@xiaoxiang781216 actually @casaroli commented with me he also thinks zblue should go to nuttx-apps, having almost 1Mi LoC of BT/BLE, that we know probably will have a critical CVE (because its surface area), is very dangerous. Been in nuttx-apps will not protect much for devices running on Flat mode, but will for Protected and Kernel modes.
There was a problem hiding this comment.
For this initial PR, I would like to keep the scope focused on the host stack infrastructure, public headers, build integration, and compile coverage. The actual test framework is planned to come together with the Bluetooth shell/tools in nuttx-apps.git, so that tests can exercise the stack through the same user-facing interfaces.
For protocol-level signaling simulation, we can evaluate a Zephyr AutoPTS-like approach or BSWorld-based tests, but I think that should be done as a follow-up after the base stack lands; otherwise this already large PR will become much harder to review.
There was a problem hiding this comment.
I understand the concern about the attack surface. A full BT/BLE stack is definitely security-sensitive, and we should treat it as such.
However, I think this is very similar to the situation Zephyr faces: the Bluetooth host stack is a core OS networking subsystem with a large attack surface, so the right solution is to harden it, fuzz/test it, and keep fixing issues in the stack itself. I do not think moving it to nuttx-apps fundamentally solves the security problem.
For the majority of NuttX deployments today, especially IoT devices, Flat mode is still the main usage model. In that model, putting the stack in nuttx-apps does not provide real isolation. It also does not solve the performance and integration issues around HCI, net buffers, protocol state, and driver interaction.
For Protected/Kernel mode, I agree that userspace isolation would be valuable. But today we do not yet have a complete Classic Bluetooth stack that can run properly in that model. We had also considered porting BlueZ, but the glibc, D-Bus, and userspace runtime dependencies make it a poor fit for typical NuttX targets.
So my view is:
- security is a real concern, but apps placement is not a complete solution;
- Flat mode remains the dominant deployment model for NuttX IoT devices;
- zblue is much closer to an OS networking subsystem than to an application;
- BlueZ-style userspace architecture is too heavy for many NuttX targets;
- we should land the core stack in nuttx.git first, then continue hardening, testing, fuzzing, and eventually evaluate better isolation for Protected/Kernel mode.
In other words, I agree we need to be careful about security, but I still think the practical first step is to integrate the host stack as a NuttX networking subsystem and improve its robustness there.
There was a problem hiding this comment.
Another important point is performance in Flat mode.
For many low-frequency IoT chips, running the Bluetooth host stack close to the
kernel/lower-half driver path has very visible benefits: fewer context
switches, fewer data copies, and less scheduling overhead between the HCI
driver, buffer management, protocol state machine, and upper layers.
Bluetooth is also very latency-sensitive. Having direct access to NuttX kernel
primitives such as interrupt control, lower-level locks, work queues, signals,
and timing APIs allows the stack to make better use of the hardware and reduce
overhead on constrained devices.
@casaroli I think you know this tradeoff very well from your optimization in
the event notification path:
#20387
Even removing one extra function indirection or one unnecessary interrupt
disable/enable pair can matter on small MCUs. For the same reason, putting the
Bluetooth host stack on the kernel-side path gives us a more practical
performance baseline for the main NuttX IoT use case, especially in Flat mode.
There was a problem hiding this comment.
@anchao yes, Zephyr is known to get using everything on kernel side, even their SSH port runs on the kernel side. You are right about the performance tradeoff but we need to evaluate if this tradeoff is worse than the security hole it adds. I never used NimBLE in Protected/Kernel mode, maybe @raiden00pl had some experience with it and could share his view about the performance.
There was a problem hiding this comment.
Yes Alan, I agree this tradeoff needs to be evaluated carefully.
My main goal here is to reach a consensus with the community on the practical
direction for NuttX. Bluetooth is a very large area, covering security,
performance, driver integration, host protocols, profiles, testing, and
different build modes, so it cannot be solved by one person or one PR alone.
I really appreciate your patience and the feedback from everyone. I hope we can
find a path that works for the current NuttX use cases while still leaving room
to improve security isolation and Protected/Kernel mode support over time.
There was a problem hiding this comment.
@anchao thank you for your patience on that too! I don't want to be a road blocker and truly believe NuttX needs this stack as an alternative to current situation (there is nothing wrong with NimBLE but it doesn't have all the features we need). But we need to get it in a way it doesn't jeopardize the project or the products using NuttX.
There was a problem hiding this comment.
@anchao Thanks for taking your time and trying to find a consensus
I would propose to have both BT implementations and provide alternatives at build time,
this way the users can select the one that they need while keeping compatibility
Best regards
Alin J
6a55baa to
bc3479e
Compare
Add a native NuttX Bluetooth host stack under libs/zblue together with the public Bluetooth header namespace, net_buf memory support, and build integration. The stack provides a complete host-side foundation that can be built inside NuttX without requiring an external RTOS runtime, while keeping the controller interface separated through the HCI transport and driver abstraction layers. The implementation is organized by protocol layer and upper profile coverage: - Core Host: - Bluetooth address handling - identity management - HCI command and event processing - buffer ownership and monitor support - settings storage and key management - SMP pairing support - GATT database handling - ATT request processing - L2CAP channels - ISO channels - advertising and scanning - connection management - direction finding and channel sounding - common data helpers These pieces provide both the internal protocol machinery and the public APIs needed by applications, services, and profiles. - Classic BR/EDR: - inquiry and connection management - BR/EDR L2CAP - RFCOMM - SDP - SCO plumbing - secure simple pairing - A2DP - AVRCP and AVRCP cover art - GOEP and OBEX - BIP - PBAP - MAP - HFP Audio Gateway - HFP Hands-Free - HID Device and HID Host - Bluetooth Mesh: - provisioning and bearer handling - network, transport, and access layers - subnet and key management - replay protection - beacons - friend and low-power-node behavior - GATT proxy and proxy client/server - heartbeat - configuration client/server - health client/server - model message helpers - settings persistence - BLOB transfer - firmware update and distribution - remote provisioning - large composition data - directed forwarding - bridge configuration - on-demand private proxy - opcode aggregation - private beacon - SAR configuration - solicitation PDU RPL - statistics - related client and server models - LE Audio: - BAP unicast client/server - BAP broadcast source/sink - scan delegator and broadcast assistant - PACS and ASCS - CAP acceptor, initiator, and commander - AICS - VCP and VOCS - MICP - CSIP - TBS - MCS and MCC - media proxy - HAS - TMAS and TMAP - GMAP - PBP - CCID and CCP - codec helpers - LC3 preset definitions - endpoint and stream management These components provide the public headers and implementation structure needed for both unicast and broadcast audio roles as well as coordinated and content-control audio use cases. - GATT Services: - GAP - BAS - DIS - TPS - HRS - CTS - ETS - IAS - ANS - NUS - OTS - service configuration and callbacks - object transfer support - Nordic UART service instances - immediate alert client/server helpers - battery service variants - Common Support: - crypto helpers - EAD - SBC codec support - host utility code - NuttX-backed kernel object wrappers - work queues and timeout helpers - atomics - settings and logging support - device stubs - iterable sections - HCI driver registration - path-derived public header guards Keep the compatibility surface local to the Bluetooth subsystem and expose public APIs through the NuttX include tree. - Build and Configuration: - standalone libs/zblue Make build integration - CMake build integration - Kconfig coverage for the core host - Kconfig coverage for Classic, Mesh, services, and LE Audio - Kconfig coverage for crypto, common library, and net_buf support - private include paths for internal compatibility headers The build integration keeps Bluetooth implementation details from leaking into unrelated NuttX targets. Note: The current Bluetooth host stack supports only flat builds. Protected and kernel builds are not supported yet. Signed-off-by: chao an <anchao.archer@bytedance.com>
bc3479e to
47ab26d
Compare
|
hi all Feedback welcome. thanks |
Thanks @chengkai15 , this is a good start. I agree we should move the detailed I have replied in the mailing list with my concerns and suggestions, especially I am happy to work with you and the community to align on a common roadmap. |
|
Hi @anchao ,
Thank you for the detailed reply, and for the offer to work together. I am
glad we agree on the most important point: NuttX should have one
Zephyr-based Bluetooth host, not two.
Let me first list where I think we already agree, then the open points and
a proposed order of work.
Where we agree:
1. One common stack. We are happy to use the openvela stack as the common
base and to work on it together with you.
2. Long-term architecture for protected/kernel builds: a BlueZ/Linux-style
split, with HCI/core/L2CAP and socket integration in the kernel, and
profiles, services and tools in userspace. This is the path described in
Section 5 of the proposal.
3. Flat builds may keep a more direct HCI path (btdev callback) for low-end
IoT chips. We see no conflict with that; it can be an option next to the
socket model.
4. Kconfig: CONFIG_ZBLUE_ENABLED as the top-level switch, with CONFIG_BT_*
for the feature options, as agreed with Alan, is fine with us.
Open point 1: fork vs. staying in sync with Zephyr
You are right that the port layer needs NuttX kernel-style primitives
today, and that the compatibility layer has a cost. In flat build we use
some internal primitives; making the port layer use only public interfaces
is part of the protected/kernel work.
Our suggestion is to fork only where the NuttX architecture requires it,
not by default:
- The layers that move into the kernel (HCI core, connection management,
L2CAP, socket integration) become NuttX-maintained code. Those are the
parts that must be adapted to NuttX networking, memory management and
build modes anyway.
- The layers above (profiles, GATT services, LE Audio, Mesh, Classic
profiles) only depend on the Zephyr Bluetooth host API, not on the Zephyr
kernel. That is also where most upstream development and security fixes
happen. Keeping them close to upstream lets NuttX keep picking those
fixes up with little effort.
This way the compatibility layer shrinks over time instead of growing, and
the divergence happens step by step, where it brings real value.
Open point 2: external repository vs. in-tree
We suggest starting with an external git repository, fetched at a pinned
revision like NimBLE. This keeps the first patches small and easy to review,
and gives everyone a working stack to test against from the start. The
kernel part will live in nuttx.git. Once the userspace part only contains
the layers above L2CAP, we can move it into nuttx-apps.git if the community
prefers that.
Proposed order of work:
1. Integrate the stack into nuttx-apps as an external git repository, as
described in the proposal.
2. Move the L2CAP layer and below into the NuttX kernel, replacing the
current kernel Bluetooth implementation (wireless/bluetooth and
net/bluetooth). The new kernel part must keep the existing functionality
and add BR/EDR Classic support.
3. Change the stack in nuttx-apps to drop its own L2CAP-and-below layers and
use the NuttX kernel instead (sockets for protected/kernel builds; for
flat builds, optionally a direct function-call/callback path to the
kernel L2CAP layer). If needed at this step, the remaining Zephyr-derived
code can be moved into nuttx-apps.git.
Each step is a separate series of small patches, and the stack keeps working
after every step.
I would like to hear what @xiaoxiang781216 , @jerpelea @acassis @cederom and others think about
this order and the two points above.
Proposed next step: once this is settled, we write a short joint roadmap
(owners and schedule for each step), post it here for review, and then
start with small, reviewable patches.
Thanks again for the open discussion.
Best regards,
Kai Cheng
…________________________________
From: archer ***@***.***>
Sent: Wednesday, October 28, 2026 9:21:58 PM
To: apache/nuttx
Cc: 成凯; Mention
Subject: [External Mail]Re: [apache/nuttx] net/bt: Add native Bluetooth host stack (PR #20686)
[外部邮件] ***@***.***进行反馈
[https://avatars.githubusercontent.com/u/758493?s=20&v=4]anchao left a comment (apache/nuttx#20686)<#20686 (comment)>
hi all We posted a proposal for integrating a Zephyr-based Bluetooth host as a userspace stack in nuttx-apps (with an optional step-by-step path to a BlueZ/Linux-style split) to dev@ https://lists.apache.org/thread.html/c6pl46o5l1ngb2zb3qtotq38o30h6v4b
Feedback welcome.
thanks
@chengkai15<https://github.com/chengkai15>
Thanks @chengkai15<https://github.com/chengkai15> , this is a good start. I agree we should move the detailed
architecture discussion to dev@ and try to converge on one common direction for
the Zephyr-based Bluetooth host instead of maintaining two separate solutions.
I have replied in the mailing list with my concerns and suggestions, especially
around the long-term sync model, whether zblue should be treated as a
NuttX-maintained fork or an always-rebased Zephyr subtree, and the desired
kernel/userspace split for Flat vs Protected/Kernel builds.
I am happy to work with you and the community to align on a common roadmap.
―
Reply to this email directly, view it on GitHub<#20686?email_source=notifications&email_token=ABDILOM3CPHBGJE6GC2UGVL5WHXHNA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTMNBXGAYTAMRYGEZ2M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#issuecomment-6470102813>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABDILONWQGLYF4LZ6SQF3BD5WHXHNAVCNFSNUABFKJSXA33TNF2G64TZHMZDEOBRGAZTENZTHNEXG43VMU5TKOBWG4ZTIMBYG4Z2C5QC>.
You are receiving this because you were mentioned.Message ID: ***@***.***>
#/******本邮件及其附件含有小米公司的保密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制、或散发)本邮件中的信息。如果您错收了本邮件,请您立即电话或邮件通知发件人并删除本邮件! This e-mail and its attachments contain confidential information from XIAOMI, which is intended only for the person or entity whose address is listed above. Any use of the information contained herein in any way (including, but not limited to, total or partial disclosure, reproduction, or dissemination) by persons other than the intended recipient(s) is prohibited. If you receive this e-mail in error, please notify the sender by phone or email immediately and delete it!******/#
|
|
Thanks for the clarification. I think we are mostly aligned on the long-term direction, especially about converging to one Zephyr-based Bluetooth host and moving toward a BlueZ/Linux-style split for protected/kernel builds. For open point 2, I still prefer not to start from an external repository model in the main NuttX integration path. My suggestion is that the code should first be adapted into a NuttX-native integration style, and then submitted directly to either nuttx.git or nuttx-apps.git, depending on the agreed layering. Fetching a large external repository at build time will also bring dependency and maintenance issues with other third-party code, and I do not think that is the best long-term integration model for an official NuttX Bluetooth stack. In my view, if the stack is going to become part of the NuttX Bluetooth architecture, it should be reviewed, built, tested, and maintained as part of the NuttX repositories, not as an external component that is only pinned by revision. Maybe you can use the current PR as a reference for the NuttX-native integration structure: top-level CONFIG_ZBLUE_ENABLED, NuttX build/Kconfig integration, NuttX-style public headers, and direct integration with the NuttX Bluetooth driver path. The implementation details can certainly be changed, but I think this kind of native integration is a better direction than relying on an external fetched repository. If the openvela version is adjusted in this direction and accepted by the community as the common upstream solution, I am willing to drop my current PR and help with that effort. My goal is not to keep my own patch, but to help NuttX get a complete and maintainable Bluetooth stack. |
|
Regarding architecture:
Regarding nomenclature:
|
|
As suggested by @linguini1, I have started a vote on the integration The vote is open until Monday, 9 November 2026, 00:00 UTC. Please vote Thanks |
Summary
This PR adds a native NuttX Bluetooth host stack under
net/bt, together withthe public Bluetooth header namespace,
net_bufmemory support, buildintegration, and a broad
sim:btcoverage configuration.The stack is ported from Zephyr Bluetooth host components and adapted to run
inside NuttX without requiring an external RTOS runtime. It keeps the controller
interface separated through the HCI transport and driver abstraction layers,
while exposing Bluetooth APIs through the NuttX public include tree.
This provides the foundation for BLE, BR/EDR Classic, Bluetooth Mesh, LE Audio,
GATT services, and profile-level shell/demo coverage in NuttX.
What is included
Core Bluetooth Host
This PR adds the core host-side Bluetooth protocol machinery, including:
These pieces provide both the internal host stack logic and the public APIs
needed by applications, services, profiles, and shell commands.
Classic BR/EDR Support
The PR adds Classic Bluetooth support, including:
Classic shell commands expose profile-level test and operation flows so these
features can be compiled and exercised from the NuttX shell environment.
Bluetooth Mesh Support
This PR adds Bluetooth Mesh host support, including:
LE Audio Support
The PR adds LE Audio infrastructure and profiles, including:
These components provide the public headers and implementation structure needed
for both unicast and broadcast audio roles, as well as coordinated and
content-control audio use cases.
GATT Services
This PR adds GATT service support and service implementations, including:
The
sim:btconfiguration enables common services such as BAS, DIS, TPS, andNUS so that GATT server behavior can be exercised from the simulator build.
Common Support and Compatibility Layer
This PR adds the compatibility and support infrastructure required by the host
stack, including:
net_bufandnet_buf_simplememory supportThe compatibility surface is kept local to the Bluetooth subsystem, while public
Bluetooth APIs are exposed through the NuttX include namespace.
Build and Configuration
This PR adds build-system integration for the Bluetooth stack:
net_bufsupportsim:btdefconfig for broad compile coverageThe build integration keeps Bluetooth implementation details contained within
the Bluetooth subsystem and avoids leaking internal compatibility headers into
unrelated NuttX targets.
Runtime/demo coverage
The
sim:btconfiguration includes demo-oriented behavior for exercising thestack in the simulator, including:
The runtime logs are intentionally kept in the NUS demo application layer rather
than being added to the protocol stack internals.
Current limitation
The current Bluetooth host stack supports only flat builds and therefore
CONFIG_BT depends on BUILD_FLAT.
Protected builds and kernel builds are not supported in this initial version.
Support for protected and kernel build modes is planned for 27Q2. As part of
that work, the related Bluetooth profiles will be added to the libc build where
needed so they can work correctly across NuttX protected/kernel build
boundaries.
Impact
N/A
Testing
The current test and validation coverage is limited to the simulator platform.
A simulator-based Bluetooth test framework has been completed and is used to
exercise both Classic Bluetooth and BLE paths. The
sim:btconfigurationprovides broad build coverage for the host stack, services, profiles, and demo
integration.
Validated coverage includes:
Build validation was performed with the simulator Bluetooth configuration:
Makefile:
CMake:
A2DP connection: