交叉编译并移植蓝牙协议栈bluez 。
交叉编译并移植bluez,网上已有很多相关教程,需要根据教程下载很多包,交叉编译过程中会遇到编译报错,或者包依赖错误等问题,这里将交叉编译成功的bluez的整套代码及编译配置过程贴出来,供大家参考!
这里以fsl平台交叉工具链编译为例,你可以配置自己的编译工具链。
交叉编译过程简单记录如下:
Cross-compiler:
fsl-imx-x11-glibc-x86_64-fsl-image-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.0.sh
Install the compiler:
$chmod 777 fsl-imx-x11-glibc-x86_64-fsl-image-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.0.sh
$./fsl-imx-x11-glibc-x86_64-fsl-image-qt5-cortexa9hf-vfp-neon-toolchain-3.14.52-1.1.0.sh
Follow the prompts to enter the tool chain directory(the default is /opt/fsl-imx-x11/)
Import the environment Var for the cross-compile tools:
$source /opt/fsl-imx-x11/3.14.52-1.1.0/environment-setup-cortexa9hf-vfp-neon-poky-linux-gnueabi
1,Compile bluez-hcidump
bluez-hcidump-configure:
cd bluez/bluez-hcidump && ./configure \
--host=arm-linux \
--prefix=$(INSTALLDIR)/bluez-hcidump
bluez-hcidump:
make -C bluez/bluez-hcidump
bluez-hcidump-clean:
make -C bluez/bluez-hcidump clean
bluez-hcidump-install:
make -C bluez/bluez-hcidump install
bluez-hcidump-distclean:
make -C bluez/bluez-hcidump distclean
2,Compile openobex_ln
openobex-configure:
if [ ! -e "bluez/openobex_ln/mybuild" ] ; then mkdir bluez/openobex_ln/mybuild;fi
cd bluez/openobex_ln/mybuild && ../configure \
--enable-usb \
--disable-irda \
--enable-apps \
--enable-bluetooth \
--prefix= \
--target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --build=x86_64-linux
openobex:
cd bluez/openobex_ln/mybuild && make
openobex-clean:
rm -rf bluez/openobex_ln/mybuild
openobex-install:
cd bluez/openobex_ln/mybuild && \
make DESTDIR=$(TOP)/lib_install install
cd bluez/openobex_ln/mybuild && make DESTDIR=$(INSTALLDIR)/bluez install
openobex-distclean:
rm -rf bluez/openobex_ln/mybuild
3,Compile obexftp_ln
(SDKTARGETSYSROOT=/opt/fsl-imx-x11/3.14.52-1.1.0/sysroots/cortexa9hf-vfp-neon-poky-linux-gnueabi)
obexftp-configure:
if [ ! -e "bluez/obexftp_ln/configure" ] ; then \
cd bluez/obexftp_ln && aclocal --force -I m4; \
libtoolize --copy --force; \
autoconf --force; \
autoheader --force; \
automake --add-missing --copy --force-missing; \
fi
cd bluez/obexftp_ln && ./configure \
--disable-python \
--target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --build=x86_64-linux \
--with-sysroot=${SDKTARGETSYSROOT} \
OPENOBEX_CFLAGS="-I$(TOP)/lib_install/usr/local/include" \
OPENOBEX_LIBS="$(TOP)/lib_install/usr/local/lib/libopenobex.la" \
--disable-builddocs \
--disable-perl \
--disable-ruby \
--disable-tcl \
--without-libiconv-prefix \
--disable-dependency-tracking \
--disable-swig
obexftp:
cd bluez/obexftp_ln && make
obexftp-clean:
cd bluez/obexftp_ln && make clean
obexftp-distclean:
cd bluez/obexftp_ln && make distclean
rm -rf bluez/obexftp_ln/build
obexftp-install:
install -d $(INSTALLDIR)/obexftp/usr/sbin
install -d $(INSTALLDIR)/obexftp/usr/lib
install -D $(TOP)/bluez/obexftp_ln/apps/.libs/obexftp $(INSTALLDIR)/obexftp/usr/sbin
install -D $(TOP)/bluez/obexftp_ln/apps/.libs/obexftpd $(INSTALLDIR)/obexftp/usr/sbin
install -D $(TOP)/bluez/obexftp_ln/obexftp/.libs/libobexftp.so.0.3.0 $(INSTALLDIR)/obexftp/usr/lib
install -D $(TOP)/bluez/obexftp_ln/multicobex/.libs/libmulticobex.so.1 $(INSTALLDIR)/obexftp/usr/lib
install -D $(TOP)/bluez/obexftp_ln/bfb/.libs/libbfb.so.0.0.5 $(INSTALLDIR)/obexftp/usr/lib
4,Compile bluez
bluez-configure:
cd bluez/bluez && ./configure \
--with-sysroot=${SDKTARGETSYSROOT} \
--target=arm-poky-linux-gnueabi --host=arm-poky-linux-gnueabi --build=x86_64-linux \
--enable-usb \
--enable-tools \
--enable-bccmd \
--enable-dfutool \
--enable-test \
--enable-hidd \
--enable-hid2hci \
--enable-datafiles \
--enable-alsa \
--enable-pand
bluez:
cd bluez/bluez && make
bluez-clean:
make -C bluez/bluez clean
bluez-distclean:
make -C bluez/bluez distclean
rm -f bluez/bluez/test/agent
bluez-install:
make DESTDIR=$(INSTALLDIR)/bluez -C bluez/bluez install
make DESTDIR=$(TOP)/lib_install -C bluez/bluez install
mkdir -p $(INSTALLDIR)/bluez/sbin && install -D $(TOP)/bluez/bluez/src/bluetoothd $(INSTALLDIR)/bluez/sbin/
rm -rf $(INSTALLDIR)/bluez/var
rm -rf $(INSTALLDIR)/bluez/include
rm -rf $(INSTALLDIR)/bluez/usr/local/include
cp -rvf $(INSTALLDIR)/bluez/usr/local/* $(INSTALLDIR)/bluez
rm -rf $(INSTALLDIR)/bluez/usr/local
TO finish these,the bluez will be installed into the INSTALLDIR directory.Then just copy it to the board.