木马派RV1106G3开发板驱动AIC8800DC USB WiFi蓝牙二合一模块

板子连线

板子调试串口接GND、RX2和TX2。
USB Type-C接口用来供电,无USB功能。

板子背面有一颗10脚芯片,嘉立创因为缺库存,没有给我贴,所以只能飞线,把RV1106G3芯片上的USB DP和DM与AIC8800DC WiFi模块的USB DP和DM相连,也就是3脚连9脚,4脚连8脚。
飞线后,板上的USB Type-C接口只能供电,没有USB功能。RV1106G3芯片的USB处于主机模式。

下载和编译幸狐官方系统镜像

虚拟机环境:Fedora 41 64位 (Fedora-Workstation-Live-x86_64-41-1.4.iso)
(为什么不用Ubuntu?因为我不喜欢Ubuntu修改后的unity风格的GNOME桌面环境,喜欢Fedora里面原生的GNOME环境)
下载代码:
cd ~/Documents
git clone https://gitee.com/LuckfoxTECH/luckfox-pico.git
cd luckfox-pico
切换到2025-03-12(Pullrequest for Luckfox Pico Pi (#246))的版本:
git reset --hard a984090f0620bf643c990422747d7306f6c82857

安装编译工具:
sudo dnf install g++
sudo dnf install dtc
sudo dnf install openssl
sudo dnf install openssl-devel-engine
sudo dnf install flex
sudo dnf install bison
sudo dnf install makeinfo
sudo dnf install gperf
sudo dnf install cmake
sudo dnf install patch
sudo dnf install perl-English
sudo dnf install perl-ExtUtils-MakeMaker
sudo dnf install perl-Thread-Queue
sudo dnf install perl-FindBin
sudo dnf install lzma
(特别注意:编译前必须安装lzma,否则编译过程中不会提示错误,但烧录到板子上后uboot无法启动linux内核,报## Checking uboot 0x00200000 (lzma @0x00400000) ... sha256(e3b0c44298...) + uboot: decompress error, ret=1的错误)

编译:
./build.sh lunch
选择[5] RV1106_Luckfox_Pico_Pro
[1] SPI_NAND
[0] Buildroot
然后
./build.sh

(重要)解决make[1]: Entering directory '/home/oct1158/Documents/luckfox-pico/sysdrv/source/kernel'后长时间无输出,且编译内核失败时不显示错误信息的问题:
修改sysdrv/source/kernel/Makefile
删掉或注释掉下面的语句
ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
  quiet=silent_
endif

报错:Unknown option 'passive-ftp'
解决方案:用sed命令把buildroot生成的文件里面的--passive-ftp选项去掉。
cd sysdrv/source/buildroot/buildroot-2023.02.6
sed -i "s/wget --passive-ftp/wget/g" utils/genrandconfig Config.in output/build/buildroot-config/autoconf.h output/build/buildroot-config/auto.conf .config
cd ../../../../

报错:../src/tramp.c:262:22: error: implicit declaration of function 'open_temp_exec_file' [-Wimplicit-function-declaration]
解决方案:修改sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-libffi-3.4.4/src/tramp.c文件。在顶部添加一行
int open_temp_exec_file(void);

烧录镜像

在fedora虚拟机上安装samba服务器:
sudo setenforce 0
sudo systemctl stop firewalld
sudo dnf install samba

把/etc/samba/smb.conf里面的workgroup = SAMBA改成
workgroup = WORKGROUP
server min protocol = NT1
lanman auth = yes
ntlm auth = yes
(后面三句话是为了支持XP系统)

启动samba服务器:
sudo systemctl start smb
sudo systemctl start nmb
设置当前用户的文件共享密码(独立密码):
sudo smbpasswd -a $(whoami)

板子按住REV键上电。
在64位Windows 7 SP1系统下以管理员身份运行瑞芯微SocToolKit_v1.98_20240705_01_win烧录软件。
(该烧录软件的系统要求很高,不支持原版64位Windows XP SP2和64位Windows Vista SP2)

芯片选择RV1106。

搜索路径选择\\fedora\oct1158\Documents\luckfox-pico\output\image。

选择正确的串口号,波特率选择1500000。勾选所有文件(一共8个文件),点击下载按钮。

烧录完成后,板子按RST键重启,即可在串口中看到启动成功。登录用户名和密码分别是root和luckfox。

修改配置文件,添加对AIC8800DC USB WiFi模块的支持

[sysdrv/source/kernel/arch/arm/boot/dts/rv1106g-luckfox-pico-pro.dts]
&usbdrd_dwc3 {
    status = "okay";
    dr_mode = "peripheral"; 改成 dr_mode = "host";
};

[project/cfg/BoardConfig_IPC/BoardConfig-SPI_NAND-Buildroot-RV1106_Luckfox_Pico_Pro-IPC.mk]
末尾添加
# enable rockchip wifi
export RK_ENABLE_WIFI=y
export RK_ENABLE_WIFI_CHIP=AIC8800DW_USB

# config wifi ssid and passwd
# this will generate /etc/wpa_supplicant.conf
export LF_WIFI_SSID="路由器名称"
export LF_WIFI_PSK="路由器密码"

[sysdrv/drv_ko/wifi/insmod_wifi.sh]
删除下列代码
#aic8800
if [ -n "$(cat /proc/device-tree/model | grep "W")" ]; then
    insmod cfg80211.ko
    insmod libarc4.ko
    insmod ctr.ko
    insmod ccm.ko
    insmod libaes.ko
    insmod aes_generic.ko
    insmod aic8800_bsp.ko
    sleep 0.2
    insmod aic8800_fdrv.ko
    sleep 2
    insmod aic8800_btlpm.ko
    sleep 0.1
fi
改成
#aic8800
if [ -f /oem/usr/ko/aic8800_fdrv.ko ]
then
    insmod /oem/usr/ko/cfg80211.ko
    insmod /oem/usr/ko/aic_load_fw.ko aic_fw_path=/oem/usr/ko/aic_fw
    insmod /oem/usr/ko/aic8800_fdrv.ko
fi

改完后重新编译并烧录,重启后板子已自动连上wifi。并且能ping通百度。
(整个过程完全不需要改内核的menuconfig)


生成的wpa_supplicant.conf配置文件内容

[root@luckfox root]# cat /etc/wpa_supplicant.conf
ctrl_interface=/var/run/wpa_supplicant
ap_scan=1
update_config=1

network={
        ssid="xxx"
        psk="xxx"
        key_mgmt=WPA-PSK
}
[root@luckfox root]#

Fedora 42 gcc15编译时遇到的错误

Fedora41升级到42后,gcc也从14升级到了15。
用gcc15编译幸狐镜像会遇到下面三个问题。

(1)fedora42用gcc15编译host-m4-1.4.19出错,提示gl_oset.h:275:40: error: expected identifier or '(' before 'int'。

In file included from gl_avltree_oset.h:21,
                 from gl_avltree_oset.c:21:
gl_oset.h:275:1: warning: 'nodiscard' attribute ignored [-Wattributes]
  275 | GL_OSET_INLINE _GL_ATTRIBUTE_NODISCARD int
      | ^~~~~~~~~~~~~~
gl_oset.h:275:40: error: expected identifier or '(' before 'int'
  275 | GL_OSET_INLINE _GL_ATTRIBUTE_NODISCARD int
      |                                        ^~~
make[5]: *** [Makefile:2871: gl_avltree_oset.o] Error 1
make[5]: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-m4-1.4.19/lib'
make[4]: *** [Makefile:2481: all] Error 2
make[4]: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-m4-1.4.19/lib'
make[3]: *** [Makefile:2018: all-recursive] Error 1
make[3]: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-m4-1.4.19'
make[2]: *** [Makefile:1974: all] Error 2
make[2]: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-m4-1.4.19'
make[1]: *** [package/pkg-generic.mk:293: /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-m4-1.4.19/.stamp_built] Error 2
make[1]: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6'
make: *** [Makefile:618: buildroot] Error 2
make: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv'
[build.sh:error] Running build_rootfs failed!
[build.sh:error] exit code 2 from line 858:
[build.sh:info]     make rootfs -C ${SDK_SYSDRV_DIR}
[oct1158@fed41-bh8f7e0 luckfox-pico]$

解决方案:
修改sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-m4-1.4.19/lib/config.h文件,找到第2589-2595行。
注释掉前5行和最后一行,只留下倒数第二行。
//#if 201710L < __STDC_VERSION__
//# define _GL_ATTRIBUTE_NODISCARD [[__nodiscard__]]
//#elif _GL_HAS_ATTRIBUTE (warn_unused_result)
//# define _GL_ATTRIBUTE_NODISCARD __attribute__ ((__warn_unused_result__))
//#else
# define _GL_ATTRIBUTE_NODISCARD
//#endif

(2) fedora42用gcc15编译host-gettext-gnu-0.20.1出错,提示../../gettext-runtime/intl/dcigettext.c:147:7: error: conflicting types for 'getcwd'; have 'char *(void)'。

In file included from ../../gettext-runtime/intl/dcigettext.c:92:
../../gettext-runtime/intl/gettextP.h: In function 'SWAP':
../../gettext-runtime/intl/gettextP.h:119:1: warning: old-style function definition [-Wold-style-definition]
  119 | SWAP (i)
      | ^~~~
../../gettext-runtime/intl/dcigettext.c: At top level:
../../gettext-runtime/intl/dcigettext.c:147:7: error: conflicting types for 'getcwd'; have 'char *(void)'
  147 | char *getcwd ();
      |       ^~~~~~
In file included from ../../gettext-runtime/intl/dcigettext.c:65:
/usr/include/unistd.h:531:14: note: previous declaration of 'getcwd' with type 'char *(char *, size_t)' {aka 'char *(char *, long unsigned int)'}
  531 | extern char *getcwd (char *__buf, size_t __size) __THROW __wur;
      |              ^~~~~~
../../gettext-runtime/intl/dcigettext.c: In function 'libintl_dcigettext':
../../gettext-runtime/intl/dcigettext.c:640:21: error: too many arguments to function 'getcwd'; expected 0, have 2
  640 |               ret = getcwd (resolved_dirname, path_max);
      |                     ^~~~~~  ~~~~~~~~~~~~~~~~
../../gettext-runtime/intl/dcigettext.c:147:7: note: declared here
  147 | char *getcwd ();
      |       ^~~~~~
make[5]: *** [Makefile:2554: dcigettext.lo] Error 1
make[5]: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-gettext-gnu-0.20.1/gettext-tools/intl'
make[4]: *** [Makefile:2142: all] Error 2
make[4]: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-gettext-gnu-0.20.1/gettext-tools/intl'
make[3]: *** [Makefile:2177: all-recursive] Error 1
make[3]: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-gettext-gnu-0.20.1/gettext-tools'
make[2]: *** [Makefile:2045: all] Error 2
make[2]: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-gettext-gnu-0.20.1/gettext-tools'
make[1]: *** [package/pkg-generic.mk:293: /home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-gettext-gnu-0.20.1/.stamp_built] Error 2
make[1]: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv/source/buildroot/buildroot-2023.02.6'
make: *** [Makefile:618: buildroot] Error 2
make: Leaving directory '/home/oct1158/Documents/Code/C/luckfox-pico/sysdrv'
[build.sh:error] Running build_rootfs failed!
[build.sh:error] exit code 2 from line 858:
[build.sh:info]     make rootfs -C ${SDK_SYSDRV_DIR}
[oct1158@fed41-bh8f7e0 luckfox-pico]$

解决方案:
修改sysdrv/source/buildroot/buildroot-2023.02.6/output/build/host-gettext-gnu-0.20.1/gettext-runtime/intl/dcigettext.c文件,注释掉第147行的char *getcwd ();。(看清楚是6个字符的getcwd,不是上面5个字符的getwd)
(项目中一共有三个dcigettext.c文件,只需要改一个文件,就是host-gettext-gnu-0.20.1里面那个文件,其他两个文件没用到,不用改)

(3)fedora42用gcc15编译bash-5.2.15出错,提示mkbuiltins.c:267:29: error: too many arguments to function 'xmalloc'; expected 0, have 1。

解决方案:
打开sysdrv/source/buildroot/buildroot-2023.02.6/output/build/bash-5.2.15/builtins/mkbuiltins.c
将下面这些行修改正确。
行 62: static char *xmalloc (int bytes), *xrealloc (char *pointer, int bytes);
行 194: static int is_special_builtin (char *name);
行 195: static int is_assignment_builtin (char *name);
行 196: static int is_localvar_builtin (char *name);
行 197: static int is_posix_builtin (char *name);
行 198: static int is_arrayvar_builtin (char *name);
行 204: void extract_info (char *filename, FILE *structfile, FILE *externfile);
行 206: void file_error (char *filename);
行 207: void line_error (DEF_FILE *defs, char *format, ...);
行 209: void write_file_headers (FILE *structfile, FILE *externfile);
行 210: void write_file_footers (FILE *structfile, FILE *externfile);
行 211: void write_ifdefs (FILE *stream, char **defines);
行 212: void write_endifs (FILE *stream, char **defines);
行 213: void write_documentation (FILE *stream, char **documentation, int indentation, int flags);
行 214: void write_longdocs (FILE *stream, ARRAY *builtins);
行 215: void write_builtins (DEF_FILE *defs, FILE *structfile, FILE *externfile);
行 217: int write_helpfiles (ARRAY *builtins);
行 219: void free_defs (DEF_FILE *defs);
行 220: void add_documentation (DEF_FILE *defs, char *line);
行 222: void must_be_building (char *directive, DEF_FILE *defs);
行 223: void remove_trailing_whitespace (char *string);

第439-440行:
在第一个参数前加上(void *)
    array->array = (char **)xrealloc
      ((void *)array->array, (array->size += array->growth_rate) * array->width);

第1014-1026行:
/* Produce an error for DEFS with FORMAT and ARGS. */
#include <stdarg.h>
void
line_error (DEF_FILE *defs, char *format, ...)
{
  va_list list;
  if (defs->filename[0] != '/')
    fprintf (stderr, "%s", error_directory ? error_directory : "./");
  fprintf (stderr, "%s:%d:", defs->filename, defs->line_number + 1);
  va_start(list, format);
  vfprintf (stderr, format, list);
  va_end(list);
  fprintf (stderr, "\n");
  fflush (stderr);
}


在电脑上交叉编译bluez-5.28蓝牙协议栈

将幸狐linux镜像里面的交叉编译器添加到PATH环境变量:
export PATH=$PATH:/home/oct1158/Documents/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin
查看gcc编译器版本:
arm-rockchip830-linux-uclibcgnueabihf-gcc -v
版本是gcc version 8.3.0 (crosstool-NG 1.24.0)

工作目录:
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-rockchip830-linux-uclibcgnueabihf --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-rockchip830-linux-uclibcgnueabihf-gcc AR=arm-rockchip830-linux-uclibcgnueabihf-ar LD=arm-rockchip830-linux-uclibcgnueabihf-ld ./configure --prefix=/opt/bluez

make
make install DESTDIR=$(pwd)/_install
cd ..

【交叉编译libiconv-1.18】

wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.18.tar.gz
tar xf libiconv-1.18.tar.gz
cd libiconv-1.18
./configure --host=arm-rockchip830-linux-uclibcgnueabihf --prefix=/opt/bluez
make
make install DESTDIR=$(pwd)/_install
cd ..

【交叉编译gettext-0.23.2】
gettext-0.24和gettext-0.25这两个版本需要用到_NL_NUMERIC_THOUSANDS_SEP_WC宏,幸狐的gcc8.3交叉编译器里面没有,所以无法编译成功。

wget https://ftp.gnu.org/pub/gnu/gettext/gettext-0.23.2.tar.gz
tar xf gettext-0.23.2.tar.gz
cd gettext-0.23.2
./configure --host=arm-rockchip830-linux-uclibcgnueabihf --prefix=/opt/bluez --with-libiconv-prefix=$(pwd)/../libiconv-1.18/_install/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-rockchip830-linux-uclibcgnueabihf --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" ZLIB_CFLAGS=-I$(pwd)/../zlib-1.3.1/_install/opt/bluez/include ZLIB_LIBS="-L$(pwd)/../zlib-1.3.1/_install/opt/bluez/lib -lz" CFLAGS="-I$(pwd)/../gettext-0.23.2/_install/opt/bluez/include -I$(pwd)/../libiconv-1.18/_install/opt/bluez/include" LDFLAGS="-L$(pwd)/../gettext-0.23.2/_install/opt/bluez/lib -L$(pwd)/../libiconv-1.18/_install/opt/bluez/lib"
make
make install DESTDIR=$(pwd)/_install
cd ..

libtool:   error: '/opt/bluez/lib/libiconv.la' is not a valid libtool archive解决方案:
修改$(pwd)/../gettext-0.23.2/_install/opt/bluez/lib/libintl.la文件,第20行
dependency_libs=' -R/home/oct1158/Downloads/bluez/gettext-0.23.2/../libiconv-1.18/_install/opt/bluez/lib -L/home/oct1158/Downloads/bluez/gettext-0.23.2/../libiconv-1.18/_install/opt/bluez/lib -lpthread /opt/bluez/lib/libiconv.la'
删掉最后的/opt/bluez/lib/libiconv.la
dependency_libs=' -R/home/oct1158/Downloads/bluez/gettext-0.23.2/../libiconv-1.18/_install/opt/bluez/lib -L/home/oct1158/Downloads/bluez/gettext-0.23.2/../libiconv-1.18/_install/opt/bluez/lib -lpthread'

ModuleNotFoundError: No module named 'imp'解决方案:
修改py-compile文件,第119行和第140行的import sys, os, py_compile, imp的imp改成importlib,并在下一行赋值imp=importlib。

【交叉编译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-rockchip830-linux-uclibcgnueabihf --prefix=/opt/bluez
make
make install DESTDIR=$(pwd)/_install
cd ..

【交叉编译dbus-1.15.6】
dbus-1.15.6是最后一个压缩包里面有configure脚本的版本。
dbus-1.15.8是最后一个压缩包里面有configure.ac文件的版本。
从dbus-1.15.10版本开始就只支持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-rockchip830-linux-uclibcgnueabihf --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-rockchip830-linux-uclibcgnueabihf-gcc CXX=arm-rockchip830-linux-uclibcgnueabihf-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-rockchip830-linux-uclibcgnueabihf --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-rockchip830-linux-uclibcgnueabihf --prefix=/opt/bluez --with-shared
make
修改progs/Makefile文件里面第82行的INSTALL_PROG变量,在变量值的末尾添加
--strip-program=arm-rockchip830-linux-uclibcgnueabihf-strip
然后make install DESTDIR=$(pwd)/_install
cd ..

【交叉编译bluez-5.28】
支持uclibcgnueabihf-gcc编译器的最高bluez版本为5.28。
更高版本的bluez需要<wordexp.h>头文件,而uclibcgnueabihf-gcc编译器不支持这个头文件,要换成gnueabihf-gcc编译器才行。

wget https://www.kernel.org/pub/linux/bluetooth/bluez-5.28.tar.gz
tar xf bluez-5.28.tar.gz
cd bluez-5.28
./configure --host=arm-rockchip830-linux-uclibcgnueabihf --prefix=/opt/bluez --disable-udev --with-dbusconfdir=/opt/bluez/share --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 -L$(pwd)/../gettext-0.23.2/_install/opt/bluez/lib -lintl -L$(pwd)/../libiconv-1.18/_install/opt/bluez/lib -liconv" 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 ..

注意:--with-dbusconfdir目录必须设置为dbus的安装目录下的share目录。其他四个目录没有用,随便写。

tools/rctest.c: In function 'recv_mode':
tools/rctest.c:504:19: error: 'SIOCGSTAMP' undeclared (first use in this function); did you mean 'SIOCGRARP'?
     if (ioctl(sk, SIOCGSTAMP, &tv) < 0) {
                   ^~~~~~~~~~
                   SIOCGRARP
tools/rctest.c:504:19: note: each undeclared identifier is reported only once for each function it appears in
解决方案:修改tools/rctest.c和tools/l2test.c文件,在顶部添加#include <linux/sockios.h>

【打包】
注意打包时cp命令必须加sudo,以保证打包后的文件在板子上的所有者为root。

mkdir _install
sudo cp -r libffi-3.5.1/_install/* _install
sudo cp -r zlib-1.3.1/_install/* _install
sudo cp -r libiconv-1.18/_install/* _install
sudo cp -r gettext-0.23.2/_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.28/_install/* _install
cd _install
(进去后只有opt和root目录,如果有其他目录说明之前操作有误)
tar cf bluez.tar opt root

得到的压缩包大小为118MB。

编译AIC8800DC蓝牙USB驱动

AIC8800DC的WiFi和蓝牙可以都走USB接口,板子上RV1106芯片和AIC8800DC模块之间只需要接USB线,不需要接串口线。木马派板子上就只接了USB线,没有接串口线,不用改板子就能用蓝牙。
AIC8800DC蓝牙USB驱动 github代码项目网址:

https://github.com/radxa-pkg/aic8800/releases
https://codeload.github.com/radxa-pkg/aic8800/tar.gz/refs/tags/3.0%2Bgit20240327.3561b08f-7

下载并解压aic8800dc wifi蓝牙二合一模块的linux驱动源码:

cd ~/Downloads
wget https://codeload.github.com/radxa-pkg/aic8800/tar.gz/refs/tags/3.0%2Bgit20240327.3561b08f-7 -O aic8800-3.0-git20240327.3561b08f-7.tar.gz
tar xf aic8800-3.0-git20240327.3561b08f-7.tar.gz

进入幸狐的linux内核配置菜单:
cd ~/Documents/luckfox-pico
./build.sh kernelconfig
进入Networking support,按y键选中Bluetooth subsystem support。
取消选择Networking support  --->  Bluetooth subsystem support  --->  Bluetooth device drivers里面的所有东西。特别是HCI USB driver,这个绝对不能勾选上,否则蓝牙USB驱动(aic_btusb.ko)无法成功下载固件,导致只能扫描(而且只能扫描部分设备),无法配对。
  x x         --- Bluetooth subsystem support                                                 x x
  x x         [*]   Bluetooth Classic (BR/EDR) features (NEW)                                 x x
  x x         < >     RFCOMM protocol support (NEW)                                           x x
  x x         < >     BNEP protocol support (NEW)                                             x x
  x x         < >     HIDP protocol support (NEW)                                             x x
  x x         [ ]     Bluetooth High Speed (HS) features (NEW)                                x x
  x x         [*]   Bluetooth Low Energy (LE) features (NEW)                                  x x
  x x         [ ]   Enable LED triggers (NEW)                                                 x x
  x x         [ ]   Enable Microsoft extensions (NEW)                                         x x
  x x         [*]   Export Bluetooth internals in debugfs (NEW)                               x x
  x x         [ ]   Bluetooth self testing support (NEW)                                      x x
  x x         [ ]   Enable runtime option for debugging statements (NEW)                      x x
  x x               Bluetooth device drivers  --->
保存。
然后./build.sh编译内核。

将幸狐的linux内核文件夹单独复制一份出来并编译(这份内核用于编译ko驱动模块,不用于烧写):
cp -r ~/Documents/luckfox-pico/sysdrv/source/kernel ~/Documents/kernel_for_modules
cp ~/Documents/luckfox-pico/sysdrv/source/objs_kernel/.config ~/Documents/kernel_for_modules/.config
cd ~/Documents/kernel_for_modules
make ARCH=arm CROSS_COMPILE=~/Documents/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-

进入蓝牙驱动目录:cd ~/Downloads/aic8800-3.0-git20240327.3561b08f-7/src/USB/driver_fw/drivers/aic_btusb
修改Makefile文件,CONFIG_PLATFORM_ROCKCHIP改成y,CONFIG_PLATFORM_UBUNTU改成n。
找到ifeq ($(CONFIG_PLATFORM_ROCKCHIP), y)下面,KDIR改成复制出来的内核目录,如/home/oct1158/Documents/kernel_for_modules。
CROSS_COMPILE改成交叉编译器所在目录,如/home/oct1158/Documents/luckfox-pico/tools/linux/toolchain/arm-rockchip830-linux-uclibcgnueabihf/bin/arm-rockchip830-linux-uclibcgnueabihf-。

修改aic_btusb.h文件,第39-43行,把两个CONFIG_BLUEDROID的值都改成0,表示用的是bluez蓝牙协议栈。
#ifdef CONFIG_PLATFORM_UBUNTU
#define CONFIG_BLUEDROID        0 /* bleuz 0, bluedroid 1 */
#else
#define CONFIG_BLUEDROID        0 /* bleuz 0, bluedroid 1 */
#endif

修改aic_btusb.c文件,第2309-2313行,把两个aic_default_fw_path变量的值都改成"/oem/usr/ko/aic_fw/aic8800DC"。
#if (CONFIG_BLUEDROID == 0)
static const char* aic_default_fw_path = "/oem/usr/ko/aic_fw/aic8800DC";
#else
static const char* aic_default_fw_path = "/oem/usr/ko/aic_fw/aic8800DC";
#endif

然后用make命令编译。

修改报错的文件:
aic_btusb.c 第2601行和第2672行 0x%0lx改成0x%0x
            第5121行firmware_info *fw_info = data->fw_info;下一行加上(void)fw_info;
内核目录/Makefile(也就是~/Documents/kernel_for_modules/Makefile) 第823行注释掉 #KBUILD_CFLAGS += $(call cc-option,-Wimplicit-fallthrough,)

编译得到aic_btusb.ko。
先把修改后的内核镜像(~/Documents/luckfox-pico/output/image)通过串口烧录到板子上,板子启动后,将bluez.tar和aic_btusb.ko上传到板子上。
可以用FileZilla软件通过SFTP - SSH File Transfer Protocol上传,用户名root,密码luckfox。
bluez.tar文件太大,有118MB,必须上传到SD卡上。不然没有空间解压。

在板子上执行:tar xf bluez.tar -C /
可以将bluez解压到板子的/opt/bluez目录下。
如果空间不够,也可以把opt/bluez文件夹放到外部sd卡上(必须为ext4分区),然后把bluez文件夹软链接到板子的/opt目录下。

在板子上用vi编译器修改/etc/profile文件。
找到第一句话export PATH="/bin:/sbin:/usr/bin:/usr/sbin"
在下面加两句
export PATH=$PATH:/opt/bluez/bin
export LD_LIBRARY_PATH=/opt/bluez/lib
保存文件,用exit命令退出命令行,再输入用户名和密码重新进入命令行,即可生效。

将aic_btusb.ko放到/root/bluetooth目录下。
insmod /root/bluetooth/aic_btusb.ko

然后用hciconfig -a命令就可以看到有hci0出现了。
[root@luckfox root]# hciconfig -a
hci0:   Type: Primary  Bus: USB
        BD Address: 2C:C3:E6:1F:0C:97  ACL MTU: 1021:9  SCO MTU: 255:4
        DOWN
        RX bytes:624 acl:0 sco:0 events:37 errors:0
        TX bytes:389 acl:0 sco:0 commands:37 errors:0
        Features: 0xbf 0xee 0xcd 0xfe 0xd8 0x3d 0x7b 0x87
        Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV3
        Link policy: RSWITCH SNIFF
        Link mode: PERIPHERAL ACCEPT

[root@luckfox root]#

扫描设备:
[root@luckfox opt]# hciconfig hci0 up
[ 3891.549890] aic_btusb: btusb_open: Start
[ 3891.549921]  download_patch 0
[ 3891.549930] aic_btusb: btusb_open: End
[root@luckfox opt]# hcitool scan
Scanning ...
        00:13:04:89:38:07       n/a
        A4:50:46:B5:5F:5A       ben的MI 8 UD
        D8:CE:3A:72:37:CB       Mi Phone 489
        66:32:63:2C:F9:2F       QR380A-F92F
        10:32:7E:97:45:76       n/a
[root@luckfox opt]#

【启动蓝牙后台进程】
[配置]
添加messagebus用户和组:
(系统用户,且不可登录。-S表示编号从100开始)
addgroup -S messagebus
adduser -G messagebus -SDH messagebus
(可以不管addgroup: group 'messagebus' in use这条消息)

确保/opt/bluez/share/dbus-1/system.d/bluetooth.conf文件存在,否则无法启动bluetoothd后台进程,会报D-Bus setup failed: Connection ":1.0" is not allowed to own the service "org.bluez" due to security policies in the configuration file的错误。

[启动]
启动dbus-daemon进程:
rm /opt/bluez/var/run/dbus/pid
/opt/bluez/bin/dbus-daemon --system

启动bluetoothd后台进程:
/opt/bluez/libexec/bluetooth/bluetoothd &

启动obexd后台进程:
export $(/opt/bluez/bin/dbus-launch)
/opt/bluez/libexec/bluetooth/obexd &

在命令行中运行:
bluetoothctl
在里面执行discoverable on和pairable on,手机上就可以搜索到名叫BlueZ 5.28的蓝牙设备,并且在手机上可以配对和连接成功,不需要输入密码。
输入quit命令可退出bluetoothctl。


扩展阅读:木马派RV1106开发板驱动AIC8800DC USB蓝牙模块,用bluez-alsa库与蓝牙音箱配对并播放wav声音文件-优快云博客

### Kali Linux 5.2 AICSemi AIC8800DC 网卡驱动安装教程 在Kali Linux 5.2系统中安装AICSemi AIC8800DC网卡的驱动,通常需要执行以下操作以确保网卡能够正常工作并支持混杂模式。以下是详细的安装和配置方法[^1]。 #### 1. 检查硬件兼容性 首先,确认AICSemi AIC8800DC网卡是否与Linux内核兼容。可以使用`lsusb`命令来检测设备是否被正确识别: ```bash lsusb ``` 如果网卡被识别,会显示类似以下内容: ``` Bus 001 Device 004: ID 1bba:0880 AICSemi Technology Co., Ltd AIC8800DC ``` #### 2. 更新系统包 确保系统的软件包是最新的,以便安装过程中避免依赖问题: ```bash apt update && apt upgrade -y ``` #### 3. 安装必要的工具和库 安装编译驱动所需的工具和库文件: ```bash apt install build-essential dkms git linux-headers-$(uname -r) -y ``` #### 4. 获取并编译驱动 AICSemi官方或社区可能提供了适用于Linux驱动程序。可以通过以下步骤获取并安装: 1. 访问AICSemi官方网站或GitHub仓库,查找AIC8800DC驱动源码。 2. 克隆或下载驱动代码到本地: ```bash git clone https://github.com/example/aic8800dc-driver.git cd aic8800dc-driver ``` 3. 编译并安装驱动: ```bash make make install ``` #### 5. 加载驱动模块 安装完成后,加载驱动模块到内核中: ```bash modprobe aic8800dc ``` #### 6. 验证网卡状态 使用`ifconfig`或`ip`命令检查网卡是否已被激活: ```bash ifconfig ``` 或者: ```bash ip link show ``` 如果网卡被成功激活,可以继续将其设置为混杂模式。 #### 7. 设置混杂模式 通过`airmon-ng`工具将网卡切换到监听模式(Monitor Mode): ```bash airmon-ng start wlan2 ``` 此命令会创建一个名为`wlan2mon`的新接口,用于捕获无线数据包。 #### 8. 验证混杂模式 使用以下命令验证网卡是否已进入混杂模式: ```bash iwconfig wlan2mon ``` 输出应包含`Mode:Monitor`字段。 --- ### 注意事项 - 如果驱动无法正常工作,可能需要手动调整内核模块参数或更新内核版本。 - 在某些情况下,可能需要禁用其他干扰模块(如`rt2800usb`),可通过以下命令完成: ```bash airmon-ng check kill ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

巨大八爪鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值