第一部分是kernel
内核配置参考rk文档,把device driver 下wireless相关的先勾选上。
编译到buildin有问题,识别不到,所以打算编译成ko
cd kernel/drivers/net/wireless/rockchip_wlan/rtl8188eu
make -C /home/lzm/workspace/rk3288/zy_n10/kernel/ M=`pwd` modules
得到8188eu.ko
lsusb,看vid pid,是存在的
看初始化函数,发现被注释,修改打开
第二部分,android打开Settings配置
commit e0394d5bb67a76fedbbbdca3f9cba39fbdd9c576
Author: songyoulin <songyoulin@star-net.cn>
Date: Tue Oct 17 16:25:15 2017 +0800
provide EthernetSettings interface
packages/apps/Settings/AndroidManifest.xml | 9 ++++-----
packages/apps/Settings/src/com/android/settings/Settings.java | 1 +
packages/apps/Settings/src/com/android/settings/SettingsActivity.java | 1 +
commit 17dad10a1276a568e2952741a9a188d0bd6ced19
Author: youchangning <youchangning@star-net.cn>
Date: Tue Nov 15 09:35:39 2016 +0800
hide settings
device/rockchip/rk3288/system.prop | 2 +-
packages/apps/Settings/src/com/android/settings/SettingsActivity.java | 16 ++++++++++++++++
--- a/packages/apps/Settings/src/com/android/settings/SettingsActivity.java
+++ b/packages/apps/Settings/src/com/android/settings/SettingsActivity.java
@@ -1224,6 +1224,10 @@ public class SettingsActivity extends Activity
|| Utils.isMonkeyRunning()) {
removeTile = true;
}
+
+ if (!showDev) {
+ removeTile = true;
+ }
} else if (id == R.id.nfc_payment_settings) {
if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_NFC)) {
removeTile = true;
@@ -1260,6 +1264,18 @@ public class SettingsActivity extends Activity
if (!"box".equals(SystemProperties.get("ro.target.product", "tablet"))){
removeTile = true;
}
+ } else if ((id == R.id.power_save_settings) ||
+ (id == R.id.location_settings) ||
+ (id == R.id.account_settings) ||
+ (id == R.id.security_settings) ||
+ (id == R.id.accessibility_settings) ||
+ (id == R.id.language_settings) ||
+ (id == R.id.display_settings) ||
+ (id == R.id.notification_settings) ||
+ (id == R.id.date_time_settings)) {
+ if (!showDev) {
+ removeTile = true;
+ }
}
if (UserHandle.MU_ENABLED && UserHandle.myUserId() != 0
commit 203df58cfb3281b9445b86e302eac883c93e970f
E/WifiService( 456): Invoking mWifiStateMachine.setWifiEnabled
E/WifiStateMachine( 456): setting operational mode to 1
E/RkWifiCtrl( 456): Wifi driver is not ready.
E/RkWifiCtrl( 456): rk_wifi_load_driver:(insmod)
E/RkWifiCtrl( 456): rk_wifi_load_driver: open(/sys/class/rkwifi/driver) for write failed: Permission denied (13)
E/WifiStateMachine( 456): Failed to load driver
E/WifiStateMachine( 456): setSuspendOptimizations: 2 true
E/WifiStateMachine( 456): mSuspendOptNeedsDisabled 0
W/Vibrator( 456): Failed to vibrate; no vibrator service.
E/WifiService( 456): Invoking mWifiStateMachine.setWifiEnabled
rk这个有点坑了。。。
lzm@compilere:~/workspace/rk3288/zy_n10$ grep -rn "rk_wifi_load_driver" *
hardware/libhardware_legacy/include/hardware_legacy/wifi.h:58:int rk_wifi_load_driver(int enable);
hardware/libhardware_legacy/wifi/wifi.c:315: if (rk_wifi_load_driver(1) < 0)
hardware/libhardware_legacy/wifi/wifi.c:376: ret = rk_wifi_load_driver(0);
hardware/libhardware_legacy/wifi/rk_wifi_ctrl.c:48:int rk_wifi_load_driver(int enable);
hardware/libhardware_legacy/wifi/rk_wifi_ctrl.c:195:int rk_wifi_load_driver(int enable)
hardware/libhardware_legacy/wifi/rk_wifi_ctrl.c:201: ALOGE("rk_wifi_load_driver:(%s)", enable? "insmod":"rmmod");
hardware/libhardware_legacy/wifi/rk_wifi_ctrl.c:216: ALOGE("rk_wifi_load_driver: open(%s) for write failed: %s (%d)",
hardware/libhardware_legacy/wifi/rk_wifi_ctrl.c:224: ALOGE("rk_wifi_load_driver: write(%s) failed: %s (%d)",
属于hal层,
HAL概述
https://www.cnblogs.com/lcw/p/3335505.html
编译完放置在 /system/lib/
130|root@EMT100T:/sys/class/rkwifi # ls /system/lib/
libhardware.so libharfbuzz_ng.so libhwui.so
libhardware_legacy.so libhevcdec.so
单独编译:
source build/envsetup.sh
lzm@compilere:~/workspace/rk3288/zy_n10$ lunch
You're building on Linux
Lunch menu... pick a combo:
1. rk3288-user
2. rk3288-userdebug
3. rk3288_box-userdebug
4. rk3288-eng
5. mini_emulator_mips-userdebug
6. mini_emulator_arm64-userdebug
7. mini_emulator_x86-userdebug
8. mini_emulator_x86_64-userdebug
9. m_e_arm-userdebug
10. aosp_shamu-userdebug
11. aosp_flounder-userdebug
Which would you like? [aosp_arm-eng] 2
cd hardware/libhardware_legacy
mm
android源码目录下的build/envsetup.sh文件,描述编译的命令
- m: Makes from the top of the tree.
- mm: Builds all of the modules in the current directory.
- mmm: Builds all of the modules in the supplied directories.
要想使用这些命令,首先需要在android源码根目录执行. build/envsetup.sh 脚本设置环境
m:编译所有的模块
mm:编译当前目录下的模块,当前目录下要有Android.mk文件
mmm:编译指定路径下的模块,指定路径下要有Android.mk文件
下面举个例子说明,假设我要编译android下的hardwarelibhardware_legacypower模块,当前目录为源码根目录,方法如下:
1、. build/envsetup.sh
2、mmm hardware/libhardware_legacy/power/
或者 :
1、. build/envsetup.sh
2、cd hardware/libhardware_legacy/power/
3、mm
adb push libhardware_legacy.so /system/lib/
adb shell am start com.android.settings/com.android.settings.Settings
130|root@EMT100T:/ # logcat -s RkWifiCtrl
--------- beginning of main
--------- beginning of system
D/RkWifiCtrl( 439): check_wifi_preload: Wifi driver is not preload when bootup, load when open wifi.
E/RkWifiCtrl( 439): rk_wifi_load_driver:(rmmod)
E/RkWifiCtrl( 439): Wifi driver is not ready.
D/RkWifiCtrl( 439): check_wifi_preload: Wifi driver is not preload when bootup, load when open wifi.
E/RkWifiCtrl( 439): Wifi driver is not ready.
E/RkWifiCtrl( 439): rk_wifi_load_driver:(insmod)
E/RkWifiCtrl( 439): Wifi driver is not ready.
E/RkWifiCtrl( 439): Wifi driver is not ready.
E/RkWifiCtrl( 439): Wifi driver is not ready.
E/RkWifiCtrl( 439): Wifi driver is not ready.
E/RkWifiCtrl( 439): Wifi driver is not ready.
E/RkWifiCtrl( 439): Wifi driver is not ready.
E/RkWifiCtrl( 439): Wifi driver is not ready.
net/rfkill/rfkill-wlan.c:100:int get_wifi_chip_type(void)
net/rfkill/rfkill-wlan.c:152:EXPORT_SYMBOL(get_wifi_chip_type);
net/rfkill/rfkill-wlan.c:491: chip = get_wifi_chip_type();
强制返回
} else if (strcmp(wifi_chip_type_string, "rtl8188eu") == 0) {
type = WIFI_RTL8188EU;
kernel$ vi drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c
看了下,主要也是这些接口,主要是看当前的chip类型,还有就是电源控制,没啥用。
void rkwifi_sysif_exit(void)
{
// need to remove the sys files and class
class_remove_file(rkwifi_class, &class_attr_chip);//返回芯片类型
class_remove_file(rkwifi_class, &class_attr_power);//电源控制
class_remove_file(rkwifi_class, &class_attr_driver);//驱动特殊初始化
#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
class_remove_file(rkwifi_class, &class_attr_preload);
看看驱动特殊初始化有没做啥?
static int wifi_init_exit_module(int enable)
{
int ret = 0;
#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
#else
int type = get_wifi_chip_type();
//#ifdef CONFIG_RKWIFI
if (type < WIFI_AP6XXX_SERIES) {
if (enable > 0)
ret = rockchip_wifi_init_module_rkwifi();
else
rockchip_wifi_exit_module_rkwifi();
return ret;
}
//#endif
//#ifdef CONFIG_RTL_WIRELESS_SOLUTION
if (type < WIFI_RTL_SERIES) {
if (enable > 0)
ret = rockchip_wifi_init_module_rtkwifi();
else
rockchip_wifi_exit_module_rtkwifi();
return ret;
}
//#endif
//#ifdef CONFIG_ESP8089
if (type == WIFI_ESP8089) {
if (enable > 0)
ret = rockchip_wifi_init_module_esp8089();
else
rockchip_wifi_exit_module_esp8089();
return ret;
}
//#endif
#endif
return ret;
}
可以看到最后调用了不同的驱动初始化,这里我只看我们的
rockchip_wifi_init_module_rtkwifi
麻烦,这么多。。。。
lzm@compilere:~/workspace/rk3288/zy_n10/kernel$ grep -rn "rockchip_wifi_init_module_rtkwifi" drivers/net/
Binary file drivers/net/built-in.o matches
drivers/net/wireless/rockchip_wlan/rtl8188fu/os_dep/linux/usb_intf.c:1662:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8188fu/os_dep/linux/usb_intf.c:1696:late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8188fu/os_dep/linux/usb_intf.c:1699:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8723bs/os_dep/linux/sdio_intf.c:1047:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8723bs/os_dep/linux/sdio_intf.c:1083:late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8723bs/os_dep/linux/sdio_intf.c:1086:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8189es/os_dep/linux/sdio_intf.c:1061:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8189es/os_dep/linux/sdio_intf.c:1095:late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8189es/os_dep/linux/sdio_intf.c:1098:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c:145:extern int rockchip_wifi_init_module_rtkwifi(void);
drivers/net/wireless/rockchip_wlan/wifi_sys/rkwifi_sys_iface.c:172: ret = rockchip_wifi_init_module_rtkwifi();
drivers/net/wireless/rockchip_wlan/rtl8723bu/os_dep/linux/usb_intf.c:1761:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8723bu/os_dep/linux/usb_intf.c:1793:late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8723bu/os_dep/linux/usb_intf.c:1796:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8812au/os_dep/linux/usb_intf.c:1758:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8812au/os_dep/linux/usb_intf.c:1790:late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8812au/os_dep/linux/usb_intf.c:1793:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8723au/os_dep/linux/usb_intf.c:2163:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8723au/os_dep/linux/usb_intf.c:2195:late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8723au/os_dep/linux/usb_intf.c:2198:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8192cu/os_dep/linux/usb_intf.c:1622:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8192cu/os_dep/linux/usb_intf.c:1654:late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8192cu/os_dep/linux/usb_intf.c:1657:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8192du/os_dep/linux/usb_intf.c:1651:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8192du/os_dep/linux/usb_intf.c:1683:late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8192du/os_dep/linux/usb_intf.c:1686:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8723bs-vq0/os_dep/linux/sdio_intf.c:1047:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8723bs-vq0/os_dep/linux/sdio_intf.c:1083:late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8723bs-vq0/os_dep/linux/sdio_intf.c:1086:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8189fs/os_dep/linux/sdio_intf.c:1059:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8189fs/os_dep/linux/sdio_intf.c:1093:late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8189fs/os_dep/linux/sdio_intf.c:1096:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8188eu/os_dep/linux/usb_intf.c:1946:int rockchip_wifi_init_module_rtkwifi(void)
drivers/net/wireless/rockchip_wlan/rtl8188eu/os_dep/linux/usb_intf.c:1978://late_initcall(rockchip_wifi_init_module_rtkwifi);
drivers/net/wireless/rockchip_wlan/rtl8188eu/os_dep/linux/usb_intf.c:1981:EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
Binary file drivers/net/wireless/rockchip_wlan/rtl8188eu/os_dep/linux/usb_intf.o matches
可以看到其实就是使能电源。。。以及驱动初始化。
int rockchip_wifi_init_module_rtkwifi(void)
{
#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
int type = get_wifi_chip_type();
if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return 0;
#endif
printk("
");
printk("=======================================================
");
printk("==== Launching Wi-Fi driver! (Powered by Rockchip) ====
");
printk("=======================================================
");
printk("Realtek 8188EU USB WiFi driver (Powered by Rockchip,Ver %s) init.
", RTL8192_DRV_VERSION);
rockchip_wifi_power(1);
return rtw_drv_entry();
}
void rockchip_wifi_exit_module_rtkwifi(void)
{
#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
int type = get_wifi_chip_type();
if (type < WIFI_AP6XXX_SERIES || type == WIFI_ESP8089) return;
#endif
printk("
");
printk("=======================================================
");
printk("==== Dislaunching Wi-Fi driver! (Powered by Rockchip) ====
");
printk("=======================================================
");
printk("Realtek 8188EU USB WiFi driver (Powered by Rockchip,Ver %s) init.
", RTL8192_DRV_VERSION);
rtw_drv_halt();
rockchip_wifi_power(0);
}
#ifdef CONFIG_WIFI_LOAD_DRIVER_WHEN_KERNEL_BOOTUP
//late_initcall(rockchip_wifi_init_module_rtkwifi);
//module_exit(rockchip_wifi_exit_module_rtkwifi);
#else
EXPORT_SYMBOL(rockchip_wifi_init_module_rtkwifi);
EXPORT_SYMBOL(rockchip_wifi_exit_module_rtkwifi);
#endif
//module_init(rtw_drv_entry);
late_initcall(rtw_drv_entry);
module_exit(rtw_drv_halt);
logcat -s WifiHW
E/WifiHW ( 445): Failed to stop supplicant
logcat -s WifiStateMachine
发现wpa_supplicant service没启动。。。。
https://blog.csdn.net/wh_19910525/article/details/7392199
lzm@compilere:~/workspace/rk3288/zy_n10/frameworks$ grep -rn "Failed to start supplicant!" *
opt/net/wifi/service/java/com/android/server/wifi/WifiStateMachine.java:5273: loge("Failed to start supplicant!");
frameworks$ vi opt/net/wifi/service/java/com/android/server/wifi/WifiStateMachine.java
同时过滤多个tag
logcat -s 'RkWifiCtrl | WifiHW | WifiStateMachine'
130|root@EMT100T:/ # logcat *:D
I/wpa_supplicant( 1256): Successfully initialized wpa_supplicant: for broadcom wifi
E/wpa_supplicant( 1257): Failed to open Android control socket 'wpa_wlan0'
E/wpa_supplicant( 1257): Failed to initialize wpa_supplicant
E/wpa_supplicant( 1261): Failed to open Android control socket 'wpa_wlan0'
E/wpa_supplicant( 1261): Failed to initialize wpa_supplicant
^C
排查到最后,发现是init脚本里面启动wpa_supplicant service部分没包含进去。