1 说明
rtl8723DS是Wi-Fi、蓝牙二合一芯片方案。Wi-Fi支持2.4G频段,支持AP与STA共存的工作模式,使用SDIO接口。蓝牙支持4.2协议,使用UART接口。本文内容来源于调试hi3518ev300的过程中总结的经验。可从官网下载相应软件包或者从百度网盘下载。
链接:https://pan.baidu.com/s/1VspMNhDiOYRUnOmzQeQJGQ
提取码:n1ns
2 环境描述
2.1 PC端操作系统
ubuntu1604-desktop或者ubuntu1604-server
2.2 嵌入式板端操作系统
linux,kernel: 4.9.37
2.3 嵌入式板端硬件平台
hi3518ev300,BSP:[Hi3516EV200_MPP_V1.0.1.1 B030 Release],Build Time[Jun 17 2019, 11:19:14],编译链:arm-himix100-linux-gcc,RTL8723DS WiFi、蓝牙二合一模组。
3 移植bluez 5.18
3.1 主要参考网址
https://whycan.com/p_9532.html
https://www.cnblogs.com/dong1/p/8271385.html
https://wiki.beyondlogic.org/index.php?title=Cross_Compiling_BlueZ_Bluetooth_tools_for_ARM
https://www.cnblogs.com/dylancao/p/11712833.html
3.2 zlib
tar -xzf zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure --prefix=/tmp
修改Makefile,将相关变量的值修改为如下所示:
CC=arm-himix100-linux-gcc
LDSHARED=arm-himix100-linux-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
CPP=arm-himix100-linux-gcc -E
AR=arm-himix100-linux-ar
RANLIB=arm-himix100-linux-ranlib
make
make install
问题:make: arm-himix100-linux-gcc: Command not found
解决办法:apt install lib32z1-dev
问题:arm-himix100-linux-gcc: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
解决办法:sudo apt-get install lib32stdc++6
3.3 libffi
tar -xzf libffi-3.0.13.tar.gz
cd libffi-3.0.13/
./configure --host=arm-himix100-linux --prefix=/tmp
make
make install
3.4 gettext
tar xzf gettext-0.20.2.tar.gz
cd gettext-0.20.2/
./configure --host=arm-himix100-linux --prefix=/tmp
make
make install
该过程主要防止出现如下错误:
checking for libintl.h... no
configure: error:
*** You must have either have gettext support in your C library, or use the
*** GNU gettext library. (http://www.gnu.org/software/gettext/gettext.html
3.5 libglib2.0-dev
sudo apt-get install libglib2.0-dev
该过程主要防止出现如下错误:
checking for glib-genmarshal... no
configure: error: Could not find a glib-genmarshal in your PATH
3.6 glib
tar xJf glib-2.40.0.tar.xz
cd glib-2.40.0/
CC=arm-himix100-linux-gcc ./configure --host=arm-himix100-linux LIBFFI_CFLAGS="-I/tmp/lib/libffi-3.0.13/include" LIBFFI_LIBS="-lffi -L/tmp/lib" ZLIB_CFLAGS="-I/tmp/include" ZLIB_LIBS="-lz -L/tmp/lib" --prefix=/tmp PKG_CONFIG_PATH=/tmp/lib/pkgconfig glib_cv_stack_grows=no glib_cv_uscore=yes ac_cv_func_posix_getpwuid_r=yes ac_cv_func_posix_getgrgid_r=yes CFLAGS="-I/tmp/include" CPPFLAGS="-I/tmp/include" LDFLAGS="-L/tmp/lib" PKG_CONFIG_PATH=/tmp/lib/pkgconfig
make
make install
问题:gdate.c: In function 'g_date_strftime':
gdate.c:2497:7: error: format not a string literal, format string not checked [-Werror=format-nonliteral]
tmplen = strftime (tmpbuf, tmpbufsize, locale_format, &tm);
解决办法:在g_date_strftime的定义前添加#pragma GCC diagnostic push、
#pragma GCC diagnostic ignored "-Wformat-nonliteral",在g_date_strftime的定义后添加#pragma GCC diagnostic pop,形如:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
gsize
g_date_strftime (gchar *s,
gsize slen,
const gchar *format,
const GDate *d)
{
......
}
#pragma GCC diagnostic pop
3.7 expat
tar xzf expat-2.1.0.tar.gz
cd expat-2.1.0/
./configure --host=arm-himix100-linux --prefix=/tmp
make
make install
3.8 dbus
tar xzf dbus-1.8.0.tar.gz
cd dbus-1.8.0/
CC=arm-himix100-linux-gcc ./configure --host=arm-himix100-linux --prefix=/tmp --sysconfdir=/etc LDFLAGS="-L/tmp/lib" CFLAGS="-I/tmp/include" PKG_CONFIG_PATH=/tmp/lib/pkgconfig --with-dbus-user=root
make
make install
sysconfdir指定配置文件放在/etc/dbus目录下(/etc/dbus-1/system.conf、/etc/dbus-1/system.d/bluetooth.conf),--with-dbus-user指定dbus后台程序默认的用户为root(如果不指定则为用户messagebus)
问题:
/opt/hisi-linux/x86-arm/arm-himix100-linux/host_bin/../lib/gcc/arm-linux-uclibceabi/6.3.0/../../../../arm-linux-uclibceabi/bin/ld: warning: libffi.so.6, needed by /tmp/lib/libgio-2.0.so, not found (try using -rpath or -rpath-link)
/opt/hisi-linux/x86-arm/arm-himix100-linux/host_bin/../lib/gcc/arm-linux-uclibceabi/6.3.0/../../../../arm-linux-uclibceabi/bin/ld: warning: libgmodule-2.0.so.0, needed by /tmp/lib/libgio-2.0.so, not found (try using -rpath or -rpath-link)
/opt/hisi-linux/x86-arm/arm-himix100-linux/host_bin/../lib/gcc/arm-linux-uclibceabi/6.3.0/../../../../arm-linux-uclibceabi/bin/ld: warning: libz.so.1, needed by /tmp/lib/libgio-2.0.so, not found (try using -rpath or -rpath-link)
/tmp/lib/libgobject-2.0.so: undefined reference to `ffi_type_void'
/tmp/lib/libgobject-2.0.so: undefined reference to `ffi_type_double'
/tmp/lib/libgobject-2.0.so: undefined reference to `ffi_prep_cif'
/tmp/lib/libgio-2.0.so: undefined reference to `inflate'
/tmp/lib/libgio-2.0.so: undefined reference to `deflateSetHeader@ZLIB_1.2.2'
/tmp/lib/libgio-2.0.so: undefined reference to `g_module_error'
/tmp/lib/libgobject-2.0.so: undefined reference to `ffi_type_sint32'
/tmp/lib/libgio-2.0.so: undefined reference to `deflateReset'
/tmp/lib/libgio-2.0.so: undefined reference to `deflate'
/tmp/lib/libgobject-2.0.so: undefined reference to `ffi_type_float'
/tmp/lib/libgobject-2.0.so: undefined reference to `ffi_type_uint64'
/tmp/lib/libgobject-2.0.so: undefined reference to `ffi_type_sint64'
/tmp/lib/libgio-2.0.so: undefined reference to `deflateInit2_'
/tmp/lib/libgio-2.0.so: undefined reference to `g_module_close'
/tmp/lib/libgio-2.0.so: undefined reference to `inflateGetHeader@ZLIB_1.2.2'
/tmp/lib/libgio-2.0.so: undefined reference to `deflateInit_'
/tmp/lib/libgobject-2.0.so: undefined reference to `ffi_type_pointer'
/tmp/lib/libgobject-2.0.so: undefined reference to `ffi_type_uint32'
/tmp/lib/libgio-2.0.so: undefined reference to `inflateEnd'
/tmp/lib/libgio-2.0.so: undefined reference to `g_module_open'
/tmp/lib/libgio-2.0.so: undefined reference to `deflateEnd'
/tmp/lib/libgio-2.0.so: undefined reference to `inflateInit_'
/tmp/lib/libgobject-2.0.so: undefined reference to `ffi_call'
/tmp/lib/libgio-2.0.so: undefined reference to `inflateInit2_'
/tmp/lib/libgio-2.0.so: undefined reference to `g_module_supported'
/tmp/lib/libgio-2.0.so: undefined reference to `inflateReset'
/tmp/lib/libgio-2.0.so: undefined reference to `g_module_symbol'
解决办法:
将相关库文件拷贝到编译链的安装路径并创建软链接
cp /tmp/lib/libffi.so.6.0.1 /opt/hisi-linux/x86-arm/arm-himix100-linux/target/lib/
cd /opt/hisi-linux/x86-arm/arm-himix100-linux/target/lib/
ln -s libffi.so.6.0.1 libffi.so.6
ln -s libffi.so.6.0.1 libffi.so
cp /tmp/lib/libgmodule-2.0.so.0.4000.0 /opt/hisi-linux/x86-arm/arm-himix100-linux/target/lib/
cd /opt/hisi-linux/x86-arm/arm-himix100-linux/target/lib/
ln -s libgmodule-2.0.so.0.4000.0 libgmodule-2.0.so.0
ln -s libgmodule-2.0.so.0.4000.0 libgmodule-2.0.so
cp /tmp/lib/libz.so.1.2.8 /opt/hisi-linux/x86-arm/arm-himix100-linux/target/lib/
cd /opt/hisi-linux/x86-arm/arm-himix100-linux/target/lib/
ln -s libz.so.1.2.8 libz.so
ln -s libz.so.1.2.8 libz.so.1
3.9 cmake
sudo apt-get install cmake
3.10 libical
tar xzf libical-1.0.tar.gz
cd libical-1.0/
export CC=arm-himix100-linux-gcc
export CXX=arm-himix100-linux-g++
cmake -DCMAKE_INSTALL_PREFIX=/tmp
make
make install
3.11 ncurses
tar -xzf ncurses-5.9.tar.gz
cd ncurses-5.9
export CPPFLAGS="-P"
CC=arm-himix100-linux-gcc ./configure --host=arm-himix100-linux --prefix=/tmp CXX=arm-himix100-linux-g++
make
make install
问题:In file included from ../ncurses/curses.priv.h:283:0,
from ../ncurses/lib_gen.c:19:
_51319.c:835:15: error: expected ')' before 'int'
../include/curses.h:1594:56: note: in definition of macro 'mouse_trafo'
#define mouse_trafo(y,x,to_screen) wmouse_trafo(stdscr,y,x,to_screen)
解决办法:在执行./configure之前执行export CPPFLAGS="-P"
3.12 readline
tar -xzf readline-6.3.tar.gz
cd readline-6.3/
./configure --host=arm-himix100-linux --prefix=/tmp bash_cv_wcwidth_broken=yes LDFLAGS="-L/tmp/lib"
make SHLIB_LIBS=-lncurses
make install
3.13 bluez
tar -xJf bluez-5.18.tar.xz
cd bluez-5.18
./configure --host=arm-himix100-linux --prefix=/tmp/ PKG_CONFIG_PATH=/tmp/lib/pkgconfig --disable-systemd --disable-udev --disable-cups --disable-obex --enable-library CFLAGS="-I/tmp/include"
make
make install
注意,如果需要执行obex传送文件,则要把--disable-obex去掉。
3.14 收尾
至此,/tmp目录下包含了blueZ套件运行的库文件(静态库和动态库)、头文件、可执行文件。
root@ubuntu:/home/lijun# ls -R /tmp/lib/*.so
/tmp/lib/libasprintf.so /tmp/lib/libgettextpo.so /tmp/lib/libgobject-2.0.so /tmp/lib/libintl.so
/tmp/lib/libdbus-1.so /tmp/lib/libgettextsrc-0.20.2.so /tmp/lib/libgthread-2.0.so /tmp/lib/libreadline.so
/tmp/lib/libexpat.so /tmp/lib/libgettextsrc.so /tmp/lib/libhistory.so /tmp/lib/libtextstyle.so
/tmp/lib/libffi.so /tmp/lib/libgio-2.0.so /tmp/lib/libical.so /tmp/lib/libz.so
/tmp/lib/libgettextlib-0.20.2.so /tmp/lib/libglib-2.0.so /tmp/lib/libicalss.so
/tmp/lib/libgettextlib.so /tmp/lib/libgmodule-2.0.so /tmp/lib/libicalvcal.so
root@ubuntu:/home/lijun# ls -R /tmp/include
/tmp/include:
autosprintf.h dbus-1.0 expat_external.h expat.h gettext-po.h gio-unix-2.0 glib-2.0 ical.h libical libintl.h ncurses readline textstyle textstyle.h zconf.h zlib.h
root@ubuntu:/home/lijun# ls -R /tmp/bin
/tmp/bin:
autopoint dbus-daemon dbus-send gdbus gettext.sh glib-genmarshal gresource infocmp msgcmp msgexec msginit ncurses5-config tabs tset
captoinfo dbus-launch dbus-uuidgen gdbus-codegen gio-querymodules glib-gettextize gsettings infotocap msgcomm msgfilter msgmerge ngettext tic xgettext
clear dbus-monitor envsubst gettext glib-compile-resources glib-mkenums gtester msgattrib msgconv msgfmt msgunfmt recode-sr-latin toe xmlwf
dbus-cleanup-sockets dbus-run-session gapplication gettextize glib-compile-schemas gobject-query gtester-report msgcat msgen msggrep msguniq reset tput
可以把这些文件夹拷贝到掉电不丢失的地方,方便下次开机调试时不用重新编译,直接拷贝到/tmp文件夹即可。