Alex Blog

在 Hailo H15 SOC 上使用 Yocto 扩展支持 WiFi(aic8800)

今天我们展示下如何在 Hailo H15 SOC 上使用 Yocto 的方式扩展支持 WiFi。

因为我手头只有一个 aic8800 的 USB 无线网卡,通过卖家直接拿到了对应的 Linux driver 以及对应的脚本,基于这些素材实现了 Yocto 添加支持。

最终的所有代码可以通过 GitHub 链接进行查看,以一个 meta-aic-wifi 实现了整个功能。

整个 meta 主要包含以下三个部分:

  • 新增 recipe linux-yocto-hailo.bbappend,从而对原始 kernel 部分进行 append 修改
  • 新增 recipe aic8800-driver_1.0.bb,将原始的aic8800驱动代码修改为 Yocto 的版本,并且支持同时将驱动 ko,对应的 firmware 以及 aic.rules 加载到设备中
  • 新增 recipe packagegroup-aic8800.bb,方便将我们需要的驱动以及对应依赖的 WiFi 工具 wpa-supplicant

具体代码结构:

├── conf
│   └── layer.conf
├── README.md
├── recipes-core
│   └── packagegroups
│       └── packagegroup-aic8800.bb
└── recipes-kernel
    ├── aic8800-driver
    │   ├── aic8800-driver_1.0.bb
    │   └── files
    │       ├── aic.rules
    │       ├── driver
    │       │   ├── aic8800_fdrv
    │       │   ├── aic_load_fw
    │       │   ├── COPYING
    │       │   ├── Kconfig
    │       │   └── Makefile
    │       └── fw
    │           └── aic8800D80
    └── linux-yocto-hailo
        ├── aic8800-wifi.cfg
        ├── linux-yocto-hailo.bbappend
        └── usb-support.cfg

详细讲解

针对 Kernel 部分

因为 Hailo 本身的 recipe 为 linux-yocto-hailo,所以我们使用 linux-yocto-hailo.bbappend 来进行 Kernel config 的修改与添加。

具体可以参考本身Hailo的meta-hailo-soczh 中 DSP 的 recipe,meta-hailo-soc/meta-hailo-dsp/recipes-kernel/linux-yocto-hailo

我们也是类似将对应的 config 部分分为两类:

  • 一个是 USB 的支持(usb-support.cfg
  • 一个是 WiFi 的支持(aic8800-wifi.cfg

针对 AIC 驱动部分

  • 主要使用 Yocto 对应的 inherit module 模块,其会自动的进行驱动 ko 文件的编译,加载以及安装,我们只需要在 recipe 中增加 firmware 以及 udev 的安装。
  • 因为代码中没有 Yocto 支持的 make oldconfig,所以我们在 .bb 中增加如下内容:
do_configure() {
    # Skip do_configure because Makefile does not support 'oldconfig'
    :
}
  • 需要针对商家提供的一般 Linux 的源码修改 Makefile 适合 Yocto 的编译,整体还是要修改为 Yocto 的编译方式。

针对 Packagegroup 部分

  • 主要也是使用 Yocto 编译系统的 inherit packagegroup
  • 为了简便,针对 WiFi 的应用程序只增加了 wpa-supplicant 来进行 WiFi 的连接。

我们增加一个 recipe 是为了方便后续将 USB WiFi 部分增加到整个 Yocto 的编译环境。

因为有这个 recipe,我们只需要在 meta-hailo/meta-hailo-vpu/recipes-core/images/include/core-image-append.inc 增加我们的这个 package:

IMAGE_INSTALL:append = " \
    packagegroup-hailo-integrated-nnc \
    packagegroup-aic8800 \
    packagegroup-hailo-hailort"

我们就只需要与原来一样编译 bitbake,就可以将我们需要的所有对应 USB WiFi 的所有东西包含到对应的 image 中去。

检查是否正确集成

通过如下命令查看是否将我们的 package 放到整个 image 中去了:

bitbake -e core-image-minimal | grep ^IMAGE_INSTALL

查看是否真的将我们需要的 recipe 增加到了 image 中:

bitbake -e aic8800-driver | grep ^PACKAGES=

查看是否针对当前的 kernel 进行了修改:

bitbake linux-yocto-hailo -c configure

最终烧录

最终,我们通过 bitbake core-image-minimal 编译整个 image 并烧录到开发板中去。记得要同时进行串口烧录并且要 wic 烧录,因为我们升级了 Kernel。

设备验证

重启开发板以后,可以通过 ifconfig -a 查看是否存在 wlan0 网口。

如果没有,试试拔插一下 USB WiFi 模组,理论上会自动加载驱动。

如果没有这个网口,可以通过 dmesg 查看下具体的讯息,也可以使用类似:

zcat /proc/config.gz | grep CONFIG_USB_SUPPORT

查看之前的 kernel 修改是否启动。

WiFi 连接

如果一切 OK:

wpa_supplicant -i wlan0 -c wpa_supplicant.conf -B

wpa_supplicant.conf 内容如下:

ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1

network={
    ssid="SSID"
    psk="Password"
}

设置 IP 地址:

ifconfig wlan0 192.168.0.30 netmask 255.255.255.0 up

设置网关:

route add default gw 192.168.0.1 wlan0

修改 DNS:

# 编辑 /etc/resolv.conf,增加一行:
nameserver 8.8.8.8

这样我们就可以连上网络了 🎉。

 


已发布

分类

来自

标签:

评论

《 “在 Hailo H15 SOC 上使用 Yocto 扩展支持 WiFi(aic8800)” 》 有 3 条评论

  1. alex 的头像
    alex

    实际上,后面我这边更新了github repo.
    不需要修改原始的packagegroup.
    只需要新增一个 kas的yaml就可以了
    header:
    version: 11

    repos:
    meta-aic-wifi:
    url: “https://github.com/alex2014git/meta-aic-wifi”
    refspec: a104b3bab20b62deeca1cf842c12c56f9bb2a30d

  2. Ferdinand 的头像
    Ferdinand

    Hi,
    Thanks a lot for the Yocto recipie for AIC8800 module. I have been trying to build the same from another repo for some time with no success.

    Can you share where you got access to the base firmware ? I am trying to build the driver for SDIO support rather than USB. I am building the driver for radxa zero 3w which has even the same architecture as Hailo H15.

    Thank you

    1. alex 的头像

      when i buy the module, i asked the sales to support have the driver and firmware.
      Maybe you could do the same thing.

回复 alex 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注