Tutorial: Ralink RT61 network card installation

Discussion in 'Linux, BSD and Other OS's' started by Addis, May 28, 2006.

  1. Addis

    Addis The King

    Likes Received:
    91
    Trophy Points:
    48
    Introduction:

    This is a howto on installing and configuring a wireless network card on linux.

    Many network cards from manufacturers such as Dlink actually use wireless chipsets from other manufacturers. Ralink is one of them, Broadcom also produce the chips for the wireless cards.

    I recently bought a CNET Total Network Solutions wireless card. The card itself uses a ralink rt61 chip. Ralink have been kind enough to provide linux drivers in the form of source code to the public, they can be found here.

    This tutorial will guide you through installing the drivers for a card using the rt61 WLAN chipset, these can be from many manufacturers. One way to find out which chipset you have is to physically look at the card. On my card, the main chip had the text "rt2561". DO NOT confuse this with an rt2500 chipset. Although they have the same major series number, the actual chipset is rt61.

    If you do not have access to the card itself, you can use the command:
    Code:
    lspci
    and then look for
    Code:
    0000:01:02.0 Network controller: RaLink: Unknown device 0302
    Prerequisites

    For the installation to go successfully, you will need:
    • Your kernel headers -- I'm using Mandriva, so I did "urpmi kernel-source" as root. For other distributions use the appropriate package manager to install the source code or headers for your kernel version. To find your kernel version do "uname -r". In Ubuntu linux and some other distributions, this is known as the "kernel-headers".
    • Root privileges for creating and copying files to outside your home directory.
    • GCC 4.0 or higher and other development packages like "make". Note that the your kernel must be compiled with gcc 3.4 or greater. Ubuntu 5.10 by default will not work and a newer kernel is needed.
    • Basic knowledge of Vim or other binary mode capable text editor.
    • Basic knowledge of command line functions.

    Installing drivers

    For the rt61 WLAN chipsets, you will need to download the drivers directly from Ralink. Here's a quick link: http://www.ralinktech.com/drivers/Linux/RT61_Linux_STA_Drv1.0.4.0.tar.gz

    Download that, and put it into your home directory. For now we will be using an unprivileged user and then "su" to root when needed.

    First unpack the drivers with
    Code:
    tar -xzf RT61_Linux_STA_Drv1.0.4.0.tar.gz
    for those who are unfamiliar with the CLI, you can use the tab key to complete the file name without having to type it all out.

    By default, the directory is set with non write permissions for the user, so we will need to change that. This can be done with
    Code:
    chmod -R 666 RT61_Linux_STA_Drv1.0.4.0/
    Now move into the directory with
    Code:
    cd RT61_Linux_STA_Drv1.0.4.0/
    Inside, there are 2 directories, Module and WPA Supplicant. We will only be using the Module directory.
    Code:
    cd Module
    The drivers allow the installation for the 2.4 kernel and the 2.6 kernel. Most people with modern distributions now use the 2.6 kernel. Modules for the 2.6 kernel end in .ko. Assuming that you are using a 2.6 kernel we will need to make sure that "make" uses the right makefile for your kernel. Do:
    Code:
    cp Makefile.6 Makefile
    That will overwrite the default makefile.

    Now we will build the kernel module, do:
    Code:
    make all
    and the module should compile. Warnings from the compiler are normal, if you get errors however and it doesn't compile; make sure that you've got the proper kernel source code, gcc and other build tools.

    If it was successful, you should now have some .bin files and the kernel module in the directory. We will now install the necessary files. Root privileges will now be required. do
    Code:
    su
    rootpassword


    Code:
    mkdir /etc/Wireless
    mkdir /etc/Wireless/RT61STA
    cp *.bin /etc/Wireless/RT61STA     #this copies all .bin files to the newly created directory.
    cp rt61sta.dat /etc/Wireless/RT61STA  #copies the wifi configuration file
    
    Please not that the /etc/Wireless/RT61STA directory must be made exactly, as it is where the module looks for the configuration files.

    Now move to the new directory created:
    Code:
    cd /etc/Wireless/RT61STA
    We'll now need to configure the module, do
    Code:
    vi -b rt61sta.dat
    Now refer to the README file back in the driver directory for the different configuration options. Many of them will be fine left as the default apart from ones that are specific to your setup, e.g. SSID, security options etc. If you are unfamiliar with vim then look here: vim tutorial

    I'm going to post my rt61sta.dat file as an example:
    Code:
    CountryRegion=0
    CountryRegionABand=7
    WirelessMode=0
    SSID=EMERSON
    NetworkType=Infra
    Channel=0
    AuthMode=WPAPSK
    EncrypType=TKIP
    DefaultKeyID=1
    Key1Type=0
    Key1Str=0
    Key2Type=0
    Key2Str=
    Key3Type=0
    Key3Str=
    Key4Type=0
    Key4Str=
    WPAPSK=mywpapskpassphrase
    TxBurst=0
    PktAggregate=0
    TurboRate=0
    WmmCapable=0
    AckPolicy1=0
    AckPolicy2=0
    AckPolicy3=0
    AckPolicy4=0
    BGProtection=0
    IEEE80211H=0
    TxRate=0
    RTSThreshold=2347
    FragThreshold=2346
    RoamThreshold=75
    PSMode=CAM
    TxPreamble=0
    FastRoaming=0
    Once you've finished making the required changes save and exit with
    Code:
    [Escape key]:wq
    Testing and final installation

    Now you should have the module configured and ready to go. Go back to the RT61_Linux_STA_Drv1.0.4.0/Module directory and then do:
    Code:
    cp rt61.ko /lib/modules/`uname -r`/kernel/drivers/net/
    depmod
    modprobe rt61
    Now check that the new network interface is listed:
    Code:
    iwconfig
    An entry for ra0 should be there. Only use iwconfig for checking that the network interface is there, do not use it for configuration as rt61 must use its own configuration file.

    If everything went smoothly, you should have the wireless card activated. We will now need to configure it for your network.

    DHCP users

    Chances are you'll be using DHCP to get the IP address from your router along with other network settings. Once the module is loaded you'll need to use a dhcp client. Try:
    Code:
    dhcpcd ra0
    If you don't have dhcpcd then try
    Code:
    dhclient ra0
    That should work.


    Static IP users

    Because of a glitch in my card or my router, I have to use a static IP. If you need to as well, then you'll need to use:
    Code:
    ifconfig ra0 IPADDRESS up
    Then you'll also need to set up your default gateway if you want internet access. Do
    Code:
    route add default gw (ROUTER IP ADDRESS)
    You'll also need to put some DNS servers into your /etc/resolv.conf file if you want to use the internet. That is out of the scope if this tutorial. The Resolv.conf File

    Now thats done, check for connectivity with
    Code:
    ping (router ip)
    or you can check for internet connectivity with
    Code:
    ping www.google.com
    We will now modify a few configuration files to enable the driver to be loaded on boot. use
    Code:
    vi /etc/modprobe.conf
    and add
    Code:
    alias ra0 rt61
    to the bottom of the file.

    Your distribution may already do the configuration necessary to start the network interface on boot, so most of the time this is all that is needed. If you need to do some extra configuration commands, you can always just add them to the /etc/rc.d/rc.local file. If you have any questions or problems please post here. :)


    Finishing Touches

    The follow steps are optional but you may do them to improve your setup.

    At the moment our rt61sta.dat file is stored on the system but is readable by everyone. This is quite insecure, as any user can see the security settings of the network. To change this, move to the /etc/Wireless/RT61STA directory and as root:
    Code:
    chmod 600 rt61sta.dat
    That will allow only the root user to read the file.
     
  2. megamaced

    megamaced Geek Geek Geek!

    Likes Received:
    0
    Trophy Points:
    36
    Good work Addis. :)

    Once Sniper sets up the HOWTO forum, we can stick this in there.
     

Share This Page