Realtek Wi-Fi SDK For Android O 8.0 PDF
Realtek Wi-Fi SDK For Android O 8.0 PDF
Realtek Wi-Fi SDK For Android O 8.0 PDF
x
ver. 1.0.1
Contents
Release History ............................................................................................................. 2
Introduction .................................................................................................................. 3
1. Copy Necessary Files into SDK .......................................................................... 4
2. Platform Related Files ......................................................................................... 4
2.1. BoardConfig.mk ....................................................................................... 4
2.2. init.xxx.rc .................................................................................................. 6
2.3. Others ........................................................................................................ 8
3. System Resource Configurations ........................................................................ 9
4. wpa_supplicant_8............................................................................................... 11
5. Driver Configurations for Android 8.0 ............................................................ 11
6. FAQ ..................................................................................................................................... 13
6.1. Wi-Fi (STA mode) .................................................................................. 13
6.1.1. Why Wi-Fi can’t enable? ........................................................... 13
6.2. Portable Wi-Fi hotspot (AP mode) ....................................................... 14
6.2.1. Why Portable Wi-Fi hotspot can’t enable? ............................. 14
6.3. Wi-Fi Direct (P2P mode) ....................................................................... 14
6.3.1. There is no Wi-Fi Direct UI shown?......................................... 14
6.3.2. Wi-Fi Direct can’t scan any peer? ............................................ 14
1
Release History
1.0.0 2017/08/25 1. First formal release
1.0.1 2018/02/26 1. Support wifi_hal
2
SDK packages
hardware/realtek/*
Folder to store private code from Realtek.
Introduction
This document provides a simple guide to help engineers to apply Realtek Wi-Fi
solution onto their Android O 8.0 system. For now, we have supported the following
two scenarios:
To port Realtek Wi-Fi driver onto Android 8.0 platform, you can go through the
following guide with reference codes within our driver package's
realtek_wifi_SDK_for_android_O_8.0_20180227.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.
In this document, ANDROID_SDK is the path of top folder of the target Android
SDK; this term is used in the following paragraphs.
3
1. Copy Necessary Files into SDK
After unzipping realtek_wifi_SDK_for_android_O_8.0_20180227.tar.gz, copy the
following folder into ANDROID_SDK/hardware/folder:
hardware/realtek
4
BOARD_WIFI_VENDOR := realtek
ifeq ($(BOARD_WIFI_VENDOR), realtek)
WPA_SUPPLICANT_VERSION := VER_0_8_X
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl
BOARD_HOSTAPD_DRIVER := NL80211
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_rtl
BOARD_WLAN_DEVICE := realtek
endif
BOARD_WIFI_VENDOR := realtek
To distinguish the platform Wi-Fi device from products of other vendors, we
define variable BOARD_WIFI_VENDOR as realtek. This is for compile-time choices
to be applied for Realtek Wi-Fi solutions.
WPA_SUPPLICANT_VERSION := VER_0_8_X
For Android L, please set WPA_SUPPLICANT_VERSION as VER_0_8_X to
5
use wpa_supplicant_8.
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_rtl
BOARD_HOSTAPD_DRIVER := NL80211
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 library.
BOARD_WLAN_DEVICE
In Android 8.X, BOARD_WLAN_DEVICE is used to choose which vendor
wifi_hal should be applied. You have to set BOARD_WLAN_DEVICE := realtek to
use realtek’s wifi_hal.
6
2.2. init.xxx.rc
For Wi-Fi to operate properly, we need some actions and daemons to be defined
as service inside init.xxx.rc. In general, the init.xxx.rc file is located in:
ANDROID_SDK/device/<soc_vendor_name>/<board_name>/
Take Hikey board for example:
ANDROID_SDK/linaro/hikey /init.common.rc
insmod
Please select one of action definitions below according to your requirement.
Meanwhile, please make sure your wlan.ko has right seclabel and mode as
on boot
on boot
7
wpa_supplicant
Please select one of service definitions below according to your requirement.
(For concurrent mode)
-e/data/misc/wifi/entropy.bin -N \
-O/data/misc/wifi/sockets \
-g@android:wpa_wlan0
class main
disabled
oneshot
-O/data/misc/wifi/sockets \
-e/data/misc/wifi/entropy.bin -g@android:wpa_wlan0
class main
disabled
oneshot
8
2.3. Others
For topics mentioned here, you can add the following code segments in any .mk
file which your platform will use. Take Hikey board for example:
ANDROID_SDK /device/linaro/hikey/device-common.mk.
Add android.hardware.wifi.xml
To claim Wi-Fi support for your device, please add the rule in the
PRODUCT_COPY_FILES variable to copy the permission definition file of Wi-Fi to
the /system/etc/permissions/ folder of your system image.
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.wifi.xml:system/etc/permissions/android.hardware.wifi.xml
Add android.hardware.wifi.direct.xml
To claim Wi-Fi Direct (P2P) support for your device, please add the rule in the
PRODUCT_COPY_FILES variable to copy the permission definition file of Wi-Fi
Direct to the /system/etc/permissions/ folder of your system image.
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.wifi.direct.xml:system/etc/permissions/android.hardware.wifi.direct.xml
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 “5. Driver Configurations
for Android 8.x”
9
Set wifi.interface
To specify the wifi interface name in Android, a system property named
“wifi.interface” is used. For Realtek Wi-Fi driver, Wi-Fi interface name is assigned
with “wlan%d”. In general, you should set wifi.interface as “wlan0”.
PRODUCT_PROPERTY_OVERRIDES += \
wifi.interface=wlan0
Set wifi.direct.interface
If you require p2p support, you have to set wifi.direct.interface as “p2p0”
PRODUCT_PROPERTY_OVERRIDES += \
wifi.direct.interface=p2p0
Toybox_vendor
In android 8.x, we need toybox_vendor to insmod. If you do not set the config in device.mk
PRODUCT_SHIPPING_API_LEVEL := 26
#ifeq ($(PRODUCT_FULL_TREBLE),true)
############################################
# static version to be installed in /vendor
#
….
LOCAL_MODULE := toybox_vendor
….
include $(BUILD_EXECUTABLE)
#endif
wifi_hal
To support wifi_hal, you have to patch
$ANDROID_SDK/frameworks/opt/net/wifi/libwifi_hal/Android.mk as below.
10
Device manifest file
The Device manifest file is provided by the device. It lives in the Android source tree at
device/${VENDOR}/${DEVICE}/manifest.xml and on the device at /vendor/manifest.xml
<hal format="hidl">
<name>android.hardware.wifi</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>IWifi</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl">
<name>android.hardware.wifi.supplicant</name>
<transport>hwbinder</transport>
<version>1.0</version>
<interface>
<name>ISupplicant</name>
<instance>default</instance>
</interface>
</hal>
networkAttributes
To define the system’s available network interfaces, make sure the wifi interface
items is defined in the networkAttributes resource configuration in the config.xml.
For example:
config_tether_wifi_regexs
The interfaces set here are tetherable Wi-Fi interfaces which will be used as
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 example:
config_tether_upstream_types
The connection types set here are used as the interfaces for WAN port to connect
to internet. For example, adding Wi-Fi and Ethernet:
At least one item should be declared here to enable the “Tehtering & portable
hotspot” option of WirelessSettings in Settings.apk.
To know the definition and set other upstream connection types, please refer to
ANDROID_SDK/frameworks/base/core/java/android/net/ConnectivityManager.java.
config_enableWifiDisplay
To enable Wi-Fi Display(Miracast) function, set config_enableWifiDisplay
to
true:
<bool name="config_enableWifiDisplay">true</bool>
12
4. wpa_supplicant_8
We provide wpa_supplicant_8_O_8.x_rtw_r24597.20171025.tar.gz or newer
version in the wpa_supplicant_hostapd/ of our SW release package. You can:
13
RTW_USE_CFG80211_STA_EVENT is used for driver to indicate new
cfg80211 STA event, which is required by wpa_supplicant_8 of Android 8.0
Linux kernel supports this feature after kernel 3.2. For kernel version between
3.0 and 3.2, please refer to the patch file:
linux-3.0.42_STATION_INFO_ASSOC_REQ_IES.diff
By default, the probe callback is used to set up Wi-Fi power and remove callback
is used to close Wi-Fi power.
To compile Realtek Wi-Fi driver with the above setting, please refer to the
following document:
document/Quick_Start_Guide_for_Driver_Compilation_and_Installation.pdf
Adding platform selection and setting sections for compilation settings of your
platform.
For example, if you want to configure Realtek Wi-Fi driver for the
(STA+P2P)/AP scenario, make sure the macros: CONFIG_IOCTL_CFG80211,
RTW_USE_CFG80211_STA_EVENT, CONFIG_RADIO_WORK and
CONFIG_CONCURRENT_MODE are defined into the EXTRA_CFLAGS settings as
following:
14
CONFIG_PLATFORM_ANDROID_M60_SAMPLE = y
…
…
…
ifeq ($(CONFIG_PLATFORM_ANDROID_ML0_SAMPLE), y)
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_RADIO_WORK
ARCH := arm
CROSS_COMPILE := /toolchain/bin/arm-none-linux-gnueabi-
KSRC := / android_sdk/android_l/ kernel
endif
…
CONFIG_RTW_WIFI_HAL = y
…
15
6. FAQ
6.1. Wi-Fi (STA mode)
6.1.1. Why Wi-Fi can’t enable?
The whole Wi-Fi enabling procedure includes the following three main ch eck
points. Please check in sequence:
Is network interface(s) created?
insmod driver success
Wi-Fi device is recognized
wlan0 is created
16
6.2. Portable Wi-Fi hotspot (AP mode)
6.2.1. Why Portable Wi-Fi hotspot can’t enable?
The whole Portable Wi-Fi hotspot enabling procedure includes the following
three main check points. Please check in sequence:
Is network interface created?
insmod driver success
Wi-Fi device is recognized
wlan0 is created
17