Commit bb410ab
zephyr-cp: fix Pico 2 W BLE bring-up found on hardware
Four changes needed to get BLE actually working on a Pico 2 W, all found
by bisecting the failures over SWD.
The settings partition was 2K at 0x180800 — neither erase-sector aligned
nor large enough for one of the RP2350's 4K sectors. flash_area_get_sectors()
returned zero sectors, settings_nvs then computed its sector size from an
uninitialised struct and failed with -EDOM, so bt_enable() returned -33
before ever opening the HCI driver. That surfaced as a bare "OSError: 33"
from "import _bleio", which is where the adapter is enabled (the _bleio
module's __init__ calls common_hal_bleio_adapter_set_enabled). main has
since grown it to one aligned 4K sector at 0x17f000, which fixes the -EDOM
but is still one sector short: nvs_mount() rejects fewer than two sectors
with -EINVAL. Give settings two sectors at 0x17e000, taking the extra one
from the code partition. nvm and circuitpy stay at 0x180000 and 0x181000,
where cptools/check_partitions.py requires them to match
ports/raspberrypi, so the CIRCUITPY filesystem is not moved.
A board whose settings sectors hold content from a previous layout then
fails differently: NVS reads it as "all sectors closed" and refuses to
mount with -EDEADLK. CONFIG_NVS_INIT_BAD_MEMORY_REGION lets it reclaim a
region it does not recognise, so the first boot after a layout change
recovers on its own instead of needing a manual erase over SWD.
The CYW43439's BT controller firmware (CYW4343A2_001.003.016.0065.0000)
does not implement the Bluetooth 5 extended advertising/scanning commands.
It rejects LE Set Extended Scan Parameters (0x2041) with status 0x01
"Unknown HCI Command", so scanning failed with -EIO. The port defaults
BT_EXT_ADV on, which is right for the nRF parts but wrong here, so turn it
off for this board and let the host use the legacy 0x200B/0x200C commands.
Also raise the system workqueue stack and enable HW_STACK_PROTECTION (the
MPU turned several silent corruptions into clean, named faults while
debugging this), and enable BT HCI driver/host debug logging in
debug.conf.
Verified on hardware: patchram loads over the shared gSPI bus, the
controller reports BD_ADDR 2C:CF:67:B7:62:AC (= WiFi MAC + 1), and a scan
returns nearby advertisers by name. 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 8ff2ba3 commit bb410ab
4 files changed
Lines changed: 37 additions & 3 deletions
File tree
- ports/zephyr-cp
- boards/raspberrypi/rpi_pico2_w_zephyr
Lines changed: 8 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
Lines changed: 14 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
14 | 25 | | |
15 | 26 | | |
16 | | - | |
| 27 | + | |
17 | 28 | | |
18 | 29 | | |
19 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
0 commit comments