Realtek R8192D USB WiFi Integration
References
- Linux Wireless Linux Kernel Networking (4 )- Advanced topics: http://www.haifux.org/lectures/206/wirelessLec.pdf
- cfg80211 presentation: http://wireless.kernel.org/en/developers/Documentation/cfg80211?action=AttachFile&do=view&target=control.pdf
Overview
This articles is based on Realtek R8712U USB WiFi Integration.
However, the chipset to integrate is a Realtek R8192DU chipset inside a TRENDnet TEW-664UB V2.0R WLAN USB dongle.
Existing Linux support
Checked USB IDs on Ubuntu host:
lsusb ... Bus 003 Device 009: ID 20f4:664b
Sure it's a Realtek RTL8192DU chip set.
Community version : https://github.com/lwfinger/rtl8192du.git
Original driver from Realtek: http://www.realtek.com/downloads/downloadsView.aspx?Langid=1&PNid=21&PFid=53&Level=5&Conn=4&ProdID=310&DownTypeID=3&GetDown=false&Downloads=true#3102
Integrating the driver to the linux-2.6.32.17-psp03.01.39 DM36x kernel
Patching USB
We found out that the CPPI USB DMA controller loses data packets in conjunction with the bulk transfers with this WIFI controller.
Extend the kernel configuration and the Makefile
cd $DEVDIR/kernel quilt add linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/Kconfig quilt add linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/Makefile
Add a config item to linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/Kconfig
... config RTL8192DU tristate "Realtek 8192DU USB support" ---help--- This is a driver for RTL8192DU based cards. These are USB based chips found in devices such as: TRENDnet TEW-664UB V2.0R ...
Add a sub directory build to linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/Makefile
... obj-$(CONFIGRTL8192DU) += rtl8192du/ ...
Refresh the patch
cd $DEVDIR/kernel quilt refresh
Add the patch to the bsp's arch-dm368 and clean up the kernel patch stack
echo "add_realtek_rtl8192du_usb_wlan_support.patch" >> $DEVDIR/bsp/arch-dm368/patches/linux-2.6.32.17-psp03.01.01.39/series cd $DEVDIR make kernel_clean FORCE=1 make kernel
Position the quilt stack again to the patch
cd $DEVDIR/kernel quilt pop arch/add_realtek_rtl8192du_usb_wlan_support.patch
Clone the existing driver to integrate into a temporary directory
mkdir -p $HOME/work/tmp cd $HOME/work/tmp git clone https://github.com/lwfinger/rtl8192du.git
Create the driver directoryin the kernel
mkdir $DEVDIR/linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du
Create the same files as in the cloned driver
cd $HOME/work/tmp/rtl8192du/core for file in *.c; do touch $DEVDIR/kernel/linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/$file; done cd $HOME/work/tmp/rtl8192du/hal for file in *.c; do touch $DEVDIR/kernel/linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/$file; done cd $HOME/work/tmp/rtl8192du/os_dep for file in *.c; do touch $DEVDIR/kernel/linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/$file; done cd $HOME/work/tmp/rtl8192du/include for file in *.h; do touch $DEVDIR/kernel/linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/$file; done
Add the driver sources to the patch
cd $DEVDIR/kernel quilt add linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/* quilt add linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/include/*
cp $HOME/work/tmp/rtl8192du/core/*.c linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/ cp $HOME/work/tmp/rtl8192du/hal/*.c linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/ cp $HOME/work/tmp/rtl8192du/os_dep/*.c linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/ cp $HOME/work/tmp/rtl8192du/include/*.h linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/
quilt refresh
Add a driver Makefile
touch linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/Makefile quilt add linux-2.6.32.17-psp03.01.01.39/drivers/net/wireless/rtl8192du/Makefile
Contents:
rtl8192du-objs := rtw_cmd.o \ rtw_security.o \ rtw_debug.o \ rtw_io.o \ rtw_ioctl_set.o \ rtw_ieee80211.o \ rtw_mlme.o \ rtw_mlme_ext.o \ rtw_wlan_util.o \ rtw_pwrctrl.o \ rtw_rf.o \ rtw_recv.o \ rtw_sta_mgt.o \ rtw_ap.o \ rtw_xmit.o \ rtw_p2p.o \ rtw_tdls.o \ rtw_br_ext.o \ rtw_sreset.o \ rtw_efuse.o \ hal_intf.o \ hal_com.o \ rtl8192d_hal_init.o \ rtl8192d_phycfg.o \ rtl8192d_rf6052.o \ rtl8192d_dm.o \ rtl8192d_rxdesc.o \ rtl8192d_cmd.o \ usb_halinit.o \ rtl8192du_led.o \ rtl8192du_xmit.o \ rtl8192du_recv.o \ Hal8192DUHWImg.o \ rtl8192d_xmit.o \ usb_ops_linux.o \ osdep_service.o \ os_intfs.o \ usb_intf.o \ usb_ops_linux.o \ ioctl_linux.o \ xmit_linux.o \ mlme_linux.o \ recv_linux.o \ ioctl_cfg80211.o \ rtw_android.o
quilt refresh --strip-trailing-whitespace
Activate the driver in the kernel configuration
cd $DEVDIR make config
Select


Fixes to match the 2.6.32 kernel
Local headers are included with <...>
Search and replace with "...".
vzalloc is not present
Compilation errors like:
drivers/net/wireless/rtl8192du/rtw_xmit.c:93: error: implicit declaration of function 'vzalloc'
occur.
vzalloc(...) is just a zero-set version of vmalloc(...) in later kernels.
Replace:
<a_pointer> = vzalloc(<a_size>);
with:
<a_pointer> = vmalloc(<a_size>); memset(<a_pointer>, 0, <a_size>);
Test results
Bandwidth check
Configuration
- 11g AP network without security
- distance between AP and board ~30cm
- distance between AP and server ~1m
- Server IP configuration got by DHCP: 192.168.1.9/255.255.255.0
- Board IP configuration got by DHCP: 192.168.1.3/255.255.255.0
= Bandwidth results
- TCP - 8.85 MBits/sec
- UDP 22.72 Mbits/sec
Endurance check
Ran iperf testing TCP for two days without any kernel messages being logged.