RK3288 Android5.1 RTL8723DS WIFI/BT模块移植 以及AP6XXX模块与RTL8723DS模块做兼容

 

一、rk3288 android5.1 rtl8723ds移植

瑞芯微对RK3288 Android7.1的SDK已经集成了RTL8723DS的模块并做了wifi模块的兼容,但是android5.1并没有集成8723ds的模块,所以介绍下rtl8723ds在rk3288 android5.1上的移植步骤,有时候也难免会出现换供应商换wifi模块的时候,所以以下也会介绍如何对AP6XXX模块与RTL8723DS模块做兼容。

1.将rtl8723DS.zip解压到kernel/drivers/net/wireless/rockchip_wlan/目录

rtl8723DS.zip下载地址:https://download.csdn.net/download/Mrdeath/12926260

2.打上如下patch

补丁下载:https://download.csdn.net/download/Mrdeath/12923627

diff --git a/device/common/bluetooth/libbt_rtk8723bs/src/hardware.c b/device/common/bluetooth/libbt_rtk8723bs/src/hardware.c
index 972ab74bf2..45bd7083d5 100755
--- a/device/common/bluetooth/libbt_rtk8723bs/src/hardware.c
+++ b/device/common/bluetooth/libbt_rtk8723bs/src/hardware.c
@@ -126,6 +126,7 @@ struct rtk_bt_vendor_config{
 #define ROM_LMP_8723cs_cg        0x8705//0x8703+2
 #define ROM_LMP_8723cs_vf         0x8706//0x8703+3
 #define ROM_LMP_8822b               0x8822
+#define ROM_LMP_8723ds              0x8723
 
 #define CHIP_8723CS_CG 3
 #define CHIP_8723CS_VF 4
@@ -261,6 +262,7 @@ uint16_t project_id[]=
     ROM_LMP_8703b,
     ROM_LMP_8723c,
     ROM_LMP_8822b,
+	ROM_LMP_8723ds,
 	ROM_LMP_NONE
 };
 
@@ -282,6 +284,7 @@ static patch_info patch_table[] = {
     { ROM_LMP_8723cs_xx, "rtl8723cs_xx_fw", "rtl8723cs_xx_config"},     //rtl8723cs_xx
     { ROM_LMP_8723cs_cg, "rtl8723cs_cg_fw", "rtl8723cs_cg_config"},     //rtl8723cs_cg
     { ROM_LMP_8723cs_vf,  "rtl8723cs_vf_fw", "rtl8723cs_vf_config"},     //rtl8723cs_vf
+    { ROM_LMP_8723ds,     "rtl8723ds_fw", "rtl8723ds_config"},
     /* add entries here*/
 
     { ROM_LMP_NONE,  "rtl_none_fw", "rtl_none_config"}
@@ -626,7 +629,7 @@ uint32_t rtk_get_bt_config(unsigned char** config_buf,
     size_t filelen;
     int fd;
     FILE* file = NULL;
-
+    ALOGD("LOUHN: bt_chip_type=%s",bt_chip_type);
     if (strcmp(bt_chip_type, "RTL8723BS_VQ0") == 0)
         sprintf(bt_config_file_name, BT_CONFIG_DIRECTORY, "rtl8723bs_VQ0_config");
     else
diff --git a/external/bluetooth/bluedroid/hci/src/bt_hci_bdroid.c b/external/bluetooth/bluedroid/hci/src/bt_hci_bdroid.c
index 8feaee265b..a04c195a1a 100755
--- a/external/bluetooth/bluedroid/hci/src/bt_hci_bdroid.c
+++ b/external/bluetooth/bluedroid/hci/src/bt_hci_bdroid.c
@@ -344,7 +344,7 @@ static int init(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr)
 #else//if defined HCI_USE_RTK_H5
     extern int check_wifi_chip_type_string(char *type);
 	check_wifi_chip_type_string(type);
-	if (!strncmp(type, "RTL8723BS", 9)) {
+	if (!strncmp(type, "RTL8723BS", 9) || !strncmp(type, "RTL8723DS", 9)) {
 	    extern tHCI_IF hci_h5_func_table;
 	    p_hci_if = &hci_h5_func_table;
 	    ALOGD("%s, use hci h5", __func__);
diff --git a/external/bluetooth/bluedroid/hci/src/vendor.c b/external/bluetooth/bluedroid/hci/src/vendor.c
index 4d09574243..ff2ae9f005 100755
--- a/external/bluetooth/bluedroid/hci/src/vendor.c
+++ b/external/bluetooth/bluedroid/hci/src/vendor.c
@@ -65,7 +65,7 @@ bool vendor_open(const uint8_t *local_bdaddr) {
 
     extern int check_wifi_chip_type_string(char *type);
     check_wifi_chip_type_string(type);
-    if (!strncmp(type, "RTL8723BS", 9)) {
+    if (!strncmp(type, "RTL8723BS", 9) || !strncmp(type, "RTL8723DS", 9)) {
         strcpy(vendor_so, "libbt-vendor-rtl8723bs.so");
     } else if (!strcmp(type, "RTL8723BU")) {
         strcpy(vendor_so, "libbt-vendor-rtl8723bu.so");
diff --git a/external/bluetooth_rtk/bluedroid/hci/src/bt_hci_bdroid.c b/external/bluetooth_rtk/bluedroid/hci/src/bt_hci_bdroid.c
index a7ac86e005..71a7ee0ce9 100755
--- a/external/bluetooth_rtk/bluedroid/hci/src/bt_hci_bdroid.c
+++ b/external/bluetooth_rtk/bluedroid/hci/src/bt_hci_bdroid.c
@@ -344,8 +344,10 @@ static int init(const bt_hc_callbacks_t* p_cb, unsigned char *local_bdaddr)
 #else//if defined HCI_USE_RTK_H5
     extern int check_wifi_chip_type_string(char *type);
 	check_wifi_chip_type_string(type);
+	ALOGD("LOUHN:in hci type=%s",type);
 	if (!strncmp(type, "RTL8723BS", 9) ||
-	    !strncmp(type, "RTL8723CS", 9)) {
+	    !strncmp(type, "RTL8723CS", 9) ||
+	    !strncmp(type, "RTL8723DS", 9)) {
 	    extern tHCI_IF hci_h5_func_table;
 	    p_hci_if = &hci_h5_func_table;
 	    ALOGD("%s, use hci h5", __func__);
diff --git a/external/bluetooth_rtk/bluedroid/hci/src/vendor.c b/external/bluetooth_rtk/bluedroid/hci/src/vendor.c
index e440fcc3e8..546056d1c8 100755
--- a/external/bluetooth_rtk/bluedroid/hci/src/vendor.c
+++ b/external/bluetooth_rtk/bluedroid/hci/src/vendor.c
@@ -65,8 +65,10 @@ bool vendor_open(const uint8_t *local_bdaddr) {
 
     extern int check_wifi_chip_type_string(char *type);
     check_wifi_chip_type_string(type);
+    ALOGD("LOUHN:type=%s",type);
     if (!strncmp(type, "RTL8723BS", 9) ||
-        !strncmp(type, "RTL8723CS", 9)) {
+        !strncmp(type, "RTL8723CS", 9) ||
+	!strncmp(type, "RTL8723DS", 9)) {
         strcpy(vendor_so, "libbt-vendor-rtl8723bs.so");
     } else if (!strncmp(&type[7], "BU", 2) || // like RTL8723AU/BU RTL8811AU
 	       !strncmp(&type[7], "AU", 2)) {
diff --git a/kernel/arch/arm/boot/dts/rk3288-box.dts b/kernel/arch/arm/boot/dts/rk3288-box.dts
index 63537738d9..9347af57a8 100644
--- a/kernel/arch/arm/boot/dts/rk3288-box.dts
+++ b/kernel/arch/arm/boot/dts/rk3288-box.dts
@@ -57,7 +57,7 @@
 	* esp8089 ==> esp8089;
 	* other   ==> for other wifi;
 	*/
-	wifi_chip_type = "ap6256";
+	wifi_chip_type = "rtl8723ds";
 	sdio_vref = <3300>; //1800mv or 3300mv
 
 	//keep_wifi_power_on;
diff --git a/kernel/arch/arm/configs/hzmct_defconfig b/kernel/arch/arm/configs/hzmct_defconfig
index 433b1941f2..ea5a92615d 100644
--- a/kernel/arch/arm/configs/hzmct_defconfig
+++ b/kernel/arch/arm/configs/hzmct_defconfig
@@ -1424,7 +1424,7 @@ CONFIG_WLAN=y
 CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP=y
 CONFIG_RTL_WIRELESS_SOLUTION=y
 # CONFIG_RTL_WIFI_NONE is not set
-CONFIG_RTL8188EU=y
+# CONFIG_RTL8188EU is not set
 # CONFIG_RTL8189ES is not set
 # CONFIG_RTL8192CU is not set
 # CONFIG_RTL8192DU is not set
@@ -1433,6 +1433,7 @@ CONFIG_RTL8188EU=y
 # CONFIG_RTL8723BS is not set
 # CONFIG_RTL8723BS_VQ0 is not set
 # CONFIG_RTL8812AU is not set
+CONFIG_RTL8723DS=y
 CONFIG_ESP8089=y
 CONFIG_RKWIFI=y
 # CONFIG_BCM4330 is not set
diff --git a/kernel/drivers/net/wireless/Kconfig b/kernel/drivers/net/wireless/Kconfig
index 544aa86f0d..813cc33591 100755
--- a/kernel/drivers/net/wireless/Kconfig
+++ b/kernel/drivers/net/wireless/Kconfig
@@ -53,6 +53,7 @@ source "drivers/net/wireless/rockchip_wlan/rtl8723bu/Kconfig"
 source "drivers/net/wireless/rockchip_wlan/rtl8723bs/Kconfig"
 source "drivers/net/wireless/rockchip_wlan/rtl8723bs-vq0/Kconfig"
 source "drivers/net/wireless/rockchip_wlan/rtl8812au/Kconfig"
+source "drivers/net/wireless/rockchip_wlan/rtl8723DS/Kconfig"
 endchoice
 endif
 
diff --git a/kernel/drivers/net/wireless/Makefile b/kernel/drivers/net/wireless/Makefile
index fb61bb0007..fdc79beba3 100755
--- a/kernel/drivers/net/wireless/Makefile
+++ b/kernel/drivers/net/wireless/Makefile
@@ -11,5 +11,6 @@ obj-$(CONFIG_RTL8723BU)	       += rockchip_wlan/rtl8723bu/
 obj-$(CONFIG_RTL8812AU)	       += rockchip_wlan/rtl8812au/
 obj-$(CONFIG_RKWIFI)           += rockchip_wlan/rkwifi/
 obj-$(CONFIG_RTL8723BS)        += rockchip_wlan/rtl8723bs/
+obj-$(CONFIG_RTL8723DS)        += rockchip_wlan/rtl8723DS/
 obj-$(CONFIG_RTL8723BS_VQ0)    += rockchip_wlan/rtl8723bs-vq0/
 obj-$(CONFIG_ESP8089)   += rockchip_wlan/esp8089/
diff --git a/kernel/drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c b/kernel/drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c
index f90f6c842e..9f62c2d745 100755
--- a/kernel/drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c
+++ b/kernel/drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c
@@ -123,6 +123,11 @@ static ssize_t wifi_chip_read(struct class *cls, struct class_attribute *attr, c
 	    printk("Current WiFi chip is ESP8089.\n");
 	}
 
+	if(type == WIFI_RTL8723DS) {
+            count = sprintf(_buf, "%s", "RTL8723DS");
+            printk("Current WiFi chip is RTL8723DS.\n");
+        }
+
     return count;
 }
 
diff --git a/kernel/include/linux/rfkill-wlan.h b/kernel/include/linux/rfkill-wlan.h
index 8b34fafa5d..cbaa62f704 100755
--- a/kernel/include/linux/rfkill-wlan.h
+++ b/kernel/include/linux/rfkill-wlan.h
@@ -66,6 +66,7 @@ enum {
     WIFI_RTL8723AU,
     WIFI_RTL8189ES,
     WIFI_RTL8812AU,
+    WIFI_RTL8723DS,
     WIFI_RTL_SERIES,
     WIFI_ESP8089,
     TYPE_MAX,
diff --git a/kernel/net/rfkill/rfkill-wlan.c b/kernel/net/rfkill/rfkill-wlan.c
index d42163570a..8fd5a22ea5 100755
--- a/kernel/net/rfkill/rfkill-wlan.c
+++ b/kernel/net/rfkill/rfkill-wlan.c
@@ -143,7 +143,9 @@ int get_wifi_chip_type(void)
     } else if (strcmp(wifi_chip_type_string, "rtl8189es") == 0) {
         type = WIFI_RTL8189ES;
     } else if (strcmp(wifi_chip_type_string, "rtl8812au") == 0) {
-        type = WIFI_RTL8812AU;                        
+        type = WIFI_RTL8812AU;                
+    } else if (strcmp(wifi_chip_type_string, "rtl8723ds") == 0) {
+        type = WIFI_RTL8723DS;    
     } else if (strcmp(wifi_chip_type_string, "esp8089") == 0) {
         type = WIFI_ESP8089;
     } else {
diff --git a/vendor/rockchip/common/bluetooth/realtek/firmware/uart/rtlbtfw_cfg.mk b/vendor/rockchip/common/bluetooth/realtek/firmware/uart/rtlbtfw_cfg.mk
index fb9f1c5334..f81f1027ae 100755
--- a/vendor/rockchip/common/bluetooth/realtek/firmware/uart/rtlbtfw_cfg.mk
+++ b/vendor/rockchip/common/bluetooth/realtek/firmware/uart/rtlbtfw_cfg.mk
@@ -5,6 +5,8 @@ PRODUCT_COPY_FILES += \
                 $(LOCAL_PATH)/rtl8723b_config:system/etc/firmware/rtl8723bs_config \
                 $(LOCAL_PATH)/rtl8723b_VQ0_fw:system/etc/firmware/rtl8723bs_VQ0_fw \
 		$(LOCAL_PATH)/rtl8723b_VQ0_config:system/etc/firmware/rtl8723bs_VQ0_config \
+		$(LOCAL_PATH)/rtl8723ds_fw:system/etc/firmware/rtl8723ds_fw \
+		$(LOCAL_PATH)/rtl8723ds_config:system/etc/firmware/rtl8723ds_config \
                 $(LOCAL_PATH)/rtl8761a_fw:system/etc/firmware/rtl8761as_fw \
                 $(LOCAL_PATH)/rtl8761a_config:system/etc/firmware/rtl8761as_config \
                 $(LOCAL_PATH)/rtl8821a_fw:system/etc/firmware/rtl8821as_fw   \

3.将rtl8723ds_fw rtl8723ds_config两个固件拷贝到vendor/rockchip/common/bluetooth/realtek/firmware/uart/目录下

rtl8723ds_fw rtl8723ds_config固件下载:https://download.csdn.net/download/Mrdeath/12923609

4.用libbt_rtk8723bs.zip替换device/common/bluetooth/目录下的libbt_rtk8723bs

libbt_rtk8723bs.zip替换后可能会覆盖掉上面补丁里的部分修改,没关系,直接覆盖就行

libbt_rtk8723bs.zip:https://download.csdn.net/download/Mrdeath/12923587

完成以上操作后在menuconfig里面勾选上CONFIG_RTL8723DS就能够使用rtl8923ds驱动了

 

二、AP6XX与RTL8723DS做兼容

这里我以AP6212A模块与RTL8723DS模块举例

1.设置wifi驱动为模块形式加载

1)将CONFIG_RTL8723DS=m,

添加CONFIG_WIFI_BUILD_MODULE=y ,

CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP=n

CONFIG_RKWIFI=m

CONFIG_RTL8723DS=m

2)并修改kernel/drivers/net/wireless/Kconfig文件,下将drivers/net/wireless/rockchip_wlan/rtl8723DS/Kconfig移动到endchoice endif下面,因为不这样移动rtl8723ds就编译不了模块

3)修改rk_wifi_config.c的编译顺序

diff --git a/kernel/arch/arm/configs/hzmct_defconfig b/kernel/arch/arm/configs/hzmct_defconfig
index e45921ab5d..b4795a40e4 100644
--- a/kernel/arch/arm/configs/hzmct_defconfig
+++ b/kernel/arch/arm/configs/hzmct_defconfig
@@ -1421,10 +1421,11 @@ CONFIG_USB_IPHETH=y
 CONFIG_USB_SIERRA_NET=y
 # CONFIG_USB_VL600 is not set
 CONFIG_WLAN=y
-CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP=y
+CONFIG_WIFI_BUILD_MODULE=y
+# CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP is not set
 CONFIG_RTL_WIRELESS_SOLUTION=y
-CONFIG_RTL_WIFI_NONE=y
-# CONFIG_RTL8188EU is not set
+# CONFIG_RTL_WIFI_NONE is not set
+CONFIG_RTL8188EU=y
 # CONFIG_RTL8189ES is not set
 # CONFIG_RTL8192CU is not set
 # CONFIG_RTL8192DU is not set
diff --git a/kernel/drivers/net/wireless/Kconfig b/kernel/drivers/net/wireless/Kconfig
index 033f184cee..686a2c245c 100755
--- a/kernel/drivers/net/wireless/Kconfig
+++ b/kernel/drivers/net/wireless/Kconfig
@@ -26,6 +26,12 @@ if WLAN
 #	  ---help---
 #	    rda5990P fm bt wifi
 
+config WIFI_BUILD_MODULE
+    bool "build wifi ko modules"
+    default n
+    ---help---
+      Wifi drivers will compile as ko module
+
 config WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
     bool "Wifi load driver when kernel bootup"
     default y
diff --git a/kernel/drivers/net/wireless/Makefile b/kernel/drivers/net/wireless/Makefile
index fdc79beba3..345db2fd8e 100755
--- a/kernel/drivers/net/wireless/Makefile
+++ b/kernel/drivers/net/wireless/Makefile
@@ -2,6 +2,7 @@
 # Makefile for the Linux Wireless network device drivers.
 #
 obj-y += rockchip_wlan/wifi_sys/rkwifi_sys_iface.o
+obj-y += rockchip_wlan/rkwifi/rk_wifi_config.o
 obj-$(CONFIG_RTL8192CU)        += rockchip_wlan/rtl8192cu/
 obj-$(CONFIG_RTL8192DU)        += rockchip_wlan/rtl8192du/
 obj-$(CONFIG_RTL8188EU)	       += rockchip_wlan/rtl8188eu/
diff --git a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/Makefile b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/Makefile
index ff74deb2b0..3c63b2d0a1 100644
--- a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/Makefile
+++ b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/Makefile
@@ -1,7 +1,7 @@
 #rkwifi packed Makefile
 # (gwl)
 
-obj-$(CONFIG_RKWIFI) += rk_wifi_config.o
+#obj-$(CONFIG_RKWIFI) += rk_wifi_config.o
 obj-$(CONFIG_RKWIFI) += bcmdhd/ 
 
 .PHONY: clean

diff --git a/kernel/drivers/net/wireless/Kconfig b/kernel/drivers/net/wireless/Kconfig
index 813cc33591..033f184cee 100755
--- a/kernel/drivers/net/wireless/Kconfig
+++ b/kernel/drivers/net/wireless/Kconfig
@@ -53,10 +53,10 @@ source "drivers/net/wireless/rockchip_wlan/rtl8723bu/Kconfig"
 source "drivers/net/wireless/rockchip_wlan/rtl8723bs/Kconfig"
 source "drivers/net/wireless/rockchip_wlan/rtl8723bs-vq0/Kconfig"
 source "drivers/net/wireless/rockchip_wlan/rtl8812au/Kconfig"
-source "drivers/net/wireless/rockchip_wlan/rtl8723DS/Kconfig"
+#source "drivers/net/wireless/rockchip_wlan/rtl8723DS/Kconfig"
 endchoice
 endif
-
+source "drivers/net/wireless/rockchip_wlan/rtl8723DS/Kconfig"
 #source "drivers/net/wireless/rockchip_wlan/mt5931/Kconfig"
 source "drivers/net/wireless/rockchip_wlan/esp8089/Kconfig"
 source "drivers/net/wireless/rockchip_wlan/rkwifi/Kconfig"

2.做两个模块的兼容

1).rk_wifi_ctrl.c和wifi.c拷贝到hardware/libhardware_legacy/wifi/

两个文件的下载地址:https://download.csdn.net/download/Mrdeath/12923719

2).2.在net/rfkill/rfkill-wlan.c的prob下添加rockchip_wifi_set_carddetect(1);

     rockchip_wifi_set_carddetect(1);是用于扫卡功能,sdio通过扫卡识别模块的PIDVID,根据PIDVID加载对应驱动

diff --git a/kernel/net/rfkill/rfkill-wlan.c b/kernel/net/rfkill/rfkill-wlan.c
index 4d26839492..d1e8634a93 100755
--- a/kernel/net/rfkill/rfkill-wlan.c
+++ b/kernel/net/rfkill/rfkill-wlan.c
@@ -981,7 +981,7 @@ static int rfkill_wlan_probe(struct platform_device *pdev)
     }
 
     rockchip_wifi_voltage_select();
+    rockchip_wifi_set_carddetect(1);
 

3)固定bcmdhd驱动的固件加载路径

--- a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
+++ b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
@@ -501,8 +501,8 @@ uint dhd_download_fw_on_driverload = TRUE;
 /* Definitions to provide path to the firmware and nvram
  * example nvram_path[MOD_PARAM_PATHLEN]="/projects/wlan/nvram.txt"
  */
-char firmware_path[MOD_PARAM_PATHLEN];
-char nvram_path[MOD_PARAM_PATHLEN];
+char firmware_path[MOD_PARAM_PATHLEN]="/system/etc/firmware/fw_bcm43438a1.bin";
+char nvram_path[MOD_PARAM_PATHLEN]="/system/etc/firmware/nvram_ap6212a.txt";

 4)在vendor/rockchip/common/wifi/目录下创建modules目录,将ko文件放入该目录下,最后编译SDK

两个模块兼容方案完成

 

以上是以前写的内容,现在要完善以上的方案。

上面的方案存在一个问题,就是当 firmware_path、char nvram_path这两个路径固定之后,就没法对APXX系列的模块进行兼容了,为了以后能有更好的兼容性,这个地方需要修改。

 

1.在wifi.c文件中添加一个save_wifi_chip_type函数,该函数的作用是将读取到的wifi的类型保存到/data/wifi_chip目录下

diff --git a/hardware/libhardware_legacy/wifi/wifi.c b/hardware/libhardware_legacy/wifi/wifi.c
index d4476c8353..4640650018 100644
--- a/hardware/libhardware_legacy/wifi/wifi.c
+++ b/hardware/libhardware_legacy/wifi/wifi.c
@@ -164,6 +164,8 @@ static const char P2P_CONFIG_FILE[]     = "/data/misc/wifi/p2p_supplicant.conf";
 static const char CONTROL_IFACE_PATH[]  = "/data/misc/wifi/sockets";
 static const char MODULE_FILE[]         = "/proc/modules";
 
+static const char RECOGNIZE_WIFI_CHIP[] = "/data/wifi_chip";
+
 static const char IFNAME[]              = "IFNAME=";
 #define IFNAMELEN                      (sizeof(IFNAME) - 1)
 static const char WPA_EVENT_IGNORE[]    = "CTRL-EVENT-IGNORE ";
@@ -197,6 +199,8 @@ wifi_ko_file_name module_list[] =
     {"RTL8189FS", RTL8189FS_DRIVER_MODULE_PATH },
     {"SSV6051",     SSV6051_DRIVER_MODULE_PATH },
     {"ESP8089",     ESP8089_DRIVER_MODULE_PATH },
 
+int save_wifi_chip_type(char *type)
+{
+        int ret, found;
+        int fd;
+        char buf[64];
+
+        ret = access(RECOGNIZE_WIFI_CHIP, R_OK|W_OK);
+
+        if ((ret == 0) || (errno == EACCES)) {
+                if ((ret != 0) && (chmod(RECOGNIZE_WIFI_CHIP, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) != 0)) {
+                        ALOGE("Cannot set RW to \"%s\": %s", RECOGNIZE_WIFI_CHIP, strerror(errno));
+                        return -1;
+                }
+                ALOGD("%s is exit\n", RECOGNIZE_WIFI_CHIP);
+                return 0;
+        }
+
+        fd = TEMP_FAILURE_RETRY(open(RECOGNIZE_WIFI_CHIP, O_CREAT|O_RDWR, 0664));
+        if (fd < 0) {
+                ALOGE("Cannot create \"%s\": %s", RECOGNIZE_WIFI_CHIP, strerror(errno));
+                return -1;
+        }
+        ALOGD("%s is not exit,save wifi chip\n", RECOGNIZE_WIFI_CHIP);
+        strcpy(buf, type);
+        ALOGD("recognized wifi chip = %s, save to %s\n", buf, RECOGNIZE_WIFI_CHIP);
+        if (TEMP_FAILURE_RETRY(write(fd, buf, strlen(buf)+1)) != strlen(buf)+1) {
+                ALOGE("Error writing \"%s\": %s", RECOGNIZE_WIFI_CHIP, strerror(errno));
+                close(fd);
+                return -1;
+        }
+        close(fd);
+        if (chmod(RECOGNIZE_WIFI_CHIP, 0664) < 0) {
+                ALOGE("Error changing permissions of %s to 0664: %s",RECOGNIZE_WIFI_CHIP, strerror(errno));
+                unlink(RECOGNIZE_WIFI_CHIP);
+                return -1;
+        }
+        if (chown(RECOGNIZE_WIFI_CHIP, AID_SYSTEM, AID_WIFI) < 0) {
+                ALOGE("Error changing group ownership of %s to %d: %s",RECOGNIZE_WIFI_CHIP, AID_WIFI, strerror(errno));
+                unlink(RECOGNIZE_WIFI_CHIP);
+                return -1;
+        }
+        return 1;
+}
+
+
 int wifi_load_driver()
 {
     char* wifi_ko_path = NULL ;
@@ -322,6 +371,7 @@ int wifi_load_driver()
     ALOGD("%s", __func__);
     if (wifi_type[0] == 0)
         check_wifi_chip_type_string(wifi_type);
+       save_wifi_chip_type(wifi_type);
     for (i=0; i< (int)(sizeof(module_list) / sizeof(module_list[0])); i++) {
         if (!strcmp(wifi_type , module_list[i].wifi_name)) {
             wifi_ko_path = module_list[i].wifi_module_path;

2.将firmware_path和nvram_path固定的路径还原,在rockchip_wifi_init_module_rkwifi函数中去读取/data/wifi_type文本里的内容,根据读取出来的信息,去加载对应的文件

index 4670927873..7d8e85baa0 100755
--- a/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
+++ b/kernel/drivers/net/wireless/rockchip_wlan/rkwifi/bcmdhd/dhd_linux.c
@@ -33,6 +33,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #ifdef ENABLE_ADAPTIVE_SCHED
 #include 
 #endif /* ENABLE_ADAPTIVE_SCHED */
@@ -501,8 +503,8 @@ uint dhd_download_fw_on_driverload = TRUE;
 /* Definitions to provide path to the firmware and nvram
  * example nvram_path[MOD_PARAM_PATHLEN]="/projects/wlan/nvram.txt"
  */
-char firmware_path[MOD_PARAM_PATHLEN]="/system/etc/firmware/fw_bcm43438a1.bin";
-char nvram_path[MOD_PARAM_PATHLEN]="/system/etc/firmware/nvram_ap6212a.txt";
+char firmware_path[MOD_PARAM_PATHLEN];
+char nvram_path[MOD_PARAM_PATHLEN];
 char clm_path[MOD_PARAM_PATHLEN];
 char config_path[MOD_PARAM_PATHLEN];
 
@@ -7855,7 +7857,12 @@ static int wifi_init_thread(void *data)
 int rockchip_wifi_init_module_rkwifi(void)
 {
        
-       
+    const char RECOGNIZE_WIFI_CHIP[] = "/data/wifi_chip";      
+    struct file *fp; 
+    loff_t pos = 0;
+     mm_segment_t fs;
+    char wifi_type[16];
+
 #ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
     int type = get_wifi_chip_type();
     if (type > WIFI_AP6XXX_SERIES) return 0;
@@ -7865,6 +7872,29 @@ int rockchip_wifi_init_module_rkwifi(void)
     printk("=======================================================\n");
     printk("%s WiFi driver (Powered by Rockchip,Ver %s) init.\n", WIFI_MODULE_NAME, RKWIFI_DRV_VERSION);
 
+    if((fp = filp_open(RECOGNIZE_WIFI_CHIP,O_RDONLY,0)) != NULL) {
+       fs=get_fs();
+       set_fs(KERNEL_DS); 
+       vfs_read(fp,wifi_type,16,&pos); 
+       set_fs(fs); 
+    } else {
+       printk("LOUHN Can not read %s to get wifi type \n",RECOGNIZE_WIFI_CHIP);
+    }
+    filp_close(fp,NULL);
+    printk("LOUHN Wifi type(get from %s):%s\n",RECOGNIZE_WIFI_CHIP,wifi_type);
+    
+    if(!strcmp(wifi_type,"AP6212A")){
+       strcpy(firmware_path,"/system/etc/firmware/fw_bcm43438a1.bin");
+       strcpy(nvram_path,"/system/etc/firmware/nvram_ap6212a.txt");
+    } else if(!strcmp(wifi_type,"AP6256")){
+       strcpy(firmware_path,"/system/etc/firmware/fw_bcm43456c5_ag.bin");
+        strcpy(nvram_path,"/system/etc/firmware/nvram_ap6256.txt");
+    }else{
+       strcpy(firmware_path,"/system/etc/firmware/fw_bcm43438a1.bin");
+        strcpy(nvram_path,"/system/etc/firmware/nvram_ap6212a.txt");
+    }
+
+
 #ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
 {
     struct task_struct *kthread = kthread_run(wifi_init_thread, NULL, "wifi_init_thread");

 

你可能感兴趣的:(RK3288_Android)