目前共有3篇帖子。 字體大小:較小 - 100% (默認)▼  內容轉換:港澳繁體▼
 
點擊 回復
28 2
交叉編譯bluez藍牙協議棧(安裝到板子上的/opt/bluez目錄)
一派掌門 二十級
1樓 發表于:2025-6-24 20:54

交叉編譯器:arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-linux-gnueabihf

export PATH=$PATH:/home/oct1158/Downloads/arm-gnu-toolchain-14.2.rel1-x86_64-arm-none-linux-gnueabihf/bin


工作目錄:

mkdir ~/Downloads/bluez

cd ~/Downloads/bluez


【交叉編譯libffi-3.5.1】

wget https://github.com/libffi/libffi/releases/download/v3.5.1/libffi-3.5.1.tar.gz

tar xf libffi-3.5.1.tar.gz

cd libffi-3.5.1

./configure --host=arm-none-linux-gnueabihf --prefix=/opt/bluez

make

make install DESTDIR=$(pwd)/_install

cd ..


【交叉編譯zlib-1.3.1】

wget https://www.zlib.net/zlib-1.3.1.tar.gz

tar xf zlib-1.3.1.tar.gz

cd zlib-1.3.1

CC=arm-none-linux-gnueabihf-gcc AR=arm-none-linux-gnueabihf-ar LD=arm-none-linux-gnueabihf-ld ./configure --prefix=/opt/bluez

make

make install DESTDIR=$(pwd)/_install

cd ..


【交叉編譯glib-2.57.1】

glib-2.57.1是最後一個壓縮包裏面有configure腳本的版本。

glib-2.59.0是最後一個壓縮包裏面有configure.ac文件的版本。

從glib-2.59.1版本開始就只支持meson了,不再支持configure了。

wget https://download.gnome.org/sources/glib/2.57/glib-2.57.1.tar.xz

tar xf glib-2.57.1.tar.xz

cd glib-2.57.1

echo glib_cv_stack_grows=no > arm-linux.cache

echo glib_cv_uscore=no >> arm-linux.cache

./configure --host=arm-none-linux-gnueabihf --cache-file=arm-linux.cache --prefix=/opt/bluez --disable-libelf --disable-libmount --with-pcre=internal LIBFFI_CFLAGS=-I$(pwd)/../libffi-3.5.1/_install/opt/bluez/include LIBFFI_LIBS="-L$(pwd)/../libffi-3.5.1/_install/opt/bluez/lib -lffi" CFLAGS=-I$(pwd)/../zlib-1.3.1/_install/opt/bluez/include LDFLAGS=-L$(pwd)/../zlib-1.3.1/_install/opt/bluez/lib

make

make install DESTDIR=$(pwd)/_install


ModuleNotFoundError: No module named 'imp'解決方案:

修改py-compile文件,第119行和第140行的import sys, os, py_compile, imp,imp改成importlib,並在下一行賦值imp=importlib。


cd ..


【交叉編譯expat-2.7.1】

wget https://github.com/libexpat/libexpat/releases/download/R_2_7_1/expat-2.7.1.tar.gz

tar xf expat-2.7.1.tar.gz

cd expat-2.7.1

./configure --host=arm-none-linux-gnueabihf --prefix=/opt/bluez

make

make install DESTDIR=$(pwd)/_install

cd ..


【交叉編譯dbus-1.15.6】

dbus-1.15.6是最後一個壓縮包裏面有configure腳本的版本。

dbus-1.15.10是最後一個壓縮包裏面有configure.ac文件的版本。

從dbus-1.15.12版本開始就只支持meson了,不再支持configure了。

wget https://dbus.freedesktop.org/releases/dbus/dbus-1.15.6.tar.xz

tar xf dbus-1.15.6.tar.xz

cd dbus-1.15.6

./configure --host=arm-none-linux-gnueabihf --prefix=/opt/bluez EXPAT_CFLAGS=-I$(pwd)/../expat-2.7.1/_install/opt/bluez/include EXPAT_LIBS="-L$(pwd)/../expat-2.7.1/_install/opt/bluez/lib -lexpat"

make

make install DESTDIR=$(pwd)/_install

cd ..


【交叉編譯libical-3.0.20】

wget https://github.com/libical/libical/releases/download/v3.0.20/libical-3.0.20.tar.gz

tar xf libical-3.0.20.tar.gz

cd libical-3.0.20

CC=arm-none-linux-gnueabihf-gcc CXX=arm-none-linux-gnueabihf-g++ cmake . -DICAL_GLIB=False -DCMAKE_INSTALL_PREFIX=/opt/bluez

make

make install DESTDIR=$(pwd)/_install

cd ..


【交叉編譯readline-8.2.13】

wget https://ftp.gnu.org/gnu/readline/readline-8.2.13.tar.gz

tar xf readline-8.2.13.tar.gz

cd readline-8.2.13

./configure --host=arm-none-linux-gnueabihf --prefix=/opt/bluez

make

make install DESTDIR=$(pwd)/_install

cd ..


【交叉編譯ncurses-6.5】

wget https://ftp.gnu.org/gnu/ncurses/ncurses-6.5.tar.gz

tar xf ncurses-6.5.tar.gz

cd ncurses-6.5

./configure --host=arm-none-linux-gnueabihf --prefix=/opt/bluez --with-shared

make

修改progs/Makefile文件裏面第82行的INSTALL_PROG變量,在變量值的末尾添加

--strip-program=arm-none-linux-gnueabihf-strip

然後make install DESTDIR=$(pwd)/_install

cd ..


【交叉編譯bluez-5.66】

wget http://www.kernel.org/pub/linux/bluetooth/bluez-5.66.tar.xz

tar xf bluez-5.66.tar.xz

cd bluez-5.66

sudo dnf install python-docutils

./configure --host=arm-none-linux-gnueabihf --prefix=/opt/bluez --disable-udev --with-dbusconfdir=/root/bluetooth --with-dbussystembusdir=/root/bluetooth --with-dbussessionbusdir=/root/bluetooth --with-systemdsystemunitdir=/root/bluetooth --with-systemduserunitdir=/root/bluetooth DBUS_CFLAGS="-I$(pwd)/../dbus-1.15.6/_install/opt/bluez/include/dbus-1.0 -I$(pwd)/../dbus-1.15.6/_install/opt/bluez/lib/dbus-1.0/include" DBUS_LIBS="-L$(pwd)/../dbus-1.15.6/_install/opt/bluez/lib -ldbus-1" GLIB_CFLAGS="-I$(pwd)/../glib-2.57.1/_install/opt/bluez/include/glib-2.0 -I$(pwd)/../glib-2.57.1/_install/opt/bluez/lib/glib-2.0/include" GLIB_LIBS="-L$(pwd)/../glib-2.57.1/_install/opt/bluez/lib -lglib-2.0" ICAL_CFLAGS=-I$(pwd)/../libical-3.0.20/_install/opt/bluez/include ICAL_LIBS="-L$(pwd)/../libical-3.0.20/_install/opt/bluez/lib -lical -licalvcal" CFLAGS=-I$(pwd)/../readline-8.2.13/_install/opt/bluez/include LDFLAGS="-L$(pwd)/../readline-8.2.13/_install/opt/bluez/lib -L$(pwd)/../ncurses-6.5/_install/opt/bluez/lib -lncursesw"

make

make install DESTDIR=$(pwd)/_install

cd ..


【打包】

mkdir _install

sudo cp -r libffi-3.5.1/_install/* _install

sudo cp -r zlib-1.3.1/_install/* _install

sudo cp -r glib-2.57.1/_install/* _install

sudo cp -r expat-2.7.1/_install/* _install

sudo cp -r dbus-1.15.6/_install/* _install

sudo cp -r libical-3.0.20/_install/* _install

sudo cp -r readline-8.2.13/_install/* _install

sudo cp -r ncurses-6.5/_install/* _install

sudo cp -r bluez-5.66/_install/* _install

cd _install

tar czf bluez.tar.gz opt root

mv bluez.tar.gz /var/www/html/oct1158


一派掌門 二十級
2樓 發表于:2025-6-24 21:01

【安裝到板子上】

cd /mnt/sdfat

wget https://192.168.4.42/oct1158/bluez.tar.gz --no-check-certificate

tar xf bluez.tar.gz -C /


【在板子上運行】

[root@luckfox-rv1106 ~]# /opt/bluez/bin/btmon

/opt/bluez/bin/btmon: error while loading shared libraries: libglib-2.0.so.0: cannot open shared object file: No such file or directory

[root@luckfox-rv1106 ~]# LD_LIBRARY_PATH=/opt/bluez/lib /opt/bluez/bin/btmon

Bluetooth monitor ver 5.66

Failed to open channel: Address family not supported by protocol

[root@luckfox-rv1106 ~]#

 
一派掌門 二十級
3樓 發表于:2025-6-25 11:20

下面7個命令,要在編譯bluez-5.66的時候,./configure加上--enable-deprecated選項才能編譯出來。

ciptool

hciattach

hciconfig

hcidump

hcitool

rfcomm

sdptool


./configure --host=arm-none-linux-gnueabihf --prefix=/opt/bluez --disable-udev --enable-deprecated --with-dbusconfdir=/root/bluetooth --with-dbussystembusdir=/root/bluetooth --with-dbussessionbusdir=/root/bluetooth --with-systemdsystemunitdir=/root/bluetooth --with-systemduserunitdir=/root/bluetooth DBUS_CFLAGS="-I$(pwd)/../dbus-1.15.6/_install/opt/bluez/include/dbus-1.0 -I$(pwd)/../dbus-1.15.6/_install/opt/bluez/lib/dbus-1.0/include" DBUS_LIBS="-L$(pwd)/../dbus-1.15.6/_install/opt/bluez/lib -ldbus-1" GLIB_CFLAGS="-I$(pwd)/../glib-2.57.1/_install/opt/bluez/include/glib-2.0 -I$(pwd)/../glib-2.57.1/_install/opt/bluez/lib/glib-2.0/include" GLIB_LIBS="-L$(pwd)/../glib-2.57.1/_install/opt/bluez/lib -lglib-2.0" ICAL_CFLAGS=-I$(pwd)/../libical-3.0.20/_install/opt/bluez/include ICAL_LIBS="-L$(pwd)/../libical-3.0.20/_install/opt/bluez/lib -lical -licalvcal" CFLAGS=-I$(pwd)/../readline-8.2.13/_install/opt/bluez/include LDFLAGS="-L$(pwd)/../readline-8.2.13/_install/opt/bluez/lib -L$(pwd)/../ncurses-6.5/_install/opt/bluez/lib -lncursesw"

 

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
(快捷鍵:Ctrl+Enter)
 

本帖信息

點擊數:28 回複數:2
評論數: ?
作者:巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2025-6-25 11:20
 
©2010-2025 Purasbar Ver2.0
除非另有聲明,本站採用共享創意姓名標示-相同方式分享 3.0 Unported許可協議進行許可。