Skip to content

About

Native USB Bluetooth HCI adapter firmware for Raspberry Pi Pico W on Linux.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

PicoBlatand

Native USB Bluetooth HCI adapter firmware for Raspberry Pi Pico W on Linux.

PicoBlatand transforms a Raspberry Pi Pico W into a generic plug-and-play USB Bluetooth controller recognized directly by the Linux kernel btusb driver. Unlike solutions that rely on virtual serial (CDC) ports and user-space daemons like btattach or hciattach, PicoBlatand implements standard USB Wireless Controller class descriptors (Class 0xE0, Subclass 0x01, Protocol 0x01).

When connected, the Linux kernel loads btusb.ko, initializes the hci0 interface, and hands over full control to BlueZ for pairing, L2CAP, SDP, GATT, and HID profiles (game controllers, mice, keyboards).


Project Structure

  • main.c: Dual-core bridge logic connecting the CYW43439 controller and TinyUSB.
  • bth_device.c / bth_device.h: TinyUSB Bluetooth HCI device class driver (control, interrupt, and bulk endpoints).
  • usb_descriptors.c / usb_descriptors.h: Standard USB Class 0xE0:01:01 descriptors compatible with btusb.
  • tusb_config.h: TinyUSB configuration for RP2040 buffers and endpoints.
  • btstack_config.h: Minimum configuration required by the SDK to initialize the CYW43439 controller firmware.
  • CMakeLists.txt: Build configuration for CMake and the Pico SDK.

Architecture and Implementation

  • Core 1 (Radio Controller): Dedicated entirely to communicating with the Infineon/Cypress CYW43439 chip through the low-level cyw43_driver. Runs non-blocking polling, retrieves incoming HCI events and ACL data packets from the radio, and enqueues them into critical-section-guarded FIFO rings. It also writes outbound HCI commands and ACL packets to the radio.
  • Core 0 (USB Controller): Runs the TinyUSB device stack and the Bluetooth HCI class driver. Dispatches packets across USB endpoints:
    • Endpoint 0 (Control): Receives standard HCI commands sent by the host kernel (HCI_COMMAND_PKT).
    • Endpoint 0x81 (Interrupt IN, 64 bytes): Transmits HCI event packets to the host (HCI_EVENT_PKT).
    • Endpoint 0x02 (Bulk OUT, 64 bytes): Receives outbound ACL data from the host (HCI_ACL_PKT).
    • Endpoint 0x82 (Bulk IN, 64 bytes): Transmits inbound ACL data from the radio to the host (HCI_ACL_PKT).
  • Buffer Alignment: All buffers passed to CYW43 low-level functions are 4-byte aligned (__attribute__((aligned(4)))) to avoid DMA bus access faults (CYBT_ERR_BADARG).
  • Endpoint Sizing: The Interrupt IN endpoint is configured to the 64-byte Full-Speed maximum to prevent DPRAM overflow and host timeouts when delivering large events such as HCI_Read_Local_Supported_Commands.

Technical Specifications and Limitations

Bluetooth Specification

The CYW43439 controller runs proprietary Cypress/Infineon ROM/patch firmware and reports compliance with Bluetooth Core Specification 5.2, supporting both BR/EDR (Classic Bluetooth) and BLE (Bluetooth Low Energy, including LE 2M PHY).

Bandwidth and Throughput

  • Over-the-Air Physical Rate: Up to 2-3 Mbps raw in BR/EDR (2-DH5, 3-DH5 modulation) and 1-2 Mbps in BLE (LE 1M / LE 2M PHY).
  • Internal SPI Bus: Operates at approximately 33 MHz half-duplex between the RP2040 and CYW43439.
  • USB Interface: Full-Speed USB 2.0 (12 Mbps signaling rate, providing ~8-9 Mbps effective payload throughput).
  • Intended Workloads: HID peripherals (DualShock 4, DualSense, Xbox Wireless Controller, Nintendo Switch Pro Controller, Wiimotes, mice, keyboards), BLE sensors, and serial/SPP communication. These operate well within available bandwidth, ensuring low latency.

Audio and Isochronous Limitations

  • No SCO / eSCO Support (Voice Audio): USB descriptors provide a single Bluetooth HCI interface without isochronous audio endpoints to ensure stable enumeration with btusb. Voice profiles (HSP/HFP) and microphone inputs are not supported.
  • A2DP Stereo Streaming: A2DP audio packets are transmitted over standard ACL links (L2CAP). While BlueZ and audio servers (PipeWire / PulseAudio) can negotiate an A2DP connection, continuous streaming may experience buffer underruns due to SPI bridge overhead and buffer sizing. This adapter is not intended for low-latency or high-fidelity audio playback.

Flashing Instructions

  1. Download PicoBlatand-v1.0.0.uf2 from the Releases page.
  2. Hold down the white BOOTSEL button on the Raspberry Pi Pico W.
  3. Plug the USB cable into your Linux PC while holding BOOTSEL, then release the button.
  4. A removable drive named RPI-RP2 will appear.
  5. Copy the UF2 binary to the drive:
    cp PicoBlatand-v1.0.0.uf2 /run/media/$USER/RPI-RP2/
  6. The board will reboot automatically and initialize as a native USB Bluetooth adapter.

Verification on Linux

1. Kernel Detection

Check dmesg to verify btusb detects the controller:

sudo dmesg | tail -n 25

Expected output:

usb 1-1: new full-speed USB device number ... using xhci_hcd
usb 1-1: New USB device found, idVendor=2e8a, idProduct=000b, bcdDevice= 1.00
usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1: Product: PicoBlatand Bluetooth Adapter
usb 1-1: Manufacturer: Raspberry Pi
Bluetooth: Core ver 2.22
Bluetooth: Generic Bluetooth USB device found
Bluetooth: hci0: read local version complete
Bluetooth: hci0: Primary controller ...

2. Adapter Status

Inspect the controller using bluetoothctl, btmgmt, or hciconfig:

bluetoothctl list

Or:

sudo btmgmt info

Or:

hciconfig -a

3. Pairing Devices with bluetoothctl

Pair game controllers or peripherals:

bluetoothctl
[bluetooth]# power on
[bluetooth]# default-agent
[bluetooth]# scan on
# Put your controller or peripheral in pairing mode
[bluetooth]# pair XX:XX:XX:XX:XX:XX
[bluetooth]# connect XX:XX:XX:XX:XX:XX
[bluetooth]# trust XX:XX:XX:XX:XX:XX

Linux will automatically load the required kernel driver (e.g. hid-generic, hid-sony, hid-nintendo).


Building from Source

Prerequisites

Debian / Ubuntu:

sudo apt-get update
sudo apt-get install -y cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential git

Arch Linux / Manjaro:

sudo pacman -S cmake arm-none-eabi-gcc arm-none-eabi-newlib base-devel git

Build Steps

  1. Clone the Pico SDK if not already available:

    git clone --recurse-submodules https://github.com/raspberrypi/pico-sdk.git
    export PICO_SDK_PATH="$(pwd)/pico-sdk"
  2. Generate build files and compile:

    mkdir build
    cd build
    cmake -DPICO_BOARD=pico_w ..
    make -j$(nproc)
  3. The generated PicoBlatand.uf2 binary will be located in the build/ directory.


License

This project is licensed under the GNU General Public License v3.0 (GPL-3.0). See LICENSE for details.

About

Native USB Bluetooth HCI adapter firmware for Raspberry Pi Pico W on Linux.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages