arm Linux支持蓝牙耳机(采集播放)

arm Linux支持蓝牙耳机(采集播放)

一,移植blueZ
1,依赖expat,ncurses,readline,libical,eudev,dbus分别交叉编译
重编dbus
./configure --prefix=/mnt --libexecdir=/home/disk3/zuoNan/bluez/install/libexec --libdir=/home/disk3/zuoNan/bluez/install/lib --includedir=/home/disk3/zuoNan/bluez/install/include --datarootdir=/mnt/ --host=arm-hisiv500-linux CC=arm-hisiv500-linux-gcc CFLAGS=-I/home/disk3/zuoNan/bluez/install/include LDFLAGS="-L/home/disk3/zuoNan/bluez/install/lib -lintl" --cache-file=arm-linux.cache --with-x=no --with-dbus-user=root --with-system-socket=/var/run/dbus/system_bus_socket --with-systemduserunitdir=/var/run/dbus/
增加
–with-dbus-user=root
–with-system-socket=/var/run/dbus/system_bus_socket
–with-systemduserunitdir=/var/run/dbus/
–prefix=/mnt 会影响移植到开发板中system.conf的路径

开始向开发板移植
1,cp dbus-demon 到/mnt
/mnt/lib # tftp -g 172.168.100.14 -r libdbus-1.so.3
/mnt/lib # tftp -g 172.168.100.14 -r libexpat.so.1
Q1
./dbus-daemon --system --print-pid --print-address --nopidfile
Failed to start message bus: Failed to open “/mnt/dbus-1/system.conf”: No such file or directory
mkdir /mnt/dbus-1/
system.conf考进来
Q2
Failed to start message bus: Failed to bind socket “/var/run/dbus/system_bus_socket”: No such file or directory

mkdir /var/run/dbus/ -p

./dbus-daemon --system --print-pid --print-address --nopidfile
unix:path=/var/run/dbus/system_bus_socket,guid=ec2b4ac03fc7a6f84b4f43a1614dd2131117

成功起来了

2,交叉编译blueZ
./configure --prefix=/mnt --host=arm-hisiv500-linux --target=arm-hisiv500-linux --enable-library --disable-udev GLIB_LIBS=/home/disk3/zuoNan/bluez/install/lib/libglib-2.0.so GLIB_CFLAGS=-I/home/disk3/zuoNan/bluez/install/include/glib-2.0/ DBUS_LIBS=/home/disk3/zuoNan/bluez/install/lib/libdbus-1.so DBUS_CFLAGS=-I/home/disk3/zuoNan/bluez/install/include/dbus-1.0 LDFLAGS="-L/home/disk3/zuoNan/bluez/install/lib/ -lncurses" CC=“arm-hisiv500-linux-gcc -I/home/disk3/zuoNan/bluez/install/include -I/home/disk3/zuoNan/bluez/install/include/glib-2.0 -I/home/disk3/zuoNan/bluez/install/lib/dbus-1.0/include/ -L/home/disk3/zuoNan/bluez/install/lib -lncurses -lintl” --with-systemduserunitdir=/home/disk3/zuoNan/bluez/install/ --with-systemdsystemunitdir=/home/disk3/zuoNan/bluez/install/

make

3,报错
/home/disk3/zuoNan/bluez/install/lib/libreadline.so: undefined reference to tgoto' /home/disk3/zuoNan/bluez/install/lib/libreadline.so: undefined reference totgetflag’
/home/disk3/zuoNan/bluez/install/lib/libreadline.so: undefined reference to PC' /home/disk3/zuoNan/bluez/install/lib/libreadline.so: undefined reference totgetstr’
/home/disk3/zuoNan/bluez/install/lib/libreadline.so: undefined reference to UP' /home/disk3/zuoNan/bluez/install/lib/libreadline.so: undefined reference totputs’
/home/disk3/zuoNan/bluez/install/lib/libreadline.so: undefined reference to tgetent' /home/disk3/zuoNan/bluez/install/lib/libreadline.so: undefined reference toBC’
/home/disk3/zuoNan/bluez/install/lib/libreadline.so: undefined reference to `tgetnum’
解决:
make -n > make.log找到对应的make
在最后面加上-lncurses
例:
echo " CCLD " client/bluetoothctl;/bin/sh ./libtool --silent --tag=CC --mode=link arm-hisiv500-linux-gcc -I/home/disk3/zuoNan/bluez/install/include -I/home/disk3/zuoNan/bluez/install/include/glib-2.0 -I/home/disk3/zuoNan/bluez/install/lib/dbus-1.0/include/ -L/home/disk3/zuoNan/bluez/install/lib -lncurses -lintl -g -O2 -L/home/disk3/zuoNan/bluez/install/lib/ -o client/bluetoothctl client/main.o client/display.o client/agent.o client/advertising.o client/adv_monitor.o client/gatt.o gdbus/libgdbus-internal.la src/libshared-glib.la /home/disk3/zuoNan/bluez/install/lib/libglib-2.0.so /home/disk3/zuoNan/bluez/install/lib/libdbus-1.so -lreadline -lncurses

4,向开发板移植
./bluetoothd -n -d &
Q1
/mnt # bluetoothd[1208]: Bluetooth daemon 5.56
D-Bus setup failed: Connection “:1.0” is not allowed to own the service “org.bluez” due to security policies in the configuration file
bluetoothd[1208]: src/main.c:main() Unable to get on D-Bus
A1
/mnt/etc/dbus-1/system.d/bluetooth.conf

Q2
bluetoothd[2011]: src/adapter.c:adapter_init() Failed to access management interface
bluetoothd[2011]: src/main.c:main() Adapter handling initialization failed
A2
烧录新的uimage解决(make menuconfig 勾选蓝牙相关选项)

二,移植blueasla(勾起bluez 和 alsa)
1,依赖libsndfile-1.0.28,lib-alsa,alsa-utils,sbc,fdk_aac,glib,dbus分别交叉编译
2,交叉编译blueasla
./configure --prefix=/home/disk3/zuoNan/pulseAudio/bluez-alsa-master/bluez-alsa-master/install_dir --enable-aac --enable-debug --host=arm-hisiv500-linux CC=arm-hisiv500-linux-gcc CFLAGS="-I/home/disk3/zuoNan/bluez/bluez-5.56-zzc/lib -I/home/disk3/zuoNan/pulseAudio/sbc-1.3/install_dir/include -I/home/disk3/zuoNan/pulseAudio/fdk-aac-2.0.2/install_dir/include -I/home/disk3/zuoNan/pulseAudio/alsa-lib-1.2.5.1/install_dir/include -I/home/disk3/zuoNan/bluez/install/include" LDFLAGS="-L/home/disk3/zuoNan/bluez/install_new/lib -lbluetooth -L/home/disk3/zuoNan/pulseAudio/sbc-1.3/install_dir/lib -lsbc -L/home/disk3/zuoNan/pulseAudio/fdk-aac-2.0.2/install_dir/lib -lfdk-aac -L/home/disk3/zuoNan/pulseAudio/alsa-lib-1.2.5.1/install_dir/lib -lasound -L/home/disk3/zuoNan/bluez/install/lib -ldbus-1" BLUEZ_LIBS=-L/home/disk3/zuoNan/bluez/install_new/lib BLUEZ_CFLAGS=-I/home/disk3/zuoNan/bluez/bluez-5.56-zzc/lib SBC_CFLAGS=-I/home/disk3/zuoNan/pulseAudio/sbc-1.3/install_dir/include SBC_LIBS=-L/home/disk3/zuoNan/pulseAudio/sbc-1.3/install_dir/lib AAC_CFLAGS=-I/home/disk3/zuoNan/pulseAudio/fdk-aac-2.0.2/install_dir/include AAC_LIBS=-L/home/disk3/zuoNan/pulseAudio/fdk-aac-2.0.2/install_dir/lib DBUS1_CFLAGS="-I/home/disk3/zuoNan/bluez/install/include/dbus-1.0 -I/home/disk3/zuoNan/bluez/install/lib/dbus-1.0/include/" DBUS1_LIBS=-L/home/disk3/zuoNan/bluez/install/lib ALSA_CFLAGS=-I/home/disk3/zuoNan/pulseAudio/alsa-lib-1.2.5.1/install_dir/include ALSA_LIBS="-L/home/disk3/zuoNan/pulseAudio/alsa-lib-1.2.5.1/install_dir/lib -lasound" GLIB2_CFLAGS="-I/home/disk3/zuoNan/glib45/glib_install/include/glib-2.0 -I/home/disk3/zuoNan/glib45/glib_install/lib/glib-2.0/include -I/home/disk3/zuoNan/glib45/glib_install/include/gio-unix-2.0" GLIB2_LIBS="-L/home/disk3/zuoNan/glib45/glib_install/lib -lglib-2.0" GIO2_CFLAGS=-I/home/disk3/zuoNan/bluez/install/include GIO2_LIBS="-L/home/disk3/zuoNan/bluez/install/lib -lgio-2.0 -lgobject-2.0"

make

3,移植到开发板
cp libasound.so.2/libasound_module_pcm_bluealsa.so/libgio-2.0.so.0/libgmodule-2.0.so.0/libgobject-2.0.so.0/libsbc.so.1/bluealsa 到/mnt/lib

vi /mnt/etc/dbus-1/system.d/bluetooth.conf
添加



4,配置alsa相关
export ALSA_CONFIG_PATH=/mnt/alsa/alsa.conf

/mnt/alsa/alsa.conf -> /etc/asound.conf ->pcmname:default

新建/etc/asound.conf(蓝牙声卡信息)
pcm.!default{
type plug
slave.pcm {
type bluealsa
device “B9:CE:28:DF:78:2A”
profile “sco”
delay 1000
}
hint {
show on
description “BT Speaker”
}
}

5,起bluealsa
./bluealsa -p a2dp-source -p a2dp-sink -p hfp-hf -p hfp-ag -p hsp-hs -p hsp-ag

6,蓝牙连接耳机
./hciconfig hci0 up

./bluetoothctl
scan on
trust B9:CE:28:DF:78:2A
pair B9:CE:28:DF:78:2A
connect B9:CE:28:DF:78:2A

7,播放,录音测试
播放
./aplay -D default /mnt/picture/welcome.wav

录音
pcm_read一直阻塞,后来加-N非阻塞
./arecord -f cd -D default -N test.wav

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值