How to add support for USB WIFI for the RTL8192CU/EU module?

475 views
Skip to first unread message

Dave McLaughlin

unread,
Jan 6, 2020, 1:41:05 PM1/6/20
to android-porting
The source I have is built for the Samsung S5P6818 and on one board there is an AP6212 connected via an emmc SDIO connection. This provides Wifi via SDIO and BT view UART. 

The board I am working with has no built-in WiFi and I have tried a number of modules using the RTL8192CU, RTL8188EU, BCM43438 but none of them get detected as a wifi device. Dmesg shows they are detected as a USB device.

I have tried to add the RTL8192CU as this is included in the Linux 3.4 kernel and I have built this as a module and included this in the build. This is copied to the /system/lib/modules/ directory. 

I have found a number of references to doing this with the RTL8192CU and included the following in my BoardConfig.mk 

# wifi
BOARD_WIFI_VENDOR := realtek

ifeq ($(BOARD_WIFI_VENDOR),realtek)
WPA_SUPPLICANT_VERSION      := VER_0_8_X
BOARD_WLAN_DEVICE           := rtl
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)
WIFI_DRIVER_MODULE_NAME     := "rtl8192cu"
WIFI_DRIVER_MODULE_PATH     := "/system/lib/modules/rtl8192cu.ko"
endif

I have been unable to find lib_driver_cmd_rtl so I created this as a copy from the bcmdhd directory that was present in the source for the original BCM43438 AP6212 driver. This might be why it fails but I see no references to interface type in that code. ???

Realtek references the wpa_supplicant source but I can't locate this online.

When the board boots, dmesg shows the USB device was detected but I see the following in the debug output when I try to enable the WiFi in settings.

[ 9393.896000] dw_mmc dw_mmc.1: Hardware locked write error
[ 9393.912000] dw_mmc dw_mmc.1: Hardware locked write error
[ 9394.932000] dw_mmc dw_mmc.1: Data0: Never released by cmd52
[ 9395.936000] dw_mmc dw_mmc.1: Data0: Never released by cmd52
[ 9395.936000] dw_mmc dw_mmc.1: Hardware locked write error
[ 9396.940000] dw_mmc dw_mmc.1: Data0: Never released by cmd0
[ 9396.940000] dw_mmc dw_mmc.1: Hardware locked write error
[ 9397.948000] dw_mmc dw_mmc.1: Data0: Never released by cmd8
[ 9398.952000] dw_mmc dw_mmc.1: Data0: Never released by cmd5

This I think is the issue but I am unable to figure out where the reference to the mmc port is in the source code. My modules is on USB, not mmc.

I have tried to get Android 5.1 drivers from Realtek but have so far failed to get any response from them.

Tranphong Vu

unread,
Jan 8, 2020, 12:04:43 PM1/8/20
to davemcla...@gmail.com, android-porting
Hi Dave McLaughlin,
First i think you need to check device driver for wifi usb in your kernel.
It seems it is not work.
st1. you can check it with below command :
$ ifconfig -a
$ifconfig up $yourinterface
If this shows your wifi interface and you can up/down your wifi network interfacem you can continue to the step 2 :

st2. Android uses wpa supplicant tool to control wifi operation ( connects to a wifi network, scan ...)
so you don't need to enable Android wifi HAL to check this feature.
instead of this, you can use some tools in wpa supplicant package to check the operation of your device driver.
If it works fine go to step 3:

st3.
Enable Wifi HAL, WPA supplicant. Usually this part not different so much between devices.
But it have some modifications to support some specify feature or fixing some specific issue on a device.
About this part, you should need support from Vendor or you can debug it step by step.

Thanks,
Vu Tran


Vào Th 3, 7 thg 1, 2020 vào lúc 01:41 Dave McLaughlin <davemcla...@gmail.com> đã viết:
--
--
unsubscribe: android-porti...@googlegroups.com
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-porti...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-porting/fd57c6e1-8b84-411c-bf0d-ffb6560e6746%40googlegroups.com.

Dave McLaughlin

unread,
Jan 17, 2020, 10:39:00 AM1/17/20
to android-porting
ifconfig -a shows nothing listed for wlan0 so the driver is not being loaded.

I need to dig into how to add Realtek support to the kernel. I have found a new Android 7 kernel with RTL option in the build but it fails so I have some work to do.

Dave McLaughlin

unread,
Jan 21, 2020, 11:00:22 AM1/21/20
to android-porting
I finally have something close to working. I managed to build Android 7.0 with an RTL8188CUS module and this gets detected and I can see my wifi network in the search.

The issue that remains is the SEPOLICY and I get an audit denied as follows:

[  128.993333] init: Starting service 'p2p_supplicant'...
[  151.403333] type=1400 audit(1579495192.328:5): avc: denied { read } for pid=1375 comm="wpa_supplicant" name="rfkill" dev="tmpfs" ino=9258 scontext=u:r:wpa:s0 tcontext=u:object_r:device:s0 tclass=chr_file permissive=0

I ran audti2allow which generated the following, which I placed in wpa.te but the build complains with the error below.

allow wpa device:chr_file {read open };

The following error appears in the build output.

FAILED: /bin/bash -c "(out/host/linux-x86/bin/checkpolicy -M -c 30 -o out/target/product/nanopi3/obj/ETC/sepolicy_intermediates/sepolicy.tmp out/target/product/nanopi3/obj/ETC/sepolicy_intermediates/policy.conf ) && (out/host/linux-x86/bin/checkpolicy -M -c 30 -o out/target/product/nanopi3/obj/ETC/sepolicy_intermediates//sepolicy.dontaudit out/target/product/nanopi3/obj/ETC/sepolicy_intermediates/policy.conf.dontaudit ) && (out/host/linux-x86/bin/sepolicy-analyze out/target/product/nanopi3/obj/ETC/sepolicy_intermediates/sepolicy.tmp permissive > out/target/product/nanopi3/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains ) && (if [ \"userdebug\" = \"user\" -a -s out/target/product/nanopi3/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains ]; then echo \"==========\" 1>&2; echo \"ERROR: permissive domains not allowed in user builds\" 1>&2; echo \"List of invalid domains:\" 1>&2; cat out/target/product/nanopi3/obj/ETC/sepolicy_intermediates/sepolicy.permissivedomains 1>&2; exit 1; fi ) && (mv out/target/product/nanopi3/obj/ETC/sepolicy_intermediates/sepolicy.tmp out/target/product/nanopi3/obj/ETC/sepolicy_intermediates/sepolicy )"
libsepol.report_failure: neverallow on line 263 of system/sepolicy/domain.te (or line 9058 of policy.conf) violated by allow wpa device:chr_file { read open };

Any idea why this doesn't work?

Tranphong Vu

unread,
Jan 21, 2020, 1:36:53 PM1/21/20
to davemcla...@gmail.com, android-porting
There is existing rule in sepolicy that prohibit you to do it. Your new rule conflict with the old rule. You need to change the old rule or find another rule for this.

Vào 23:00, T.3, 21 Th1, 2020 Dave McLaughlin <davemcla...@gmail.com> đã viết:
--
--
unsubscribe: android-porti...@googlegroups.com
website: http://groups.google.com/group/android-porting

---
You received this message because you are subscribed to the Google Groups "android-porting" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-porti...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages