AX210蓝牙识别可用rock5b内核-armbian

AX210蓝牙识别可用rock5b内核-armbian

背景

之前已经给ubuntu做了蓝牙的适配,ubuntu打的内核包并不适用于armbian的,armbian的内核是自己通过一个脚本打出来的,并且armbian下面的编译参数跟ubuntu不同

比如我们需要用到的这个btusb,就是armbian做的buildin的,也就是放内核里面,不是以内核模块处理的,这个地方正常也没有问题,但是这个模块需要加载firmware的,在内核里面是无法加载外面的,需要单独处理

默认的出错显示如下:

1
2
3
4
5
root@rock-5b:/lib/firmware/intel# dmesg |grep blue
[ 5.090354] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: uart_rts_gpios = 34.
[ 5.090374] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,reset_gpio = 102.
[ 5.090390] [BT_RFKILL]: bluetooth_platdata_parse_dt: get property: BT,wake_host_irq = 21.
[ 5.845000] bluetooth hci0: Direct firmware load for intel/ibt-0041-0041.sfi failed with error -2

这个加载的启动5秒就加载了,而在ubuntu下面是14秒左右加载的,通过这里判断应该是firmware的加载问题

相关处理

下载armbian工具

1
git clone https://github.com/armbian/build.git

把编译内核指定到自己的内核

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
28
29
root@ubuntu:~/armbian/build# cat config/sources/families/rockchip-rk3588.conf
source "${BASH_SOURCE%/*}/include/rockchip64_common.inc"

BOOTSOURCE='https://github.com/radxa/u-boot.git'
BOOTBRANCH='branch:stable-5.10-rock5'
BOOTPATCHDIR="legacy"

OVERLAY_PREFIX='rockchip-rk3588'

case $BRANCH in

legacy)
UBOOT_COMPILER="aarch64-linux-gnu-"
UBOOT_USE_GCC='< 8.0'
BOOTDIR='u-boot-rockchip64'
KERNELDIR='linux-rockchip64'
KERNELSOURCE='https://github.com/zphj1987/kernel'
KERNELBRANCH='branch:stable-5.10-rock5'
KERNELPATCHDIR='rockchip-rk3588-legacy'

;;

esac

prepare_boot_configuration

family_tweaks_bsp() {
:
}

上面的KERNELSOURCE修改为我已经打好补丁的分支的,脚本会自己去下载内核

把固件打到内核里面去

1
2
3
4
5
6
7
8
9
10
11
root@ubuntu:~/armbian/build# cat config/kernel/linux-rockchip-rk3588-legacy.config|grep FIRMWARE
# CONFIG_FIRMWARE_MEMMAP is not set
# CONFIG_GOOGLE_FIRMWARE is not set
CONFIG_PREVENT_FIRMWARE_BUILD=y
CONFIG_EXTRA_FIRMWARE="intel/ibt-0041-0041.sfi intel/ibt-0041-0041.ddc"
CONFIG_EXTRA_FIRMWARE_DIR="/lib/firmware"
CONFIG_HOSTAP_FIRMWARE=y
CONFIG_HOSTAP_FIRMWARE_NVRAM=y
CONFIG_DRM_LOAD_EDID_FIRMWARE=y
# CONFIG_FIRMWARE_EDID is not set
# CONFIG_TEST_FIRMWARE is not set

注意上面的FIRMWARE目录就是/lib/firmware,固件的需要把目录带上,否则打不进去
打进去的内核是会在内核编译目录里面看到的,注意下,当前的编译机器的 /lib/firmware/intel/ibt-0041-0041.sfi这个文件路径需要存在,这里是调用编译机器的,弄到内核里面去的

1
2
3
4
5
6
7
8
9
10
root@ubuntu:~/armbian/build# ll cache/sources/linux-rockchip64/stable-5.10-rock5/drivers/base/firmware_loader/builtin/intel/
total 696
drwxrwxr-x 2 root root 4096 Nov 29 12:02 ./
drwxrwxr-x 3 root root 4096 Nov 29 12:01 ../
-rw-rw-r-- 1 root root 1360 Nov 29 12:01 ibt-0041-0041.ddc.gen.o
-rw-rw-r-- 1 root root 1509 Nov 29 12:01 .ibt-0041-0041.ddc.gen.o.cmd
-rw-rw-r-- 1 root root 516 Nov 29 12:01 ibt-0041-0041.ddc.gen.S
-rw-rw-r-- 1 root root 683224 Nov 29 12:01 ibt-0041-0041.sfi.gen.o
-rw-rw-r-- 1 root root 1509 Nov 29 12:01 .ibt-0041-0041.sfi.gen.o.cmd
-rw-rw-r-- 1 root root 516 Nov 29 12:01 ibt-0041-0041.sfi.gen.S

可以看到我们buildin的intel的 firmware

开始编译

1
root@ubuntu:~/armbian/build# ./compile.sh

可以看到我改过的文件,脚本提示了,继续就行

选第一个就行,我们上面改的是linux-rockchip-rk3588-legacy.config这个配置文件,选这个就是指的用这个配置文件


默认是没有的,需要选板子里面找

可以找到rock-5b的选项

根据os选,我的版本这个,选的这个

这个我选的这个

继续
然后就开始了,这个会下载很多东西,网络搞通畅

不用等完全编译完,等内核输出了deb包就可以

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
root@ubuntu:~/armbian/build# ll output/debs
total 245980
drwxrwxr-x 3 root root 4096 Nov 29 12:06 ./
drwxrwxr-x 8 root root 4096 Nov 29 00:33 ../
-rw-r--r-- 1 root root 128460 Nov 29 12:05 armbian-config_22.11.0-trunk_all.deb
-rw-r--r-- 1 root root 9441404 Nov 29 12:06 armbian-firmware_22.11.0-trunk_all.deb
-rw-r--r-- 1 root root 120776 Nov 29 12:06 armbian-plymouth-theme_22.11.0-trunk_all.deb
-rw-r--r-- 1 root root 2424128 Nov 29 12:06 armbian-zsh_22.11.0-trunk_all.deb
drwxrwxr-x 2 root root 4096 Nov 29 11:07 extra/
-rw-r--r-- 1 root root 733160 Nov 29 12:05 linux-dtb-legacy-rockchip-rk3588_22.11.0-trunk_arm64.deb
-rw-r--r-- 1 root root 12046524 Nov 29 12:05 linux-headers-legacy-rockchip-rk3588_22.11.0-trunk_arm64.deb
-rw-r--r-- 1 root root 18750932 Nov 29 12:05 linux-image-legacy-rockchip-rk3588_22.11.0-trunk_arm64.deb
-rw-r--r-- 1 root root 1190208 Nov 29 12:05 linux-libc-dev_22.11.0-trunk_arm64.deb
-rw-r--r-- 1 root root 206047844 Nov 29 12:00 linux-source-legacy-rockchip-rk3588_22.11.0-trunk_all.deb
-rw-r--r-- 1 root root 965872 Nov 29 11:58 linux-u-boot-legacy-rock-5b_22.11.0-trunk_arm64.deb

差不多就是上面的包,主要安装的就是这个包

1
linux-image-legacy-rockchip-rk3588_22.11.0-trunk_arm64.deb

然后把这个包放到机器上面安装即可,然后重启就行了

截图

没有问题,扫描也可以看到相关的蓝牙设备

安装内核包

1
2
3
4
5
6
7
8
9
10
11
12
13
14
root@rock-5b:~# wget https://zphj1987.com/media/rk3588/硬件篇/assets/files/linux-image-armbian-ax210-bluetooth.tar.gz  (待修改)
root@rock-5b:~# tar -xvf linux-image-armbian-ax210-bluetooth.tar.gz
root@rock-5b:~# cd debs/
root@rock-5b:~/debs# dpkg -i linux-image-legacy-rockchip-rk3588_22.11.0-trunk_arm64.deb
(Reading database ... 116838 files and directories currently installed.)
Preparing to unpack linux-image-legacy-rockchip-rk3588_22.11.0-trunk_arm64.deb ...
Unpacking linux-image-legacy-rockchip-rk3588 (22.11.0-trunk) over (22.11.0-trunk) ...
Setting up linux-image-legacy-rockchip-rk3588 (22.11.0-trunk) ...
update-initramfs: Generating /boot/initrd.img-5.10.72-rockchip-rk3588
W: Possible missing firmware /lib/firmware/rtl_bt/rtl8821a_config.bin for built-in driver btrtl
W: Possible missing firmware /lib/firmware/rtl_bt/rtl8761a_config.bin for built-in driver btrtl
update-initramfs: Converting to u-boot format
Free space after deleting the package linux-image-legacy-rockchip-rk3588 in /boot: 120M
root@rock-5b:~/debs# reboot

查看信息

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
28
29
30
31
32
33
34
35
root@rock-5b:~# lspci 
0002:20:00.0 PCI bridge: Rockchip Electronics Co., Ltd Device 3588 (rev 01)
0002:21:00.0 Network controller: Intel Corporation Wi-Fi 6 AX210/AX211/AX411 160MHz (rev 1a)
0004:40:00.0 PCI bridge: Rockchip Electronics Co., Ltd Device 3588 (rev 01)
0004:41:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8125 2.5GbE Controller (rev 04)
root@rock-5b:~# 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 003: ID 8087:0032 Intel Corp. AX210 Bluetooth
Bus 001 Device 002: ID 1a40:0101 Terminus Technology Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

root@rock-5b:~# hciconfig -a
hci0: Type: Primary Bus: USB
BD Address: C4:03:A8:86:DD:AE ACL MTU: 1021:4 SCO MTU: 96:6
UP RUNNING
RX bytes:18498 acl:0 sco:0 events:2863 errors:0
TX bytes:695221 acl:0 sco:0 commands:2861 errors:0
Features: 0xbf 0xfe 0x0f 0xfe 0xdb 0xff 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH SNIFF
Link mode: PERIPHERAL ACCEPT
Name: 'rock-5b'
Class: 0x000000
Service Classes: Unspecified
Device Class: Miscellaneous,
HCI Version: (0xc) Revision: 0x3484
LMP Version: (0xc) Subversion: 0x3484
Manufacturer: Intel Corp. (2)

命令行测试扫描蓝牙

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
root@rock-5b:~# bluetoothctl 
Agent registered
[CHG] Controller C4:03:A8:86:DD:AE Pairable: yes
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# scan on
Discovery started
[CHG] Controller C4:03:A8:86:DD:AE Discovering: yes
[NEW] Device 49:87:30:7B:75:24 49-87-30-7B-75-24
[NEW] Device 5B:DE:97:D4:1F:A5 5B-DE-97-D4-1F-A5
[NEW] Device EA:B4:45:8C:0A:72 HE3490021305
[NEW] Device 67:95:6A:BA:87:8C 67-95-6A-BA-87-8C
[NEW] Device 6E:72:EE:46:DE:93 6E-72-EE-46-DE-93
[NEW] Device 1C:BE:24:61:79:49 1C-BE-24-61-79-49
[bluetooth]#

可以看到没有问题

资源

打好的包

linux-image-armbian-ax210-bluetooth.tar