1 Scope of Document
This document describes how to port rtl8192du driver to linux 4.14.y design.
2 Requiremen
2.1 Function Requirement
Suport wifi module rtl8192du working in sta mode under linux 4.14.y kernel version
2.2 Performance Requirement
NA
3 Hardware Overview
usb interface,pin map:
USB0_N
USB0_P
Figure 1 usb wifi rtl8188eus interface block diagram
4 Functional Description
4.1 Functional Block Diagram
4.2 RTL8192DU
5 Porting
5.1 Kernel porting
Download driver for https://github.com/lwfinger/rtl8192du
Change top level Makefile
-CONFIG_PLATFORM_I386_PC = n
+CONFIG_PLATFORM_TI_AM3517 = y
ifeq ($(CONFIG_PLATFORM_TI_AM3517), y)
#EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -DCONFIG_PLATFORM_ANDROID -DCONFIG_PLATFORM_SHUTTLE
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
EXTRA_CFLAGS += -DCONFIG_TRAFFIC_PROTECT
# default setting for Android 4.1, 4.2
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
EXTRA_CFLAGS += -DCONFIG_USE_USB_BUFFER_ALLOC_TX
#CROSS_COMPILE := arm-eabi-
#KSRC := $(shell pwd)/../../../Android/kernel
#ARCH := arm
CROSS_COMPILE := /home/vmuser/sdb/ti-sdk/ti-processor-sdk-linux-am335x-evm-05.00.00.15/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/arm-linux-gnueabihf-
KSRC := /home/vmuser/sdb/ti-sdk/ti-processor-sdk-linux-am335x-evm-05.00.00.15/board-support/linux-4.14.40
ARCH := arm
KVER:= 4.14.40
Endif
Then compile driver
make modules
rtl8192du.ko on top-level……
5.2 Application Interface
After the wifi module rtl8192du driver was loaded , we can find wlan0 wlan1 network devices
6 Follow-up
Sta mode test method:
root@IoTP:~# /etc/init.d/8188euSta connect panzidong DTicNbRL
Starting 8188eu sta connectAPDRIVER = 8188eu
connect to AP_SSID : panzidong, AP_PASSWORD : DTicNbRL
Successfully initialized wpa_supplicant
.
root@IoTP:~# script_runreason: /usr/libexec/dhcpcd-run-hooks: WEXITSTATUS 127
script_runreason: /usr/libexec/dhcpcd-run-hooks: WEXITSTATUS 127
wlan1: waiting for carrier
wlan1: carrier acquired
wlan1: adding address fe80::bede:af04:e62a:30c8
script_runreason: /usr/libexec/dhcpcd-run-hooks: WEXITSTATUS 127
DUID 00:01:00:01:1e:4f:73:1f:f8:36:9b:0b:cc:1b
wlan1: IAID 7f:36:05:51
wlan1: soliciting an IPv6 router
wlan1: soliciting a DHCP lease
root@IoTP:~# wlan1: offered 172.20.10.14 from 172.20.10.1 `panzidong'
wlan1: probing address 172.20.10.14/28
root@IoTP:~# wlan1: leased 172.20.10.14 for 85536 seconds
wlan1: adding route to 172.20.10.0/28
wlan1: adding default route via 172.20.10.1
script_runreason: /usr/libexec/dhcpcd-run-hooks: WEXITSTATUS 127
forked to background, child pid 1568
root@IoTP:~# ifconfig wlan1
wlan1 Link encap:Ethernet HWaddr 02:11:7f:36:05:51
inet addr:172.20.10.14 Bcast:172.20.10.15 Mask:255.255.255.240
inet6 addr: fe80::bede:af04:e62a:30c8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4 errors:0 dropped:53 overruns:0 frame:0
TX packets:19 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1078 (1.0 KB) TX bytes:2950 (2.9 KB)
/bin/stacontrol compat rtl8188eus
root@am335x-dc:~# cat /bin/stacontrol
#!/bin/sh
# Script to control wlan1 for connect to ap, disconnect to ap, and scan round ap.
#
# Sample start call "stacontrol start wlan1"
# stop call "stacontrol stop wlan1"
# scan call "stacontrol scan wlan1"
# connect call "stacontrol connect wlan1 ssid password"
# reconnect call "stacontrol reconnect wlan1"
#
case "$1" in
start)
if [ $# -ne 2 ]
then
echo "Usage: $0 start STA_iface"
exit 1
fi
;;
stop)
if [ $# -ne 2 ]
then
echo "Usage: $0 stop STA_iface"
exit 1
fi
;;
connect)
if [ $# -ne 4 ]
then
echo "Usage: $0 connect STA_iface AP_ssid AP_password"
exit 1
fi
;;
reconnect)
if [ $# -ne 2 ]
then
echo "Usage: $0 reconnect STA_iface"
exit 1
fi
;;
scan)
if [ $# -ne 2 ]
then
echo "Usage: $0 scan STA_iface"
exit 1
fi
;;
*)
echo "Usage: $0 start STA_iface"
echo "Usage: $0 stop STA_iface"
echo "Usage: $0 connect STA_iface AP_ssid AP_password"
echo "Usage: $0 reconnect STA_iface"
echo "Usage: $0 scan STA_iface"
exit 1
;;
esac
# Symbols for needed programs
IPTABLES=/sbin/iptables
IFCONFIG=/sbin/ifconfig
WPA_SUPPLICANT_CONF=/etc/wpa_supplicant-tmp.conf
WPA_SUPPLICANT=/sbin/wpa_supplicant
WPA_PASSPHRASE=/usr/bin/wpa_passphrase
WPA_CLI=/sbin/wpa_cli
DHCPCD=/usr/sbin/dhcpcd
# Symbols for STA and external interfaces
NET_STA=$2
AP_SSID=$3
AP_PASSWORD=$4
APDRIVER=""
STA_METRIC=2
case "$1" in
start)
killall -9 wpa_supplicant
# KILL NET_STA dhcp server
FILE="/var/run/dhcpcd-${NET_STA}.pid"
if [ -r $FILE ]; then
kill -INT "$(cat ${FILE})" 2>&1
fi
# check ap ssid and passwd exist ?
[ ! -f $WPA_SUPPLICANT_CONF ] && echo "$WPA_SUPPLICANT_CONF not found" && exit 1
# check wifi driver
APDRIVER=$(lsmod | grep "8188eu" | cut -d' ' -f 1)
echo "APDRIVER = $APDRIVER"
if [ "$APDRIVER" != "8188eu" ];
then
# insmod 8188eu wifi driver
insmod /lib/modules/4.14.40/kernel/drivers/wifi/8188eu.ko
insmod /lib/modules/4.14.40/kernel/drivers/wifi/8192du.ko
sleep 10
fi
$IFCONFIG $NET_STA down
$IFCONFIG $NET_STA up
wpa_supplicant -i$NET_STA -c $WPA_SUPPLICANT_CONF -B
sleep 3
#Notice:netplugd service will run NET_STA dhcp server...
$DHCPCD -m $STA_METRIC -t 0 $NET_STA &
$IPTABLES -t nat -A POSTROUTING -o $NET_STA -j MASQUERADE
sleep 3
exit 1
;;
stop)
killall -9 wpa_supplicant
# KILL NET_STA dhcp server
FILE="/var/run/dhcpcd-${NET_STA}.pid"
if [ -r $FILE ]; then
kill -INT "$(cat ${FILE})" 2>&1
fi
# check ap ssid and passwd exist ?
$IFCONFIG $NET_STA 0.0.0.0
$IFCONFIG $NET_STA down
exit 1
;;
connect)
killall -9 wpa_supplicant
# KILL NET_STA dhcp server
FILE="/var/run/dhcpcd-${NET_STA}.pid"
if [ -r $FILE ]; then
kill -INT "$(cat ${FILE})" 2>&1
fi
APDRIVER=$(lsmod | grep "8188eu" | cut -d' ' -f 1)
echo "APDRIVER = $APDRIVER"
if [ "$APDRIVER" != "8188eu" ];
then
# insmod 8188eu wifi driver
insmod /lib/modules/4.14.40/kernel/drivers/wifi/8188eu.ko
insmod /lib/modules/4.14.40/kernel/drivers/wifi/8192du.ko
sleep 10
fi
$IFCONFIG $NET_STA down
$IFCONFIG $NET_STA up
sleep 3
echo "connect to AP_SSID : $AP_SSID, AP_PASSWORD : $AP_PASSWORD"
$WPA_PASSPHRASE "$AP_SSID" "$AP_PASSWORD" > $WPA_SUPPLICANT_CONF
$WPA_SUPPLICANT -i$NET_STA -c $WPA_SUPPLICANT_CONF -B
sleep 1
$DHCPCD -m $STA_METRIC -t 0 $NET_STA &
$IPTABLES -t nat -A POSTROUTING -o $NET_STA -j MASQUERADE
exit 1
;;
reconnect)
killall -9 wpa_supplicant
# KILL NET_STA dhcp server
FILE="/var/run/dhcpcd-${NET_STA}.pid"
if [ -r $FILE ]; then
kill -INT "$(cat ${FILE})" 2>&1
fi
APDRIVER=$(lsmod | grep "8188eu" | cut -d' ' -f 1)
echo "APDRIVER = $APDRIVER"
if [ "$APDRIVER" != "8188eu" ];
then
# insmod 8188eu wifi driver
insmod /lib/modules/4.14.40/kernel/drivers/wifi/8188eu.ko
insmod /lib/modules/4.14.40/kernel/drivers/wifi/8192du.ko
sleep 10
fi
[ ! -f $WPA_SUPPLICANT_CONF ] && echo "$WPA_SUPPLICANT_CONF not found" && exit 1
$WPA_SUPPLICANT -i$NET_STA -c $WPA_SUPPLICANT_CONF -B
sleep 3
$DHCPCD -m $STA_METRIC -t 0 $NET_STA &
sleep 3
$IPTABLES -t nat -A POSTROUTING -o $NET_STA -j MASQUERADE
exit 1
;;
scan)
# confirm the wifi driver is insmod, so we can search aps.
APDRIVER=$(lsmod | grep "8188eu" | cut -d' ' -f 1)
echo "APDRIVER = $APDRIVER"
if [ "$APDRIVER" != "8188eu" ];
then
# insmod 8188eu wifi driver
insmod /lib/modules/4.14.40/kernel/drivers/wifi/8188eu.ko
insmod /lib/modules/4.14.40/kernel/drivers/wifi/8192du.ko
sleep 5
fi
killall -9 wpa_supplicant
# KILL NET_STA dhcp server
FILE="/var/run/dhcpcd-${NET_STA}.pid"
if [ -r $FILE ]; then
kill -INT "$(cat ${FILE})" 2>&1
fi
$IFCONFIG $NET_STA down
$IFCONFIG $NET_STA up
sleep 3
$WPA_SUPPLICANT -Dwext -i$NET_STA -c /etc/wpa_0_8.conf -B
sleep 2
$WPA_CLI -p /var/run/wpa_supplicant scan
sleep 3
$WPA_CLI -p /var/run/wpa_supplicant scan_results
killall -9 wpa_supplicant
# avoid wlan in scan mode, run dhcp server.
FILE="/var/run/dhcpcd-${NET_STA}.pid"
if [ -r $FILE ]; then
kill -INT "$(cat ${FILE})" 2>&1
fi
exit 1
;;
*)
echo "Usage: $0 start STA_iface"
echo "Usage: $0 stop STA_iface"
echo "Usage: $0 connect STA_iface AP_ssid AP_password"
echo "Usage: $0 reconnect STA_iface"
echo "Usage: $0 scan STA_iface"
exit 1
;;
esac