编译dbus
export CFLAGS="-I/usr/local/musl/include  "
export LDFLAGS="-L/usr/local/musl/lib"
./configure \
  --host=arm-linux-musleabi \
  --prefix=/data/musl/usr \
  --sysconfdir=/data/musl/etc \
  --datadir=/data/musl/share \
  --disable-systemd \
  --disable-tests \
  --disable-xml-docs

编译musl-obstack
wget https://codeload.github.com/void-linux/musl-obstack/zip/refs/heads/master -O musl_obstack.zip

编译 fts_close
wget https://codeload.github.com/void-linux/musl-fts/zip/refs/heads/master -O musl_fts.zip
export CFLAGS="-I/usr/local/musl/include --static "
export LDFLAGS="-L/usr/local/musl/lib --static"
./configure --host=arm-linux-musleabi --prefix=/usr/local/musl

编译libargp//修改函数名称arm-linux-musleabi-nm ./libargp.a | grep argp_parse
git clone https://github.com/argp/argp-standalone.git
cd argp-standalone
使用你的交叉工具链编译:
./configure --host=arm-linux-musleabi --prefix=/usr/local/musl
make
make install


编译libelf 
export CFLAGS="-I/usr/local/musl/include --static "
export LDFLAGS="-L/usr/local/musl/lib  -lz -largp -lfts -lobstack --static "
./configure --host=arm-linux-musleabi --program-prefix=/usr/local/musl  --disable-libdebuginfod --disable-debuginfod
make
make install


编译zlib
export CC=arm-linux-musleabi-gcc
export AR=arm-linux-musleabi-ar
export RANLIB=arm-linux-musleabi-ranlib
export CFLAGS="-Os -fPIC"
export PREFIX=/usr/local/musl

./configure --static --prefix=$PREFIX
make
make install

编译libmount
禁用

编译blkid
禁用

编译ffi
./configure \
  CC=arm-linux-musleabi-gcc \
  --host=arm-linux-musleabi \
  --prefix=/usr/local/musl \
  --disable-shared \
  --enable-static \
  CFLAGS="-O2 -static" \
  LDFLAGS="-static"

make -j$(nproc)
make install


编译pcre
./configure \
  CC=arm-linux-musleabi-gcc \
  --host=arm-linux-musleabi \
  --prefix=/usr/local/musl \
  --disable-shared \
  --enable-static \
  CFLAGS="-O2 -static" \
  LDFLAGS="-static"

make -j16 && make install


arm musl 编译 glib

cross.txt
[binaries]
c = 'arm-linux-musleabi-gcc'
cpp = 'arm-linux-musleabi-g++'
ar = 'arm-linux-musleabi-ar'
strip = 'arm-linux-musleabi-strip'
pkgconfig = 'pkg-config'

[properties]
c_args = ['-static']
cpp_args = ['-static']
needs_exe_wrapper = true

[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'armv7'
endian = 'little'


命令
meson setup --cross-file=../cross.txt --prefix=/usr/local/musl   -Ddefault_library=static   -Dtests=false -Dinstalled_tests=false -Dman=false -Dgtk_doc=false -Dlibmount=disabled -Dselinux=disabled

ninja 
ninja install


编译expat
./configure --host=arm-linux-musleabi --disable-shared --enable-static --prefix=/usr/local/musl
make 
make install

编译D-bus
./configure --host=arm-linux-musleabi --disable-shared --enable-static --prefix=/usr/local/musl
make 
make install

编译ncurse
./configure --host=arm-linux-musleabi --disable-shared --enable-static --prefix=/usr/local/musl  STRIP=/ohos/bluz_deng/arm-linux-musleabi-cross/bin/arm-linux-musleabi-strip
make 
make install STRIP=/ohos/bluz_deng/arm-linux-musleabi-cross/bin/arm-linux-musleabi-strip

编译bluez
export CFLAGS="-I/usr/local/musl/include --static "
export LDFLAGS="-L/usr/local/musl/lib --static"
export CC=arm-linux-musleabi-gcc
export CXX=arm-linux-musleabi-g++
export AR=arm-linux-musleabi-ar
export AS=arm-linux-musleabi-as
export LD=arm-linux-musleabi-ld
export RANLIB=arm-linux-musleabi-ranlib
export STRIP=arm-linux-musleabi-strip
export PKG_CONFIG_PATH=export SYSROOT=/ohos/bluz_deng/arm-linux-musleabi-cross/arm-linux-musleabi/usr/lib/pkgconfig
export SYSROOT=/ohos/bluz_deng/arm-linux-musleabi-cross/arm-linux-musleabi

./configure \
  --host=arm-linux-musleabi \
  --prefix=/data/bluez \
  --disable-systemd \
  --disable-udev \
  --disable-obex \
  --disable-cups \
  --enable-tools \
  --enable-client \
  --disable-manpages \
  CFLAGS="--static -I$SYSROOT/usr/include -I/usr/local/musl/include -I./lib"  \
  LDFLAGS="--static -L$SYSROOT/usr/lib -L/usr/local/musl/lib" \
  LIBS="-lreadline -lncurses"

make -j$(nproc)
make install


解决glib依赖到x86的问题
pkg-config --cflags glib-2.0
export PKG_CONFIG_PATH=/usr/local/musl/lib/pkgconfig
export PKG_CONFIG_SYSROOT_DIR=/
export PKG_CONFIG_LIBDIR=/usr/local/musl/lib/pkgconfig

 

使用bluez 验证蓝牙模块是否可以进行扫描和连接


PATH=$PATH:/data/tools
PATH=$PATH:/data/install/bin
PATH=$PATH:/data/musl/usr/bin

//重新编译 dbus
//配置system.conf
 dbus-daemon --system --nopidfile --fork
 export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/data/musl/var/run/dbus/system_bus_socket


蓝牙模块
60:58:01:55:66:25

手机:
59:65:69:15:BB:04

[DEL] Device 77:3F:CD:3E:63:90 Dengdeng

mkdir -p /data/tmp/bluetooth/cache
/data/tools/bluetoothd -n -d  -P /data/tmp/bluetooth

bluetoothctl
[bluetooth]# power on
[bluetooth]# agent on
[bluetooth]# default-agent
[bluetooth]# scan on

[bluetooth]# pair 59:65:69:15:BB:04
[bluetooth]# trust 59:65:69:15:BB:04
[bluetooth]# connect 59:65:69:15:BB:04


bluetoothctl <<EOF
power on
agent on
default-agent
pairable on
discoverable on
EOF

btmgmt name MyDevice

btmgmt advertise on


3    bluetoothctl pair <bd-mac>    配对蓝牙设备
4    bluetoothctl connect  <bd-mac>    连接蓝牙设备
5    bluetoothctl disconnect <bd-mac>    断开蓝牙设备
6    bluetoothctl power on    蓝牙开
7    bluetoothctl power off    蓝牙关


脚本化控制:
bluetoothctl <<EOF
power on
agent on
default-agent
scan on
EOF


接收蓝牙的通知消息
bluetoothctl
#[bluetooth]# menu gatt
#list-attributes 59:65:69:15:BB:04
[bluetooth]# select-attribute 0x0027
[bluetooth]# notify on
[bluetooth]# read
[bluetooth]# back
[bluetooth]# disconnect F4:22:7A:71:FB:BB

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐