Page MenuHomeFreeBSD

Initial cut at Intel AX210 bluetooth support
ClosedPublic

Authored by shurd on Apr 19 2024, 3:46 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Aug 30, 3:26 PM
Unknown Object (File)
Sat, Aug 30, 2:56 PM
Unknown Object (File)
Fri, Aug 29, 10:16 PM
Unknown Object (File)
Mon, Aug 18, 9:21 AM
Unknown Object (File)
Mon, Aug 18, 1:12 AM
Unknown Object (File)
Thu, Aug 14, 4:47 PM
Unknown Object (File)
Sat, Aug 9, 6:42 AM
Unknown Object (File)
Mon, Aug 4, 3:23 PM

Details

Summary

This allows loading the firmware and attaching the driver. I haven't yet managed to pair with aything.

Test Plan

Will test with BT stuff I have laying around.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 57253
Build 54141: arc lint + arc unit

Event Timeline

shurd requested review of this revision.Apr 19 2024, 3:46 AM
shurd retitled this revision from Initial work... doesn't. to Initial cut at Intel AX210 bluetooth support.Apr 19 2024, 3:48 AM
shurd edited the summary of this revision. (Show Details)
shurd edited the test plan for this revision. (Show Details)

Tested with Google Pixel Buds A... with virtual_oss, pairs and right channel works.

  • Retry reset command up to twice.
  • Add macros for TLV types

Going on vacation for a couple weeks, and will look at this again when I get back... adding adrian@ as a reviewer, feel free to add more appropriate reviewers as actionable feedback will be welcome when I return.

I wonder if that'll support a lot more than just AX210?

With minor modifications and updated comms/iwmbtfw it works with AX211.

diff --git a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c
index 058b9137dd8e..ecaa06c2d21e 100644
--- a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c
+++ b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c
@@ -99,8 +99,9 @@ static const STRUCT_USB_HOST_ID ubt_intel_devs[] =
 	{ USB_VPI(USB_VENDOR_INTEL2, 0x0025, UBT_INTEL_DEVICE_8260) },
 	{ USB_VPI(USB_VENDOR_INTEL2, 0x0026, UBT_INTEL_DEVICE_8260) },
 	{ USB_VPI(USB_VENDOR_INTEL2, 0x0029, UBT_INTEL_DEVICE_8260) },
-	/* Intel AX210 */
+	/* Intel AX210, AX211 */
 	{ USB_VPI(USB_VENDOR_INTEL2, 0x0032, UBT_INTEL_DEVICE_TLV) },
+	{ USB_VPI(USB_VENDOR_INTEL2, 0x0033, UBT_INTEL_DEVICE_TLV) },
 };
 
 /*
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8 b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
index 700108ac8379..d47f9e91ae0f 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.8
@@ -28,7 +28,7 @@
 .Os
 .Sh NAME
 .Nm iwmbtfw
-.Nd firmware download utility for Intel Wireless 7260/8260/8265/AX210 chip based Bluetooth
+.Nd firmware download utility for Intel Wireless 7260/8260/8265/AX210/AX211 chip based Bluetooth
 USB devices
 .Sh SYNOPSIS
 .Nm
@@ -45,7 +45,7 @@ device.
 .Pp
 This utility will
 .Em only
-work with Intel Wireless 7260/8260/8265/AX210 chip based Bluetooth USB devices and some of
+work with Intel Wireless 7260/8260/8265/AX210/AX211 chip based Bluetooth USB devices and some of
 their successors.
 The identification is currently based on USB vendor ID/product ID pair.
 The vendor ID should be 0x8087
diff --git a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.conf b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.conf
index 77ed79e8458e..070aa0b4c20d 100644
--- a/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.conf
+++ b/usr.sbin/bluetooth/iwmbtfw/iwmbtfw.conf
@@ -6,6 +6,6 @@ notify 100 {
 	match "subsystem"	"DEVICE";
 	match "type"		"ATTACH";
 	match "vendor"		"0x8087";
-	match "product"		"(0x07dc|0x0a2a|0x0aa7|0x0a2b|0x0aaa|0x0025|0x0026|0x0029|0x0032)";
+	match "product"		"(0x07dc|0x0a2a|0x0aa7|0x0a2b|0x0aaa|0x0025|0x0026|0x0029|0x0032|0x0033)";
 	action "/usr/sbin/iwmbtfw -d $cdev -f /usr/local/share/iwmbt-firmware";
 };
diff --git a/usr.sbin/bluetooth/iwmbtfw/main.c b/usr.sbin/bluetooth/iwmbtfw/main.c
index 662967f090c1..caf6924228e9 100644
--- a/usr.sbin/bluetooth/iwmbtfw/main.c
+++ b/usr.sbin/bluetooth/iwmbtfw/main.c
@@ -77,6 +77,7 @@ static struct iwmbt_devid iwmbt_list_82xx[] = {
 static struct iwmbt_devid iwmbt_list_tlv[] = {
 
 	{ .vendor_id = 0x8087, .product_id = 0x0032 },
+	{ .vendor_id = 0x8087, .product_id = 0x0033 },
 
 };
 
@@ -718,6 +719,8 @@ main(int argc, char *argv[])
 		switch (ver.hw_variant) {
 			case 0x17:
 				break;
+			case 0x18:
+				break;
 			default:
 				iwmbt_err("unknown hw_variant 0x%02x", (int) ver.hw_variant);
 				goto shutdown;

I tested this change in 14.1-STABLE and a pair of Fairbuds XL. After ensuring the firmware was loaded, I ran the following commands:

  1. service bluetooth start ubt0
  2. hccontrol -n ubt0hci inquiry
  3. hccontrol -n ubt0hci create_connection headphones
  4. <added entries to /etc/bluetooth/hcsecd.conf and /etc/bluetooth/hosts>`
  5. virtual_oss -T /dev/sndstat -S -a o,-4 -C 2 -c 2 -r 44100 -b 16 -s 1024 -R /dev/null -P /dev/bluetooth/headphones -d dspbt -t vdsp.ctl

I tried this both with and without running hccontrol -n ubt0hci write_authentication_enable 1, and settings the -P device name to /dev/bluetooth/headphones and /dev/bluetooth/<BT_ADDR>

With the Fairbuds, I received backend_bt: PSM=0x19 and backend_bt: Could not connect to HC: 60 after running the virtual_oss command.

I'll add markj to reviews as he was the one to add the last additions if I remember correctly and actually knows the code.
Also wulf has been active in that area in the past if I don't misremember.

Might help you to actually get a good review.

Here is a patch for AX210/AX211 bluetooth adapters we use @work for quite some time: https://people.freebsd.org/~wulf/iwmbtfw.diff

Here is a patch for AX210/AX211 bluetooth adapters we use @work for quite some time: https://people.freebsd.org/~wulf/iwmbtfw.diff

Can this be placed as a separate review?

Can this be placed as a separate review?

Yes it can. Along with realtek BT firmware loader. But I don't know who is willing to review that. Volunteers are welcome.

Can this be placed as a separate review?

Yes it can. Along with realtek BT firmware loader. But I don't know who is willing to review that. Volunteers are welcome.

If you open dedicated reviews for these leave the numbers here; I might even have a look. Out of curiosity -- which realtek?

tl88

In D44861#1052291, @bz wrote:

Can this be placed as a separate review?

Yes it can. Along with realtek BT firmware loader. But I don't know who is willing to review that. Volunteers are welcome.

If you open dedicated reviews for these leave the numbers here; I might even have a look. Out of curiosity -- which realtek?

RTL88 or something around that called v1 in Linux sources. I did not started RTL89(v2) porting.

In D44861#1052291, @bz wrote:

If you open dedicated reviews for these leave the numbers here; I might even have a look.

Done: D46734 D46735 D46736 D46737 D46738 D46739 D46740

This revision is now accepted and ready to land.Mar 25 2025, 8:50 PM
ziaee requested changes to this revision.Mar 25 2025, 9:40 PM

This is very cool! I have an AX211 and would like Bluetooth. This patch rolls back consistency changes we made in the manual's document description.

In current it currently reads "iwmbtfw - download firmware for Intel Wireless AC Bluetooth USB devices". Maybe we could do "iwmbtfw - download firmware for Intel Wireless AC/AX devices"? It's already at the limit of a std console.

This revision now requires changes to proceed.Mar 25 2025, 9:40 PM
bz requested changes to this revision.Mar 25 2025, 10:09 PM

Okay, I'll stop; have a look at c1643cedbf243 and related please and rebase this if case anything is still anything lacking. Also please do a style(9) pass.
I know this is older than what is in main.

@wulf may be of good assistance .

@adrian please don't click Accept Revision if you haven't even had a short look at the code and what's in the tree.

libexec/rc/rc.d/bluetooth
130

Is this general or specific to Intel 22000 BT? If general it doesn't belong here.

sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c
144

The assignment here and two lines down just makes this so unreadable;

151

Magic number. Can that be defined somewhere? Funny enough the counter parts are here:
usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c: .opcode = htole16(0xfc05),
usr.sbin/bluetooth/iwmbtfw/iwmbt_hw.c: .opcode = htole16(0xfc05),

And there is iwmbt_get_version_tlv(); I thought I had looked at code before.

159

return () her eand everywhere in this change

171

More magic numbers. Is this IWMBT_TLV_IMAGE_TYPE ?

usr.sbin/bluetooth/iwmbtfw/iwmbt_fw.c
182

iwmbt_get_fwname_tlv() is in main.

I believe apart from possible startup issues this is no longer needed for the AX21 compared to what is in main and stable/14?

The raw diff does not apply anymore on 15.0-CURRENT 45165aab2d229a1377fb2c054d5c7c338acc268a

What does a nvme commit have to do with this? The only thing which is left from this change is the changes to the startup script.

19a577ea5cae1238065106de9080cb6f3e66034d
c1643cedbf243424370162febf6d9180bdd1df58
0b23c50ae834d11842810304e4ddad2754298ada
aa0b938434a8af8eebf8f2634914f2d9fe8a5dc4

added this and other functionality to FreeBSD already if I am not mistaken.

sys/netgraph/bluetooth/drivers/ubt/ng_ubt_intel.c
103

With CURRENT as of 45165aab2d229a1377fb2c054d5c7c338acc268a this conflicts with the definition of UBT_INTEL_DEVICE_9260

So for an AX201-based card (8087:0026) I currently get this:

rene@tuxedo:~/oss/freebsd/src/bluetooth $ sudo iwmbtfw -DI -d ugen1.4
main: opening dev 1.4
iwmbt_is_supported: found iwmbtfw compatible
iwmbt_get_version: Can't get version: : code=0, size=6
handle_8260: iwmbt_get_version() failed code -1
iwmbtfw: main: Firmware download failed!
rene@tuxedo:~/oss/freebsd/src/bluetooth $ sudo usbconfig -lv | grep AX
ugen1.4: bcdUSB=0x0201 bDeviceClass=0x00e0 bDeviceSubClass=0x0001 bDeviceProtocol=0x0001 idVendor=0x8087 idProduct=0x0026 bcdDevice=0x0002 iManufacturer=000000 iProduct=000000 iSerialNumber=000000 bNumConfigurations=0x0001 vendor='Intel Corp.' product='AX201 Bluetooth'

and from existing code:

	{ USB_VPI(USB_VENDOR_INTEL2, 0x0026, UBT_INTEL_DEVICE_8260) },
In D44861#1161448, @bz wrote:

The raw diff does not apply anymore on 15.0-CURRENT 45165aab2d229a1377fb2c054d5c7c338acc268a

What does a nvme commit have to do with this? The only thing which is left from this change is the changes to the startup script.

19a577ea5cae1238065106de9080cb6f3e66034d
c1643cedbf243424370162febf6d9180bdd1df58
0b23c50ae834d11842810304e4ddad2754298ada
aa0b938434a8af8eebf8f2634914f2d9fe8a5dc4

added this and other functionality to FreeBSD already if I am not mistaken.

Oh the commit I posted just happens to be the commit I am on.

So for an AX201-based card (8087:0026) I currently get this:

rene@tuxedo:~/oss/freebsd/src/bluetooth $ sudo iwmbtfw -DI -d ugen1.4
main: opening dev 1.4
iwmbt_is_supported: found iwmbtfw compatible
iwmbt_get_version: Can't get version: : code=0, size=6
handle_8260: iwmbt_get_version() failed code -1
iwmbtfw: main: Firmware download failed!
rene@tuxedo:~/oss/freebsd/src/bluetooth $ sudo usbconfig -lv | grep AX
ugen1.4: bcdUSB=0x0201 bDeviceClass=0x00e0 bDeviceSubClass=0x0001 bDeviceProtocol=0x0001 idVendor=0x8087 idProduct=0x0026 bcdDevice=0x0002 iManufacturer=000000 iProduct=000000 iSerialNumber=000000 bNumConfigurations=0x0001 vendor='Intel Corp.' product='AX201 Bluetooth'

and from existing code:

	{ USB_VPI(USB_VENDOR_INTEL2, 0x0026, UBT_INTEL_DEVICE_8260) },

That sounds likely. Then this change here has nothing to do with your device.
The 9xxx one in main covers all up to ax210 (and possibly onward; never checked my Be200) which is just called TLV here.

As I keep saying, the only thing from this review which is not functionally in main as much as I can say is the rc.d script changes.

If your BT does not work, I'd suggest checking forums and bugzilla and if there's no info to that, open a PR?

This revision was not accepted when it landed; it landed in state Needs Revision.Fri, Aug 29, 8:47 PM
Closed by commit rG40652f86b5ef: rc: bluetooth: startup improvements (authored by shurd, committed by bz). · Explain Why
This revision was automatically updated to reflect the committed changes.