From 7527914691ea32b4c04df7d3c241f5a84e375364 Mon Sep 17 00:00:00 2001 From: tyeth Date: Wed, 9 Sep 2026 12:30:48 +0100 Subject: [PATCH] zephyr-cp: fix USB loss under BLE load on the Pico W boards The rpi_pico UDC driver's internal thread stack was only raised in debug.conf, so release builds kept Zephyr's 512-byte default and dropped off USB partway through a _bleio scan -- CDC port and CIRCUITPY volume both disappearing, with a USB device/stack error on reset. Move it to prj.conf so every build gets it. Verified on a Pico 2 W: a 12s active scan yielding 925 reports from 20 distinct devices now completes with USB intact, where the same workload previously killed the bus. This commit used to also raise BT_MAX_CONN to 4 on the Pico 2 W (Zephyr defaults to 1). Upstream has since set CONFIG_BT_MAX_CONN=5 port-wide in prj.conf, so that part is dropped: keeping it would now lower the limit. Co-Authored-By: Claude Opus 5 Co-Authored-By: Claude Opus 5.5 --- ports/zephyr-cp/prj.conf | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ports/zephyr-cp/prj.conf b/ports/zephyr-cp/prj.conf index be6e22c8fa8..574f207c5a4 100644 --- a/ports/zephyr-cp/prj.conf +++ b/ports/zephyr-cp/prj.conf @@ -117,3 +117,9 @@ CONFIG_BT_MAX_PAIRED=3 # region it does not recognise instead, so first boot after a layout change # recovers on its own rather than needing a manual erase. CONFIG_NVS_INIT_BAD_MEMORY_REGION=y + +# The rpi_pico UDC driver's internal thread defaults to 512 bytes, which +# overflows once USB is servicing traffic alongside the WiFi/BT gSPI bus -- +# the board drops off USB mid-run ("USB device stack error" on reset). This +# was previously only raised in debug.conf, so release builds still crashed. +CONFIG_UDC_RPI_PICO_STACK_SIZE=2048