# Two major issues left: 2. bluetooth

## curmudgeon

Despite claims that bluetooth now "just works" in linux, I have a different experience.

The device:

```

$ lspci -v

[...]

02:00.0 Network controller: Ralink corp. RT3290 Wireless 802.11n 1T/1R PCIe

    Subsystem: Hewlett-Packard Company Ralink RT3290LE 802.11bgn 1x1 Wi-Fi and Bluetooth 4.0 Combo Adapter

    Flags: bus master, fast devsel, latency 0, IRQ 34

    Memory at f0a10000 (32-bit, non-prefetchable) [size=64K]

    Capabilities: [40] Power Management version 3

    Capabilities: [50] MSI: Enable- Count=1/32 Maskable- 64bit+

    Capabilities: [70] Express Endpoint, MSI 00

    Capabilities: [100] Advanced Error Reporting

    Capabilities: [140] Device Serial Number 00-00-1d-5f-77-e6-77-3c

    Kernel driver in use: rt2800pci

02:00.1 Bluetooth: Ralink corp. RT3290 Bluetooth

    Subsystem: Hewlett-Packard Company Ralink RT3290LE 802.11bgn 1x1 Wi-Fi and Bluetooth 4.0 Combo Adapter

    Flags: bus master, fast devsel, latency 0, IRQ 3

    Memory at f0a00000 (32-bit, non-prefetchable) [size=64K]

    Capabilities: [40] Power Management version 3

    Capabilities: [50] MSI: Enable- Count=1/32 Maskable- 64bit+

    Capabilities: [70] Express Endpoint, MSI 00

    Capabilities: [100] Advanced Error Reporting

    Capabilities: [140] Device Serial Number 00-00-1e-5f-77-e6-77-3c

[...]

```

Have the firmware in the proper place:

```

$ ls -al /lib/firmware/rt3290.bin 

-rw-r--r-- 1 root root 4096 2019-05-12 09:28:30 /lib/firmware/rt3290.bin

```

It seems that the kernel sees it. From dmesg:

```

Bluetooth: Core ver 2.22

NET: Registered protocol family 31

Bluetooth: HCI device and connection manager initialized

Bluetooth: HCI socket layer initialized

Bluetooth: L2CAP socket layer initialized

Bluetooth: SCO socket layer initialized

[...]

Bluetooth: RFCOMM socket layer initialized

Bluetooth: RFCOMM ver 1.11

Bluetooth: HIDP (Human Interface Emulation) ver 1.2

Bluetooth: HIDP socket layer initialized

```

Seems to start fine:

```

May 12 10:17:05 system bluetoothd[2412]: Bluetooth daemon 5.50

May 12 10:17:05 system bluetoothd[2412]: Starting SDP server

May 12 10:17:05 system bluetoothd[2412]: kernel lacks bnep-protocol support

May 12 10:17:05 system bluetoothd[2412]: System does not support network plugin

May 12 10:17:05 system bluetoothd[2412]: Bluetooth management interface 1.14 initialized

```

But, the agent can't find the controller

```

# bluetoothctl 

Agent registered

[bluetooth]# list

[bluetooth]# devices

No default controller available

```

Any thoughts? Thank you in advance.Last edited by curmudgeon on Sat Jun 15, 2019 10:50 am; edited 2 times in total

----------

## genterminl

Might you need to load some kernel module, or enable something in the kernel?  What do you get from

  lsmod | egrep "blue|bt"

and

  zcat /proc/config.gz | egrep -i "blue|bt"

----------

## Ant P.

Your kernel drivers are fine. Try running "rfkill unblock bluetooth" (or "echo 1 | tee /sys/class/bluetooth/hci0/rfkill*/state").

----------

## curmudgeon

 *Ant P. wrote:*   

> Your kernel drivers are fine. Try running "rfkill unblock bluetooth" (or "echo 1 | tee /sys/class/bluetooth/hci0/rfkill*/state").

 

The first command did nothing, and I couldn't execute the second (see below). Obviously, I still have some doubt about the drivers.

```

$ ls -al /sys/class/bluetooth/

total 0

drwxr-xr-x  2 root root 0 2019-05-14 23:11:23 ./

drwxr-xr-x 50 root root 0 2019-05-14 23:11:23 ../

```

----------

## Ant P.

Didn't pay enough attention, sorry. Just noticed it's a PCIe with two subdevices. I looked around and found this Ralink hardware has a years-long history of problems in Linux and very few solutions.

There's an out-of-tree driver for the bluetooth part. That looks like your best chance at getting it to work.

----------

## curmudgeon

 *Ant P. wrote:*   

> Didn't pay enough attention, sorry. Just noticed it's a PCIe with two subdevices. I looked around and found this Ralink hardware has a years-long history of problems in Linux and very few solutions.
> 
> There's an out-of-tree driver for the bluetooth part. That looks like your best chance at getting it to work.

 

I was going to give that a crack, despite my doubts (it seems that the ebuild wants CONFIG_RT2800PCI completely disabled (not compiled in and module blacklisted), so that unless this module handles both wireless and bluetooth, the ability to use bluetooth would come at an unacceptable cost.

Anyway, the ebuild failed for reasons far beyond my ken:

```

>>> Compiling source in /var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999 ...

make -j3 

make -C /usr/src/linux M=/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999 modules

make[1]: Entering directory '/usr/src/linux-4.19.37-gentoo'

  CC [M]  /var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_main.o

  CC [M]  /var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_init.o

  CC [M]  /var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_pci.o

  CC [M]  /var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_bluez.o

/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_bluez.c: In function ‘rtbt_hps_iface_init’:

/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_bluez.c:381:22: error: ‘HCI_BREDR’ undeclared (first use in this function); did you mean ‘HCI_RESET’?

     hdev->dev_type = HCI_BREDR;

                      ^~~~~~~~~

                      HCI_RESET

/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_bluez.c:381:22: note: each undeclared identifier is reported only once for each function it appears in

make[2]: *** [scripts/Makefile.build:303: /var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_bluez.o] Error 1

make[2]: *** Waiting for unfinished jobs....

/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_init.c: In function ‘BthInitializePrerequire’:

/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_init.c:1024:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation]

   if ((pAd->MACVersion != 0x00) && (pAd->MACVersion != 0xFFFFFFFF))

   ^~

/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_init.c:1027:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’

    KeStallExecutionProcessor(5);

    ^~~~~~~~~~~~~~~~~~~~~~~~~

/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_init.c: In function ‘Rtbth_Set_Radio_Led’:

/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_init.c:1185:3: warning: typedef ‘flag_t’ locally defined but not used [-Wunused-local-typedefs]

 } flag_t;

   ^~~~~~

/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_pci.c: In function ‘rtbt_pci_probe’:

/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999/rtbth_core_pci.c:198:1: warning: label ‘err_hps_iface’ defined but not used [-Wunused-label]

 err_hps_iface:

 ^~~~~~~~~~~~~

make[1]: *** [Makefile:1524: _module_/var/tmp/portage/net-wireless/rtbth-99999999/work/rtbth-99999999] Error 2

make[1]: Leaving directory '/usr/src/linux-4.19.37-gentoo'

make: *** [Makefile:24: all] Error 2

 * ERROR: net-wireless/rtbth-99999999::temp failed (compile phase):

 *   emake failed

```

I will make a guess though, that bluez has changed so much that this module (as written) will no longer work with it.

If you have any ideas on how to get this to compile, I will give it one last shot - otherwise, it looks like time to abandon the whole idea of bluetooth on this machine.

----------

## Ant P.

I made an attempt at trying to fix the source to compile, but it's too far beyond my C ability. It spewed a lot more errors than shown there (I'm using kernel 5.0 and gcc9).

In my experience any cheap USB BT dongle will work just as well, it's not worth putting much effort into getting this working.

----------

## curmudgeon

 *Ant P. wrote:*   

> I made an attempt at trying to fix the source to compile, but it's too far beyond my C ability. It spewed a lot more errors than shown there (I'm using kernel 5.0 and gcc9).
> 
> In my experience any cheap USB BT dongle will work just as well, it's not worth putting much effort into getting this working.

 

I agree with your assessment. Thanks again for your efforts on this.

----------

## DaggyStyle

I'm intrigued, what is the vid and did of the device? e.g. lspci -n -s "02:00.1"

EDIT:

take a look at this: https://github.com/loimu/rtbth-dkms

----------

## curmudgeon

 *DaggyStyle wrote:*   

> I'm intrigued, what is the vid and did of the device? e.g. lspci -n -s "02:00.1"
> 
> EDIT:
> 
> take a look at this: https://github.com/loimu/rtbth-dkms

 

Oops, didn't see that at the time. Okay, I will take one more look at this (since it appears that someone actually maintains this, with a release just last year). :) I have compiled and installed the module, but I still can't see the device.

```

$ lspci -n -s "02:00.1" -v

02:00.1 0d11: 1814:3298

        Subsystem: 103c:18ec

        Flags: bus master, fast devsel, latency 0, IRQ 34

        Memory at f0a00000 (32-bit, non-prefetchable) [size=64K]

        Capabilities: [40] Power Management version 3

        Capabilities: [50] MSI: Enable- Count=1/32 Maskable- 64bit+

        Capabilities: [70] Express Endpoint, MSI 00

        Capabilities: [100] Advanced Error Reporting

        Capabilities: [140] Device Serial Number 00-00-1e-5f-77-e6-77-3c

        Kernel driver in use: rtbt

        Kernel modules: rtbth

```

The startup messages (from dmesg) remain the same as before.

I see this when I load the module:

```

Jun 15 09:43:34 system kernel: rtbth: loading out-of-tree module taints kernel.

Jun 15 09:43:34 system kernel: Bluetooth: RTBT_Tb: vendor=0x1814, device=0x3298

Jun 15 09:43:34 system kernel: Bluetooth: RTBT_Tb: vendor=0x0, device=0x0

Jun 15 09:43:34 system kernel: Bluetooth: DynamicAlloc pci_device_id table at 0x00000000c5386990 with size 64

Jun 15 09:43:34 system kernel: Bluetooth: RTBT_Tb: vendor=0x1814, device=0x3298

Jun 15 09:43:34 system kernel: Bluetooth: Convert: vendor=0x1814, device=0x3298

Jun 15 09:43:34 system kernel: Bluetooth: RTBT_Tb: vendor=0x0, device=0x0

Jun 15 09:43:34 system kernel: Bluetooth: pci_device_id: vendor=0x1814, device=0x3298

Jun 15 09:43:34 system kernel: Bluetooth: rtbt_pci_probe(): PCI Dev(0000:02:00.1) get resource at 0xf0a00000,VA 0xffffc900009a0000,IRQ 34.

Jun 15 09:43:34 system kernel: Bluetooth: call dev_ops->dev_ctrl_init!

Jun 15 09:43:34 system kernel: Bluetooth: call dev_ops->dev_resource_init!

Jun 15 09:43:34 system kernel: RX_Base_PTR0(0x180)= 0xbb171000

Jun 15 09:43:34 system kernel: RX_Base_PTR1(0x190)= 0x280

```

And this (as before) when I start the daemon:

```

Jun 15 09:59:15 system bluetoothd[3139]: Bluetooth daemon 5.50

Jun 15 09:59:15 system bluetoothd[3139]: Starting SDP server

Jun 15 09:59:15 system bluetoothd[3139]: kernel lacks bnep-protocol support

Jun 15 09:59:15 system bluetoothd[3139]: System does not support network plugin

Jun 15 09:59:15 system bluetoothd[3139]: Bluetooth management interface 1.14 initialized

```

And the agent still can't find the controller.

```

# bluetoothctl 

Agent registered

[bluetooth]# list

[bluetooth]# devices

No default controller available

```

----------

