Skip to content

ports/stm32: Add Zephyr BLE support for WB55 and PYBD.#20

Draft
andrewleech wants to merge 5 commits intopr/zephyr-ble-corefrom
pr/zephyr-ble-stm32
Draft

ports/stm32: Add Zephyr BLE support for WB55 and PYBD.#20
andrewleech wants to merge 5 commits intopr/zephyr-ble-corefrom
pr/zephyr-ble-stm32

Conversation

@andrewleech
Copy link
Owner

Summary

Adds Zephyr BLE integration for the STM32 port, targeting the NUCLEO_WB55 and PYBD_SF6 boards. The WB55's BLE controller runs on the M0+ coprocessor (CPU2) and communicates with the M4 host via IPCC mailbox — the HCI driver in mpzephyrport.c bridges this to the Zephyr BLE host's H4 transport.

The IPCC/rfcore integration required careful handling of the CPU2 lifecycle: HCI_Reset must not be sent to CPU2 as it corrupts all 192KB of SRAM1. This is prevented by a drv_quirk_no_reset() hook in the Zephyr host's hci_core.c.

Build variants: NUCLEO_WB55 BOARD_VARIANT=zephyr_ble and PYBD_SF6 BOARD_VARIANT=zephyr_ble.

Depends on #19.

Testing

11/11 BLE multitests passing on WB55 with nRF52840 DK as peripheral. PYBD variant builds but has not been tested with Zephyr BLE (PYBD is primarily used as a NimBLE reference central).

Trade-offs and Alternatives

The STM32 integration touches several files beyond the BLE-specific code (linker scripts, FreeRTOS hooks, system_stm32 changes) because the WB55's dual-core architecture and IPCC memory layout require careful memory section placement. These changes are guarded by MICROPY_BLUETOOTH_ZEPHYR defines where possible.

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-stm32 branch from 86b9e6a to 123460b 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-stm32 branch from 8e853d6 to 7e0b581 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-stm32 branch from 86dba95 to edf2fd6 Compare March 6, 2026 02:53
@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-stm32 branch from c408c95 to 7dfdb11 Compare March 6, 2026 23:09
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch 3 times, most recently from 50639b0 to c11d224 Compare March 11, 2026 12:08
@andrewleech
Copy link
Owner Author

/review

@mpy-reviewer
Copy link

mpy-reviewer bot commented Mar 13, 2026

Review failed. Retry with /review.

@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from 09ee309 to e1abf3a Compare March 16, 2026 08:08
pi-anl added 4 commits March 16, 2026 20:26
Cleanup unused functions, macros and debug helpers that were never called
or only conditionally compiled behind disabled feature flags. Removes dead
registry system, PSA crypto stubs, LIFO operations, and various unused
helper functions and inlines from kernel/device/config headers. Also
deletes gatt_pragma.h which is unreferenced.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Add Zephyr BLE variant configuration for PYBD_SF6 board, with HCI UART
readpacket support for bulk reading from the BT coprocessor.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
Update mp_handle_pending() calls to use the
mp_handle_pending_behaviour_t enum instead of bool, matching
the current signature in py/scheduler.c.

Add mp_bluetooth_zephyr_l2cap_flush_recv_notify() call to
port_run_task, consistent with RP2 and nRF ports. Without this,
deferred L2CAP recv notifications were never delivered to Python.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
@andrewleech andrewleech force-pushed the pr/zephyr-ble-stm32 branch from e1abf3a to 0c5c401 Compare March 16, 2026 09:32
Use ZEPHYR_BLE_POLL_INTERVAL_MS for poll timer values.
Enable CONFIG_BT_AUTO_DATA_LEN_UPDATE for NUCLEO_WB55.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
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