Search

Ubuntu 12.04 - Setup wifi key based on Ralink RT2572T

Contents[Hide]

dropcap-ubuntu-wifi

Few days back, I was needing a wifi 54G key. Having an old OvisLink Wifi 54G 802.11b/g USB key, I tried to use it under Ubuntu Precise 12.04.

This key is using a Ralink RT2572T which is recognised out-of-the-box by Ubuntu 12.04. But it doesn't work as expected.

Wifi connection takes place, but sometimes the card doesn't get DHCP address and most of the time data stream stops for few seconds, and then restart.

Also, under encrypted networks, the data can't succeed to get thru. In fact, these troubles come from 2 functionnalities :

  • power management, which needs to be disabled
  • hardware encryption, which also needs to be disabled

This article explains how to setup these 2 tweaks to get a fully working Ralink RT2572T wifi adapter under Ubuntu Precise 12.04.

It has been tested successfully on Ubuntu 12.04 i386 version with original 3.2.0-23 and latest 3.8.10 kernels.

1. Check Hardware

Make sure you are having a RT2572T chipset :

# lsusb
Bus 001 Device 008: ID 148f:2570 Ralink Technology, Corp. RT2570 Wireless Adapter

If power management problem occurs, you should get this type of records in syslog :

/var/log/syslog

phy1 -> rt2x00lib_autowakeup: Error - Device failed to wakeup.
phy1 -> rt2500usb_set_device_state: Error - Device failed to enter state 1 (-16).
phy1 -> rt2500usb_set_device_state: Error - Device failed to enter state 3

2. Disable Hardware Encryption

Hardware encryption was added to rt2500usb module in kernel 2.6.29.

This feature is giving trouble, especially when using WEP encryption.

You can disable it and force software encryption quite easily by setting-up a module option in /etc/modprobe.d/net-rt2572.conf.

# sudo gedit /etc/modprobe.d/net-rt2572.conf

/etc/modprobe.d/net-rt2572.conf

# Ralink RT2572T - disable hardware encryption
options rt2500usb nohwcrypt=1

3. Disable Power Mamangement

Under Ubuntu, RT2572 power management is broken.

Because of that, your wifi card may become unaccessible very often, not allowing any data transfer.

This misbehaviour can be suppressed quite easily by disabling power management on the USB adapter.

To disable poer management, you need to handle 3 types of events :

  1. Computer boot
  2. USB key insertion
  3. Computer resume (after suspend)

First two conditions can be handled quite nicely with a udev rule. Latest condition has to be handled thru a power management script.

3.1. Get Adapter Interface

First thing to do is to find the adapter wireless interface name.

# iwconfig
lo no wireless extensions.

eth0 no wireless extensions.

wlan1 IEEE 802.11bg ESSID:"bernaerts"
Mode:Managed Frequency:2.417 GHz Access Point: 00:26:F2:A6:69:E6
Bit Rate=48 Mb/s Tx-Power=20 dBm
...

Here the USB key is known as wlan1.

We now know that we have to throw the following command to disable power management on the Ralink RT2572T USB key :

/sbin/iwconfig wlan1 power off

3.2. Udev Rule

To switch off power management as soon as adapter is detected, we will setup a specific udev rule.

The udev rule will be placed under /etc/udev/rules.d and it will be named starting with 99- so that it is executed last.

It will be triggered by the Vendor ID and Device ID detected with the lsusb command.

# sudo gedit /etc/udev/rules.d/99-rt2572t.rules

/etc/udev/rules.d/99-rt2572t.rules

# disable power management for RT2572T
SUBSYSTEMS=="usb", ATTRS{idVendor}=="148f", ATTRS{idProduct}=="2570", ACTION=="add", RUN+="/sbin/iwconfig wlan1 power off"

3.3. Power Management Script

Power management during suspend and resume are handled via some scripts under /etc/pm/sleep.d.

These scripts are called every time the computer suspends and resumes from suspend mode.

So we need to declare a resume script that will be in charge of disabling power management on our Ralink RT2572T adapter.

sudo gedit /etc/pm/sleep.d/10_rt2572t
sudo chmod +x /etc/pm/sleep.d/10_rt2572t

/etc/pm/sleep.d/10_rt2572t

#!/bin/sh

# This script disable power management on Ralink RT2572T after resume

case $1 in
  hibernate|suspend)
    echo "Nothing to be done"
    ;;
  thaw|resume)
    echo "Disable power management for RT2572T"
    /sbin/iwconfig wlan1 power off
    ;;
  *)
    ;;
esac

You can now reboot your computer which is now ready to properly handle a Ralink RT2572T adapter.

Your wifi connection should be fast and stable.

Hope it helps.

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus