• zynq平台蓝牙协议栈移植


    zynq平台蓝牙协议栈移植

    需要在zynq平台添加蓝牙模块的支持,运行蓝牙相关的命令(hciconfig/hcitool)等,经过一番研究和多次实验之后,蓝牙协议栈最终移植成功。下面是相关库的具体编译过程和过程中遇到问题的解决方法。

    • 虚拟机环境:Ubuntu16.04.3

    编译安装bluez-libs-3.36

    ./configure --prefix=/opt/bluez/bluez-libs-3.36 --host=arm-linux --target=arm-linux CC=arm-linux-gnueabihf-gcc
    make
    sudo make install
    
    • 1
    • 2
    • 3

    编译安装expat-2.5.0

    ./configure --prefix=/opt/bluez/expat-2.5.0 --host=arm-linux --target=arm-linux CC=arm-linux-gnueabihf-gcc
    make
    sudo make install
    
    • 1
    • 2
    • 3

    编译安装dbus-1.15.2

    ./configure --prefix=/opt/bluez/dbus-1.15.2 --host=arm-linux --target=arm-linux CC="arm-linux-gnueabihf-gcc -lexpat -I/opt/bluez/expat-2.5.0/include -L/opt/bluez/expat-2.5.0/lib" --cache-file=arm-linux.cache --with-x=no --enable-tests=no
    make
    sudo make install
    
    #错误
    checking for EXPAT... configure: error: Package requirements (expat) were not met:
    No package 'expat' found
    Consider adjusting the PKG_CONFIG_PATH environment variable if you
    installed software in a non-standard prefix.
    Alternatively, you may set the environment variables EXPAT_CFLAGS
    and EXPAT_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.
    #解决
    export EXPAT_CFLAGS=/opt/bluez/expat-2.5.0/bin
    export EXPAT_LIBS=/opt/bluez/expat-2.5.0/lib
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    编译zlib-1.2.13

    注:当前的configure文件是没有选项参数可供我们配置使用,只能配置生成Makefile后,修改Makefile。
    
    ./configure
    
    vi Makefile
    # 这里的交叉编译工具(arm-none-linux-gnueabi-),大家要根据自己的实际情况来定,可能名字不一样
    CROSS_COMPILE=arm-none-linux-gnueabi-
    CC=$(CROSS_COMPILE)gcc
    LDSHARED=$(CROSS_COMPILE)gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
    CPP=$(CROSS_COMPILE)gcc -E
    AR=$(CROSS_COMPILE)ar
    RANLIB=$(CROSS_COMPILE)ranlib
    prefix =${HOME}/zlib
    
    make
    
    make install
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    编译安装glib-2.26.1

    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
    
    ./configure --prefix=/opt/bluez/glib-2.26.1 --host=arm-linux --target=arm-linux CC="arm-linux-gnueabihf-gcc -I/opt/bluez/dbus-1.15.2/include -I/opt/bluez/bluez-libs-3.36/include -I/opt/bluez/expat-2.5.0/include -L/opt/bluez/dbus-1.15.2/lib -L/opt/bluez/bluez-libs-3.36/lib -L/opt/bluez/expat-2.5.0/lib -I/opt/bluez/zlib-1.2.13/include -L/opt/bluez/zlib-1.2.13/lib" CXX=arm-linux-gnueabihf-g++ --cache-file=arm-linux.cache
    make
    make install
    
    #错误
    gzlibcompressor.c:28:10: fatal error: zlib.h: No such file or directory
    #include 
    解决
    交叉编译zlib库,并指定路径-I/opt/bluez/zlib-1.2.13/include -L/opt/bluez/zlib-1.2.13/lib
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15

    编译安装bluez-utils-3.36

    #注意生成的Makefile中的路径
    export DBUS_CFLAGS = -I/opt/bluez/dbus-1.15.2/include/dbus-1.0 -I/opt/bluez/dbus-1.15.2/lib/dbus-1.0/include
    export GLIB_CFLAGS = -I/opt/bluez/glib-2.26.1/include/glib-2.0
    #如果make时报头文件不存在,则查看链接的头文件路径是否正确,是否是检查编译的库的路径
    
    ./configure --prefix=/opt/bluez/bluez-utils-3.36 --host=arm-linux --target=arm-linux CC="arm-linux-gnueabihf-gcc -I/opt/bluez/dbus-1.15.2/include/dbus-1.0 -I/opt/bluez/dbus-1.15.2/lib/dbus-1.0/include -I/opt/bluez/bluez-libs-3.36/include -I/opt/bluez/expat-2.5.0/include -L/opt/bluez/dbus-1.15.2/lib -L/opt/bluez/bluez-libs-3.36/lib -L/opt/bluez/expat-2.5.0/lib -I/opt/bluez/zlib-1.2.13/include -L/opt/bluez/zlib-1.2.13/lib -I/opt/bluez/glib-2.26.1/include/glib-2.0 -I/opt/bluez/glib-2.26.1/lib/glib-2.0/include -L/opt/bluez/glib-2.26.1/lib" --disable-audio
    make
    make install
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    拷贝至目标板

    #copy /opt/arm/bluez/sbin/* 到你的文件系统/sbin
    
    cp bluez/sbin/*   /sbin/
    
    #copy /opt/arm/bluez/bin/ 下的 hcitool,rfcomm,sdptool 到你的文件系统 /bin
    
    cp bluez/bin/*    /bin/
    
    #copy /opt/arm/bluez/lib/* 到文件系统的/lib下 
    
    #copy /opt/arm/bluez/etc/bluetooth/* 到你的文件系统 /etc
    
    cp bluez/etc/bluetooth  /etc/
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
  • 相关阅读:
    JSP与ASP、PHP的比较
    TikTok社交心理学:短视频如何连接人心
    【综合笔试题】30. 串联所有单词的子串
    Handler-线程间通信
    第十四届蓝桥杯省赛C++B组D题【飞机降落】题解(AC)
    Softing tManager模块为系统集成商架起IT到OT的桥梁
    抽空写了个小游戏(未完待续)
    如何让光从光纤平滑地进入波导?
    【无标题】
    简单了解一下:NodeJS的WebSocket网络编程
  • 原文地址:https://blog.csdn.net/tgdzsjh/article/details/127814508