`
xitong
  • 浏览: 6188850 次
文章分类
社区版块
存档分类
最新评论

ARM USB蓝牙,Bluez 移植。

 
阅读更多

标题:USB 蓝牙适配器在ARM 开发板下的使用:

关键字: dbus,bluez-lib, bluez-utils, USB 蓝牙,ARM

正文:

1、我的操作环境是

主机:xp + VMware ubuntu 10.10 。 开发板:OK6410 。 文件系统: yaffs2 。 蓝牙:蓝牙适配器(适配器在PC ubuntu 下测试可用)。交叉编译器:arm-linux-gcc 4.3.2

操作环境环境提示:如果你有red hat 或者 Fedora 这两个操作环境,建议你首选这两个环境,应为Ubuntu 操作起来问题太多了。

2、配置内核支持Bluetooth,

2.1 make menuconfig

[*] Networking support<wbr>---&gt;<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<*><wbr><wbr>Bluetooth subsystem support<wbr>---&gt;<wbr><wbr><wbr>//蓝牙子系统必须选择</wbr></wbr></wbr></wbr></wbr></wbr>

<*><wbr><wbr>L2CAP protocol suppor<wbr><wbr><wbr><wbr><wbr><wbr>//逻辑链路控制和适配协议。</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<*><wbr><wbr>SCO links support<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>//蓝牙语音和耳机支持</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<*><wbr><wbr>RFCOMM protocol suppor<wbr><wbr><wbr><wbr><wbr>//面向流的传输协议,支持拨号网络等</wbr></wbr></wbr></wbr></wbr></wbr></wbr>

[*]<wbr><wbr>RFCOMM TTY support<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>//</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<*><wbr><wbr>BNEP protocol support<wbr><wbr><wbr><wbr><wbr><wbr>//蓝牙网络封装协议,自组网支持</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

[*]<wbr><wbr>Multicast filter support<wbr><wbr><wbr>//蓝牙多播,支持支持BNEP</wbr></wbr></wbr></wbr></wbr>

[*]<wbr><wbr>Protocol filter support //蓝牙多播,支持支持支持BNEP</wbr></wbr>

<*><wbr><wbr>HIDP protocol support<wbr><wbr><wbr><wbr><wbr><wbr>//基本支持协议</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

Bluetooth device drivers<wbr>---&gt;</wbr>

<*> HCI USB driver<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>//USB蓝牙模块支持</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<M>HCI UART driver<wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr>//基于串口,CF卡或PCMCIA的蓝牙</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<*> HCI BlueFRITZ! USB driver

<*> HCI VHCI (Virtual HCI device) driver

2.2 下载内核 检测USB 蓝牙设备信息:

[root@Mr /mnt]#usb 1-1: new full speed USB device using s3c2410-ohci and address
usb 1-1: New USB device found, idVendor=0a12, idProduct=0001
usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[root@Mr /mnt]#

[root@FORLINX6410]# hciconfig检测蓝牙设备
hci0: Type: 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
[root@FORLINX6410]#

3、移植 Bluez 蓝牙协议栈

3.1 所依赖的库文件:

bluez-libs-3.36.tar.gz

dbus-1.5.12.tar.gz

expat-2.0.1.tar.gz

glib-2.26.1.tar.gz

bluez-utils-3.36.tar.gz

libusb-0.1.12.tar.gz

应用的安装步骤:

3.2,编译安装bluez-lib-3.36.tar.gz

这个库不需要什么依赖,直接解压,配置,编译然后安装即可。

#tarzxvfbluez-lib-3.36.tar.gz

#./configure--profix=/opt/libs--host=arm-linux--target=arm-linuxCC=arm-linux-gcc

#make

#makeinstall

3.3,编译安装expat-2.0.1.tar.gz

这个库是后面的dbus依赖的,你也可以用libxml2来代替expat,官方网站上说dbus必须依赖于他们中的一个,我这里用的是expat-2.0.1.tar.gz

#tarzxvfexpat-2.0.1.tar.gz

#./configure--profix=/opt/libs--host=arm-linux--target=arm-linuxCC=arm-linux-gcc

#make

#makeinstall

3.4,编译安装dbus-1.5.12.tar.gz

#tarzxvfdbus-1.5.12.tar.gz

#echoac_cv_have_abstract_sockets=yes>arm-linux.cache

#./configure--profix=/opt/libs--host=arm-linux--target=arm-linuxCC="arm-linux-gcc-I/opt/libs/include-L/opt/libs/lib"--cache-file=arm-linux.cache--with-x=no

#make

#makeinstall

3.5,编译安装glib-2.26.1.tar.gz

#tar-zxjfglib-2.26.1.tar.gz

#echoac_cv_type_long_long=yes>arm-linux.cache

#echoglib_cv_stack_grows=no>>arm-linux.cache

#echoglib_cv_uscore=no>>arm-linux.cache

#echoc_cv_func_posix_getpwuid_r=yes>>arm-linux.cache

#echoac_cv_func_posix_getgrgid_r=yes>>

注意:">"和">>"的区别

#./configure--profix=/opt/libs--host=arm-linux--target=arm-linuxCC="arm-linux-gcc-I/opt/libs/include-L/opt/libs/lib"--cache-file=arm-linux.cache

#make

#makeinstall

3.6,编译安装libusb-0.1.12.tar.gz

这个库不需要什么依赖,直接解压,配置,编译然后安装即可。

#tarzxvflibusb-0.1.12.tar.gz

#./configure--profix=/opt/libs--host=arm-linux--target=arm-linuxCC="arm-linux-gcc-I/opt/libs/include-L/opt/libs/lib"

#make

#makeinstall

3.7,编译安装bluez-utils-3.36.tar.gz

#tarzxvfbluez-utils-3.36.tar.gz

#./configure--profix=/opt/libs--host=arm-linux--target=arm-linuxCC="arm-linux-gcc-I/opt/libs/include-L/opt/libs/lib"--disable-audio

#make

#makeinstall

4、可能出现的问题和解决方案:

4.1 编译dbus 时出现:

1checking for accept4... yes
checking abstract socket namespace... no
checking for pkg-config... (cached) /usr/local/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for XML_ParserCreate_MM in -lexpat... no
configure: error: Could not find expat.h, check config.log for failed attempts

解决方案:

export LDFLAGS=-Wl,-L/usr/local/lib,-lexpat
export CPPFLAGS=-I/usr/local/include

4.2 安装glib 时出现glib msgfmt.. no (这个问题极易出现在Ubuntu 上)

解决方案:apt-get install gettest

4.3 安装glib 时出现error: Could not find a glib-genmarshal in your PATH,
解决方案:先在主机安装 apt-get install libglib2.0-dev

4.4 bluez-utils ./configure 时出现:BLUEZ no Bluetooth library is required

解决方案:sudo apt-get install libbluetooth-dev

4.5 bluez-utils ./configure 时出现:configure: error: D-Bus library is required

解决方案:sudo apt-get install libdbus-1-dev libdbus-glib-1-dev

4.5 bluez-utils 编译 make 时出现bluez libgmodule-2.0.so could not read symbols: File in wrong 等

解决方案: 查看 glib 配置时的 arm-linux.cache 和环境变量的配置,问题极有可能出现在这里


5 bluez 测试

5.1 测试准备

在自己配置 ./configure --prefix=/opt/libs 时 说明自己的库会被安装在/opt/libs 下

copy /opt/libs/sbin/* 到你的文件系统 /sbin

copy /opt/libs/bin/ 下的hcitool,rfcomm,sdptool 到你的文件系统 /bin

copy /opt/libs/etc/bluetooth/* 到你的文件系统 /etc

5.2 测试命令

[root@FORLINX6410]# hciconfig hci0 up 启用蓝牙

[root@FORLINX6410]# hciconfig hci0 iscan配置开发板蓝牙可被查找
[root@FORLINX6410]# hcitool scan 查找蓝牙
Scanning ...
00:22:A5:E2:85:AC HTC click 这个是我手机的蓝牙设备
[root@FORLINX6410]#




分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics