SBC-T113S产品特性:
- 采用Allwinner公司Cortex-A7双核T113-S3/S4处理器,运行最高速度为1.2GHZ;
- 内置64-bit XuanTie C906 RISC-V协处理器(仅T113-S4支持);
- 支持JPEG/MJPEG视频编码,最大分辨率1080p@60fps;支持多格式1080P@60fps视频解码 (H.265,H.264, MPEG-1/2/4);
- 支持RGB666/LVDS/MIPI-DSI,分辨率最高1920x1080;
- 支持128-256M Bytes DDR3 SDRAM,其中T113-S3内置128MB;T113-S4内置256MB;
- 支持SPI NAND存储和启动(默认:256MB)或者EMMC启动(默认:4GB,最大32GB);
- 支持一路USB2.0 OTG(设计为TYPE-A接口);支持二路USB2.0 HOST;
- 支持七路RS232通信或者6路RS232和1路RS485(非隔离);
- 支持一路CAN BUS通信(非隔离);
- 支持一路10/100M以太网;
- 稳定的操作系统的支持,可预装LINUX 5.4(Preempt)或者OpenWRT;
- 经典尺寸主板,尺寸为120*100MM;
SBC-T113S产品功能评估图:
蓝牙控制及蓝牙播放音频测试:
主板板载了一个USB WiFi模块RTL8723DU,该模块带BT4.2功能。板载RTL8723DU模组的外观如下:
图70 RTL8723DU模块实物图
首先确认bt模块的驱动是否已经正常工作,通过lsmod来判断,如下信息中表示8723du的bt已经正常工作
root@T113-Embfly:/userdata# hciconfig -a
root@T113-Embfly:~# lsmod
Module Size Used by Not tainted
8723du 2162688 0
rtk_btusb 65536 0
sunxi_ce 57344 0
ch343 24576 0
cdc_acm 24576 0
hid_multitouch 20480 0
如果通过lsmod指令未发现可用的bt驱动(rtk_btusb),则可以通过insmod指令进行驱动插入,bt的驱动在/lib/modules/5.4.61/目录(如果是Preempt linux,则驱动在/lib/modules/5.4.61-rt37目录)。
另外,bt的驱动还需要两个配置文件,当bt驱动加载时,务必保证rtl8723du_config 和rtl8723du_fw两个文件在/lib/firmware/的目录下,否则bt驱动加载不成功。驱动加载正确的信息如下:
root@T113-Embfly:# insmod rtk_btusb.ko
[ 7964.303169] rtk_btusb: Realtek Bluetooth USB driver ver 3.1.32e1d0b.20210819-170430
[ 7964.311850] rtk_btcoex: rtk_btcoex_init: version: 1.2
[ 7964.317513] rtk_btcoex: create workqueue
[ 7964.322343] rtk_btcoex: alloc buffers 1408, 2240 for ev and l2
[ 7964.329075] rtk_btusb: btusb_probe intf->cur_altsetting->desc.bInterfaceNumber 0
[ 7964.337365] rtk_btusb: btusb_probe can_wakeup 1, may wakeup 0
[ 7964.343827] rtk_btusb: patch_add
[ 7964.347451] rtk_btusb: auto suspend is disabled
[ 7964.352568] rtk_btusb: pid = 0xd723
[ 7964.356478] rtk_btusb: patch_add: Reset gEVersion to 0xff
[ 7964.362590] rtk_btusb: set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
[ 7964.370965] rtk_btusb: btusb_probe: done
[ 7964.375679] usbcore: registered new interface driver rtk_btusb
[ 7964.377514] rtk_btusb: btusb_open start
[ 7964.386578] rtk_btusb: btusb_open hdev->promisc ==0
[ 7964.392129] rtk_btusb: download_patch start
root@ok113i:/home/forlinx# [ 7964.396839] rtk_btusb: chip type value: 0x71
[ 7964.403997] rtk_btusb: HCI reset.
[ 7964.416814] rtk_btusb: read_ver_rsp->lmp_subver = 0x8723
[ 7964.423054] rtk_btusb: read_ver_rsp->hci_rev = 0xd
[ 7964.428449] rtk_btusb: patch_entry->lmp_sub = 0x8723
[ 7964.434017] rtk_btusb: load_firmware start
[ 7964.438638] rtk_btusb: lmp_version = 0x8723
[ 7964.443325] rtk_btusb: config filename rtl8723du_config
[ 7964.449952] rtk_btusb: no bdaddr file /opt/bdaddr
[ 7964.455252] rtk_btusb: Origin cfg len 22
[ 7964.459688] rtk_btusb: 55 ab 23 87 10 00 d9 00 01 0f e4 00 01 08 8d 00
[ 7964.467005] rtk_btusb: 01 fa 8f 00 01 bf
[ 7964.471497] rtk_btusb: New cfg len 22
[ 7964.475600] rtk_btusb: 55 ab 23 87 10 00 d9 00 01 0f e4 00 01 08 8d 00
[ 7964.482969] rtk_btusb: 01 fa 8f 00 01 bf
[ 7964.487399] rtk_btusb: fw name is rtl8723du_fw
[ 7964.492801] rtk_btusb: This is not 8723a, use new patch style!
[ 7964.499374] rtk_btusb: rtk_get_eversion: gEVersion 255
[ 7964.505815] rtk_btusb: eversion->status = 0x0, eversion->version = 0x2
[ 7964.513566] rtk_btusb: load_firmware: New gEVersion 2
[ 7964.519331] rtk_btusb: rtk_get_fw_project_id: opcode 0, len 1, data 9
[ 7964.526565] rtk_btusb: lmp_version is 8723, project_id is 8723, match!
[ 7964.533909] rtk_btusb: fw_version = 0x82a8a133
[ 7964.538921] rtk_btusb: number_of_total_patch = 3
[ 7964.544092] rtk_btusb: chipID 3
[ 7964.547606] rtk_btusb: patch_length 0x889c
[ 7964.552220] rtk_btusb: start_offset 0x00004940
[ 7964.557198] rtk_btusb: Svn version: -1433992835
[ 7964.562301] rtk_btusb: Coexistence: BTCOEX_20210106-3b3b
[ 7964.568274] rtk_btusb: buf_len = 0x88b2
[ 7964.572647] rtk_btusb: fw: exists, config file: exists
[ 7964.578430] rtk_btusb: load_firmware done
[ 7964.582960] rtk_btusb: download_data start
[ 7964.855824] rtk_btusb: download_data done
[ 7964.860346] rtk_btusb: HCI reset.
[ 7964.873812] rtk_btusb: read_ver_rsp->lmp_subver = 0xa133
[ 7964.880054] rtk_btusb: read_ver_rsp->hci_rev = 0x82a8
[ 7964.885730] rtk_btusb: patch_entry->lmp_sub = 0x8723
[ 7964.891337] rtk_btusb: Rtk patch end 0
[ 7964.895538] rtk_btusb: btusb_open set HCI_RUNNING
[ 7964.900945] rtk_btcoex: Open BTCOEX
[ 7964.904856] rtk_btusb: btusb_open end
[ 7964.911832] rtk_btcoex: BTCOEX hci_rev 0x82a8
[ 7964.916883] rtk_btcoex: BTCOEX lmp_subver 0xa133
[ 7964.943829] rtk_btusb: btusb_notify: hci0 evt 3
[ 7967.007992] rtk_btusb: btusb_flush add delay
[ 7967.022915] rtk_btusb: btusb_close
[ 7967.045574] rtk_btcoex: Close BTCOEX
[ 7967.049615] rtk_btcoex: -x
此时,再一次查看系统的蓝牙设备信息会打印如下:
root@T113-Embfly:# hciconfig -a
hci0: Type: Primary Bus: USB
BD Address: 2C:C3:E6:67:4D:3C ACL MTU: 1021:8 SCO MTU: 255:12
DOWN
RX bytes:584 acl:0 sco:0 events:30 errors:0
TX bytes:369 acl:0 sco:0 commands:30 errors:0
Features: 0xff 0xff 0xff 0xfa 0xdb 0xbd 0x7b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: SLAVE ACCEPT
检查完成后,我们要开始使能hci设备了,并运行bluetoothd服务,如果不提前运行他们,后续的指令不能正常执行,特别是后续的bluetoothctl控制程序。
Target# hciconfig hci0 up
Target# bluetoothd -C -n &
root@T113-Embfly:~# hciconfig hci0 up
[11881.757207] rtk_btusb: btusb_open start
[11881.761522] rtk_btusb: btusb_open hdev->promisc ==0
[11881.767123] rtk_btusb: download_patch start
[11881.771819] rtk_btusb: chip type value: 0x71
[11881.777958] rtk_btusb: chip_type->status = 0x0, chip_type->chip = 0xbeef
[11881.785530] rtk_btusb: HCI reset.
[11881.798954] rtk_btusb: read_ver_rsp->lmp_subver = 0x6f71
[11881.804936] rtk_btusb: read_ver_rsp->hci_rev = 0x92b7
[11881.810600] rtk_btusb: patch_entry->lmp_sub = 0x8723
[11881.816194] rtk_btusb: Firmware already exists
[11881.821193] rtk_btusb: Rtk patch end 1
[11881.825443] rtk_btusb: chip type value: 0x71
[11881.830233] rtk_btusb: btusb_open set HCI UP RUNNING
[11881.835958] rtk_btcoex: Open BTCOEX
[11881.839876] rtk_btusb: btusb_open end
[11881.852407] rtk_btcoex: rtk_vendor_cmd_to_fw: opcode 0xfc1b
[11881.855022] rtk_btcoex: BTCOEX hci_rev 0x92b7
[11881.863750] rtk_btcoex: BTCOEX lmp_subver 0x6f71
[11881.918043] debugfs: File 'le_min_key_size' in directory 'hci0' already present!
[11881.926394] debugfs: File 'le_max_key_size' in directory 'hci0' already present!
[11881.934759] debugfs: File 'force_bredr_smp' in directory 'hci0' already present!
root@T113-Embfly:~# bluetoothctl
root@T113-Embfly:~# bluetoothd -C -n &
[1] 1805
root@T113-Embfly:~# bluetoothd[1805]: Bluetooth daemon 5.50
bluetoothd[1805]: Starting SDP server
bluetoothd[1805]: kernel lacks bnep-protocol support
bluetoothd[1805]: System does not support network plugin
bluetoothd[1805]: Bluetooth management interface 1.14 initialized
bluetoothd[1805]: Sap driver initialization failed.
bluetoothd[1805]: sap-server: Operation not permitted (1)
bluetoothd[1805]: Failed to set privacy: Rejected (0x0b)
蓝牙工具软件的介绍和使用
bluetoothctl 是一个交互式且易于使用的工具,用于控制蓝牙设备。它是在基于 Linux 的操作系统上管理蓝牙的主要实用程序。本指南将向您展示如何使用 bluetoothctl 在主板上设置蓝牙设备和连接。
- 扫描附近的设备
要主动搜索可以连接的蓝牙设备,请使用扫描命令,如下所示:
Target#bluetoothctl scan on
当您运行上述命令时,您的电脑将查找并列出系统范围内的所有蓝牙设备。
root@T113-Embfly:# bluetoothctl scan on
root@T113-Embfly:# [ 838.048556] rtk_btcoex: hci (periodic)inq start
Discovery started
[CHG] Controller 40:80:E1:F1:BE:0C Discovering: yes
[CHG] Device 90:CE:B8:0D:E2:1E RSSI: -84
[CHG] Device 78:2B:46:43:EE:31 RSSI: -20
[CHG] Device 78:2B:46:43:EE:31 TxPower: 12
[NEW] Device 34:29:EF:38:D9:1B 34-29-EF-38-D9-1B
[NEW] Device F4:4E:FD:3B:95:A6 EDIFIER M350
[CHG] Device 20:23:06:4C:2B:9D RSSI: -74
[CHG] Device 34:29:EF:2C:E3:55 RSSI: -70
[NEW] Device 4E:3C:D4:78:B4:2D K3_2db478
[CHG] Device 45:8B:13:BD:35:11 RSSI: -82
[CHG] Device 45:8B:13:BD:35:11 TxPower: 12
[CHG] Device 20:23:06:3C:9D:68 RSSI: -68
[CHG] Device D8:CC:81:37:40:FC RSSI: -76
[CHG] Device D8:CC:81:37:40:FC UUIDs: 0000ab00-0000-1000-8000-00805f9b34fb
[NEW] Device 02:68:EB:0E:98:4F 02-68-EB-0E-98-4F
[CHG] Device 5A:B1:27:82:D2:BA RSSI: -66
[CHG] Device 5A:B1:27:82:D2:BA TxPower: 7
所有蓝牙设备都标记为设备,后跟各自的媒体访问控制 (MAC) 地址,这是网络上设备的唯一标识符。 MAC 地址遵循格式 XX : XX : XX : XX : XX : XX。 Bluetoothctl 还显示设备的名称,例如上面输出中的 EDIFIER M350(我们测试使用的蓝牙音箱)。
注意:如果您找不到所需的蓝牙设备,请确保您的系统蓝牙可被发现。
要使其他设备可以发现您的蓝牙适配器,请使用以下命令:
bluetoothctl discoverable on
- 连接到您的设备
现在您已经有了可以连接的蓝牙设备列表,可以使用 MAC 地址连接到特定设备。
连接蓝牙设备的最简单方法是使用配对命令将其与您设备配对。
bluetoothctl pair
F4:4E:FD:3B:95:A6
注意:请记住将本手册使用的MAC地址 F4:4E:FD:3B:95:A6 替换为您设备的相应 MAC 地址。
如果您要连接的设备具有 GUI 界面,例如智能手机,设备将显示提示,要求您接受连接。系统还会要求您确认PC上的配对。您可以通过在命令行中键入yes来执行此操作。
对于已与主板配对的设备,以后只需使用connect命令即可连接到它们即可,如下所示:
bluetoothctl connect
F4:4E:FD:3B:95:A6
- 使用bluetoothctl列出配对设备
您可以通过运行以下命令来查看当前与系统配对的设备:
bluetoothctl paired-devices
您还可以使用以下命令列出计算机蓝牙范围内的设备:
bluetoothctl devices
- 信任配对设备
除了与蓝牙设备配对外,您还可以选择信任某些设备,以便将来轻松连接到它们。
要信任蓝牙设备:
bluetoothctl trust
F4:4E:FD:3B:95:A6
您可以通过发出以下命令来取消信任设备:
bluetoothctl untrust
F4:4E:FD:3B:95:A6
- 断开蓝牙设备
要取消配对蓝牙设备,请使用删除命令,如下所示:
bluetoothctl remove
F4:4E:FD:3B:95:A6
您还可以使用bluetoothctl将设备与系统断开连接:
bluetoothctl disconnect
F4:4E:FD:3B:95:A6
如果您希望阻止特定设备连接到您的系统,可以使用阻止命令,后跟该设备的 MAC 地址。
bluetoothctl block
F4:4E:FD:3B:95:A6
要取消阻止设备,只需将上述命令中的单词阻止替换为取消阻止即可。
- 使用bluetoothctl的交互模式
bluetoothctl是一个交互式实用程序。我们建议使用交互模式,因为它更快、更容易使用。要进入交互模式,只需运行不带参数的bluetoothctl命令,如下所示:
bluetoothctl
root@T113-Embfly:/embfly_test# bluetoothctl
Agent registered
切换到交互模式后,您可以发出命令,先看看它有什么指令,如下所示:
[bluetooth]# help
Menu main:
Available commands:
-------------------
advertise Advertise Options Submenu
scan Scan Options Submenu
gatt Generic Attribute Submenu
list List available controllers
show [ctrl] Controller information
select <ctrl> Select default controller
devices List available devices
paired-devices List paired devices
system-alias <name> Set controller alias
reset-alias Reset controller alias
power <on/off> Set controller power
pairable <on/off> Set controller pairable mode
discoverable <on/off> Set controller discoverable mode
agent <on/off/capability> Enable/disable agent with given capability
default-agent Set agent as the default one
advertise <on/off/type> Enable/disable advertising with given type
set-alias <alias> Set device alias
scan <on/off> Scan for devices
info [dev] Device information
pair [dev] Pair with device
trust [dev] Trust device
untrust [dev] Untrust device
block [dev] Block device
unblock [dev] Unblock device
remove <dev> Remove device
connect <dev> Connect device
disconnect [dev] Disconnect device
menu <name> Select submenu
version Display version
quit Quit program
exit Quit program
help Display help about this program
export Print evironment variables
[bluetooth]#
这些指令和非交互模式的时候是一样的。
要退出 bluetoothctl 交互模式,只需在提示符中键入 exit 即可。