Skip to content

Commit 036ffe9

Browse files
tyethclaude
andcommitted
zephyr-cp: enable BLE on the Raspberry Pi Pico W
Same CYW43439 as the Pico 2 W, and the shared-bus HCI driver needed no board-specific work, so this is the Pico 2 W change applied to the RP2040 board: - overlay: hang the infineon,cyw43-bt-hci node off the stock infineon,airoc-wifi node and point zephyr,bt-hci at it. - overlay: the settings partition had the same defect as the Pico 2 W's -- originally 2K at 0x180800, neither erase-sector aligned nor big enough for one of the RP2040's 4K sectors; main has since made it one aligned 4K sector at 0x17f000, which is still one short of the two nvs_mount() insists on, so bt_enable() fails before opening the HCI driver. Give settings two sectors at 0x17e000, taken from the code partition. nvm and circuitpy stay at 0x180000 and 0x181000 to match ports/raspberrypi (cptools/check_partitions.py checks this), so CIRCUITPY is not moved. - conf: BT_EXT_ADV=n, since this controller rejects the Bluetooth 5 extended advertising commands, plus a deeper system workqueue stack. HW_STACK_PROTECTION is deliberately left off here: it earned its place on the Cortex-M33 but costs RAM, and this is the constrained board. Builds at 68.67% flash and 84.32% RAM of 264K, so BLE fits with about 42K to spare. Verified on hardware after the "ranges" fix (now on main): the adapter comes up as WiFi MAC + 2 and a legacy LE scan returns nearby advertisers. That run used the earlier layout with settings at 0x181000; the 0x17e000 placement is build-tested only. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
1 parent f675fb7 commit 036ffe9

3 files changed

Lines changed: 65 additions & 1 deletion

File tree

‎ports/zephyr-cp/boards/raspberrypi/rpi_pico_w_zephyr/autogen_board_info.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "Raspberry Pi Foundation Raspberry Pi Pico"
33

44
[modules]
55
__future__ = true
6-
_bleio = false
6+
_bleio = true # Zephyr board has _bleio
77
_eve = false
88
_pew = false
99
_pixelmap = false

‎ports/zephyr-cp/boards/raspberrypi/rpi_pico_w_zephyr/board.conf‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,12 @@ CONFIG_MBEDTLS_ENTROPY_C=y
2020
CONFIG_MBEDTLS_CTR_DRBG_C=y
2121

2222
CONFIG_TEST_RANDOM_GENERATOR=y
23+
24+
# Bluetooth over the shared gSPI bus (CONFIG_BT itself comes from the
25+
# zephyr,bt-hci chosen node in the overlay).
26+
#
27+
# The CYW43439's BT controller firmware does not implement the Bluetooth 5
28+
# extended advertising/scanning commands, and the port defaults BT_EXT_ADV on,
29+
# so turn it off here and let the host use the legacy 0x200B/0x200C commands.
30+
CONFIG_BT_EXT_ADV=n
31+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,58 @@
11
/* Partition layout is owned by the mcuboot fork (dts/raspberrypi/rpi_pico.dtsi)
22
* and applied to this image by sysbuild. This overlay only adds board/app config. */
3+
4+
/*
5+
* Settings partition: one exception to the layout above. sysbuild prepends the
6+
* adaboot layout (dts/raspberrypi/rpi_pico_w.dtsi) to this overlay, so what
7+
* is set here wins.
8+
*
9+
* The settings partition backs Bluetooth bond keys via NVS, so it must be
10+
* erase-sector aligned and hold at least two of the RP2040's 4K sectors.
11+
* The layout gives it one (0x17f000, 4K); nvs_mount() rejects a single sector
12+
* with -EINVAL, which makes bt_enable() fail before ever opening the HCI
13+
* driver and surfaces as a bare OSError from "import _bleio".
14+
*
15+
* nvm and the filesystem must stay where ports/raspberrypi puts them
16+
* (cptools/check_partitions.py enforces this), so the second sector comes out
17+
* of the code partition, not out of the CIRCUITPY drive. The code partition
18+
* still starts at 0x100, after the second stage bootloader.
19+
*/
20+
&code_partition {
21+
reg = <0x100 (0x17e000 - 0x100)>;
22+
};
23+
24+
/delete-node/ &storage_partition;
25+
26+
&flash0 {
27+
partitions {
28+
storage_partition: partition@17e000 {
29+
compatible = "zephyr,mapped-partition";
30+
label = "storage";
31+
reg = <0x17e000 0x2000>;
32+
};
33+
};
34+
};
35+
36+
/*
37+
* Bluetooth. Same CYW43439 as the Pico 2 W: HCI is not on a UART, it shares
38+
* the WiFi gSPI bus, so hang the shared-bus HCI transport off the board's
39+
* stock infineon,airoc-wifi node and point the host at it. CONFIG_BT then
40+
* enables itself via the zephyr,bt-hci chosen (see
41+
* ../../../internal-modules/circuitpython-kconfig/Kconfig).
42+
*/
43+
&pio0_spi0 {
44+
airoc-wifi@0 {
45+
cyw43_bt_hci: cyw43_bt_hci {
46+
compatible = "infineon,cyw43-bt-hci";
47+
status = "okay";
48+
};
49+
};
50+
};
51+
52+
/ {
53+
chosen {
54+
zephyr,bt-hci = &cyw43_bt_hci;
55+
};
56+
};
57+
358
#include "../../../app.overlay"

0 commit comments

Comments
 (0)