Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Got bluetooth working on raspberry zero 2 w



Hi,

> Am 02.12.2026 um 21:17 schrieb Maximo Pech <makzpj%gmail.com@localhost>:
> 
> After nearly 2 weeks of hard work finally got this working.
> 
> hw.model = raspberrypi,model-zero-2-w
> 
> [     2.573504] bwfm0: CLM file default:    brcmfmac43430-sdio.clm_blob
> [     2.573504] bwfm0: CLM file model-spec:
> brcmfmac43430-sdio.raspberrypi,model-zero-2-w.clm_blob
> [     3.833579] bwfm0: CHIPACTIVE
> [     3.933584] bwfm0: address 2c:cf:67:9f:c9:14
> [     3.933584] bwfm0: wl0: Oct 23 2017 03:55:53 version 7.45.98.38
> (r674442 CY) FWID 01-e58d219f
> [    12.094240] wsdisplay0: screen 4 added (default, vt100 emulation)
> [    35.655809] btuart0: major 93 minor 524288
> [    61.010189] bthub0 at btuart0 local-bdaddr 2c:cf:67:9f:c9:15
> 
> armv7# btconfig -v btuart0
> btuart0: bdaddr 2c:cf:67:9f:c9:15 flags 0x3<UP,RUNNING>
> num_cmd = 1
> num_acl = 8 (max 8), acl_mtu = 1021
> num_sco = 1 (max 1), sco_mtu = 64
> HCI version: 4.1 rev 0x00b6
> class: [0x000000]
> name: "BCM43438A1 37.4MHz Raspberry Pi 3-0043O"
> voice: [0x0060]
> pin: variable
> inquiry mode: std
> options:
> 
> The way I did this was:
> 
> gpio=YES in rc.conf
> 
> In /etc/gpio.conf I have the below lines, apparently to initialize
> this bt controller it needs a sequence of turning off then turning on
> GPIO 42.
> 
> ! /usr/sbin/gpioctl gpio0 42 set out
> ! /usr/sbin/gpioctl gpio0 42 off
> ! /bin/sleep 0.120
> ! /usr/sbin/gpioctl gpio0 42 on

Preferably, we’d make a driver do this.

However, as long as you manually attach it using btattach, I don’t think it is
reasonable to have the driver do it automatically.

If you end up writing a driver that attaches it automatically: If you check the 
device tree documentation for the bluetooth driver in question, there is a 
reset-gpios property so the driver can do it. 

> 
> Now for the changes to the kernel code
> 
> sys/arch/evbarm/conf/GENERIC line 278
> 
> bcmgpio* at fdt?
> change to
> bcmgpio* at fdt? pass 3
> 
> This is so that bcmgpio attaches before plcom and configures properly
> the pin functions according to the device tree.
> 
> For /sys/arch/evbarm/dev/plcom.c around line 1474
> 
> lvl = PL011_IFLS_1EIGHTH;
> sc->sc_ifls |= PL011_IFLS_TXIFLS(lvl);
> sc->sc_burstlen = 4;
> 
> This is so that the pl011 controller can properly cross the tx fifo
> threshold and generate a tx interrupt.

Do you have a diff(1) file of your changes? That makes reviewing and applying
your changes easier and less error-prone on our end because it can be applied 
by a tool instead of manually searching line 1474 in a file and modifying it. 
If you use git, hg or any other version control system, they should have an 
option to export a diff.

The bcmgpio change looks ok, although I think you can lower it to pass 2? The 
gpio driver depends on interrupts, which are initialized in pass 1. Generally, 
try to keep the pass number as low as possible.

PL011 I can’t comment on, I’d have to read myself into the manual.

> 
> Finally after system boot btattach as this
> 
> btattach -i 115200 -fP bcm43xx /dev/dplcom0 3000000
> 
> and btconfig buart0 up
> 
> That's it. Yes, I know those changes may not be the best way to do it,
> but as a first approach to incorporating support for this bt
> controller I think this information would be useful. Thoughts?

Lastly, in your last message you mentioned your using LLMs for this project.
Please be aware of the NetBSD LLM policy on writing code. For one-line fixes 
like the bcmgpio change, I’d let it pass because there is only one way to do it, 
but bigger changes must be human written. (debugging is not forbidden though)



Home | Main Index | Thread Index | Old Index