Chinaunix首页 | 论坛 | 博客
  • 博客访问: 9145761
  • 博文数量: 1725
  • 博客积分: 12961
  • 博客等级: 上将
  • 技术积分: 19840
  • 用 户 组: 普通用户
  • 注册时间: 2009-01-09 11:25
个人简介

偷得浮生半桶水(半日闲), 好记性不如抄下来(烂笔头). 信息爆炸的时代, 学习是一项持续的工作.

文章分类

全部博文(1725)

文章存档

2024年(1)

2023年(26)

2022年(112)

2021年(217)

2020年(157)

2019年(192)

2018年(81)

2017年(78)

2016年(70)

2015年(52)

2014年(40)

2013年(51)

2012年(85)

2011年(45)

2010年(231)

2009年(287)

分类: Android平台

2016-04-01 11:33:16

为树莓派交叉编译BlueZ 配置并测试
http://blog.sina.com.cn/s/blog_7cedb56d0102v0r3.html



1、我的操作环境是 

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

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

2、配置内核支持Bluetooth,

2.1 make menuconfig


[*] Networking support  --->               

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

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

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

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

[*]   RFCOMM TTY support          //

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

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

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

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

Bluetooth device drivers  --->

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

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

<*> 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

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

  #tar zxvf bluez-lib-3.36.tar.gz

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

  #make

  #make install

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

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

  #tar zxvf expat-2.0.1.tar.gz

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

  #make

  #make install

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

  #tar zxvf dbus-1.5.12.tar.gz

  #echo ac_cv_have_abstract_sockets=yes>arm-linux.cache

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

  #make

  #make install

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

  #tar  -zxjf  glib-2.26.1.tar.gz

#echo ac_cv_type_long_long=yes>arm-linux.cache

#echo glib_cv_stack_grows=no>>arm-linux.cache

#echo glib_cv_uscore=no>>arm-linux.cache

#echo c_cv_func_posix_getpwuid_r=yes>>arm-linux.cache

#echo ac_cv_func_posix_getgrgid_r=yes>>

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

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

#make

#make install

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

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

  #tar zxvf  libusb-0.1.12.tar.gz

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

  #make

  #make install

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

  #tar zxvf bluez-utils-3.36.tar.gz

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

  #make

  #make install

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 (这个问题极易出现在 上)

解决方案: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]#



阅读(2818) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~