morrownr / USB-WiFi

USB WiFi Adapter Information for Linux
2.62k stars 172 forks source link

[Help]: bluetoothctl scan on: No default controller available #507

Open HamzaHajeir opened 3 days ago

HamzaHajeir commented 3 days ago

Checklist

uname

Linux HamzaHajeir 5.15.153.1-microsoft-standard-WSL2+ #3 SMP Sun Sep 15 23:57:54 +03 2024 x86_64 x86_64 x86_64 GNU/Linux

lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0e8d:0608 MediaTek Inc. Wireless_Device Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub

rfkill

1: hci0: Bluetooth
         Soft blocked: no
         Hard blocked: no

dkms

[NO OUTPUT]

iw

nl80211 not found.

What happened?

I have WSL and want to manage bluetooth from within it.

I've followed [this instruction][1] to build the custom WSL, including all the required checks into .config file.

Here's the latest .config file content that built the latest WSL firmware: https://pastebin.com/5CBrBf7c

And have used usbipd to share and attach the bluetooth device through:

Where both run successfully, and:

However, running bluetoothctl scan on result in No default controller available.

My finding concludes that btmtk module is missing within the system. And I don't know how to find/have/run it.

From my research I've registered many useful commands, here's the outputs of them:

Sep 16 00:05:39 HamzaHajeir bluetoothd[485]: src/plugin.c:plugin_init() System does not support csip plugin Sep 16 00:05:39 HamzaHajeir bluetoothd[485]: profiles/audio/micp.c:micp_init() D-Bus experimental not enabled Sep 16 00:05:39 HamzaHajeir bluetoothd[485]: src/plugin.c:plugin_init() System does not support micp plugin Sep 16 00:05:39 HamzaHajeir bluetoothd[485]: src/plugin.c:plugin_init() System does not support vcp plugin Sep 16 00:05:39 HamzaHajeir bluetoothd[485]: src/plugin.c:plugin_init() System does not support mcp plugin Sep 16 00:05:39 HamzaHajeir bluetoothd[485]: src/plugin.c:plugin_init() System does not support bass plugin Sep 16 00:05:39 HamzaHajeir bluetoothd[485]: src/plugin.c:plugin_init() System does not support bap plugin Sep 16 00:05:39 HamzaHajeir bluetoothd[485]: profiles/network/bnep.c:bnep_init() kernel lacks bnep-protocol support Sep 16 00:05:39 HamzaHajeir bluetoothd[485]: src/plugin.c:plugin_init() System does not support network plugin Sep 16 00:05:39 HamzaHajeir bluetoothd[485]: Bluetooth management interface 1.21 initialized


- `sudo dmesg | grep firmware`:

[ 0.051585] Spectre V2 : Enabling Restricted Speculation for firmware calls [ 25.755056] bluetooth hci0: Direct firmware load for mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin failed with error -2 [ 25.755059] Bluetooth: hci0: Failed to load firmware file (-2) [ 25.755504] Bluetooth: hci0: Failed to set up firmware (-2) [26548.979065] bluetooth hci0: Direct firmware load for mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin failed with error -2 [26548.979113] Bluetooth: hci0: Failed to load firmware file (-2) [26548.980582] Bluetooth: hci0: Failed to set up firmware (-2)


Note I've followed [this procedure (#3)][2] to include `BT_RAM_CODE_MT7961_1_2_hdr.bin` and other files, adding all files.

Therefore: 
- `ls -a /lib/firmware/mediatek | grep MT7961`:

BT_RAM_CODE_MT7961_1_2_hdr.bin BT_RAM_CODE_MT7961_1_2_hdr.bin.zst BT_RAM_CODE_MT7961_1a_2_hdr.bin BT_RAM_CODE_MT7961_1a_2_hdr.bin.zst WIFI_MT7961_patch_mcu_1_2_hdr.bin WIFI_MT7961_patch_mcu_1_2_hdr.bin.zst WIFI_RAM_CODE_MT7961_1.bin WIFI_RAM_CODE_MT7961_1.bin.zst


- `lsusb -v -s 001:003` (Note 003 is the corresponding device ID):

Bus 001 Device 003: ID 0e8d:0608 MediaTek Inc. Wireless_Device Device Descriptor: bLength 18 bDescriptorType 1 bcdUSB 2.10 bDeviceClass 239 Miscellaneous Device bDeviceSubClass 2 [unknown] bDeviceProtocol 1 Interface Association bMaxPacketSize0 64 idVendor 0x0e8d MediaTek Inc. idProduct 0x0608 Wireless_Device bcdDevice 1.00 iManufacturer 5 MediaTek Inc. iProduct 6 Wireless_Device iSerial 7 000000000 bNumConfigurations 1 Configuration Descriptor: bLength 9 bDescriptorType 2 wTotalLength 0x00fe bNumInterfaces 3 bConfigurationValue 1 iConfiguration 8 Config_01 bmAttributes 0xc0 Self Powered MaxPower 100mA Interface Association: bLength 8 bDescriptorType 11 bFirstInterface 0 bInterfaceCount 3 bFunctionClass 224 Wireless bFunctionSubClass 1 Radio Frequency bFunctionProtocol 1 Bluetooth iFunction 4 BT_FUNCTION Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 0 bAlternateSetting 0 bNumEndpoints 3 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 1 BT_ACL_If Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x81 EP 1 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0010 1x 16 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 0x0200 1x 512 bytes bInterval 0 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x02 EP 2 OUT bmAttributes 2 Transfer Type Bulk Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 0 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 2 BT_SCO_If Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 4 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0000 1x 0 bytes bInterval 4 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 1 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 2 BT_SCO_If Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 4 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0009 1x 9 bytes bInterval 4 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 2 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 2 BT_SCO_If Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 4 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0011 1x 17 bytes bInterval 4 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 3 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 2 BT_SCO_If Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 4 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0019 1x 25 bytes bInterval 4 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 4 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 2 BT_SCO_If Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 4 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0021 1x 33 bytes bInterval 4 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 5 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 2 BT_SCO_If Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 4 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x0031 1x 49 bytes bInterval 4 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 1 bAlternateSetting 6 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 2 BT_SCO_If Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x83 EP 3 IN bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x003f 1x 63 bytes bInterval 4 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x03 EP 3 OUT bmAttributes 1 Transfer Type Isochronous Synch Type None Usage Type Data wMaxPacketSize 0x003f 1x 63 bytes bInterval 4 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 2 bAlternateSetting 0 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 3 BT_ISO_If Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x8a EP 10 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 0x0a EP 10 OUT bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0040 1x 64 bytes bInterval 1 Interface Descriptor: bLength 9 bDescriptorType 4 bInterfaceNumber 2 bAlternateSetting 1 bNumEndpoints 2 bInterfaceClass 224 Wireless bInterfaceSubClass 1 Radio Frequency bInterfaceProtocol 1 Bluetooth iInterface 3 BT_ISO_If Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x8a EP 10 IN bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 1 Endpoint Descriptor: bLength 7 bDescriptorType 5 bEndpointAddress 0x0a EP 10 OUT bmAttributes 3 Transfer Type Interrupt Synch Type None Usage Type Data wMaxPacketSize 0x0200 1x 512 bytes bInterval 1 Binary Object Store Descriptor: bLength 5 bDescriptorType 15 wTotalLength 0x000c bNumDeviceCaps 1 USB 2.0 Extension Device Capability: bLength 7 bDescriptorType 16 bDevCapabilityType 2 bmAttributes 0x00000000 (Missing must-be-set LPM bit!) Device Status: 0x0003 Self Powered Remote Wakeup Enabled


- `hciconfig -a`:

hci0: Type: Primary Bus: USB BD Address: 00:00:00:00:00:00 ACL MTU: 0:0 SCO MTU: 0:0 DOWN RX bytes:0 acl:0 sco:0 events:0 errors:0 TX bytes:0 acl:0 sco:0 commands:0 errors:0 Features: 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Packet type: DM1 DH1 HV1 Link policy: Link mode: PERIPHERAL ACCEPT


- `rfkill` Shows unblocked hard and software:

ID TYPE DEVICE SOFT HARD 1 bluetooth hci0 unblocked unblocked


- `lsmod | grep -i bt` - This one which shows me that the module MTK module is missing:

btusb 53248 0 btrtl 24576 1 btusb btbcm 24576 1 btusb btintel 36864 1 btusb bluetooth 573440 11 btrtl,btintel,btbcm,btusb


And finally: 
- `journalctl --dmesg --boot=-0 --grep blue`

Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: Core ver 2.22 Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: Starting self testing Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: ECDH test passed in 2653 usecs Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: SMP test passed in 1100 usecs Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: Finished self testing Sep 16 00:05:39 HamzaHajeir kernel: NET: Registered PF_BLUETOOTH protocol family Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: HCI device and connection manager initialized Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: HCI socket layer initialized Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: L2CAP socket layer initialized Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: SCO socket layer initialized Sep 16 00:05:39 HamzaHajeir kernel: bluetooth hci0: Direct firmware load for mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin failed with error -2 Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: hci0: Failed to load firmware file (-2) Sep 16 00:05:39 HamzaHajeir kernel: Bluetooth: hci0: Failed to set up firmware (-2) Sep 16 19:56:59 HamzaHajeir kernel: bluetooth hci0: Direct firmware load for mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin failed with error -2 Sep 16 19:56:59 HamzaHajeir kernel: Bluetooth: hci0: Failed to load firmware file (-2) Sep 16 19:56:59 HamzaHajeir kernel: Bluetooth: hci0: Failed to set up firmware (-2)



What could be the issue? And how to solve it?

Note that I've tried running the bluetooth within Ubuntu from VMBox and it does work from within. Ofcourse when the bluetooth adapter not attached to WSL.

  [1]: https://github.com/dorssel/usbipd-win/wiki/WSL-support
  [2]: https://github.com/morrownr/USB-WiFi/blob/main/home/How_to_Install_Firmware_for_Mediatek_based_USB_WiFi_adapters.md
morrownr commented 3 days ago

Hi @HamzaHajeir

You are doing some things that I have no experience with. A quick look and the only thing that stands out is the following:

BT_RAM_CODE_MT7961_1_2_hdr.bin
BT_RAM_CODE_MT7961_1_2_hdr.bin.zst
BT_RAM_CODE_MT7961_1a_2_hdr.bin
BT_RAM_CODE_MT7961_1a_2_hdr.bin.zst
WIFI_MT7961_patch_mcu_1_2_hdr.bin
WIFI_MT7961_patch_mcu_1_2_hdr.bin.zst
WIFI_RAM_CODE_MT7961_1.bin
WIFI_RAM_CODE_MT7961_1.bin.zst

That tells me you have probably updated the firmware but having two versions of each firmware file may or may not be bad but I have not tested it. You might want to delete the .zst files.

I'll ponder this issue.

HamzaHajeir commented 3 days ago

@morrownr Thanks for your quick response.

AFAIK the zst files are just compressed files, not executable ones, therefore I don't see an issue (But maybe I'm wrong?).

What I'm wondering is the question what triggers btmtk module? Is it these firmware files or another source? In the Ubuntu that runs over VMBox (And as I've seen in other issues while searching), btmtk presents when running lsmod | grep -i bt.

morrownr commented 3 days ago

AFAIK the zst files are just compressed files...

Yes, compressed binary files. The kernel reads compressed and non-compressed binary files. You have both. Tell me which one the kernel is using?

HamzaHajeir commented 2 days ago

Yes, compressed binary files. The kernel reads compressed and non-compressed binary files. You have both. Tell me which one the kernel is using?

I've just renamed the .bin files and here's:

It seems the fail line is reduced by one :).

UPDATE:

Even when flipping the active one (renaming back the .bin files and renaming .zst files), produces the same error line.

morrownr commented 2 days ago

Even when flipping the active one (renaming back the .bin files and renaming .zst files), produces the same error line.

The firmware issue I mentioned is likely not the source of your problem. I'll do some more research on that and update my firmware guide but let's drop that issue for now.

I have WSL and want to manage bluetooth from within it.

I do not know what WSL is. Can you enlighten me?

FYI: This site does have heavy traffic but it is not a social media site so it can take some time for replies on specific topics... especially on a topic like this. Why? My history started with learning to program with FORTRAN, My history of small computer operating systems is: CP/M. PC-DOS, DR-DOS, OS/2 and Linux. I have almost no experience with Windows. There are a lot of very smart people, including Linux kernel devs, that stop by at times and some may have Windows experience but this may not be the optimal place for you to get help... but I don't know that for sure.

HamzaHajeir commented 1 day ago

I do not know what WSL is. Can you enlighten me?

It's Windows Subsystem for Linux. I'm also new into using this.

I'm new to it. But the experience is too much better than VM.

I might consider immigrating into Linux sometime in future, not ready for that atm. Setup another OS? my memory is almost full :.

FYI: This site does have heavy traffic but it is not a social media site so it can take some time for replies on specific topics... especially on a topic like this. Why? My history started with learning to program with FORTRAN, My history of small computer operating systems is: CP/M. PC-DOS, DR-DOS, OS/2 and Linux. I have almost no experience with Windows. There are a lot of very smart people, including Linux kernel devs, that stop by at times and some may have Windows experience but this may not be the optimal place for you to get help... but I don't know that for sure.

I see your point, I appreciate your trying to help out.

Bue me also don't know where the most suitable place to ask. WSL2 repository have issues section disabled.

Update, I've just found a place to raise the issue (https://github.com/microsoft/WSL/issues/12048). Hope they come with real help.

morrownr commented 7 hours ago

But I also don't know where the most suitable place to ask.

I understand. Maybe this is a good place if you are not in a hurry.

Where would I go if I want to learn more about WSL?

I might consider immigrating into Linux sometime in future...

I've been using Linux since 1994 so I have some experience... kidding. Something to consider: One of the best ways to learn Linux is to grab an old desktop or laptop that is still functional but not used anymore... those can usually be found found in many places for nothing... maybe in your closet. My main dev box here is 11 years old and it is faster than I need. My point being is that we can get you going with Linux on a system that would not support Windows 11, 10 or ever 8... probably 7. That could save you the trouble of messing with WSL.

HamzaHajeir commented 6 hours ago

I understand. Maybe this is a good place if you are not in a hurry.

Where would I go if I want to learn more about WSL?

Thank you for your patience and help. I'm not in a hurry.

Per anything new to me, I personally prefer to watch an introductory video, here's a top on search on Youtube: https://www.youtube.com/watch?v=qYlgUDKKK5A&t=9s . Ofcourse there's more.

And here's an official document for WSL: https://learn.microsoft.com/en-us/windows/wsl/about. It also provides some videos.

I've been using Linux since 1994 so I have some experience... kidding. Something to consider: One of the best ways to learn Linux is to grab an old desktop or laptop that is still functional but not used anymore... those can usually be found found in many places for nothing... maybe in your closet. My main dev box here is 11 years old and it is faster than I need. My point being is that we can get you going with Linux on a system that would not support Windows 11, 10 or ever 8... probably 7. That could save you the trouble of messing with WSL.

I see, I have another PC but I have one monitor now, that PC keeps an old state of files there :). I'll check if a too old laptop is working xD.

But per the project I work on, yet speed of compilation matters, but more importantly the apparently new Bluetooth standard (BLE) is supported.