记录笔记:
a)当Android Version < v4.4时,从Makefile中移除“DHDCFLAGS += -DWL_IFACE_COMB_NUM_CHANNELS”
b) 当Kernel Version > v3.8时,在Makefile中移除“DHDCFLAGS += -DWL_ENABLE_P2P_IF”
c) 当Kernel Version > v3.13时,在Makefile中追加“DHDOFILES += wl_cfgvendor.o”
CONFIG_CFG80211=y
BOARD_WLAN_VENDOR := BROADCOM
ifeq ($(BOARD_WLAN_VENDOR), BROADCOM)
WPA_SUPPLICANT_VERSION := VER_0_8_X
BOARD_WLAN_DEVICE := bcmdhd
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
BOARD_HOSTAPD_DRIVER := NL80211
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
# associate with hardware/libhardware_legacy/wifi/
WIFI_DRIVER_MODULE_NAME := "bcmdhd" // 同当前模块的名称保持一致
WIFI_DRIVER_FW_PATH_PARAM? := "/sys/module/bcmdhd/parameters/firmware_path" //以下几处定义主要用到wifi.c中,文件路径名称可自行调整
WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/bcmdhd.ko"
WIFI_DRIVER_FW_PATH_STA := "/system/vendor/firmware/fw_bcmdhd.bin"
WIFI_DRIVER_FW_PATH_AP := "/system/vendor/firmware/fw_bcmdhd_apsta.bin"
WIFI_DRIVER_MODULE_ARG :=
"firmware_path=/system/vendor/firmware/fw_bcmdhd.bin
nvram_path=/system/vendor/firmware/nvram.txt"
endif
3. 以下内容以系统默认情况为主,如未包含则添加
a) "init.rc"
# Broadcom wifi driver //此处添加主要是为了仅在上电时插入模块,等同于编译进Kernel
setprop drv.ins bcmdhd.ko //修改的目的在于可调整不同firmware、nvram路径名称
on property:.kodrv.ins=bcmdhd
chmod 644 /system/lib/modules/bcmdhd.ko
insmod /system/lib/modules/bcmdhd.ko
"firmware_path=/system/vendor/firmware/fw_bcmdhd.bin
nvram_path=/system/vendor/firmware/nvram.txt"
insmod /system/lib/modules/bcmdhd.ko "firmware_path=/system/wifi/fw_bcmdhd.bin
nvram_path=/system/wifi/bcmdhd.cal"
########## kernel version >= 3.10.x ##########
# 1. broadcom wifi sta p2p concurrent service //kernel-3.10以后的版本Driver(version 1.141.xx以上)仅生成wlan0
service p2p_supplicant /system/bin/wpa_supplicant \
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
-O/data/misc/wifi/sockets -puse_p2p_group_interface=1 \
-e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
class late_start
socket wpa_wlan0 dgram 660 wifi wifi
disabled
oneshot
# 2. broadcom wifi station and softap
service wpa_supplicant /system/bin/wpa_supplicant \
//wpa_cli -p/data/misc/wifi/sockets -iwlan0
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
-O/data/misc/wifi/sockets \
-puse_p2p_group_interface=1 \
-e/data/misc/wifi/entropy.bin
socket wpa_wlan0 dgram 660 wifi wifi
class late_start
disabled
oneshot
########## kernel version >= 3.10.x ##########
b) "imx6/etc/init.rc"
# give system access to wpa_supplicant.conf for backup and restore
mkdir /data/misc/wifi 0770 wifi wifi //测试时可将该权限设定777 //检测运行时/data/misc/wifi/wpa_supplicant.con & p2p_supplicant是否正常创建
mkdir /data/misc/wifi/sockets 0770 wifi wifi
//wpa_supplicant会对该文件存在读取回写的动作
mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi
chmod 0660 /data/misc/wifi/wpa_supplicant.conf
# Prepare for wifi
setprop wifi.interface wlan0
setprop wifi.ap.interface wlan0
c) wpa_supplicant
I. "android/external/wpa_supplicant_8/wpa_supplicant/wpa_supplicant.conf" :
ctrl_interface=wlan0
update_config=1
eapol_version=1
ap_scan=1
fast_reauth=1
II. "android/hardware/broadcom/wlan/bcmdhd/config/wpa_supplicant_overlay.conf"
disable_scan_offload=1
p2p_disabled=1
III. "android/hardware/broadcom/wlan/bcmdhd/config/p2p_supplicant_overlay.conf"
disable_scan_offload=1
IV. "android/external/wpa_supplicant_8/wpa_supplicant/Android.mk"
include $(CLEAR_VARS)
LOCAL_MODULE := wpa_supplicant
ifdef CONFIG_DRIVER_CUSTOM
LOCAL_STATIC_LIBRARIES := libCustomWifi
endif
ifneq ($(BOARD_WPA_SUPPLICANT_PRIVATE_LIB),) //参见Boardconfig.mk中定义
LOCAL_STATIC_LIBRARIES += $(BOARD_WPA_SUPPLICANT_PRIVATE_LIB)
endif
LOCAL_SHARED_LIBRARIES := libc libcutils liblog
ifeq ($(CONFIG_TLS), openssl)
LOCAL_SHARED_LIBRARIES += libcrypto libssl libkeystore_binder
endif
ifdef CONFIG_DRIVER_NL80211
LOCAL_STATIC_LIBRARIES += libnl_2
endif
LOCAL_CFLAGS := $(L_CFLAGS)
LOCAL_SRC_FILES := $(OBJS)
LOCAL_C_INCLUDES := $(INCLUDES)
include $(BUILD_EXECUTABLE)
V. "android/external/wpa_supplicant_8/hostapd/Android.mk"
include $(CLEAR_VARS)
LOCAL_MODULE := hostapd
LOCAL_MODULE_TAGS := optional
ifdef CONFIG_DRIVER_CUSTOM
LOCAL_STATIC_LIBRARIES := libCustomWifi
endif
ifneq ($(BOARD_HOSTAPD_PRIVATE_LIB),) //参见Boardconfig.mk中定义
LOCAL_STATIC_LIBRARIES += $(BOARD_HOSTAPD_PRIVATE_LIB)
endif
LOCAL_SHARED_LIBRARIES := libc libcutils liblog libcrypto libssl
ifdef CONFIG_DRIVER_NL80211
LOCAL_STATIC_LIBRARIES += libnl_2
endif
LOCAL_CFLAGS := $(L_CFLAGS)
LOCAL_SRC_FILES := $(OBJS)
LOCAL_C_INCLUDES := $(INCLUDES)
include $(BUILD_EXECUTABLE)
4. 修改 "imx6/sabresd_6dq.mk" 直接编译(firmware、nvram、wpa_supplicant.conf等)添加到指定目录,或手动拷贝到指定目录
#BOARD_WLAN_DEVICE_REV := bcm4335 -include hardware/broadcom/wlan/bcmdhd/config/config-bcm.mk
#WIFI_BAND := 802_11_ABG
$(call inherit-product, hardware/broadcom/wlan/bcmdhd/firmware/bcm4335/device-bcm.mk) //参见"hardware/broadcom/wlan/bcmdhd/config/config-bcm.mk"
5. 修改 "hardware/libhardware_legacy/wifi/Android.mk"
LOCAL_SRC_FILES += wifi/wifi.c //Broadcom使用默认wifi.c即可
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../external/wpa_supplicant_8/src/common
6. 修改 "hardware/libhardware_legacy/wifi/wifi.c"
#ifndef WIFI_DRIVER_MODULE_PATH
#define WIFI_DRIVER_MODULE_PATH "/system/lib/modules/bcmdhd.ko"
#endif
#ifndef WIFI_DRIVER_MODULE_NAME
#define WIFI_DRIVER_MODULE_NAME "bcmdhd"
#endif
#ifndef WIFI_DRIVER_MODULE_ARG
#define WIFI_DRIVER_MODULE_ARG
"firmware_path=/system/vendor/firmware/fw_bcmdhd.bin
nvram_path=/system/vendor/firmware/nvram.txt"
#endif
#define WIFI_TEST_INTERFACE wlan0 // setprop wifi.interface wlan0
static int insmod(const char *filename, const char *args) //的为了在setting中ON/OFF时不会反复insmod/rmmod
{ //反复insmod/rmmod会导致不能再次启动 配合①使用
return 0;
}
static int rmmod(const char *modname)
{
return 0;
}