# USB Bluetooth dongle



## balanga (Mar 3, 2016)

Does FreeBSD have support for any USB  Bluetooth dongles?


----------



## lme@ (Mar 3, 2016)

Yes, via ng_ubt().


----------



## kpa (Mar 3, 2016)

Yes but caveat emptor, the bluetooth support in FreeBSD isn't that good really and hangs very often or causes disconnects without any good reason.


----------



## balanga (Mar 4, 2016)

kpa said:


> Yes but caveat emptor, the bluetooth support in FreeBSD isn't that good really and hangs very often or causes disconnects without any good reason.



If it's already there, I'm sure it will improve over time. I ask because I'd like to buy a bluetooth keyboard. I'd like to get one of these:-

http://shop.lenovo.com/us/en/itemdetails/0B47189/460/60AC6A0372B14F5BA7B12F1FF88E33C7

so I'd like to know how I could get it working with my FreeBSD box. Are there any particular Bluetooth dongles which work best with FreeBSD?


----------



## lme@ (Mar 4, 2016)

kpa is right regarding FreeBSD's sub-optimal Bluetooth support. But at least I can use an Apple Wireless Keyboard, so the Lenovo one should also work.
I used my notebook's internal bluetooth device so I cannot recommend any USB dongle.


----------



## balanga (Mar 18, 2016)

lme@ said:


> kpa is right regarding FreeBSD's sub-optimal Bluetooth support. But at least I can use an Apple Wireless Keyboard, so the Lenovo one should also work.
> I used my notebook's internal bluetooth device so I cannot recommend any USB dongle.



I have my Lenovo Bluetooth keyboard now along with a bluetooth dongle. Just wondered how I would go about trying to connect it up.

Do I need to install any drivers for it? And how do I tell if the system recognises it?


----------



## lme@ (Mar 21, 2016)

Try it with the script provided at:
https://reviews.freebsd.org/D3778


----------



## Vladimir Botka (Jun 13, 2016)

Hello, I have trouble to find working BT USB dongle in FreeBSD 10.3 [1-3]. From the comments I see, that it's working for some of you. Would it be possible to post the output of "usbconfig" for a working dongle?

[1]

```
Jun 13 10:49:25 planc devd: Executing '/etc/rc.d/bluetooth quietstop ubt0'
Jun 13 10:49:40 planc kernel: ugen0.6: <Sweex> at usbus0
Jun 13 10:49:40 planc kernel: ubt0: <Sweex BT204 Bluetooth Micro Adapter Class, class 224/1, rev 2.00/52.76, addr 17> on usbus0
Jun 13 10:49:40 planc devd: Executing '/etc/rc.d/bluetooth quietstart ubt0'
Jun 13 10:49:47 planc admin: /etc/rc.d/bluetooth: ERROR: Unsupported device:
```
[2]
	
	



```
Jun 13 11:03:06 planc devd: Executing '/etc/rc.d/bluetooth quietstart ubt0'
Jun 13 11:03:06 planc devd: Executing 'logger Unknown USB device: vendor 0x0a5c product 0x2148 bus uhub2'
Jun 13 11:03:06 planc root: Unknown USB device: vendor 0x0a5c product 0x2148 bus uhub2
```
[3]
	
	



```
Jun 13 11:01:53 planc devd: Executing '/etc/rc.d/bluetooth quietstart ubt0'
Jun 13 11:01:53 planc devd: Executing 'logger Unknown USB device: vendor 0x050d product 0x016a bus uhub2'
Jun 13 11:01:53 planc root: Unknown USB device: vendor 0x050d product 0x016a bus uhub2
```


----------



## trumee (Jun 25, 2016)

Hello

I am looking for suggestions for supported usb bluetooth dongle which works well in FreeBSD. 

Thanks


----------



## wblock@ (Jun 25, 2016)

Stuff based on the Broadcom BCM20702 chipset has been recommended to me.  I don't have one yet, though, and my experiments with Bluetooth have been amazingly frustrating.


----------



## trumee (Jun 30, 2016)

I bought this device. Unfortunately I got the following error

```
Jun 29 19:31:55 box kernel: ugen1.5: <Broadcom Corp> at usbus1
Jun 29 19:31:55 box devd: Executing 'kldload -n ng_ubt'
Jun 29 19:31:55 box devd: Executing 'kldload -n ng_ubt'
Jun 29 19:31:55 box kernel: ubt0: <Broadcom Corp BCM20702A0, rev 2.00/1.12, addr 5> on usbus1
Jun 29 19:31:55 box devd: Executing 'logger Unknown USB device: vendor 0x0a5c product 0x21ec bus uhub3'
Jun 29 19:31:55 box root: Unknown USB device: vendor 0x0a5c product 0x21ec bus uhub3
Jun 29 19:31:55 box devd: Executing 'logger Unknown USB device: vendor 0x0a5c product 0x21ec bus uhub3'
Jun 29 19:31:55 box root: Unknown USB device: vendor 0x0a5c product 0x21ec bus uhub3
Jun 29 19:31:55 box devd: Executing '/etc/rc.d/bluetooth quietstart ubt0'
Jun 29 19:31:55 box kernel: WARNING: attempt to domain_add(bluetooth) after domainfinalize()
Jun 29 19:31:55 box kernel: WARNING: attempt to domain_add(netgraph) after domainfinalize()
```

Is there anyway to make this a known device?


----------



## wblock@ (Jun 30, 2016)

Which version of FreeBSD are you using?


----------



## Phishfry (Jun 30, 2016)

I don't see the device PID in the usbdevs file.
https://github.com/freebsd/freebsd/blob/master/sys/dev/usb/usbdevs


----------



## Phishfry (Jun 30, 2016)

Have you seen this?
https://forums.freebsd.org/threads/39425/


----------



## Phishfry (Jun 30, 2016)

I do notice above post PID=21e8 while yours is PID=21ec.
Still neither is in usbdevs so I am not sure if that step is even needed. You have ubt0: it appears.


----------



## Phishfry (Jun 30, 2016)

Looking further at the forum i see this:
https://forums.freebsd.org/threads/39679/page-3#post-224952

It explains why wblock@  was asking the version you are using.


----------



## kpa (Jun 30, 2016)

Bluetooth support in FreeBSD is unfortunately very dated and may not work for you at all. As far as I know currently there are no active FreeBSD developers working on it. I hope we don't end up axing it completely like OpenBSD did a while ago, it's a real possibility if no one wants to maintain it:

http://openbsd-archive.7691.n7.nabble.com/Bluetooth-Support-td274983.html


----------



## trumee (Jun 30, 2016)

wblock@ said:


> Which version of FreeBSD are you using?



I am running 10.3.


----------



## ronaldlees (Jul 7, 2016)

From what I've scratched together, it seems that the current bluetooth stack in FreeBSD will do Bluetooth 2.0 or less, but not Bluetooth 2.1-EDR nor 3.0 nor 4.0.  I could be wrong, but that's what the situation seems to be.  Unfortunately, it's getting hard to find the older Bluetooth dongles, or the peripherals they are used with.  A Bluetooth 3.0 keyboard will not (necessarily) work with Bluetooth 2.0, AFAIK.  

I remember a few years ago using a pair of Bluetooth 2.0 dongles for a custom FreeBSD application I was working on, and IIRC it worked OK, but that doesn't necessarily translate to any other kind of peripheral working as well.  I don't remember much of the details.  Then - there is the issue of chipset, which is another angle of complication.

It'd be nice if a developer would take an interest in this, because Bluetooth is regaining some popularity among computer users (driven by things like bluetooth speakers, and other mobile device market things).

I just found one of the old dongles in a junk drawer and plugged it in.   For what it's worth:

_<vendor 0x0a12 Bluetooth2.1+EDR, rev 2.00>_​
That apparently contradicts my first sentence, unless I was using it in "2.0 mode"


----------



## sidetone (Oct 15, 2016)

How well does FreeBSD support Bluetooth version 2.1? From the Handbook, there were drivers which supported 1.1, UART USB devices, and other specific hardware. It is not clear, but section '30.5.1. Loading Bluetooth Support' in the FreeBSD Handbook seems to be about Bluetooth (USB) dongles. https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/network-bluetooth.html

Does the driver ng_hci(4) (mentioned in the next section '30.5.2. Finding Other Bluetooth Devices') work well with Bluetooth version 2.1? This generic driver is meant without Bluetooth (USB) dongles, if my motherboard has Bluetooth capability?

Duplicate Thread USB bluetooth dongle?.56731


----------



## trumee (Sep 4, 2017)

I modified /usr/src/sys/dev/usb/usbdev and added

```
product BROADCOM BCM20702A0     0x21ec  BCM20702A0 Bluetooth USB dongle
```

In addition, appended the entry in /usr/src/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c to

```
/* Broadcom BCM20702A0 */
        { USB_VPI(USB_VENDOR_ASUS, 0x17b5, 0) },
        { USB_VPI(USB_VENDOR_ASUS, 0x17cb, 0) },
        { USB_VPI(USB_VENDOR_LITEON, 0x2003, 0) },
        { USB_VPI(USB_VENDOR_FOXCONN, 0xe042, 0) },
        { USB_VPI(USB_VENDOR_DELL, 0x8197, 0) },
        { USB_VPI(USB_VENDOR_BROADCOM, 0x21ec, 0) },
```
After compiling the the ng_ubt module and loading it, i still get an unknown device


```
Sep  4 12:39:16 nas kernel: ugen0.7: <Broadcom Corp BCM20702A0> at usbus0
Sep  4 12:39:16 nas kernel: ubt0 numa-domain 0 on uhub2
Sep  4 12:39:16 nas kernel: ubt0: <Broadcom Corp BCM20702A0, rev 2.00/1.12, addr 8> on usbus0
Sep  4 12:39:17 nas root: Unknown USB device: vendor 0x0a5c product 0x21ec bus uhub2
Sep  4 12:39:17 nas root: Unknown USB device: vendor 0x0a5c product 0x21ec bus uhub2
Sep  4 12:39:57 nas : /etc/rc.d/bluetooth: ERROR: Unable to setup Bluetooth stack for device ubt0
Sep  4 12:40:07 nas kernel: ng_hci_process_command_timeout: ubt0hci - unable to complete HCI command OGF=0x3, OCF=0x3. Timeout
Sep  4 12:40:09 nas : /etc/rc.d/bluetooth: ERROR: Unable to setup Bluetooth stack for device ubt0
```

Loaded modules is shown below. Is there any module i need to compile after changing usbdev?


```
# kldstat
Id Refs Address            Size     Name
 1   84 0xffffffff80200000 1f67a88  kernel
 2    1 0xffffffff82169000 316708   zfs.ko
 3    2 0xffffffff82480000 cb78     opensolaris.ko
 4    1 0xffffffff8248d000 21f08    geom_eli.ko
 5    1 0xffffffff824af000 44bd8    ipfw.ko
 6    1 0xffffffff824f4000 1afec8   sfxge.ko
 7    1 0xffffffff826a4000 4d18     coretemp.ko
 8    1 0xffffffff826a9000 bd50     aesni.ko
 9    1 0xffffffff826b5000 4d78     uslcom.ko
10    3 0xffffffff826ba000 a9b8     ucom.ko
11    1 0xffffffff826c5000 35b060   vmm.ko
12    1 0xffffffff82c21000 5936     fdescfs.ko
13    1 0xffffffff82c27000 bdb0     if_lagg.ko
14    1 0xffffffff82c33000 38c0     umodem.ko
15    1 0xffffffff82c37000 2986     uhid.ko
16    1 0xffffffff82c3a000 3650     ums.ko
17    1 0xffffffff82c3e000 3123     nmdm.ko
18    1 0xffffffff82c42000 9a4c     if_bridge.ko
19    1 0xffffffff82c4c000 5e61     bridgestp.ko
20    1 0xffffffff82c52000 59c6     if_tap.ko
21    1 0xffffffff82c58000 864c     ipmi.ko
22    1 0xffffffff82c61000 f7f      smbus.ko
23    1 0xffffffff82c62000 a877     linprocfs.ko
24    1 0xffffffff82c6d000 7b0f     linux_common.ko
25    1 0xffffffff82c75000 6679     nullfs.ko
27    5 0xffffffff82c81000 c57d     netgraph.ko
28    2 0xffffffff82c8e000 a6bd     ng_hci.ko
29    3 0xffffffff82c99000 107f     ng_bluetooth.ko
30    1 0xffffffff82c9b000 d5be     ng_l2cap.ko
31    1 0xffffffff82ca9000 1c393    ng_btsocket.ko
32    1 0xffffffff82cc6000 39cc     ng_socket.ko
33    1 0xffffffff82c7c000 360b     ng_ubt.ko
```

Any idea what could be the issue?


----------



## trumee (Sep 4, 2017)

Under linux the device says


```
[    2.966713] usb 5-2: Product: BCM20702A0
[    2.966766] usb 5-2: Manufacturer: Broadcom Corp
[    2.976651] Bluetooth: hci0: BCM: chip id 63
[    2.978593] Bluetooth: hci0: BCM20702A1 (001.002.014) build 0000
[    2.981720] bluetooth hci0: Direct firmware load for brcm/BCM20702A1-0a5c-21ec.hcd failed with error -2
[    2.981788] Bluetooth: hci0: BCM: Patch brcm/BCM20702A1-0a5c-21ec.hcd not found
```

The firmware is at https://github.com/winterheart/broadcom-bt-firmware/blob/master/brcm/BCM20702A1-0a5c-21ec.hcd

After the firmware is loaded, i get the following in linux

```
$ dmesg |grep -i bluetooth
[    1.670030] Bluetooth: Core ver 2.20
[    1.670128] Bluetooth: HCI device and connection manager initialized
[    1.670179] Bluetooth: HCI socket layer initialized
[    1.670227] Bluetooth: L2CAP socket layer initialized
[    1.670278] Bluetooth: SCO socket layer initialized
[    2.708083] Bluetooth: HCI UART driver ver 2.3
[    2.708130] Bluetooth: HCI UART protocol H4 registered
[    2.708192] Bluetooth: HCI UART protocol BCSP registered
[    2.708239] Bluetooth: HCI UART protocol LL registered
[    2.708287] Bluetooth: HCI UART protocol ATH3K registered
[    2.708335] Bluetooth: HCI UART protocol Three-wire (H5) registered
[    2.708384] Bluetooth: HCI UART protocol BCM registered
[    2.709173] Bluetooth: RFCOMM TTY layer initialized
[    2.709223] Bluetooth: RFCOMM socket layer initialized
[    2.709275] Bluetooth: RFCOMM ver 1.11
[    2.709323] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    2.709372] Bluetooth: HIDP socket layer initialized
[    2.710833] Bluetooth: Starting self testing
[    2.735652] Bluetooth: ECDH test passed in 24151 usecs
[    2.736592] Bluetooth: SMP test passed in 51 usecs
[    2.736663] Bluetooth: Finished self testing
[    2.975625] Bluetooth: hci0: BCM: chip id 63
[    2.977618] Bluetooth: hci0: BCM20702A1 (001.002.014) build 0000
[    3.773599] Bluetooth: hci0: BCM20702A1 (001.002.014) build 1460
[    7.762846] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    7.762852] Bluetooth: BNEP filters: protocol multicast
[    7.762861] Bluetooth: BNEP socket layer initialized
```


----------

