我是靠谱客的博主 重要芝麻,最近开发中收集的这篇文章主要介绍wifi 移植过程,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1:关于wifi 总线sdio的配置,前面的博客已经说过
2:这一章主要描述wifi移植
WL_REG_ON 主要用于上电,休眠的时候,请保持该GPIO上电,否则会丢失wifi内部的状态,导致wifi唤醒失败;
WL_HOST_WAKE 主要用于wifi设备有数据的时候,唤醒CPU,进入中断,关于中断流程上面已经说过。
3:主要包含的文件有:
1>: bcmdhd.ko wifi驱动模块
2>:fw_bcmdhd_bin; wifi固件
3>nvram.txt wifi的配置信息
4>dhd 或者wl 用于用户测试
4:make menuconfig
CONFIG_CFG80211=m
使用cfg80211.ko

5:将驱动加入内核 kernel/driver/net/wireless/bcmdhd/
6: 在kernel/driver/net/wireless/Kconfig
加入 source "driver/net/wireless/bcmdhd/Kconfig"
7: 在kernel/driver/net/wireless/Makefile
加入 obj-$(CONFIG_BCMDHD) += bcmdhd/
8:make menuconfig

9:wifi GPIO配置 host_wake
WL_REG_ON


10:修改BroadConfig.mk
# Wifi
BOARD_WLAN_VENDOR := broadcom

#for broadcom vendor
ifeq ($(BOARD_WLAN_VENDOR),broadcom)
BOARD_WLAN_DEVICE := bcmdhd
WPA_SUPPLICANT_VERSION := VER_0_8_X
TARGET_KERNEL_MODULES :=
kernel_imx/drivers/net/wireless/bcmdhd/bcmdhd.ko:system/lib/modules/bcmdhd.ko
kernel_imx/net/wireless/cfg80211.ko:system/lib/modules/cfg80211.ko
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
BOARD_HOSTAPD_DRIVER := NL80211
BOARD_HOSTAPD_PRIVATE_LIB_BCM := lib_driver_cmd_bcmdhd
BOARD_WPA_SUPPLICANT_PRIVATE_LIB_BCM := lib_driver_cmd_bcmdhd
WIFI_DRIVER_FW_PATH_PARAM := "/sys/module/bcmdhd/parameters/firmware_path"
WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/bcmdhd.ko"
WIFI_DRIVER_MODULE_NAME := "bcmdhd"
WIFI_DRIVER_MODULE_ARG := "iface_name=wlan firmware_path=/system/vendor/firmware/fw_bcmdhd.bin nvram_path=/system/vendor/firmware/nvram.txt"
SW_BOARD_USR_WIFI := bcm4335
WIFI_DRIVER_FW_PATH_STA := "/system/vendor/firmware/fw_bcmdhd.bin"
WIFI_DRIVER_FW_PATH_AP := "/system/vendor/firmware/fw_bcmdhd_ap.bin"
BCM_NVRAM_SRC_FILE := "/system/vendor/firmware/nvram.txt"
BCM_CONFIG_SRC_FILE := "/system/etc/firmware/config.txt"

11:修改init.rc
service p2p_supplicant /system/bin/wpa_supplicant
-ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf
-I/system/etc/wifi/p2p_supplicant_overlay.conf -N
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf
-I/system/etc/wifi/wpa_supplicant_overlay.conf
-O/data/misc/wifi/sockets -puse_p2p_group_interface=1
-e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
class main
socket wpa_wlan0 dgram 660 wifi wifi
disabled
oneshot
service wpa_supplicant /system/bin/wpa_supplicant
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf
-I/system/etc/wifi/wpa_supplicant_overlay.conf
-O/data/misc/wifi/sockets
-e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
socket wpa_wlan0 dgram 660 wifi wifi
class main
disabled
oneshot

wpa_ctil 与wpa_supplicant 主要使用socket通信,套接字目录:
1:/dev/socket/wpa_wlan0
2:/data/misc/wifi/sockets/
int wifi_connect_on_socket_path(const char *path)
{
    char supp_status[PROPERTY_VALUE_MAX] = {''};

    /* Make sure supplicant is running */
    if (!property_get(supplicant_prop_name, supp_status, NULL)
            || strcmp(supp_status, "running") != 0) {
        ALOGE("Supplicant not running, cannot connect");
        return -1;
    }

    ctrl_conn = wpa_ctrl_open(path);
    if (ctrl_conn == NULL) {
        ALOGE("Unable to open connection to supplicant on "%s": %s",
             path, strerror(errno));
        return -1;
    }
    monitor_conn = wpa_ctrl_open(path);
    if (monitor_conn == NULL) {
        wpa_ctrl_close(ctrl_conn);
        ctrl_conn = NULL;
        return -1;
    }
    if (wpa_ctrl_attach(monitor_conn) != 0) {
        wpa_ctrl_close(monitor_conn);
        wpa_ctrl_close(ctrl_conn);
        ctrl_conn = monitor_conn = NULL;
        return -1;
    }

    if (socketpair(AF_UNIX, SOCK_STREAM, 0, exit_sockets) == -1) {
        wpa_ctrl_close(monitor_conn);
        wpa_ctrl_close(ctrl_conn);
        ctrl_conn = monitor_conn = NULL;
        return -1;
    }

    return 0;
}

/* Establishes the control and monitor socket connections on the interface */
int wifi_connect_to_supplicant()
{
    static char path[PATH_MAX];

    if (access(IFACE_DIR, F_OK) == 0) {
        snprintf(path, sizeof(path), "%s/%s", IFACE_DIR, primary_iface);//primary_iface = wlan0
    } else {
        snprintf(path, sizeof(path), "@android:wpa_%s", primary_iface);
    }
    return wifi_connect_on_socket_path(path);
}
12:调试
1:insmod cfg80211.ko
2: insmode bcmdhd.ko
ifconfig wlan0 up 查看wifi驱动是否加载正常,如果不正常一般是GPIO配置不正确,上电时序错误等,需要使用示波器测试时序,可以测试SDIO是否有数据。
13:修改hal层
根据自定义二个.ko ,修改hal层,加载wifi驱动

最后

以上就是重要芝麻为你收集整理的wifi 移植过程的全部内容,希望文章能够帮你解决wifi 移植过程所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部