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.

@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from ba9ebb7 to 86b9e6a Compare March 5, 2026 04:34
@andrewleech andrewleech force-pushed the pr/zephyr-ble-zephyr branch from 209f127 to e5ef1fe Compare March 5, 2026 04:34
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from 86b9e6a to 123460b Compare March 5, 2026 05:54
@andrewleech andrewleech force-pushed the pr/zephyr-ble-zephyr branch from e5ef1fe to 1b4ef75 Compare March 5, 2026 05:54
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from 123460b to 8e853d6 Compare March 5, 2026 06:33
@andrewleech andrewleech force-pushed the pr/zephyr-ble-zephyr branch from 1b4ef75 to 67b0f9a Compare March 5, 2026 06:33
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from 8e853d6 to 7e0b581 Compare March 5, 2026 06:54
@andrewleech andrewleech force-pushed the pr/zephyr-ble-zephyr branch from 67b0f9a to ced1184 Compare March 5, 2026 06:54
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from 7e0b581 to 86dba95 Compare March 5, 2026 12:38
@andrewleech andrewleech force-pushed the pr/zephyr-ble-zephyr branch 2 times, most recently from 4442799 to 08fc8bd Compare March 6, 2026 02:53
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch 2 times, most recently from edf2fd6 to c408c95 Compare March 6, 2026 06:26
@andrewleech andrewleech force-pushed the pr/zephyr-ble-zephyr branch 2 times, most recently from 4e2de49 to d00aaec Compare March 6, 2026 23:09
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from c408c95 to 7dfdb11 Compare March 6, 2026 23:09
@andrewleech andrewleech force-pushed the pr/zephyr-ble-zephyr branch from d00aaec to 4545298 Compare March 10, 2026 08:49
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from 7dfdb11 to 3f023f6 Compare March 10, 2026 08:49
@andrewleech andrewleech force-pushed the pr/zephyr-ble-zephyr branch from 4545298 to b3e9a17 Compare March 11, 2026 11:22
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from 3f023f6 to 50639b0 Compare March 11, 2026 11:22
pi-anl added 3 commits March 11, 2026 23:05
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-zephyr branch from b3e9a17 to cdaf654 Compare March 11, 2026 12:08
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from 50639b0 to c11d224 Compare March 11, 2026 12:08
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