How to compile rtl8192cu.ko for Raspberry Pi running Raspian?

If you want to use Wifi modules such as Edimax EW-7811Un with your Raspberry Pi, you will need the appropriate driver. For unknown reasons, the kernel-included driver for this module does not work. Luckily, Realtek is providing an open-source driver for exactly this radio module. To compile it, do this:

Download the Driver

You can get it at the Realtek Homepage. The direct link is ftp://WebUser:Lc9FuH5r@209.222.7.36/cn/wlan/RTL819xCU%20_USB_linux_v3.4.3_4369.20120622.zip

Unpack and change dir

unzip RTL819xCU _USB_linux_v3.4.3_4369.20120622.zip
cd RTL8188C_8192C_USB_linux_v3.4.3_4369.20120622/driver
tar -xvzf rtl8188C_8192C_usb_linux_v3.4.3_4369.20120622.tar.gz
cd rtl8188C_8192C_usb_linux_v3.4.3_4369.20120622

Deaktivate Debug output

Open the file include/autoconf.h in your favorite editor and change the last section of the file to look like so:

/*
 * Debug  Related Config
 */
//#define CONFIG_DEBUG_RTL871X

#define DBG     0
// #define CONFIG_DEBUG_RTL819X

// #define CONFIG_PROC_DEBUG    1

//#define DBG_IO
//#define DBG_DELAY_OS
//#define DBG_MEM_ALLOC
//#define DBG_IOCTL

//#define DBG_TX
//#define DBG_XMIT_BUF
//#define DBG_TX_DROP_FRAME

//#define DBG_RX_DROP_FRAME
//#define DBG_RX_SEQ
//#define DBG_RX_SIGNAL_DISPLAY_PROCESSING
//#define DBG_RX_SIGNAL_DISPLAY_SSID_MONITORED "jeff-ap"

//#define DBG_EXPIRATION_CHK

//#define DBG_SHOW_MCUFWDL_BEFORE_51_ENABLE
//#define DBG_ROAMING_TEST

//#define DBG_HAL_INIT_PROFILING
// #define DBG_MEMORY_LEAK      1

// #define DBG_CONFIG_ERROR_DETECT
//#define DBG_CONFIG_ERROR_RESET


(in other words: deactivate everything that looks like debugging)

Build the kernel module

You will need the appropriate compiler for the module. Also, you need to have a freshly built kernel lying around. To build the driver, to this:

make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- -C PATH_TO_BUILD_SUBDIR_OF_YOUR_KERNEL M=DIRECTORY_WHERE_THE_DRIVER_LIVES modules

You end up with a file called 8192cu.ko which is your kernel module.

Install the module in your RPI

  • Copy the module onto your RPI
  • Move the module:
    sudo mv 8192cu.ko /lib/modules/`uname -r`/kernel/drivers/net/wireless
    
  • Run depmod
    sudo depmod -a
    
  • Prevent the stock rtl8192cu.ko module from being loaded. To do this, simply append the following line to /etc/modprobe.d/raspi-blacklist.conf :
    blacklist rtl8192cu
    
  • To automatically load the newly compiled module, add the following line to /etc/modules:
    8192cu
    
  • done

Standard Wifi Config

For Wifi to work, you will need two additional things.

  • Add the interface configuration to /etc/network/interfaces
    auto wlan0
    iface wlan0 inet dhcp
    	wpa-driver wext
            wpa-conf /etc/wpa_supplicant.conf
    
  • Create a new file /etc/wpa_supplicant.conf with the following content:
    
    ctrl_interface=/var/run/wpa_supplicant
    ctrl_interface_group=0
    ap_scan=1
    
    network={
            ssid="YOUR_SSID"
            proto=RSN
            key_mgmt=WPA-PSK
            pairwise=CCMP TKIP
            group=CCMP TKIP
            psk="YOUR_WPA_PASSPHRASE"
    }
    

    Please replace YOUR_SSID and YOUR_WPA_PASSPHRASE with the appropriate values.

  • Enjoy!

2 Comments

  1. Heribert Riesbeck

    Your instructions concerning concerning compilation of the rtl8192cu.ko driver module into the RaspberryPi (Raspian) Kernel appear at first sight easy enough although some explanation would be appreciated.

    I require more detailed explanation with building the Kernel module on an Ubuntu System.

    Thusfar, I have done the following:

    1. Downloaded the Kernel sources from github.com. The files are now located in “my home” directory /raspberrypi-linux
    2. Downloaded and installed the necessary compiler prereqisites with apt-get install git ncurses-dev make gcc-arm-linux-gnueabi
    3. Downloaded and extracted the Wifi driver package from Realtek as per your writeup. The file resides in my homedirectory but not in the subdir /raspberrypi-linux
    4. Modfified file “include/autoconfig.h” as per your instructions. The rtl8188_8192_usb…. directory also contains a “Makefile”

    Firstly, given the above description, can I compile the module on a PC Ubuntu system?
    Then, where should the expanded rtl8188C_8192C_usb…..file be located?. Together with the source files?
    Should the above files be located in the root directory or can they remain in “my home” directory for the compile process?
    Do I use the “Makefile” of step 4 to build the driver?

    Your assistance would much appreciated.
    Thank you very kindly.
    Heribert Riesbeck

    Reply
  2. Pingback: Raspbian Wifi Dongle | axelhawker.com

Leave a Reply to Heribert Riesbeck Cancel reply

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

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