linux 蓝牙协议栈以及工具移植大全(原创)

#!/bin/bash


bluez_version=bluez-4.95
glib_version=glib-2.28.8
expat_version=expat-2.0.1
dbus_version=dbus-1.4.14
bluez_dump_version=bluez-hcidump-2.1
openobex_version=openobex-1.3
libical_version=libical-0.43
obexd_version=obexd-0.41

install_dir=/opt/02install/
arm_install_dir=/opt/02install/02arm
x86_install_dir=/opt/01install/01x806


if [ -e "./$bluez_version" ] ; then
    rm $bluez_version -r
fi

if [ -e "./$glib_version" ]; then
    rm $glib_version -r
fi

if [ -e "./$expat_version" ]; then
    rm $expat_version -r
fi
#rm $expat_verison
if [ -e "./$dbus_version" ]; then
    rm $dbus_version -r
fi

if [ -e "./$bluez_dump_version" ]; then
    rm $bluez_dump_version -r
fi

if [ -e "./$libical_version" ]; then
    rm $libical_version -r
fi

if [ -e "./$openobex_version" ]; then
    rm $openobex_version -r
fi

if [ -e "$install_dir" ]; then
    rm $install_dir -r
    echo "rm $install_dir"
fi

mkdir -p /opt/02install/

tar -xvf $glib_version.tar.bz2
cd $glib_version
#./configure  | tee x86.log.txt
#make
#make install
#make distclean

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 'ac_cv_func_posix_getpwuid_r=yes' >> arm-linux.cache
echo 'ac_cv_func_posix_getgrgid_r=yes'>> arm-linux.cache
#echo 'ac_cv
./configure --prefix=$arm_install_dir --host=arm-linux --cache-file=arm-linux.cache | tee arm.log.txt
make -j4
make install


cd ../

tar -xvf $expat_version.tar.gz

cd $expat_version

./configure --prefix=$arm_install_dir --host=arm-linux | tee arm.log.txt
make -j4
make install


cd ../

tar -xvf $dbus_version.tar.gz
cd $dbus_version
echo 'ac_cv_have_abstract_sockets=yes' > arm-linux.cache
./configure --prefix=$arm_install_dir --host=arm-linux CC="arm-linux-gcc -I$arm_install_dir/include -L$arm_install_dir/lib " \
    --cache-file=arm-linux.cache --with-x=no  | tee arm.log.txt
make -j4 | tee arm.make.txt
make install

cd ..
tar -xvf $bluez_version.tar.gz
cd $bluez_version

export DBUS_CFLAGS=-I$arm_install_dir/include/dbus-1.0  -I$arm_install_dir/lib/dbus-1.0/include
export DBUS_LIBS=-L$arm_install_dir/lib
export GLIB_CFLAGS=-I$arm_install_dir/include/glib-2.0  -I$arm_install_dir/lib/glib-2.0/include
export GLIB_LIBS=-L$arm_install_dir/lib

./configure --prefix=$arm_install_dir --host=arm-linux \
CC="arm-linux-gcc -I$arm_install_dir/include -L$arm_install_dir/lib -I$arm_install_dir/lib/glib-2.0/include -I$arm_install_dir/lib/dbus-1.0/include -ldbus-1 -lglib-2.0" \
    --disable-audio

make -j4
make install

cd ..

tar -xvf $bluez_dump_version.tar.gz
cd $bluez_dump_version
export BLUEZ_CFLAGS=-I$arm_install_dir/include
export BLUEZ_LIBS=-L$arm_install_dir/lib

./configure --prefix=$arm_install_dir CC="arm-linux-gcc -L/opt/01install/02arm/lib -lbluetooth -lglib-2.0 -ldbus-1" --host=arm-linux
make
make install
cd ..

#openobex
tar -xvf $openobex_version.tar.gz
cd $openobex_version

export BLUEZ_CFLAGS=-I$arm_install_dir/include
export BLUEZ_LIBS=-L$arm_install_dir/lib

./configure --prefix=$arm_install_dir --host=arm-linux --enable-bluetooth --disable-usb --enable-apps

#find . -type f -name "Makefile" -exec sed -e 's/arm-linux-gcc/arm-linux-gcc -lbluetooth/g' {} \;
find . -type f -name "Makefile" -exec sed -i 's/arm-linux-gcc/arm-linux-gcc -lbluetooth $(BLUEZ_LIBS) $(BLUEZ_CFLAGS) /g' {} \;
#modify include/obex.h  add "#include <bluetooth/bluetooth.h>"
make
make install

#libical-0.43
cd ..
tar -xvf $libical_version.tar.gz
cd $libical_version
./configure --prefix=$arm_install_dir --host=arm-linux
make
make install

#obexd
cd ..
tar -xvf $obexd_version.tar.gz
cd $obexd_version
export OPENOBEX_CFLAGS=-I$arm_install_dir/include
export OPENOBEX_LIBS=-L$arm_install_dir/lib
export LIBICAL_CFLAGS=-I$arm_install_dir/include
export LIBICAL_LIBS=-L$arm_install_dir/lib

./configure --prefix=$arm_install_dir \
--host=arm-linux

#add for Makefile
# -I$arm_install_dir/lib/glib-2.0/include -I$arm_install_dir/lib/dbus-1.0/include -lbluetooth -lglib-2.0 -ldbus-1 -lical -lopenobex -lexpat


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
摘 要:基于对Linux协议BlueZ 源代码的分析,给出BlueZ的组织结构和特点。分析USB 传输驱动机制和数据处理过程, 给出实现设备驱动的重要数据结构和流程,并总结Linux 下开发USB 设备驱动的一般方法和关键技术。 关键词:Linux 系统;协议;设备驱动 USB Device Driver for Linux Bluetooth Stack LIANG Jun-xue, YU Bin (Institute of Electronic Technology, PLA Information Engineering University, Zhengzhou 450004) 【Abstract】This paper depicts the structure and characteristics of BlueZ based on analyzing the source code of Linux bluetooth stack BlueZ. It analyzes the implementation of bluetooth USB transport driver scheme and data processing procedure in detail, and gives the key data structure and implementation of bluetooth device driver. It summarizes the approach of developing Linux bluetooth USB device driver and the key technology. 【Key words】Linux system; bluetooth stack; device driver 计 算 机 工 程 Computer Engineering 第 34 卷 第 9 期 Vol.34 No.9 2008 年 5 月 May 2008 ·开发研究与设计技术· 文章编号:1000—3428(2008)09—0273—03 文献标识码:A 中图分类号:TP391 1 概述 技术是开放式通信规范,而 Linux 是开放源码的操 作系统。廉价设备与免费软件的结合,促进了技术和 Linux 的发展与融合。 Linux最早的协议是由Axis Communication Inc在 1999 年发布的 OpenBT 协议。 随后, IBM 发布了 BlueDrekar 协议,但没有公开其源码。Qualcomm Incorporated 在 2001 年发布的 BlueZ 协议被接纳为 2.4.6 内核的一部分。此外, Rappore Technology 及 Nokia 的 Affix Bluetooth Stack 都是 Linux 系统下的协议,应用在不同的设备和领域中。 BlueZ 是 Linux 的官方协议,也是目前应用最广 泛的协议,几乎支持所有已通过认证的设备。对于基 于主机的应用,目前常见的硬件接口有 UART, USB 和 PC 卡等,USB 作为 PC 的标准外设接口,具有连接方便、兼 容性好和支持高速设备等特点,已广泛应用于设备。 目前对 Linux 下 USB 设备驱动的研究已较为广泛而深 入[1-4] ,但对 Linux 下的设备驱动还没有专门的研究。本 文在分析 USB 设备驱动和协议的基础上,总结了 Linux 下开发 USB 驱动程序的一般方法,并深入剖析了 其关键技术。 2 Linux 协议 BlueZ 简介 BlueZ 目前已成为一个开放性的源码工程。它可以很好 地在 Linux 支持的各种体系的硬件平台下运行,包括各种单 处理器平台、多处理器平台及超线程系统。 BlueZ 由多个独立的模块组成,内核空间主要包括设备 驱动层、核心及 HCI 层、L2CAP 与 SCO 音频层、 RFCOMM, BNEP, CMTP 与 HIDP 层、通用 SDP 库和后 台服务及面向所有层的标准套接字接口;在用户空间提供了 配置、测试及协议分析等工具。其组织结构如图 1 所示, BlueZ 没有实现专门的 SDP 层,而是将其实现为运行在后台 的服务库例程(图 1 没有描述该后台服务)。 RFOMM 层支 持标准的套接口,并提供了串行仿真 TTY 接口,这使串行端 口应用程序和协议可以不加更改地运行在设备上,例如 通过点对点协议 PPP 可实现基于 TCP/IP 协议簇的所有网络 应用。BNEP 层实现了的以太网仿真,TCP/IP 可以直接 运行于其上。 USB设备驱动 (hci_usb.o) L2CAP层(l2cap.o) RFCOMM层 (rfcomm.o) BNEP层 (bnep.o) CMTP层 (cmtp.o) 串口设备驱动 (hci_uart.o) 虚拟串口设备驱动 (hci_vhci.o) 音频 socket RFCOMM socket BNEP socket CMTP socket L2CAP socket HCI socket 内核 空间 用户 空间 串口设备 CAPI设备 输入设备 网络设备 HDIP socket 音频设备 AF_BLUETOOTH socket 音频层(sco.o) PPP TCP/IP AF_INET socket BNEP层 (bnep.o) 其他设备驱动 (bluecard_cs.o等) BlueZ工具和实用程序 HDIP层 (hdip.o) BlueZ核心 及HCI层(bluez.o/bluetooth.o) 图 1 BlueZ 组织结构 3 USB 设备驱动 设备驱动程序在 Linux 内核中起着重要作用,它使某个 硬件能响应一个定义良好的内部编程接口。这些接口隐藏了 设备的工作细节,用户通过一组独立于特定驱动程序的标准 调用来操作设备。而将这些调用映射到作用于实际硬件设备 的特有操作上,则是驱动程序的任务。
协议bluez是用于在Linux系统上支持功能的开源软件项目。对于协议移植和开发,以下是一些关键点: 1. 移植协议移植通常需要适配特定的硬件平台或操作系统。移植的关键在于理解目标平台的硬件特性和操作系统的API,并根据这些特性进行相应的修改。从硬件层面,可能需要针对不同的芯片进行驱动程序的开发或移植。从操作系统层面,需要根据操作系统的内核和接口规范进行适配,确保协议能够正确地与操作系统进行通信。 2. 开发:协议bluez的开发需要理解协议的基本原理和相关规范。开发人员需要掌握Linux系统编程和网络编程的相关知识,并深入了解协议的各个层级和模块。在协议的开发过程中,可能需要进行协议的扩展、功能的优化或新特性的添加。开发人员需要进行代码的编写、调试和测试,并确保新开发的功能与协议的其他部分相互兼容。 3. 调试和问题解决:在协议移植和开发过程中,可能会遇到各种问题和挑战。调试是解决这些问题的关键步骤之一,开发人员需要使用适当的工具和技术,如调试器、日志和追踪功能来定位和排除问题。在解决问题时,需要仔细查看相关文档、设计规范和代码实现,并通过分析日志和跟踪信息来理解问题的来源并提供解决方案。 总之,协议bluez的移植和开发需要掌握协议的基础知识,具备Linux系统编程经验,了解硬件和操作系统的特性,并运用合适的调试和问题解决技术来确保协议能够在目标平台上正确运行和提供所需的功能。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值