Realtek Wi-Fi SDK For Android JB 4 1
Realtek Wi-Fi SDK For Android JB 4 1
1
ver. 1.3.0
Contents
Release History.........................................................................................................1
SDK packages...........................................................................................................1
Introduction..............................................................................................................2
1. Copy Necessary Files into SDK........................................................................2
2. Platform Related Files......................................................................................2
2.1. BoardConfig.mk....................................................................................2
2.2. init.xxx.rc...............................................................................................4
2.3. Others....................................................................................................6
3. System Resource Configurations .....................................................................6
4. libhardware_legacy ..........................................................................................8
4.1. Apply wifi_realtek.c..............................................................................8
5. wpa_supplicant_8 .............................................................................................8
6. Patches for Android's frameworks/base/wifi/..................................................9
6.1. Patch for WifiP2pService.java..............................................................9
6.2. Patch for WifiMonitor.java.................................................................12
7. Driver Configurations for Android JB ..........................................................12
Release History
0.0.0 beta 2012/08/22 1. Support STA+P2P concurrent and SoftAP mode for Android 4.1 (JB)
1.0.0 2012/11/30 1. First normal release
1.1.0 2013/01/17 1. Update realtek_wifi_SDK_for_android_JB_4.1_20130117.tar.gz
1.1. Modify patch for WifiP2pService.java
2. Update wpa_supplicant_8_jb_4.1_rtw_r6358_20130117.tar.gz
1.2.0 2013/02/06 1. Update realtek_wifi_SDK_for_android_JB_4.1_20130206.tar.gz
1.1. Modify wifi_realtek.c
1.2. Modify patch for WifiP2pService.java
1.3.0 1. Update realtek_wifi_SDK_for_android_JB_4.1_20130306.tar.gz
1.1. Modify patch for WifiP2pService.java
1.2. Add patch for WifiMonitor.java
2. Update wpa_supplicant_8_jb_4.1_rtw_r6890.20130306.tar.gz
1.4.0 2013/03/27 1. Update wpa_supplicant_8_jb_4.1_rtw_r6986.20130327.tar.gz
SDK packages
l hardware/realtek/*
1
Folder to store config file, private code from Realtek.
l hardware/libhardware_legacy/wifi/Android.mk
Reference codes for applying wifi_realtek.c
l frameworks/base/wifi/*
Reference codes for service of Wi-Fi
Introduction
This document provides a simple guide to help engineers to apply Realtek Wi-Fi
solution onto their Android 4.1 (JB) system. For now, we have supported the
following two scenarios:
To port Realtek Wi-Fi driver onto Android 4.1 platform, you can go through the
following guide with reference codes within our driver package's
realtek_wifi_SDK_for_android_JB_4.1_20130306.tar.gz.
Because Android's SDK may differ from platform to platform, our reference
codes may not be applied on every platform without modifications. You should check
if our reference code is suitable for you to use.
2
BOARD_WIFI_VENDOR := realtek
ifeq ($(BOARD_WIFI_VENDOR), realtek)
WPA_SUPPLICANT_VERSION := VER_0_8_X
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
CONFIG_DRIVER_WEXT :=y
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl
BOARD_HOSTAPD_DRIVER := NL80211
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_rtl
BOARD_WLAN_DEVICE := rtl8192cu
#BOARD_WLAN_DEVICE := rtl8192du
#BOARD_WLAN_DEVICE := rtl8192ce
#BOARD_WLAN_DEVICE := rtl8192de
#BOARD_WLAN_DEVICE := rtl8723as
#BOARD_WLAN_DEVICE := rtl8723au
#BOARD_WLAN_DEVICE := rtl8189es
WIFI_DRIVER_MODULE_NAME := "wlan"
WIFI_DRIVER_MODULE_PATH := "/system/lib/modules/wlan.ko"
WIFI_DRIVER_MODULE_ARG := "ifname=wlan0 if2name=p2p0"
WIFI_FIRMWARE_LOADER := ""
WIFI_DRIVER_FW_PATH_STA := ""
WIFI_DRIVER_FW_PATH_AP := ""
WIFI_DRIVER_FW_PATH_P2P := ""
WIFI_DRIVER_FW_PATH_PARAM := ""
endif
l BOARD_WIFI_VENDOR := realtek
To distinguish the platform Wi-Fi device from products of other companies, we
define variable BOARD_WIFI_VENDOR as realtek. This is for compile-time choices
to be applied for Realtek Wi-Fi solutions.
l WPA_SUPPLICANT_VERSION := VER_0_8_X
For Android JB, please set WPA_SUPPLICANT_VERSION as VER_0_8_X to
use wpa_supplicant_8.
l BOARD_WPA_SUPPLICANT_DRIVER := NL80211
3
l BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_ rtl
l BOARD_HOSTAPD_DRIVER := NL80211
l BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_rtl
We use NL80211 as the driver interface for wpa_supplicant and hostapd to
communicate with driver and provide lib_driver_cmd_rtl as the private processing
library.
l BOARD_WLAN_DEVICE
Realtek provide a variety of Wi-Fi solutions to choose. For now,
BOARD_WLAN_DEVICE is not used for any purpose but we suggest setting this
variable for your Wi-Fi solution you used.
l WIFI_DRIVER_MODULE_NAME
l WIFI_DRIVER_MODULE_PATH
l WIFI_DRIVER_MODULE_ARG
These three variables will be used in libhardware_legacy (wifi.c/wifi_realtek.c)
to do insmod and remmod. The value of WIFI_DRIVER_MODULE_NAME should
match the value of MODULE_NAME specified in our driver’s Makefile at
compile-time. Please refer to “Platform Setting Section in Detail” of:
document/Quick_Start_Guide_for_Driver_Compilation_and_Installation.pdf
l WIFI_FIRMWARE_LOADER :=””
l WIFI_DRIVER_FW_PATH_STA :=””
l WIFI_DRIVER_FW_PATH_AP :=””
l WIFI_DRIVER_FW_PATH_P2P :=””
l WIFI_DRIVER_FW_PATH_PARAM :=””
Because our driver has FW embedded inside, and will automatically load FW at
NIC initialization process, there is no need to set these 5 variables, just keep them
empty.
2.2. init.xxx.rc
For Wi-Fi to operate properly, we need some daemons to be defined as service
inside init.xxx.rc. Please refer to the service definitions below:
l wpa_supplicant
4
service rtw_suppl_con /system/bin/wpa_supplicant \
-ip2p0 -Dnl80211 -c /data/misc/wifi/p2p_supplicant.conf -e/data/misc/wifi/entropy.bin -N \
-iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf
class main
socket wpa_wlan0 dgram 660 wifi wifi
disabled
oneshot
l dhcpcd
service dhcpcd_wlan0 /system/bin/dhcpcd -aABKL
class main
disabled
oneshot
5
2.3. Others
l Set wifi.interface
To specify the wifi interface name in Android, a system property named
“wifi.interface” is used. For Realtek wifi driver, wifi interface name is assigned with
“wlan%d”. In general, you should set wifi.interface as “wlan0”. For example:
PRODUCT_PROPERTY_OVERRIDES += \
wifi.interface=wlan0
l Add android.hardware.wifi.direct.xml
If you want to use Wi-Fi Direct (P2P) functionality, please add the rule in the
PRODUCT_COPY_FILES variable for your device platform related file to copy the
permission definition file of Wi-Fi Direct to the system/etc/permissions/ folder of
your system image. For example:
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hard
ware.wifi.direct.xml
With this action, the Wi-Fi Direct UI and the related service will be enabled for
your system.
When you enable this, make sure your driver is configured for STA+P2P
concurrent mode or you may encounter error when you open the Wi-Fi. Please refer to
“7. Driver Configurations for Android JB”
l networkAttributes
To define the system’s available network interfaces, make sure the wifi and
wifi_p2p interface items is defined in the networkAttributes resource configuration.
For example:
6
<string-array translatable="false" name="networkAttributes">
<item>"wifi,1,1,1,-1,true"</item>
<item>"bluetooth,7,7,0,-1,true"</item>
<item>"ethernet,9,9,2,-1,true"</item>
<item>"wifi_p2p,13,1,0,-1,true"</item>
</string-array>
l radioAttributes
To define the system’s available network interfaces, we need to define interface
items for wifi in the networkAttributes resource configuration. For example:
l config_tether_wifi_regexs
The interfaces set here are used as the interfaces for Wi-Fi LAN port. We use
'wlan0' by default when our Wi-Fi is set as softap mode. So it needs to set 'wlan0' here
for system to recognized 'wlan0' as Wi-Fi LAN port. For example:
l config_tether_upstream_types
The connection types set here are used as the interfaces for WAN port to connect
to internet. You could declared an entry in your platform dependent config.xml file to
override the global definition. For example, adding wifi and ethernet:
7
To know the definition and set other upstream connection types, please refer to
frameworks/base/core/java/android/net/ConnectivityManager.java.
4. libhardware_legacy
The libhardware_legacy library includes functionality for Wi-Fi to operate. We
have made modifications and extensions for our Wi-Fi solutions. To apply this, please
go through the following instructions:
5. wpa_supplicant_8
We provide wpa_supplicant_8_jb_4.1_rtw_r6986.20130327.tar.gz or newer
version in the wpa_supplicant_hostapd/ of our SW release package. You can:
8
ifeq ($(BOARD_WLAN_DEVICE), bcmdhd)
L_CFLAGS += -DANDROID_P2P
endif
MACRO Description
ANDROID_P2P Android’s wpa_supplicant_8 patch. Must
REALTEK_WIFI_VENDOR General purpose patch made by Realtek. Must
l Line 851:
9
case WifiMonitor.P2P_FIND_STOPPED_EVENT:
/*=== Realtek delete start ===*/
// When discovery stops in inactive state, flush to clear
// state peer data
//mWifiNative.p2pFlush();
/*=== Realtek delete end ===*/
mServiceDiscReqId = null;
sendP2pDiscoveryChangedBroadcast(false);
break;
l Line 878:
/*=== Realtek add start ===*/
case WifiMonitor.P2P_GROUP_STARTED_EVENT:
mGroup = (WifiP2pGroup) message.obj;
if (DBG) logd(getName() + " group started");
if (mGroup.isGroupOwner()) {
startDhcpServer(mGroup.getInterface());
if (mAutonomousGroup)
mWifiNative.setP2pGroupIdle(mGroup.getInterface(), 0);
} else {
// Set group idle only for a client on the group interface to speed up
// disconnect when GO is gone. Setting group idle time for a group owner
// causes connectivity issues for new clients
mWifiNative.setP2pGroupIdle(mGroup.getInterface(), GROUP_IDLE_TIME_S);
mDhcpStateMachine = DhcpStateMachine.makeDhcpStateMachine(mContext,
P2pStateMachine.this, mGroup.getInterface());
mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_START_DHCP);
WifiP2pDevice groupOwner = mGroup.getOwner();
mPeers.updateStatus(groupOwner.deviceAddress, WifiP2pDevice.CONNECTED);
sendP2pPeersChangedBroadcast();
}
mSavedPeerConfig = null;
transitionTo(mGroupCreatedState);
break;
/*=== Realtek add end ===*/
default:
return NOT_HANDLED;
10
l Line 1065:
l Line 1095:
case WifiMonitor.P2P_GROUP_STARTED_EVENT:
mGroup = (WifiP2pGroup) message.obj;
if (DBG) logd(getName() + " group started");
if (mGroup.isGroupOwner()) {
startDhcpServer(mGroup.getInterface());
/*=== Realtek add start ===*/
if (mAutonomousGroup)
mWifiNative.setP2pGroupIdle(mGroup.getInterface(), 0);
/*=== Realtek add end ===*/
} else {
l Line 1460:
logd("Stopped Dhcp server");
11
6.2. Patch for WifiMonitor.java
Add or modify the following code segment in WifiMonitor.java. For the specific
line number and code segments, please reference our reference code:
frameworks/base/wifi/java/android/net/wifi/WifiMonitor.java
l Line 217:
/* P2P-PROV-DISC-FAILURE p2p_dev_addr=42:fc:89:e1:e2:27 */
l Line 323:
public static final int P2P_SERV_DISC_RESP_EVENT = BASE + 38;
l Line 614:
} else if (dataString.startsWith(P2P_PROV_DISC_SHOW_PIN_STR)) {
mStateMachine.sendMessage(P2P_PROV_DISC_SHOW_PIN_EVENT,
new WifiP2pProvDiscEvent(dataString));
} else if (dataString.startsWith(P2P_PROV_DISC_FAILURE_STR)) {
mStateMachine.sendMessage(P2P_PROV_DISC_FAILURE_EVENT);
} else if (dataString.startsWith(P2P_SERV_DISC_RESP_STR)) {
12
MACRO STA /AP (STA+P2P)/AP Kernel ver.
CONFIG_IOCTL_CFG80211 Defined Defined ver. >= 2.6.35
RTW_USE_CFG80211_STA_EVENT Defined Defined ver. >= 3.2.0
CONFIG_CONCURRENT_MODE Undefined Defined -
CONFIG_P2P_IPS Don’t Care Defined -
Please modify both the include/autoconf.h and the specific autoconf file(needed
for compound driver release) for your Wi-Fi product.
Chip type Autoconf file to modify
RTL8192CU-series autoconf_rtl8192c_usb_linux.h
RTL8192CE-series autoconf_rtl8192c_pci_linux.h
RTL8192DU-series autoconf_rtl8192d_usb_linux.h
RTL8192DE-series autoconf_rtl8192d_pci_linux.h
RTL8723AS-series autoconf_rtl8723a_sdio_linux.h
RTL8723AU-series autoconf_rtl8723a_usb_linux.h
RTL8189ES-series autoconf_rtl8189e_sdio_linux.h
RTL8188EU-series autoconf_rtl8188e_usb_linux.h
13
#define CONFIG_IOCTL_CFG80211
#ifdef CONFIG_IOCTL_CFG80211
#define RTW_USE_CFG80211_STA_EVENT
//#define CONFIG_CFG80211_FORCE_COMPATIBLE_2_6_37_UNDER
//#define CONFIG_DEBUG_CFG80211 1
#endif
…
#define CONFIG_CONCURRENT_MODE
…
#define CONFIG_P2P_IPS
14