Realtek RTL8188eu WiFi on Raspberry Pi

The Raspberry Pi 2 is the latest from the Raspberry Foundation. Since released, I tried to get hold of one from my usual distributor but none available. Recently, I managed to get hold of two to play with from here.

Pi2ModB1GB_-comp-500x283The Raspberry Pi 2 has many improvements over the previous models. The major improvement is the processor. A Broadcom 2836, which is a quad-core ARM Cortex-A7 running @900MHz, which claimed to speeds up by as much as six times over previous models. The next improvement is the amount of RAM installed, it has been upgraded to 1GB. Other hardware spec matches that of the B+: a Videocore GPU, a 40-pin GPIO, 4 x USB 2 ports, HDMI, MicroSD card and a 10/100 Ethernet, and best of all, the physical dimensions of Pi 2 is the same as the Pi B+, so you can use enclosures designed for model B+.

Like my other Raspberry Pis, I eventually wanted to connect them via wireless networks. So I search for the Edimax WiFi dongles which is known to work out of the box with Raspberry Pis. While I search for the best price available on the internet, I came across twifi-donglehis WiFi dongle which claimed to be Raspberry Pi compatible and it’s about half the price of the Edimax WiFi dongle. Without much hesitation, I brought 2 to try out with my two new Raspberry Pi 2. While waiting for the dongle to arrive, I prepared several SD cards with the latest Raspbian (Debian Wheezy) downloaded from raspberrypi.org.

About 2 weeks later, the dongles arrived in minimalistic packaging, with each dongle wrapped in a plastic bag, placed together in a paper envelope posted from Germany. I plugged them into the Pi 2 USB port and, as expected, nothing much happened! Syslog displayed the following:

Mar 18 11:08:25 raspi2 kernel: [42378.648226] usb 1-1.2: new high-speed USB device number 6 using dwc_otg
Mar 18 11:08:26 raspi2 kernel: [42378.749955] usb 1-1.2: New USB device found, idVendor=0bda, idProduct=0179
Mar 18 11:08:26 raspi2 kernel: [42378.749980] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Mar 18 11:08:26 raspi2 kernel: [42378.749997] usb 1-1.2: Product: 802.11n NIC
Mar 18 11:08:26 raspi2 kernel: [42378.750014] usb 1-1.2: Manufacturer: Realtek
Mar 18 11:08:26 raspi2 kernel: [42378.753930] Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_A_CUT_1T1R _RomVer(0)
Mar 18 11:08:26 raspi2 ifplugd(wlan0)[3030]: ifplugd 0.28 initializing.
Mar 18 11:08:26 raspi2 kernel: [42378.898651] r8188eu 1-1.2:1.0: Direct firmware load for rtlwifi/rtl8188eufw.bin failed with error -2
Mar 18 11:08:26 raspi2 kernel: [42378.898682] r8188eu 1-1.2:1.0: Firmware rtlwifi/rtl8188eufw.bin not available
Mar 18 11:08:26 raspi2 kernel: [42378.898695] MAC Address = 00:11:22:33:44:55
Mar 18 11:08:26 raspi2 ifplugd(wlan0)[3030]: Using interface wlan0/00:11:22:33:44:55 with driver <r8188eu> (version: )
Mar 18 11:08:26 raspi2 ifplugd(wlan0)[3030]: Using detection mode: wireless extension
Mar 18 11:08:26 raspi2 ifplugd(wlan0)[3030]: Initialization complete, link beat not detected.
Mar 18 11:08:26 raspi2 kernel: [42378.929772] usb 1-1.2: USB disconnect, device number 6
Mar 18 11:08:26 raspi2 kernel: [42378.930647] R8188EU: ERROR indicate disassoc
Mar 18 11:08:26 raspi2 ifplugd(wlan0)[3030]: Exiting.

The dongle was recognized by the kernel but the firmware file was not found. I was a bit surprise given that I came across this article saying that with Raspbian 2015.01 or later, kernel 3.18 now includes support for Realtek rtl8188eu without issues, but not in my case! Looking at the syslog, the kernel tried to load the firmware file “rtl8188cufw.bin” but failed. I drilled down the directory to /lib/firmware/rtlwifi/ and found no rtl8188eufw.bin there. A quick search on the internet landed me here where I found a copy of rtl8188eufw.bin. I downloaded it and placed it in the correct place. Unplug and re-insert the WiFi dongle and I get the following syslog messages:

Mar 18 12:35:36 raspi2 kernel: [ 913.864989] usb 1-1.2: new high-speed USB device number 6 using dwc_otg
Mar 18 12:35:36 raspi2 kernel: [ 913.966737] usb 1-1.2: New USB device found, idVendor=0bda, idProduct=0179
Mar 18 12:35:36 raspi2 kernel: [ 913.966763] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Mar 18 12:35:36 raspi2 kernel: [ 913.966780] usb 1-1.2: Product: 802.11n NIC
Mar 18 12:35:36 raspi2 kernel: [ 913.966796] usb 1-1.2: Manufacturer: Realtek
Mar 18 12:35:36 raspi2 kernel: [ 913.968402] Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_A_CUT_1T1R _RomVer(0)
Mar 18 12:35:36 raspi2 ifplugd(wlan0)[2908]: ifplugd 0.28 initializing.
Mar 18 12:35:37 raspi2 wpa_supplicant[2923]: nl80211: ‘nl80211’ generic netlink not found
Mar 18 12:35:37 raspi2 wpa_supplicant[2923]: Failed to initialize driver ‘nl80211’
Mar 18 12:35:37 raspi2 wpa_supplicant[2923]: rfkill: Cannot open RFKILL control device
Mar 18 12:35:37 raspi2 ifplugd(wlan0)[2908]: Using interface wlan0/00:11:22:33:44:55 with driver <r8188eu> (version: )
Mar 18 12:35:37 raspi2 ifplugd(wlan0)[2908]: Using detection mode: wireless extension
Mar 18 12:35:37 raspi2 ifplugd(wlan0)[2908]: Initialization complete, link beat not detected.
Mar 18 12:35:37 raspi2 kernel: [ 914.915518] MAC Address =00:11:22:33:44:55

Yep! the firmware loaded correctly. To confirm the driver is loaded correctly, I used ifconfig and iwconfig :

pi@raspi2 ~$ ifconfig
eth0
Link encap:Ethernet HWaddr 88:77:66:55:44:33
inet addr:192.168.44.184 Bcast:192.168.44.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8399 errors:0 dropped:1 overruns:0 frame:0
TX packets:1519 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:484424 (473.0 KiB) TX bytes:231729 (226.2 KiB)
lo
Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
wlan0
Link encap:Ethernet HWaddr 00:11:22:33:44:55
UP BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
pi@raspi2 ~$ iwconfig
wlan0
unassociated Nickname:”<WIFI@REALTEK>”
Mode:Managed Frequency=2.412 GHz Access Point: Not-Associated
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
lo            no wireless extensions.
eth0      no wireless extensions.
pi@raspi2 ~$

Yeah! the wlan0 interface is now available, which wasn’t there before. Just to make sure everything is working correctly, I rebooted the Pi 2 to see if the kernel can recognize the dongle properly. In the bootlog, I found a line that worried me:

[ 4.987435] r8188eu: module is from the staging directory, the quality is unknown, you
have been warned.

The “r8188eu” is the module the kernel will load when the WiFi dongle plugged in, lsmod can confirm this.

pi@raspi2 ~ $ lsmod
Module                             Size          Used by
snd_bcm2835              18850              0
snd_pcm                       75388              1 snd_bcm2835
snd_seq                         53078             0
snd_seq_device           5628               1 snd_seq
snd_timer                     17784              2 snd_pcm,snd_seq
snd                                  51667              5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device
r8188eu                          435113            0
evdev                               9950               2
joydev                              8903              0
uio_pdrv_genirq          2958               0
uio                                    8119                1 uio_pdrv_genirq
pi@raspi2 ~ $

The warning tells me that this driver may be shady so I’ll take note on this.

To continue with the setting up of the wireless network, I’ll need to configure the wireless network with the correct password for the desired access point(AP). There are two ways you can do this. The easiest way is to do it via the “WiFi Configuration” in the XWindows environment, if you’re not in the graphical environment, type “startx” at the command prompt.

  1. Launch “WiFi Configuration” from Menu | Preferences, this will launch the GUI application for configuration of wireless networks.
  2. Select the correct adaptor, “wlan0” in this case, then click on  “Scan” at the bottom to bring up a new window.
  3. Click on the “Scan” button to search for your wireless AP. Double click on the desired SSID, This will bring up another window containing some more advanced options for connecting to your network.
  4. Next to PSK, type in the password for the AP you are connecting to.
  5. Click “Add” to save the entry and “Close” to close the window.
  6. Back at the main window, you should see the status changing from associating… to completed (Station) followed by the mac address of the AP you’re connected to as well as the IP address of the interface.

Once that’s done, all the configurations are saved in the file called wpa_supplicant.conf under the directory /etc/wpa_supplicant. The Pi 2 will reconnect to the same AP next time it reboots.

For those die hard command prompt users, you can modify the wpa_supplicant.conf file to connect to the desired access point. A sample of a wpa_supplicant.conf file is shown below:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid=”YOUR_ACCESS_POINT_SSID_HERE”
psk=”YOR_ACCESS_POINT_PASSWORD_HERE”
proto=RSN
key_mgmt=WPA-PSK
pairwise=TKIP
group=TKIP WEP104 WEP40
auth_alg=OPEN
}

One strange observation I notice during the connection of the wireless interface, the connection does not happen at once, but only after many failed attempts before successfully obtaining an IP address. In the syslog, I see the following messages, repeated at least 16 times, before association is made to the AP and the dhcp client “dhclient” comes into action to obtain the IP address from the DHCP server:

Mar 18 16:20:01 raspi2 kernel: [14378.619231] R8188EU: ERROR indicate disassoc
Mar 18 16:20:02 raspi2 wpa_supplicant[4020]: wlan0: Trying to associate with 33:44:55:66:77:88 (SSID=’YOUR_SSID’ freq=2412 MHz)
Mar 18 16:20:02 raspi2 wpa_supplicant[4020]: wlan0: Association request to the driver failed
Mar 18 16:20:04 raspi2 wpa_supplicant[4020]: wlan0: CTRL-EVENT-DISCONNECTED bssid=33:44:55:66:77:88 reason=0
Mar 18 16:20:04 raspi2 kernel: [14381.589252] R8188EU: ERROR indicate disassoc
Mar 18 16:20:05 raspi2 wpa_supplicant[4020]: wlan0: Trying to associate with 33:44:55:66:77:88 (SSID=’YOUR_SSID’ freq=2412 MHz)
Mar 18 16:20:05 raspi2 wpa_supplicant[4020]: wlan0: Association request to the driver failed
Mar 18 16:20:07 raspi2 wpa_supplicant[4020]: wlan0: CTRL-EVENT-DISCONNECTED bssid=33:44:55:66:77:88 reason=0

May be this is why there was the warning in the bootlog warning me about using drivers from the staging directory. May be I should look into compiling a proper driver for this WiFi dongle.

—update—

After the Pi 2 is rebooted, the error messages disappeared, the wlan0 interface associated with the desired AP and acquired the IP without problem. Some part of the memory in my Pi 2 must have been corrupted by my heavy tweaking, the reboot must have cleaned them up.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s