AX210蓝牙识别可用rock5b内核

AX210蓝牙识别可用rock5b内核

背景

AX210是intel的一个wifi和蓝牙一起的模块,这个小的模块一般是在笔记本里面的,rock5b上面的接口是支持这个模块的
AX210因为比较新,所以wifi的支持在5.10内核是没有问题的,但蓝牙在这个上面就无法启动了,报下面的错误,这个错误在网上看到很多包括X86下面的内核上面也出现了,基本上就是驱动相关的问题,然后kernel官方主线内核的5.10.155也没有合入相关的支持,没有做低版本内核的backport(其实改动量也不大,就是新增的),rock5b的5.10内核也自然就不支持这个蓝牙了

开始的时候打算整个bluetooth目录替换,发现编译不过去,内核后来的版本可能还改了其它东西,最后还是只把相关的改动弄到5.10上面来,改动还好不是很大,这个地方设计的比较好的就是只是新增了相关的函数,所以也基本上对其它的蓝牙功能没影响的

错误信息

可以看到这个错误,网上关键字很多,就是wifi可用,蓝牙不可用

1
2
[   46.734253] Bluetooth: hci0: Reading Intel version information failed (-22)
[ 46.734305] Bluetooth: hci0: Intel Read version failed (-22)

设备相关信息

3EA36E43838FFF77E315DE65AD2BD8FD

QQ20221125-0

1
2
3
4
5
6
7
8
9
10
11
root@rock-5b:/home/rock/Pictures# lsusb
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 004: ID 8087:0032 Intel Corp.
Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

上面的Bus 001 Device 004: ID 8087:0032 Intel Corp.这个就是AX210的设备,这个8087:0032是固定的设备id

1
2
3
4
5
root@rock-5b:/home/rock/Pictures# lspci
0002:20:00.0 PCI bridge: Fuzhou Rockchip Electronics Co., Ltd Device 3588 (rev 01)
0002:21:00.0 Network controller: Intel Corporation Device 2725 (rev 1a)
0004:40:00.0 PCI bridge: Fuzhou Rockchip Electronics Co., Ltd Device 3588 (rev 01)
0004:41:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)

上面的Network controller: Intel Corporation Device 2725这个也是AX210的设备id

AX210蓝牙使用情况

windows上面的蓝牙用过,感觉功能比较简单,linux下没用过,下面就记录下一些功能,我的系统安装的是官方提供的ubuntu

https://github.com/radxa/debos-radxa/releases/download/20221031-1045/rock-5b-ubuntu-focal-server-arm64-20221031-1328-gpt.img.xz

系统安装完成后就安装下桌面

1
apt install ubuntu-desktop

然后重启,进入图形界面

内核替换

替换上已经打好蓝牙补丁的内核

内核下载地址:
linux-kernel-rock5b-ax210-bluetooth.tar.gz

安装内核

1
root@rock-5b:~/kernel/packages# dpkg -i linux-image-5.10.66-blue-10-rockchip-g311cf1c0d_5.10.66-blue-10-rockchip_arm64.deb

增加sfi文件和ddc文件

1
2
wget https://anduin.linuxfromscratch.org/sources/linux-firmware/intel/ibt-0041-0041.sfi  -O /lib/firmware/intel/ibt-0041-0041.sfi
wget https://anduin.linuxfromscratch.org/sources/linux-firmware/intel/ibt-0041-0041.ddc -O /lib/firmware/intel/ibt-0041-0041.ddc

注意上面是大O(是哦不是零不是小哦),不确定就检查一下文件内容

1
2
root@rock-5b:~# ll /lib/firmware/intel/ibt-0041-0041.sfi
-rw-r--r-- 1 root root 690128 Nov 19 04:46 /lib/firmware/intel/ibt-0041-0041.sfi

检查启动项

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
root@rock-5b:~/kernel/packages# cat /boot/extlinux/extlinux.conf
#timeout 10
#menu title select kernel

label kernel-5.10.66-blue-10-rockchip-g311cf1c0d
kernel /vmlinuz-5.10.66-blue-10-rockchip-g311cf1c0d
initrd /initrd.img-5.10.66-blue-10-rockchip-g311cf1c0d
devicetreedir /dtbs/5.10.66-blue-10-rockchip-g311cf1c0d
fdtoverlays /dtbs/5.10.66-blue-10-rockchip-g311cf1c0d/rockchip/overlay/rk3588-uart7-m2.dtbo
append root=UUID=67ad0e7b-3914-48d6-97c2-c48e5e0e405b earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty1 consoleblank=0 loglevel=0 panic=10 rootwait rw init=/sbin/init rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 irqchip.gicv3_pseudo_nmi=0 switolb=1 coherent_pool=2M

label kernel-5.10.66-27-rockchip-gea60d388902d
kernel /vmlinuz-5.10.66-27-rockchip-gea60d388902d
initrd /initrd.img-5.10.66-27-rockchip-gea60d388902d
devicetreedir /dtbs/5.10.66-27-rockchip-gea60d388902d
fdtoverlays /dtbs/5.10.66-27-rockchip-gea60d388902d/rockchip/overlay/rk3588-uart7-m2.dtbo
append root=UUID=67ad0e7b-3914-48d6-97c2-c48e5e0e405b earlycon=uart8250,mmio32,0xfeb50000 console=ttyFIQ0 console=tty1 consoleblank=0 loglevel=0 panic=10 rootwait rw init=/sbin/init rootfstype=ext4 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 irqchip.gicv3_pseudo_nmi=0 switolb=1 coherent_pool=2M

注意上面修改的blue的标签的应该排在上面的,重启板卡

正常启动日志

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[   11.990430] usb 1-1.3: new full-speed USB device number 4 using ehci-platform
[ 12.135296] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[ 12.209438] usb 1-1.3: New USB device found, idVendor=8087, idProduct=0032, bcdDevice= 0.00
[ 12.209450] usb 1-1.3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 12.213051] Bluetooth: hci0: Device revision is 0
[ 12.213057] Bluetooth: hci0: Secure boot is enabled
[ 12.213059] Bluetooth: hci0: OTP lock is enabled
[ 12.213061] Bluetooth: hci0: API lock is enabled
[ 12.213063] Bluetooth: hci0: Debug lock is disabled
[ 12.213065] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
[ 12.213068] Bluetooth: hci0: Bootloader timestamp 2019.40 buildtype 1 build 38
[ 12.213804] Bluetooth: hci0: Found device firmware: intel/ibt-0041-0041.sfi
[ 12.787396] ttyFIQ ttyFIQ0: tty_port_close_start: tty->count = 1 port count = 2
[ 12.881301] fuse: init (API version 7.32)
[ 13.094139] FAT-fs (mmcblk0p1): utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!
[ 13.830192] Bluetooth: hci0: Waiting for firmware download to complete
[ 13.831152] Bluetooth: hci0: Firmware loaded in 1582218 usecs
[ 13.831226] Bluetooth: hci0: Waiting for device to boot
[ 13.857113] Bluetooth: hci0: Device booted in 25334 usecs
[ 13.858975] Bluetooth: hci0: Found Intel DDC parameters: intel/ibt-0041-0041.ddc
[ 13.861222] Bluetooth: hci0: Applying Intel DDC parameters completed
[ 13.865219] Bluetooth: hci0: Firmware timestamp 2022.39 buildtype 1 build 52159
[ 17.172415] r8125: enP4p65s0: link up
[ 17.172554] IPv6: ADDRCONF(NETDEV_CHANGE): enP4p65s0: link becomes ready
[ 20.887172] dwhdmi-rockchip fdea0000.hdmi: use tmds mode
[ 21.100098] dwhdmi-rockchip fdea0000.hdmi: use tmds mode
[ 37.005172] vcc3v3_pcie30: disabling

可以看到正常的加载了,上面的信息就是蓝牙加载这部分的内容

蓝牙使用体验

AX210如果没有装天线,蓝牙需要在10cm左右的距离才能识别的比较好,远了有问题,这个后面装了天线再验证信号情况

desktop-bluetoothicon.png
可以看到右上角的蓝牙图标可以点了,不是完全灰掉的,没打驱动无法使用


通过蓝牙助手进行蓝牙的配对,这个地方配对需要两边都确认,可以在系统设置里面配对


识别到的设备


可以看到配对成功,显示的是已经连接


设备列表里面还有其它的蓝牙设备


进行配对的操作


设置蓝牙设备可以被扫描


在系统设置里面进行连接,双击设备名称可以传文件给设备


可以看到信号

文件正在传输,没有问题


hci查询蓝牙信息

手机连rock5b以后,在手机那边播放音乐,在rock5b上面可以识别到,并且能够听到声音,作为一个音频设备处理的


wifi识别也是没有问题的

鼠标识别没有问题

1
2
3
4
root@rock-5b:~# dmesg
[ 514.872857] input: RAPOO BT4.0 Mouse as /devices/virtual/misc/uhid/0005:000E:3412.0005/input/input16
[ 514.873282] input: RAPOO BT4.0 Mouse Consumer Control as /devices/virtual/misc/uhid/0005:000E:3412.0005/input/input17
[ 514.874248] hid-generic 0005:000E:3412.0005: input,hidraw4: BLUETOOTH HID v67.01 Mouse [RAPOO BT4.0 Mouse] on c4:03:a8:86:dd:ae

mouseinput

耳机测试没有问题
erji

蓝牙已测功能

  • 1、蓝牙连接(正常)
  • 2、rock5b给手机发送文件(正常)
  • 3、手机通过蓝牙发送音频给rock5b,rock5b播放声音(正常)
  • 4、鼠标连接蓝牙到rock5b(正常)
  • 5、蓝牙连接蓝牙耳机(正常)

上面可以看到,rock5b到设备的可以发送,设备到rock5b也是能发送的,两边都是通路的
测试过程中发现,一定要加天线,否则功能可能因为信号不足,不正常

天线

上面就是买的天线ipe4接口,上面有个塑料壳子(1块钱)可以固定接口更稳定一点

相关资源

patch文件

AX210-bluetooth.patch

patch文件是以rock5b官方的内核做的patch文件,就是下面这个分支的

1
git clone -b stable-5.10-rock5 https://github.com/radxa/kernel.git

在内核代码的上一层目录里面下载上面的patch文件,然后打上patch

1
2
3
4
5
6
root@ubuntu:~/rk3588-sdk/# wget 【上面的链接】
root@ubuntu:~/rk3588-sdk/# cd kernel
root@ubuntu:~/rk3588-sdk/kernel# patch -p1 < ../AX210-bluetooth.patch
patching file drivers/bluetooth/btintel.c
patching file drivers/bluetooth/btintel.h
patching file drivers/bluetooth/btusb.c

然后编译打包即可

或者直接下载我的分支

1
root@ubuntu:~/rk3588-sdk/# git clone -b stable-5.10-rock5   --single-branch --depth 1   https://github.com/zphj1987/kernel.git

这个分支已经打好了蓝牙的补丁的

如果考虑跟官方的版本的话,就用上面的打patch的文件的方式

或者用我打好的内核deb文件如下

linux-kernel-rock5b-ax210-bluetooth.tar.gz

排错指南

错误:Reading Intel version information failed

1
2
3
4
5
6
7
8
9
[   45.961353] Bluetooth: hci0: Intel reset sent to retry FW download
[ 46.183435] usb 1-1.3: USB disconnect, device number 50
[ 46.512737] usb 1-1.3: new full-speed USB device number 51 using ehci-platform
[ 46.729278] usb 1-1.3: New USB device found, idVendor=8087, idProduct=0032, bcdDevice= 0.00
[ 46.729313] usb 1-1.3: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[ 46.734253] Bluetooth: hci0: Reading Intel version information failed (-22)
[ 46.734305] Bluetooth: hci0: Intel Read version failed (-22)
[ 46.734415] Bluetooth: hci0: Intel reset sent to retry FW download
[ 46.950300] usb 1-1.3: USB disconnect, device number 51

未安装打补丁的内核,安装即可

错误: Direct firmware load for intel/ibt-0041-0041.sfi failed with error -2

1
2
3
4
5
6
7
8
9
[    9.790666] Bluetooth: hci0: Debug lock is disabled
[ 9.790669] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
[ 9.790672] Bluetooth: hci0: Bootloader timestamp 2019.40 buildtype 1 build 38
[ 9.814394] bluetooth hci0: Direct firmware load for intel/ibt-0041-0041.sfi failed with error -2
[ 9.814410] Bluetooth: hci0: Failed to load Intel firmware file (-2)
[ 9.819751] Intel(R) Wireless WiFi driver for Linux
[ 9.829338] iwlwifi 0002:21:00.0: enabling device (0000 -> 0002)
[ 9.872571] iwlwifi 0002:21:00.0: api flags index 2 larger than supported by driver
[ 9.872638] iwlwifi 0002:21:00.0: TLV_FW_FSEQ_VERSION: FSEQ Version: 93.8.63.28

未下载sfi文件,下载即可

1
wget https://anduin.linuxfromscratch.org/sources/linux-firmware/intel/ibt-0041-0041.sfi  -o /lib/firmware/intel/ibt-0041-0041.sfi

错误:Bluetooth: hci0: Failed to load Intel DDC file intel/ibt-0041-0041.ddc (-2)

1
2
3
4
5
6
7
8
[   14.499042] Bluetooth: hci0: Waiting for firmware download to complete
[ 14.499117] Bluetooth: hci0: Firmware loaded in 1556348 usecs
[ 14.499215] Bluetooth: hci0: Waiting for device to boot
[ 14.525032] Bluetooth: hci0: Device booted in 25277 usecs
[ 14.525162] Bluetooth: hci0: Failed to load Intel DDC file intel/ibt-0041-0041.ddc (-2)
[ 14.529103] Bluetooth: hci0: Firmware timestamp 2022.39 buildtype 1 build 52159
[ 17.810272] r8125: enP4p65s0: link up
[ 17.810336] IPv6: ADDRCONF(NETDEV_CHANGE): enP4p65s0:

解决办法:

1
wget https://anduin.linuxfromscratch.org/sources/linux-firmware/intel/ibt-0041-0041.ddc -O /lib/firmware/intel/ibt-0041-0041.ddc