Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth HCI USB sample is not working #26807

Closed
brooksprumo opened this issue Jul 10, 2020 · 10 comments
Closed

Bluetooth HCI USB sample is not working #26807

brooksprumo opened this issue Jul 10, 2020 · 10 comments
Assignees
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug

Comments

@brooksprumo
Copy link
Contributor

Describe the bug
I'm trying to get the Bluetooth HCI USB sample working. I have Zephyr/NCS version v2.3.0-rc1-ncs1. I am running Ubuntu Linux in a VM on Windows 10. I am using an NRF 52840 DK board.

After building the sample and flashing the board, my Windows machine sees there's a new Bluetooth device, but something is wrong and Windows does not load the driver for it.

Annotation 2020-07-10 140301

Since Windows does not load the driver, my Linux VM does not see the Bluetooth device either. I wonder if there's something I didn't configure properly thought?

I am able to use the Bluetooth HCI UART sample and have the nrf52840 successfully show up as a Bluetooth device in my Linux VM. This won't work long-term for me because I'm only using the nrf52840 DK for prototyping, and my final product does not have a UART connection back to the Host, just a USB connection.

To Reproduce

  1. Get Zephyr/NCS version v2.3.0-rc1-ncs1
  2. Navigate to zephyr/samples/bluetooth/hci_usb
  3. Build with west build -b nrf52840dk_nrf52840
  4. Flash the board with west flash

Expected behavior
I expect that my Windows machine enumerates a new Bluetooth device, and then my Linux VM also enumerates a new Bluetooth device. After that, I would expect to use hciconfig to see the Bluetooth device and use bluetoothctl to interact with it.

Impact
This may be a showstopper for us, as that's why we're using an nrf52840 and Zephyr, just for Bluetooth HCI over USB.

Logs and console output
I'm not sure what else is useful to add. Should additional information be needed, please let me know and I'll happily add it!

Environment (please complete the following information):

Additional context
I was able to use Apache Mynewt to do Bluetooth HCI USB with the same machine and board using this example:

https://github.com/hathach/mynewt-tinyusb-example

@brooksprumo brooksprumo added the bug The issue is a bug, or the PR is fixing a bug label Jul 10, 2020
@carlescufi
Copy link
Member

carlescufi commented Jul 10, 2020

This should not be a problem, and in fact I have used a very similar setup in the past with no issues.

Since Windows does not load the driver, my Linux VM does not see the Bluetooth device either. I wonder if there's something I didn't configure properly thought?

At least with VMWare, you don't need Windows to recognize your device in order for the VM to be able to use it, since it redirects the whole USB device.
I don't think Windows supports single-mode, BLE-only controllers like Zephyr implements, so I am not surprised that Windows doesn't find drivers for it.

That said, the fact that the Mynewt example you linked works with the same setup makes me think that something in our USB configuration can be improved.

Could you please dump the contents of lsusb from the VM, specifically the full set of interfaces and descriptors for the Mynewt USB device? then perhaps @emob-nordic can take a look at ours and see if there's any differences.

EDIT:

I just tested this with Windows 10 and VMWare Workstation with a Ubuntu guest and it worked fine:

$ dmesg
[..]
[431184.487479] usb 3-3.1: new full-speed USB device number 30 using xhci_hcd
[431184.735127] usb 3-3.1: New USB device found, idVendor=2fe3, idProduct=000b, bcdDevice= 2.03
[431184.735129] usb 3-3.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[431184.735130] usb 3-3.1: Product: USB-DEV
[431184.735130] usb 3-3.1: Manufacturer: ZEPHYR
[431184.735131] usb 3-3.1: SerialNumber: D27CE311463AF0C7
[431184.774336] usbcore: registered new interface driver btusb

$ lsusb
[..]
Bus 003 Device 030: ID 2fe3:000b VMware VMware Virtual USB Mouse
[..]

$ sudo lsusb -vd 2fe3:000b
Bus 003 Device 030: ID 2fe3:000b VMware VMware Virtual USB Mouse
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x2fe3 
  idProduct          0x000b 
  bcdDevice            2.03
  iManufacturer           1 ZEPHYR
  iProduct                2 USB-DEV
  iSerial                 3 D27CE311463AF0C7
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength       0x0027
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               1
Device Status:     0x0000
  (Bus Powered)

I didn't even try to connect the device to Windows, since upon plugging it in VMWare asks whether you want to connect the device to the VM or Windows.

@brooksprumo
Copy link
Contributor Author

brooksprumo commented Jul 10, 2020

I agree, sounds strange! Below are dumps from lsusb --verbose from Zephyr and Mynewt. They are long...

Also, I just saw the EDIT too. I'll go back and check if there's anything strange about my Zephyr VM. I'll try switching the USB to USB 3 and see if that changes anything. I'll reply back to let you know.

UPDATE: Setting my VM to USB 3.1 didn't change anything that I can tell, unfortunately.

Output from Zephyr

$ lsusb

Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 003: ID 1366:1015 SEGGER 
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

And the result for $ sudo lsusb -vd 2fe3:000b is empty.

Here's the output from dmesg after power-cycling the board:

$ dmesg
[...]
[45314.756879] usb 3-1: USB disconnect, device number 3
[45327.518144] usb 3-1: new high-speed USB device number 4 using xhci_hcd
[45327.772077] usb 3-1: config 1 interface 1 altsetting 0 bulk endpoint 0x83 has invalid maxpacket 64
[45327.772082] usb 3-1: config 1 interface 1 altsetting 0 bulk endpoint 0x4 has invalid maxpacket 64
[45327.773288] usb 3-1: New USB device found, idVendor=1366, idProduct=1015, bcdDevice= 1.00
[45327.773289] usb 3-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[45327.773290] usb 3-1: Product: J-Link
[45327.773290] usb 3-1: Manufacturer: SEGGER
[45327.773291] usb 3-1: SerialNumber: 000683002044
[45327.776243] cdc_acm 3-1:1.0: ttyACM0: USB ACM device
[45327.778823] usb-storage 3-1:1.3: USB Mass Storage device detected
[45327.779177] scsi host33: usb-storage 3-1:1.3
[45328.809130] scsi 33:0:0:0: Direct-Access     SEGGER   MSD Volume       1.00 PQ: 0 ANSI: 4
[45328.810113] sd 33:0:0:0: Attached scsi generic sg2 type 0
[45328.813473] sd 33:0:0:0: [sdb] 21829 512-byte logical blocks: (11.2 MB/10.7 MiB)
[45328.816235] sd 33:0:0:0: [sdb] Write Protect is off
[45328.816239] sd 33:0:0:0: [sdb] Mode Sense: 0b 00 00 08
[45328.820079] sd 33:0:0:0: [sdb] No Caching mode page found
[45328.820086] sd 33:0:0:0: [sdb] Assuming drive cache: write through
[45328.834153]  sdb:
[45328.843347] sd 33:0:0:0: [sdb] Attached SCSI removable disk

Output from Mynewt

$ lsusb
Bus 001 Device 009: ID 1366:1015 SEGGER 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 022: ID 5678:1234  
Bus 002 Device 003: ID 0e0f:0002 VMware, Inc. Virtual USB Hub
Bus 002 Device 002: ID 0e0f:0003 VMware, Inc. Virtual Mouse
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$ sudo lsusb -vd 5678:1234

Bus 002 Device 022: ID 5678:1234  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          224 Wireless
  bDeviceSubClass         1 Radio Frequency
  bDeviceProtocol         1 Bluetooth
  bMaxPacketSize0        64
  idVendor           0x5678 
  idProduct          0x1234 
  bcdDevice            1.00
  iManufacturer           2 (error)
  iProduct                3 (error)
  iSerial                 1 1
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           85
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus Powered)
      Remote Wakeup
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x84  EP 4 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0000  1x 0 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x06  EP 6 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0000  1x 0 bytes
        bInterval               1
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       1
      bNumEndpoints           2
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0009  1x 9 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x06  EP 6 OUT
        bmAttributes            1
          Transfer Type            Isochronous
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0009  1x 9 bytes
        bInterval               1
Device Status:     0x0000
  (Bus Powered)

@carlescufi
Copy link
Member

@brooksprumo can you edit your message and use the -d vid:pid option in lsusb like I posted in mine to restrict the dump to the device in question?

@carlescufi
Copy link
Member

carlescufi commented Jul 10, 2020

Hmm I think that Mynewt sets the following fields in the Device Descriptor:

  bDeviceClass          224 Wireless
  bDeviceSubClass         1 Radio Frequency
  bDeviceProtocol         1 Bluetooth

whereas Zephyr leaves them at 0s:

  bDeviceClass            0 
  bDeviceSubClass         0 
  bDeviceProtocol         0 

And they seem to have 2 interfaces instead of one like Zephyr, wonder why.

@brooksprumo
Copy link
Contributor Author

@brooksprumo can you edit your message and use the -d vid:pid option in lsusb like I posted in mine to restrict the dump to the device in question?

Done! Let me know if there's more info that would be helpful.

@carlescufi
Copy link
Member

@brooksprumo can you edit your message and use the -d vid:pid option in lsusb like I posted in mine to restrict the dump to the device in question?

Done! Let me know if there's more info that would be helpful.

Does the mynewt controller actually work with Windows? if you try say searching for devices

@carlescufi carlescufi added the area: USB Universal Serial Bus label Jul 10, 2020
@brooksprumo
Copy link
Contributor Author

Does the mynewt controller actually work with Windows? if you try say searching for devices

I do not know how to check 🤕

But, it does look like Windows has the same issue with the Mynewt firmware as it does with Zephyr. So, I opened a different VM, still with my board running the Zephyr firmware, and the Bluetooth device was present!

lsusb -vd 2fe3:000b

Bus 003 Device 023: ID 2fe3:000b  
Couldn't open device, some information will be missing
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x2fe3 
  idProduct          0x000b 
  bcdDevice            2.03
  iManufacturer           1 
  iProduct                2 
  iSerial                 3 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           39
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xc0
      Self Powered
    MaxPower              100mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           3
      bInterfaceClass       224 Wireless
      bInterfaceSubClass      1 Radio Frequency
      bInterfaceProtocol      1 Bluetooth
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               1
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0020  1x 32 bytes
        bInterval               1

I was also able to successfully scan via bluetoothctl. So I think this means it's something about my VM. Sorry for the run-around on this. Thank you for helping me!

@carlescufi
Copy link
Member

Ok, glad to hear it! I will close this then, feel free to reopen if applicable.

@jfischer-no
Copy link
Collaborator

Hmm I think that Mynewt sets the following fields in the Device Descriptor:

  bDeviceClass          224 Wireless
  bDeviceSubClass         1 Radio Frequency
  bDeviceProtocol         1 Bluetooth

whereas Zephyr leaves them at 0s:

  bDeviceClass            0 

"If this field is reset to zero, each interface
within a configuration specifies its own
class information and the various
interfaces operate independently." (USB2.0 spec)

bDeviceSubClass 0

"If the bDeviceClass field is reset to zero,
this field must also be reset to zero." (USB2.0 spec)

bDeviceProtocol 0

"If this field is reset to zero, the device
does not use class-specific protocols on a
device basis. However, it may use class-
specific protocols on an interface basis." (USB2.0 spec)


And they seem to have 2 interfaces instead of one like Zephyr, wonder why.

Zephyr:
bInterfaceClass 224 Wireless
bInterfaceSubClass 1 Radio Frequency
bInterfaceProtocol 1 Bluetooth

@mirko
Copy link

mirko commented Oct 11, 2020

I'm having the same issue when passing through the ZEPHYR dongle (nrf52840 USB dongle) into my qemu/KVM VM.
lsusb shows device with empty identifier whereas on the hypervisor and my notebook i can use it just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus bug The issue is a bug, or the PR is fixing a bug
Projects
None yet
Development

No branches or pull requests

5 participants