当前位置:文档之家› bluez编译移植

bluez编译移植

Dbus移植步骤
1.进入dbus的目录运行./configure --host=arm-linux
--prefix=/bluetooth/dbus
2.出现错误can not run test program while cross compiling
[mystic@moolenaar]$ . checking for getpeereid... no
checking abstract socket namespace... configure: error: cannot run test program while cross compiling
See `config.log' for more details.
执行./configure时要在宿主系统中运行一些测试程序,因为是交叉编译所以这个测试是一定通不过的。

不过没问题,我们可以在configure 时指定cache-file文件来屏障掉测试程序,在下面编译glib包时会遇到同样的问题。

处理方法:
在源码包根目录下执行
[mystic@moolenaar]$ echo ac_cv_have_abstract_sockets=yes >
arm-linux.cache
或者自己新建一个文件,vim arm-linux.cache
在里面输入:ac_cv_have_abstract_sockets=yes
[mystic@moolenaar]$ ./configure --host=arm-linux
--prefix=/bluetooth/dbus --cache-file=arm-linux.cache
参数解释:--prefix指定编译好的文件存放的路径,默认会放到/usr/bin

--host 指定编译器的类型,这里指定为arm-linux交叉编
译,默认是本机的gcc编译
--cache 指定测试的信息写的地方,这里是写到了
arm-linux.cache里面
一会会提示缺少xml库,下载libxlm2,解压后:
./configure –-prefix=/bluetooth/libxml –-host=arm-linux
make ->make install
编译完成后一定要检查libxml/lib下的库文件的格式是否是ARM的,否则不能用。

查看的方式是file libxml.so.2.6.so(库名),出现ARM 表示是交叉编译的,出现i686等信息表示是本机编译的。

2. 编译dbus,cannot find -lX11
[mystic@moolenaar]$ make
arm-linux/bin/ld: cannot find -lX11
collect2: ld returned 1 exit status
make[2]: *** [dbus-launch] error 1
make[2]: Leaving directory `/3.3.2/dbus-1.0.2/tools'
make[1]: *** [all-recursive] error 1
make[1]: Leaving directory `/3.3.2/dbus-1.0.2'
make: *** [all] error 2
在开发板上不需要X Server. configure直接屏蔽掉。

[mystic@moolenaar]$ ./configure --host=arm-linux --prefix=/bluez/dbus --cache-file=arm-linux.cache --without-x
文件编译完之后,进入到--prefix指定的目录/Bluetooth/dbus的lib下,把里面的所有动态库都拷贝到linux的根目录/usr/lib下,记得用cp
的时候加上-av参数。

还有把lib/pkgconfig下的dbus-1.pc拷贝到
/usr/lib/pkgconfig。

拷贝这些文件是为了后面的bluez编译的需要。

Glib移植文档
1.进入glib的目录运行./configure --host=arm-linux
--prefix=/bluetooth/glib
2.出现错误can not run test program while cross compiling,处理方法和上面的dbus一样。

vim arm-linux.cache,里面输入如下内容:
ac_cv_type_long_long=yes
glib_cv_stack_grows=no
glib_cv_uscore=no
ac_cv_func_posix_getpwuid_r=yes
ac_cv_func_posix_getgrgid_r=yes
3. 运行./configure --prefix=/bluetooth/glib --host=arm-linux
--cache-file=arm-linux.cache
Bluez编译步骤
1.以上的文件都编译好之后开始编译bluez ,运行./configure
--prefix=/bluetooth/bluez –-host=arm-linux
2 make ->make install
3 进入编译生成的目录/bluetooth/bluez,把目录bin和sbin下的内容拷贝到制作文件系统根目录下对应的目录,我的是cp
/bluetooth/bluez/bin/*
/home/hbuser/tools/busybox-1.14.1/_install/bin和
cp /Bluetooth/bluez/sbin/*
/home/hbuser/tools/busybox-1.14.1/_install/sbin/ 接着拷贝bluez里的命令所要使用的动态库。

Cp –av
/Bluetooth/bluez/lib/lib* /home/hbuser/tools/_install/lib 下。

4 把busybox-1.14.1/_install下的目录当成nfs系统的根目录,启动开发板,这里还需要配置内核保证对蓝牙设备的支持。

5 对内核进行配置:
Usb Bluetooth 设备的驱动程序选上(编译内核时)
蓝牙设备驱动,包括相关的USB驱动,在内核中已经集成,所以不需要编写,只需要进行相关配置即可。

具体步骤如下:
运行make menuconfig
进行如下配置。

Networking ---><*> Bluetooth subsystem support --->
--- Bluetooth subsystem support
<M> L2CAP protocol support
<M> SCO links support
<M> RFCOMM protocol support
[*] RFCOMM TTY support
<M> BNEP protocol support
[*] Multicast filter support
[*] Protocol filter support
<M> HIDP protocol support
Bluetooth device drivers --->
<*> HCI USB driver
<*> HCI SDIO driver
<M> HCI UART driver
[*] UART (H4) protocol support
[*] BCSP protocol support
[*] HCILL protocol support
<M> HCI BCM203x USB driver
<M> HCI BPA10x USB driver
<M> HCI BlueFRITZ! USB driver
<M> HCI VHCI (Virtual HCI device) driver
<>Marvel Bluetooth driver support
<>Atheros firmware download driver(NEW)
USB的选项为默认即可。

选好之后编译内核make zImage,然后把内核烧写到开发板上。

6 把蓝牙设备插到开发板上。

会显示如下表示识别设备成功。

7 识别后,使用如下命令:
Hciconfig hci0 up启动hci0(蓝牙设备)
Hciconfig hcio piscan(选择工作模式)
Hcitool scan 搜索对方
搜索到对方的设备后,就运行自己的程序。

所有的准备工作完成。

相关的网站:
/index.php?aid=53
/u2/88891/showart_174339 7.html。

相关主题