OpenHarmony富设备移植指南(8)WIFI适配 原创

Diemit
发布于 2024-9-19 17:43
浏览
0收藏

OpenHarmony适配WiFi可通过HDF驱动方式进行适配,也可以通过传统Linux WiFi驱动的方式进行适配,此篇文章以Linux WiFi驱动适配为例,适配版本为OpenHarmony4.0Release

1.系统组件

使用传统WiFi适配方式,我们需要确认系统组件

...
{
      "subsystem": "wpa_supplicant-2.9",
      "components": [
        {
          "component": "wpa_supplicant-2.9",
          "features": [
            "wpa_supplicant_driver_nl80211 = true"
          ]
        }
      ]
    },
...
{
      "subsystem": "communication",
      "components": [
        {
          "component": "wifi",
          "features": [
            "wifi_feature_non_seperate_p2p = true",(树莓派4B需配置此项)
            "wifi_feature_non_hdf_driver = true"
         ]
        }
      ]
    },
...

2.WiFi驱动

WIFI适配首先要确认内核的WIFI驱动正常,以树莓派4B举例,

树莓派4B采用的WIFI是博通芯片,并内置在主板上,WiFi驱动厂商通常会分成两部分,一部分为固件,还有一部分为内核驱动,我们首先把博通的WiFi内核驱动和相关依赖编译进内核:

CONFIG_CFG80211=y
CONFIG_RFKILL=y
CONFIG_BRCMUTIL=y
CONFIG_BRCMFMAC=y


于此同时,我们还需要把WiFi固件内置到OpenHarmony的镜像中,下载WiFi固件:

​https://github.com/android-rpi/device_arpi_rpi4/tree/arpi-14/firmware/brcm​

配置固件进镜像:

OpenHarmony富设备移植指南(8)WIFI适配 -鸿蒙开发者社区

ohos_prebuilt_etc("brcmfmac43455-sdio.bin") {
  source = "brcm/brcmfmac43455-sdio.bin"
  part_name = "device_rpi4"
  install_images = [ ramdisk_base_dir ]
  module_install_dir = "lib/firmware/brcm"
  install_enable = true
}

ohos_prebuilt_etc("brcmfmac43455-sdio.clm_blob") {
  source = "brcm/brcmfmac43455-sdio.clm_blob"
  part_name = "device_rpi4"
  install_images = [ ramdisk_base_dir ]
  module_install_dir = "lib/firmware/brcm"
  install_enable = true
}

ohos_prebuilt_etc("brcmfmac43455-sdio.txt") {
  source = "brcm/brcmfmac43455-sdio.txt"
  part_name = "device_rpi4"
  install_images = [ ramdisk_base_dir ]
  module_install_dir = "lib/firmware/brcm"
  install_enable = true
}


group("firmware") {
  deps = [
    ":brcmfmac43455-sdio.bin",
    ":brcmfmac43455-sdio.clm_blob",
    ":brcmfmac43455-sdio.txt",
  ]

}


编译烧录启动树莓派之后,通过以下命令检查WiFi是否正常

ls /sys/class/net/

正常情况下net下会有wlan0节点,节点创建正常后,OpenHarmony系统中即可搜索链接WiFi。

实操视频:

​https://www.bilibili.com/video/BV1SCYSeYER5/​


©著作权归作者所有,如需转载,请注明出处,否则将追究法律责任
已于2024-9-19 17:43:54修改
收藏
回复
举报
回复
    相关推荐