Raspberry Pi / Bluetooth

Bluetooth on Raspberry Pi: ng_h4

The Bluetooth half of the Wi-Fi chip talks HCI over a serial line. FreeBSD's Bluetooth stack only knows USB dongles. ng_h4 is the missing piece in between.

A cartoon blue tooth with a Bluetooth rune on it asks: hci?

code done, radio silent FreeBSD 15.1-RELEASE-p7. The repository is not public yet. Everything below has run against a simulated radio, not yet against the real chip.

The plan

tty  <->  ng_tty(4)  <->  ng_h4  <->  ng_hci(4)  <->  ng_l2cap(4)

ng_h4 is a netgraph node of type h4 that frames HCI packets over a UART. Around it sit four small tools: rpibtpower (the radio's power GPIO), rpibtprobe, rpibtfw (sends the .hcd firmware patch: BCM43430B0.hcd, BCM43430A1.hcd or BCM4345C0.hcd) and rpibtattach, plus an rc.d/rpibt script and man pages for all of them.

BoardStatus
Zero 2 W (43430)First target. Against the simulator: load/unload 10 of 10, all 174 firmware records sent, read_bd_addr 10 of 10.
Pi 4 (CYW43455)Built, never run.
Pi 5Blocked: FreeBSD 15.1 has no driver for the Pi 5 UART or the radio's power GPIO.

Planned setup (untested on the real radio)

  1. Free the radio's UART from the serial console first. Then build and install:

    make module tools
    make install
    
  2. Enable it in /etc/rc.conf. On a Zero 2 W that is one line:

    rpibt_enable="YES"
    

    On a Pi 4 add the power line:

    rpibt_gpio_device="/dev/gpioc1"
    rpibt_power_pin="0"
    rpibt_power_flags="-H -I"
    
  3. Start it and ask the radio for its address:

    service rpibt start
    service rpibt status
    hccontrol -n ubt8hci read_bd_addr
    

Where it is stuck

With the radio on the PL011 UART the chip comes out of reset and signals ready, and then the UART sends nothing. FreeBSD's uart_pl011 takes no baud clock from the clocks property and has no RTS/CTS flow control. That report is drafted (see Upstream reports).

On the mini UART it was worse: the Zero 2 W kernel stopped right after armv8crypto0: CPU lacks AES instructions in 3 boots out of 3, and the only way back was editing config.txt from another computer.

Along the way the tests (2749 C assertions plus 1030 in stubs) turned up a NULL pointer dereference in the FreeBSD HCI event code at ng_hci_evnt.c:972. It is on the list for a report.

Built with ssg