Skip to content

ports/zephyr: Switch BLE to extmod/zephyr_ble integration.#21

Draft
andrewleech wants to merge 3 commits intopr/zephyr-ble-stm32from
pr/zephyr-ble-zephyr
Draft

ports/zephyr: Switch BLE to extmod/zephyr_ble integration.#21
andrewleech wants to merge 3 commits intopr/zephyr-ble-stm32from
pr/zephyr-ble-zephyr

Conversation

@andrewleech
Copy link
Owner

Summary

Replaces the Zephyr port's standalone modbluetooth_zephyr.c (~1000 lines) with the shared extmod/zephyr_ble integration layer. Since the Zephyr port already runs on Zephyr RTOS, the HAL shims mostly pass through to real Zephyr APIs, but using the shared extmod means BLE feature work and bug fixes apply to all ports simultaneously.

Also switches the nRF52840 DK board config from USB CDC ACM console to UART via JLink OB bridge. The Zephyr USB device_next stack has a CDC ACM RX regression (bulk OUT endpoints get STALLed) which makes USB console unreliable.

Depends on #20.

Testing

All 12 BLE multitests passing on nRF52840 DK (Zephyr port) with PYBD as central. UART console with hw-flow-control overlay working reliably.

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.

pi-anl added 3 commits March 6, 2026 16:44
Replace the native Zephyr port's custom BLE bindings with the shared
extmod/zephyr_ble integration layer. This unifies the BLE API across
all ports using Zephyr BLE, with the native Zephyr port using Zephyr's
own kernel primitives instead of the HAL shim stubs.

Includes machine.idle() fix to yield to Zephyr threads, and test
fixes for nRF52840 DK BLE multitests.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Enable synchronous BLE events and increase UART RX buffer to 512 bytes
for reliable raw-paste operation on the nRF52840 DK.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
The nRF52840 DK's USB CDC ACM console was unreliable — device enumeration
failures and stalls during raw-paste mode. Switch to UART via JLink OB
(uart0 with hw-flow-control) which is always available.

Move USB device stack init from mp_task (after console init) to
zephyr_start.c main() (before console init) so CDC ACM UART is ready
when the console subsystem opens the device. Add DTR wait for CDC ACM
console boards so output isn't lost before a host connects.

Reduce MICROPY_REPL_STDIN_BUFFER_MAX to 64 (raw-paste window=32 bytes)
to avoid overflowing USB-UART bridge buffers at 115200 baud.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from edf2fd6 to c408c95 Compare March 6, 2026 06:26
@andrewleech andrewleech force-pushed the pr/zephyr-ble-zephyr branch from 08fc8bd to 4e2de49 Compare March 6, 2026 06:26
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.

2 participants