ports/nrf: Add Zephyr BLE with on-core controller support.#22
Merged
andrewleech merged 0 commit intopr/zephyr-ble-zephyrfrom Apr 20, 2026
Merged
ports/nrf: Add Zephyr BLE with on-core controller support.#22andrewleech merged 0 commit intopr/zephyr-ble-zephyrfrom
andrewleech merged 0 commit intopr/zephyr-ble-zephyrfrom
Conversation
209f127 to
e5ef1fe
Compare
0df0fe5 to
598f9f0
Compare
e5ef1fe to
1b4ef75
Compare
598f9f0 to
f02468d
Compare
1b4ef75 to
67b0f9a
Compare
f02468d to
324c1c8
Compare
67b0f9a to
ced1184
Compare
324c1c8 to
b666c34
Compare
ced1184 to
4442799
Compare
b666c34 to
5d82670
Compare
4442799 to
08fc8bd
Compare
5d82670 to
c02a8e5
Compare
08fc8bd to
4e2de49
Compare
abf7346 to
efca591
Compare
4e2de49 to
d00aaec
Compare
efca591 to
e047fb4
Compare
4545298 to
b3e9a17
Compare
574626e to
f40367e
Compare
cdaf654 to
e04c581
Compare
f40367e to
6d2d2a6
Compare
e04c581 to
3c83b20
Compare
6d2d2a6 to
a35d098
Compare
3c83b20 to
9fed0a4
Compare
a35d098 to
6821a72
Compare
9fed0a4 to
aa4123e
Compare
6821a72 to
1e5aef0
Compare
aa4123e to
f2f7cc8
Compare
1e5aef0 to
0f44af1
Compare
f2f7cc8 to
6492bd2
Compare
0f44af1 to
633fa4b
Compare
633fa4b to
9be0165
Compare
6492bd2 to
45850ad
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Zephyr BLE support to the nRF port (PCA10056 DK and PCA10059 dongle) using the Zephyr BLE host stack with an on-core BLE controller. Unlike the RP2 and STM32 integrations which rely on external BLE controllers (CYW43, STM32WB M0+), the nRF52840 runs the Zephyr BLE controller directly on the application core alongside MicroPython.
This required building the full Zephyr BLE controller (link layer, radio HAL, ticker) against the HAL shim layer, plus IRQ management shims that bridge Zephyr's
irq_connect_dynamic()/irq_enable()/irq_disable()to NVIC operations. The controller's radio ISR and ticker timing run at hardware interrupt priority while the host stack processes events cooperatively from the main task viamp_sched_schedule_node().Also adds SysTick, soft timer, and PendSV dispatch infrastructure to the nRF port which were previously missing and are needed for the scheduler-based BLE polling.
Depends on #21.
Testing
12/12 BLE multitests passing on nRF52840 DK with PYBD as central, and 12/12 Z2Z (DK as peripheral + PCA10059 dongle as central). Bond persistence test passes via the SUSPENDED mode reactivation path (on-core controller can't cleanly restart after
bt_disable()).Performance: ~35ms/notification (GATT), ~2184 B/s (L2CAP) with PYBD; ~25ms/notification, ~2681 B/s Z2Z.
428KB flash (42%), ~220KB RAM (84%) on PCA10056.
Trade-offs and Alternatives
The on-core controller means
bt_disable()can't cleanly shut down and restart the radio — the Zephyr controller wasn't designed for this. Instead,ble.active(0)enters a SUSPENDED state that stops advertising/scanning/connections but leaves the stack running. This wastes some power but avoids the need for a full chip reset to reinitialise.The
hci_driver_wrapper.cwraps Zephyr'shci_driver.cto expose file-scope variables for RX polling, avoiding a submodule patch.Generative AI
I used generative AI tools when creating this PR, but a human has checked the code and is responsible for the description above.