Milk-V Duo开发板移植Ai-WS1-CBE WiFi驱动
参考链接
https://docs.ai-thinker.com/ai-ws1/
https://aithinker-static.oss-cn-shenzhen.aliyuncs.com/docs/_media_old/ws73_sdk_linux_ws73_1.10.111.tar.gz
https://blog.csdn.net/Boantong_/article/details/143688264?
https://bbs.elecfans.com/jishu_2496877_1_1.html
https://milkv.io/docs/duo/getting-started/buildroot-sdk
WSL中编译Linux镜像
编辑/etc/wsl.conf,加入下面两行,然后重启wsl
[interop]
appendWindowsPath = false

安装编译工具
sudo apt install -y pkg-config build-essential ninja-build automake autoconf libtool wget curl git gcc libssl-dev bc slib squashfs-tools android-sdk-libsparse-utils jq python3-distutils scons parallel tree python3-dev python3-pip device-tree-compiler ssh cpio fakeroot libncurses5 flex bison libncurses5-dev genext2fs rsync unzip dosfstools mtools tcl openssh-client cmake expect python-is-python3
sudo pip install jinja2
获取源码
git clone https://github.com/milkv-duo/duo-buildroot-sdk-v2.git --depth=1
wget https://github.com/milkv-duo/duo-buildroot-sdk-v2/releases/download/dl/dl.tar
tar xvf ./dl.tar -C ./duo-buildroot-sdk-v2/buildroot/

获取工具链
cd duo-buildroot-sdk-v2
git clone --depth=1 https://github.com/milkv-duo/host-tools.git
修改buildroot/configs/milkv-duo-musl-riscv64-sd_defconfig,增加WPA_SUPPLICANT选项
BR2_PACKAGE_WPA_SUPPLICANT=y
BR2_PACKAGE_WPA_SUPPLICANT_WPS=y
BR2_PACKAGE_WPA_SUPPLICANT_WPA3=y
BR2_PACKAGE_WPA_SUPPLICANT_CLI=y
BR2_PACKAGE_WPA_SUPPLICANT_WPA_CLIENT_SO=y
BR2_PACKAGE_WPA_SUPPLICANT_PASSPHRASE=y

编译
./build.sh milkv-duo-musl-riscv64-sd
编译过程耗时较长,耐心等待
编译完成后,镜像文件保存在out目录中 milkv-duo-musl-riscv64-sd_***.img
利用rufus将镜像文件烧录到microSD卡中
连接type-c,启动duo开发板,设置UsbNcm
ssh连接开发板,ssh root@192.168.42.1,初始密码:milkv


duo开发板中创建文件夹
mkdir /root/ko
mkdir /etc/ws73
移植驱动
下载驱动源码
wget https://aithinker-static.oss-cn-shenzhen.aliyuncs.com/docs/_media_old/ws73_sdk_linux_ws73_1.10.111.tar.gz
tar zxf ws73_sdk_linux_ws73_1.10.111.tar.gz
cd ws73_sdk_linux_ws73_1.10.111
修改Makefile
DEFAULT_KCONFIG_CONFIG := $(CONFIG_DIR)/ws73_usb_light_v2.config

修改build/config/ws73_usb_light_v2.config
WSCFG_CROSS_COMPILE="<dir>/duo-buildroot-sdk-v2/host-tools/gcc/riscv64-linux-musl-x86_64/bin/riscv64-unknown-linux-musl-"
WSCFG_KERNEL_DIR="<dir>/duo-buildroot-sdk-v2/linux_5.10/build/cv1800b_milkv_duo_musl_riscv64_sd"
# WSCFG_ARCH_ARM=y
WSCFG_ARCH_CUSTOM=y
WSCFG_ARCH_NAME="riscv"

修改driver/bsle/ble_driver/linux/ble_host_hcc.c
#if defined(CONFIG_PLAT_SUPPORT_DFR)
static oal_int32 ext_bluetooth_dfr_recovery(void);
#endif

编译驱动
make platform
make wifi
make ble
make sle
编译输出目录output/bin

将驱动,固件,配置文件发送到duo开发板
scp firmware/us/*.bin root@192.168.42.1:/etc/ws73
scp output/bin/ws73_cfg.ini root@192.168.42.1:/etc
scp output/bin/*.ko root@192.168.42.1:/root/ko
串口连接duo开发板
使用USB口连接Ai-WS1-CBE-Kit,所以USB需要配置为host,UsbNcm无法使用,只能通过串口连接duo开发板

启用usb-host
ln -sf /mnt/system/usb-host.sh /mnt/system/usb.sh
reboot
连接Ai-WS1-CBE-Kit



加载驱动
insmod ko/plat_soc.ko
insmod ko/wifi_soc.ko

查看网络接口 ifconfig,多出来Featureid0, wlan0, wlan1

修改/etc/wpa_supplicant.conf,将wifi ssid和密码写入配置文件

配置WiFi,dhcp
wpa_supplicant -iwlan0 -Dnl80211 -c /etc/wpa_supplicant.conf &
udhcpc -iwlan0

添加nameserver
echo $'nameserver 211.136.192.6\nnameserver 120.196.165.24\nnameserver 8.8.8.8' >> /etc/resolv.conf
cat /etc/resolv.conf

ping测试
ping -c4 cn.bing.com
ping -c4 www.baidu.com
