RPi Wifi

From Flav's Wiki
Jump to: navigation, search

Hardware

  • RPi B+ v1.2
  • Wifi dongle TP-Link TL-WN725N

my hardware

pi@pi2 ~ $ sudo -i
root@pi2:~# lsusb
....
Bus 001 Device 004: ID 0bda:8179 Realtek Semiconductor Corp.
....

ressources

Install the Wifi Dongle Driver

First update the system

sudo -i
uname -a
apt-get update
apt-get upgrade
rpi-udate
reboot
sudo -i

get the right package

The right driver is listed here http://www.raspberrypi.org/forums/viewtopic.php?p=462982

My system is :

root@pi2:~# uname -a
Linux pi2 3.12.26+ #708 PREEMPT Thu Sep 4 15:43:15 BST 2014 armv6l GNU/Linux

Get the file https://dl.dropboxusercontent.com/u/80256631/8188eu-201xyyzz.tar.gz where xyyzz is the one of your version

I found in the page list this entry: 3.12.26+ #702 - 8188eu-20140705.tar.gz

So:

root@pi2:~# wget https://dl.dropboxusercontent.com/u/80256631/8188eu-20140705.tar.gz
--2014-09-04 20:29:19--  https://dl.dropboxusercontent.com/u/80256631/8188eu-20140705.tar.gz
Resolving dl.dropboxusercontent.com (dl.dropboxusercontent.com)... 204.236.233.86, 184.73.184.0, 184.73.197.56, ...
Connecting to dl.dropboxusercontent.com (dl.dropboxusercontent.com)|204.236.233.86|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 300180 (293K) [application/octet-stream]
Saving to: `8188eu-20140705.tar.gz'

100%[======================================>] 300,180      301K/s   in 1.0s

2014-09-04 20:29:27 (301 KB/s) - `8188eu-20140705.tar.gz' saved [300180/300180]

Install the driver

Install the kernel driver

root@pi2:~# ls
8188eu-20140705.tar.gz
root@pi2:~# tar xzvf 8188eu-20140705.tar.gz
8188eu.ko
root@pi2:~# install -p -m 644 8188eu.ko /lib/modules/$(uname -r)/kernel/drivers/net/wireless/

Test the kernel driver

root@pi2:~# insmod /lib/modules/$(uname -r)/kernel/drivers/net/wireless/8188eu.ko
root@pi2:~# depmod -a

Is the driver loaded ?

root@pi2:~# lsmod
Module                  Size  Used by
8188eu                663004  0
....

yes

Is there now a wlan0 ?

root@pi2:~# ifconfig
....
wlan0     Link encap:Ethernet  HWaddr e8:94:f6:1a:02:eb
          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)

root@pi2:~# 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
          Encryption key: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.

yes

Test of driver after reboot

Reboot...


Then:

root@pi2:~# 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
          Encryption key: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.

Ok it works !

Setup Wifi Connexion

Good doc here: http://www.fars-robotics.net/

Method 1: Basic

Modify /etc/network/interfaces as follows:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0

iface wlan0 inet dhcp
  wpa-ssid thessid
  wpa-psk thepassphrase

This kind of config works for WPA. For WEP replace wpa-ssid/wpa-psk by wireless-essid/wireless-key.

Test you config

root@pi2:/etc/network# ifdown wlan0
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/xx:xx:xx:xx:xx:xx
Sending on   LPF/wlan0/xx:xx:xx:xx:xx:xx
Sending on   Socket/fallback
root@pi2:/etc/network# ifup wlan0
ioctl[SIOCSIWAP]: Operation not permitted
ioctl[SIOCSIWENCODEEXT]: Invalid argument
ioctl[SIOCSIWENCODEEXT]: Invalid argument
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Listening on LPF/wlan0/xx:xx:xx:xx:xx:xx
Sending on   LPF/wlan0/xx:xx:xx:xx:xx:xx
Sending on   Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPOFFER from 192.168.0.201
DHCPACK from 192.168.0.201
bound to 192.168.0.173 -- renewal in 276 seconds.
root@pi2:/etc/network# ifconfig
eth0      Link encap:Ethernet  HWaddr b8:27:eb:25:5d:3d
          inet addr:192.168.0.21  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4412 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2306 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:835756 (816.1 KiB)  TX bytes:305889 (298.7 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 e8:xx:xx:xx:xx:xx
          inet addr:192.168.0.173  Bcast:192.168.0.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:29 errors:0 dropped:1 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4038 (3.9 KiB)  TX bytes:1171 (1.1 KiB)

root@pi2:/etc/network# iwconfig
wlan0     IEEE 802.11bgn  ESSID:"XXXXXXX"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:2.422 GHz  Access Point: xx:xx:xx:xx:xx:xx
          Bit Rate:150 Mb/s   Sensitivity:0/0
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:****-****-****-****-****-****-****-****   Security mode:open
          Power Management:off
          Link Quality=100/100  Signal level=84/100  Noise level=0/100
          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.

Method 2: Using wpa_supplicant

Modify /etc/network/interfaces as follows:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0

iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Edit /etc/wpa_supplicant/wpa_supplicant.conf and add the network={.....} section:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="Your-Network-Name"
    psk="Your-Network-Password"
}


Test as in method 1.

If you want to use static ip Modify /etc/network/interfaces as follows:

auto lo

iface lo inet loopback
iface eth0 inet dhcp

allow-hotplug wlan0

iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static
    address 192.168.0.202
    netmask 255.255.255.0
    network 192.168.0.0
    gateway 192.168.0.1

Build the driver

After my kernel upgrade from 3.12.26+ to 3.12.28+ the driver was broken.

The build was not available so here is my build from sources

Resources

Build

Update the firmware

# rpi-update

and reboot.

Install and run rpi-source that install source used to build rpi-update kernels and the kernel on the Raspian image.

# 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

And with normal user:

$ rpi-source

Fails because of version of gcc used. So ignore check:

Install gcc-4.8 with root (read https://github.com/notro/rpi-source/wiki)

# apt-get install -y gcc-4.8 g++-4.8
# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 20
# update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 50
# update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.6 20
# update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50

Then try again:

$ rpi-source

It will take a while and will create linux directory in the user's home.


Create your build directory

$ build_8188eu
$ cd build_8188eu/

Branch the repository in order to keep my own copy from https://github.com/lwfinger/rtl8188eu to https://github.com/flav1972/rtl8188eu

$ git clone https://github.com/lwfinger/rtl8188eu

Build the module:

$ cd rtl8188eu
$ make


Then with root install:

# make install
install -p -D -m 644 8188eu.ko  /lib/modules/3.12.28+/kernel/drivers/net/wireless/8188eu.ko
/sbin/depmod -a 3.12.28+
mkdir -p /lib/firmware/rtlwifi
cp -n rtl8188eufw.bin /lib/firmware/rtlwifi/.

Its ok... now... problem fixed. insmod works again.