Instal Wifi USB Adapter TP-LINK TL-WN721N pada Raspberry Pi

Tutorial ini diambil dari  Embedded Linux Wiki (


Instalasi TP-Link TL-WN721N USB wireless adapter pada OS Raspbian (Debian Wheezy)

Pertama kali buka Terminal Raspbian dan login di root.  sudo -i

  • Edit /etc/apt/sources.list dengan perintah   sudo nano /etc/apt/sources.list):
 deb squeeze main non-free
 deb squeeze/updates main non-free
 deb squeeze-updates main non-free
 deb squeeze-backports main non-free
  • Update the package cache:
 sudo apt-get update
  • Download the wifi utils:
 sudo apt-get install wireless-tools usbutils 
  • Download the required firmware and put it in the correct location – you may not need to do this for your adapter or you may need different firmware – see below.
 sudo apt-get install firmware-atheros
 sudo wget
 sudo cp htc_9271.fw /lib/firmware
  • Add adapter definition to network config – eg: sudo vi /etc/network/interfaces – add the wlan0 section:
# Used by ifup(8) and ifdown(8). See the interfaces(5) manpage or
# /usr/share/doc/ifupdown/examples for more information.

auto lo

iface lo inet loopback
iface eth0 inet dhcp

# The wireless interface
auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa.conf
  • Plug in adapter
  • Confirm adapter is present:
 root@raspberrypi:~# sudo iwconfig
  lo        no wireless extensions.

  eth0      no wireless extensions.

  wlan0     IEEE 802.11bgn  ESSID:off/any
            Mode:Managed  Access Point: Not-Associated   Tx-Power=20 dBm
            Retry  long limit:7   RTS thr:off   Fragment thr:off
            Encryption key:off
            Power Management:off
  • Scan your network to see what wireless access points can be seen. You may need to do this to identify your network’s SSID (name), but it also confirms that the wifi dongle is doing something. The first command just lists the SSIDs found, the second tells you probably more than you ever want to know:
  sudo iwlist wlan0 scan | grep ESSID


  sudo iwlist wlan0 scan
  • Create the wpa.conf file – eg: sudo vi /etc/wpa.conf:

Note: The ssid is case sensitive – if your WLAN’s SSID is MYLAN, using “mylan” will not work – you won’t connect!

pairwise=CCMP TKIP
  • Start the adapter
  sudo ifup wlan0
  • Double-check whether you are connected – below the WLAN interface has been given an IP address – looks good!
 root@raspberrypi:~# ifconfig
 eth0      Link encap:Ethernet  HWaddr b8:27:eb:76:7e:2e
           inet addr:  Bcast:  Mask:
           RX packets:1060 errors:0 dropped:0 overruns:0 frame:0
           TX packets:146 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:95749 (93.5 KiB)  TX bytes:48493 (47.3 KiB)

 lo        Link encap:Local Loopback
           inet addr:  Mask:
           UP LOOPBACK RUNNING  MTU:16436  Metric:1
           RX packets:8 errors:0 dropped:0 overruns:0 frame:0
           TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:560 (560.0 B)  TX bytes:560 (560.0 B)

 wlan0     Link encap:Ethernet  HWaddr b0:48:7a:91:5c:f4
           inet addr:  Bcast:  Mask:
           RX packets:31 errors:0 dropped:0 overruns:0 frame:0
           TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:2260 (2.2 KiB)  TX bytes:1542 (1.5 KiB)

If you are now connected, well done! If not, check your editing and also have a look at the output of dmesg to see if you have any error messages. You can also view the system log for messages – for example: sudo cat /var/log/messages | more

You are connected, you can ping and be pinged, hovewer to add network connectivity you may want to specify define default gateway:

sudo route add default gw wlan0


USB interrupt/dma system debug messages

Firing up the TP-Link USB WLAN interface generates a lot of debug messages in the system log like this:

DEBUG:handle_hc_chhltd_intr_dma:: XactErr without NYET/NAK/ACK

Things may calm down a bit if the following file is created in /etc/modprobe.d (eg: sudo vi /etc/modprobe.d/smscnonturbo.conf) and then the RPi rebooted:


 options smsc95xx turbo_mode=N

This fix may slow down wired LAN performance but help with wireless and reduce the frequency of the debug messages – YMMV. If you want to undo this fix, just delete the file (sudo rm /etc/modprobe.d/smscnonturbo.conf) and reboot.
Firmware requirements

If no wlanx device is shown, you might need to download firmware for your USB wifi device (or track down other compatible drivers if they are available). To confirm this, check the dmesg output when you plug in your adapter – typing dmesg at the command prompt may be sufficient – and look for information related to your adapter – the example dmesgoutput below shows what is seen in the event of the TP-Link firmware not being present – notice that the name of the required firmware file is given (htc_9271.fw), the driver name (ath9k_htc) and an error -22 message:

  usb 1- ath9k_htc: Firmware - htc_9271.fw not found
  ath9k_htc: probe of 1- failed with error -22
  usbcore: registered new interface driver ath9k_htc

Armed with this information, try a web search for ‘debian 6’ and the name of the driver or driver file and/or head over to Also check the links at the top of this page.

Power requirements

If you experience erratic network, keyboard, mouse or Raspberry Pi operation when using a USB wifi dongle, check that whatever is powering your RPi and/or USB hub can deliver sufficient current for everything that’s connected together. The first setup tried with the TP-Link adapter had it, a keyboard, mouse and the RPi all connected to a Trust 7-port powered USB hub with a 5V 2A power supply, but in this configuration the mouse stopped working. In this case, the fix was to power the RPi from a separate 5V 1A phone power adapter.

wpasupplicant deamon failed to start

a) If you get this error when you attempt to

sudo ifup wlan0

Then there may be a syntax error in your


For example, ensure that your SSID and Password have double quotes round them, and that the curly brackets are closed.

b) Another possible solution could be changing:

iface wlan0 inet dhcp


iface wlan0 inet manual

in /etc/network/interfaces. Then sudo ifup wlan0 then sudo ifdown wlan0 then changing manual to dhcp. Works me, as described



Referensi Tambahan Untuk Jenis Enkripsi Wifi yang berbeda :


Connecting to a wireless network

For the general case of connecting to a Wi-Fi network, we recommend that you use the wpa_supplicant daemon. It handles unsecure, WEP, WPA, and WPA2 networks and provides a mechanism for saving network information in a configuration file that’s scanned on startup, thereby removing the need for you to constantly reenter network parameters after rebooting or moving from one network domain to another. The information following covers the more specific cases if you don’t want to run the supplicant.

You can connect to a wireless network by using one of the following:

We will also be rolling out a new Wi-Fi configuration GUI as part of Photon that interfaces into wpa_supplicantdirectly.

Once connected, you need to configure the interface in the standard way:

  • TCP/IP configuration in a wireless network (client in Infrastructure Mode, or ad hoc Mode)

Using no encryption

Caution: If you’re creating a wireless network with no encryption, anyone who’s within range of the wireless network (e.g. someone driving by your building) can easily view all network traffic. It’s possible to create a network without using encryption, but we don’t recommend it unless the network has been secured by some other mechanism.Many consumer devices (wireless routers to connect your internal LAN to the Internet for example) are shipped with security features such as encryption turned off. We recommend that you enable encryption in these devices rather than turn off encryption when creating a wireless network.

To connect using no encryption or authentication, type:

ifconfig ral0 ssid "network name" -nwkey

The -nwkey option disables WEP encryption and also deletes the temporary WEP key.

Note: The io-pkt manager doesn’t support a combination of Shared Key Authentication (SKA) and WEP encryption disabled.

Once you’ve entered the network name, the 802.11 network should be active. You can verify this with ifconfig. In the case of ad hoc networks, the status will be shown as active only if there’s at least one other peer on the (SSID) network:

ifconfig ral0

    ssid "network name" %%
    powersave off %%
    bssid 00:11:22:33:44:55 chan 11%%
    address: 11:44:88:44:88:44%%
    media: IEEE802.11 autoselect (OFDM36 mode 11g) %%
    status: active%%

Once the network status is active, you can send and receive packets on the wireless link.

You can also use wpa_supplicant to associate with a security-disabled Wi-Fi network. For example, if your/etc/wpa_supplicant.conf file can contain a network block as follows:

network = {
    ssid = "network name"
    key_mgmt = NONE

you can then run:

wpa_supplicant -i ral0 -c/etc/wpa_supplicant.conf

You may also use wpa_cli to tell wpa_supplicant what you want to do. You can use either ifconfig or wpa_cli to check the status of the network. To complete your network configuration, see Client in infrastructure or ad hoc mode in the section on TCP/IP interface configuration.

Using WEP (Wired Equivalent Privacy) for authentication and encryption

WEP can be used for both authentication and privacy with your wireless network. Authentication is a required precursor to allowing a station to associate with an access point. The IEEE 802.11 standard defines the following types of WEP authentication:

Open system authentication
The client is always authenticated with the WAP (i.e. allowed to form an association). Keys that are passed into the client aren’t checked to see if they’re valid. This can have the peculiar effect of having the client interface go“active” (become associated), but data won’t be passed between the AP and station if the station key used to encrypt the data doesn’t match that of the station.

Note: If your WEP station is active, but no traffic seems to be going through (e.g. dhcp.client doesn’t work), check the key used for bringing up the connection.

Shared key authentication
This method involves a challenge-response handshake in which a challenge message is encrypted by the stations keys and returned to the access point for verification. If the encrypted challenge doesn’t match that expected by the access point, then the station is prevented from forming an association.Unfortunately, this mechanism (in which the challenge and subsequent encrypted response are available over the air) exposes information that could leave the system more open to attacks, so we don’t recommended you use it. While the stack does support this mode of operation, the code hasn’t been added to ifconfig to allow it to be set.

Note that many access points offer the capability of entering a passphrase that can be used to generate the associated WEP keys. The key-generation algorithm may vary from vendor to vendor. In these cases, the generated hexadecimal keys must be used for the network key (prefaced by 0x when used with ifconfig) and not the passphrase. This is in contrast to access points, which let you enter keys in ASCII. The conversion to the hexadecimal key in that case is a simple conversion of the text into its corresponding ASCII hexadecimal representation. The stack supports this form of conversion.

Given the problems with WEP in general, we recommend you use WPA / WPA2 for authentication and encryption where possible.

The network name can be up to 32 characters long. The WEP key must be either 40 bits long or 104 bits long. This means you have to give either 5 or 13 characters for the WEP key, or a 10- or 26-digit hexadecimal value.

You can use either ifconfig or wpa_supplicant to configure a WEP network.

If you use ifconfig, the command is in the form:

ifconfig if_name ssid the_ssid nwkey the_key

For example, if your interface is ral0, and you’re using 128-bit WEP encryption, you can run:

ifconfig ral0 ssid "corporate lan" nwkey corpseckey456 up

Once you’ve entered the network name and encryption method, the 802.11 network should be active (you can verify this with ifconfig). In the case of ad hoc networks, the status will be shown as active only if there’s at least one other peer on the (SSID) network:

ifconfig ral0 
    ssid "corporate lan" nwkey corpseckey456
    powersave off
    bssid 00:11:22:33:44:55 chan 11
    address: 11:44:88:44:88:44
    media: IEEE802.11 autoselect (OFDM36 mode 11g)
    status: active

Once the network status is active, you can send and receive packets on the wireless link.

If you use wpa_supplicant, you need to edit a configuration file to tell it what you want to do. For example:

network = {       
  ssid = "corporate lan"      # The Wi-Fi network you want to associate to.
  key_mgmt= NONE              # NONE is for WEP or no security.
  wep_key0 = "corpseckey456"  # Most of the time, you may specify a list
                              # from wep_key0 to wep_key3 and use
                              # key index to specify which one to use. 

Then you may run:

wpa_supplicant -i ral0 -c your_config_file
Facebook Comments

Leave a Reply

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