How to create an accesspoint using a RealTek 8192cu Usb Wifi Dongle In RPI1 B+

8192cu is now supplied in default kernel, but it is not working when running as an access point. So I need to recompile the driver.

1.get the kernel’s headers

You have to get the kernel’s header files, the common way is

sudo apt-get install linux-headers-...

But in RPI, the easiest way is rpi-source.

sudo wget https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source -O /usr/bin/rpi-source && sudo chmod +x /usr/bin/rpi-source && /usr/bin/rpi-source -q --tag-update

The kernel is compiled by gcc-4.8.3+, so if you have the gcc below 4.8.3, you have to install it.
first add

deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi

in /etc/apt/sources.list, and then

sudo apt-get install -t jessie gcc-4.8 g++-4.8

maybe you want to manage multi gcc versions

sudo update-alternatives --remove-all gcc
sudo update-alternatives --remove-all g++
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50

also you need curses for make menuconfig

sudo apt-get install libncurses5-dev

2.compile the kernel

./rpi-source

if it fails after downloading, you can fix the error and compile it yourself.

cd /root/linux && ./make

3.compile the right 8192cu

maybe /lib/modules/3.8.11+/arch/armv6l is missing, just link it

cd /lib/modules/3.18.11+/arch && ln -s arm armv6l

then

git clone https://github.com/dz0ny/rt8192cu.git
cd rt8192cu
sudo make
sudo make install

and if you copy the ko manually, you have to add the 8192cu to blacklist avoiding the supplied driver. modify /etc/modprobe.d/8192cu.conf

blacklist rtl8192cu

4. renew the hostapd
Download the software from this url: realtek.com
the file is called “Linux Kernel 2.6.18~2.6.38 and Kernel 3.0.8…” version: 3.4.4_*
then

unzip RTL8192xC_USB_linux_.zip
tar zxvf RTL8188C_8192C_USB_linux_
/wpa_supplicant_hostapd/wpa_supplicant_hostapd-0.8_rtw_.tar.gz
cd wpa_supplicant_hostapd-0.8_
/hostapd/
make
sudo cp hostapd hostapd_cli /usr/local/sbin/

20151101 Update: I found a better way, patching the hostapd. More information please look at hostapd-rtl871xdrv, I patched hostapd 2.5, and it works fine.

5.change the config of hostapd

just add

driver=rtl871xdrv

in hostapd.conf, and also if you want more speed and your wifi support 802.11n, change to

wpa=2
wpa_pairwise=CCMP TKIP
rsn_pairwise=CCMP
wme_enabled=1
ieee80211n=1
ht_capab=[HT40+][SHORT-GI-40][DSSS_CCK-40]

Because If you’re using TKIP for encryption with WPA2, you’re restricted to 54 mbps. You have to use CCMP (AES) to get 150 mpbs.See the wiki http://en.wikipedia.org/wiki/Wi-Fi_Protected_Access#Encryption_protocol

That’s all.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.