# Help with setting up wireless networking (RaLink RT2860)

## lesha_n

Dear Gentoo users,

I am stuck trying to setup wireless networking on my amd64 box, kernel 2.6.39-gentoo-r3, and would appreciate any help you may be able to give. This is my first wireless under linux, and I am quite confused as to the exact steps to take to get it working.

(1) Which driver should I be using for my RaLink RT2860 PCI card? So far I've tried three:

[list=]

   [*] rt2860sta.ko found under kernel staging drivers (installed in /lib/modules/2.6.39-gentoo-r3/kernel/drivers/staging/rt2860/rt2860sta.ko)

   [*] rt2860sta.ko downloaded from Ralink web site and compiled (installed in 

/lib/modules/2.6.39-gentoo-r3/kernel/drivers/net/wireless/rt2860sta.ko) -- I believe this is essentially the same as above, only version 2.4.0.0 vs 2.1.0.0 supplied with the kernel

   [*] rt2800pci.ko also supplied with the kernel (installed in /lib/modules/2.6.39-gentoo-r3/kernel/drivers/net/wireless/rt2x00/rt2800pci.ko)

[/list]

I seem to be getting further ahead with the rt2860sta driver, is this the one to be used?

(2) Do I need to install the firmware file (rt2860.bin) separately? I suspect that it is already built into rt2860sta, but I am not sure.

(3) Beyond modprobe, how do I test that the interface is working (I know the card is ok, since it works under XP, no problems using my access point)? iwconfig shows "ra0" interface:

```

# iwconfig

ra0       Ralink STA

```

and after 

```

# ifconfig ra0 up

```

iwconfig shows more details:

```

# iwconfig ra0

ra0       Ralink STA  ESSID:""  Nickname:"RT2860STA"

          Mode:Auto  Frequency=2.412 GHz  Access Point: 00:25:3C:0B:C4:09   

          Bit Rate=1 Mb/s   

          RTS thr:off   Fragment thr:off

          Encryption key:off

          Link Quality=100/100  Signal level:-68 dBm  Noise level:-68 dBm

          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0

          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

```

I can even scan the access points and see mine: 

```

# iwlist scan

ra0       Scan completed :

          Cell 01 - Address: 00:25:3C:0B:C4:09

                    Protocol:802.11b/g

                    ESSID:"BELL618"

                    Mode:Managed

                    Frequency:2.412 GHz (Channel 1)

                    Quality:55/100  Signal level:-68 dBm  Noise level:-92 dBm

                    Encryption key:on

                    Bit Rates:54 Mb/s

                    IE: IEEE 802.11i/WPA2 Version 1

                        Group Cipher : CCMP

                        Pairwise Ciphers (1) : CCMP

                        Authentication Suites (1) : PSK

```

However I am at a loss what to do at this point. My access point uses WPA2-PSK mode with AES  encryption and I have the pass phrase. Should I be using wpa_supplicant or wireless-tools? I keep reading the networking guide (http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?part=4&chap=4) on wireless configuration, but I cannot figure out what to do next. I assumed I would be better off with wpa_supplicant (because of WPA2-PSK) and have added this to /etc/conf.d/net:

```

# Prefer wpa_supplicant over wireless-tools

modules="wpa_supplicant"

# It's important that we tell wpa_supplicant which driver we should

# be using as it's not very good at guessing yet

wpa_supplicant_ra0="-Dwext"

```

What should be my nest steps and where do I define access parameters to my wireless access point?

Many thanks for your help,

Aleksey

----------

## cach0rr0

youll want wpa_supplicant, as wireless-tools supports only open networks, or WEP

now, as far as setting up configuration files goes, most people only end up doing this for testing purposes while theyre making sure they have all of their driver/kernel bits set up correctly. Ultimately most end up going with some graphical management tool for wireless, such as wicd (my preference) or networkmanager. If you think youll end up just using a graphical management tool for this, you dont need to bother with /etc/conf.d/net for your wireless card

but first, make sure wpa_supplicant works

for that, you'll want to set up a wpa_supplicant.conf (in /etc/wpa_supplicant/wpa_supplicant.conf)

if you emerge wpa_supplicant, you can 'man wpa_supplicant.conf' to see details, and some sample configurations. General rule of thumb for your tests, minimal is best. So, something like this:

```

          network={

               ssid="yournetworkname"

               scan_ssid=1

               key_mgmt=WPA-PSK

               psk="yourpassword"

          }

```

Then test. Note that this will stay running on the console, so you will have to CTRL+C to kill it. Also note that this does not get you an IP, dhcp does that; wpa_supplicant merely associates and authenticates you with your AP:

```

wpa_supplicant -Dwext -i ra0 -c /etc/wpa_supplicant/wpa_supplicant.conf

```

note that 'ra0' is the name if using ralink's proprietary driver. For the staging driver or the other in-kernel driver, replace 'ra0' with 'wlan0'

You could also try:

```

wpa_supplicant -Dnl80211 -i ra0 -c /etc/wpa_supplicant/wpa_supplicant.conf

```

if the text you see on the console doing these tests seems to suggest you associate and authenticate with the AP successfully, you're in good shape. Were you to leave this running, open a new console, and fire off 'dhcpcd ra0', you should get an IP, and have connectivity. 

If wpa_supplicant does NOT get you to this point, post any errors, and we'll cross things off as they come

----------

## whiteghost

https://forums.gentoo.org/viewtopic-t-835459-start-0.html

http://en.gentoo-wiki.com/wiki/Ralink_RT2870

some kernels the drivers are staging and others out of staging.

following the wiki kernel configuration it 'unmasked'  rt2800 under wireless drivers. 

took me a while to unmask/find it

 *Quote:*   

>  Do I need to install the firmware file (rt2860.bin) separately? 

 

yes

 *Quote:*   

> created folder /lib/firmware and droped the .bin in... ifconfig wlan0 up (no errors) and now i can iwlist scan and it shows all the AP's in my hood

 

----------

## lesha_n

cach0rr0,

Thanks a lot for your help! I created /etc/wpa_supplicant/wpa_supplicant.conf following the example you provided, then fired 

```

wpa_supplicant -Dwext -i ra0 -c /etc/wpa_supplicant/wpa_supplicant.conf 

```

and then got the IP via

```

dhcpcd ra0

```

worked as a charm and I am now connected.

As far as GUI based network management tools, I actually find them more difficult to deal with, at least for the moment. I tried wicd (wicd-gtk and a KDE client) and found both rather confusing. I finally got the wicd KDE client to show my network and it showed status as connected. Curiously, however, with KDE wicd client open I kept losing connection and had to reissue 'dhcpcd ra0' to get an IP back. Perhaps there is a setting somewhere there that gets in a way, I'll look around. I am quite happy to use CLI for now.

Now that it works, how do I go about streamlining the connection process, so that I do not have to issue wpa_supplicant and dhcpcd every time? I guess creating something like /etc/init.d/net.ra0?

Thank you so much for your help!

----------

## lesha_n

whiteghost,

Thanks for your help. In the end I did not need to do anything about the firmware file (rt2860.bin), the wpa_supplicant command, together  with a sound wpa_supplicant.conf got me connected. Curiously, the RaLink README file which came with the driver, also says nothing about firmware, but rt2860.bin is included in the download. I do not see it installed anywhere when 'make install' runs, and it's not in /lib/firmware. Perhaps it is compiled right into the module during compilation of the rt2860sta driver?

----------

## cach0rr0

 *lesha_n wrote:*   

> 
> 
> Now that it works, how do I go about streamlining the connection process, so that I do not have to issue wpa_supplicant and dhcpcd every time? I guess creating something like /etc/init.d/net.ra0?
> 
> 

 

That's a two parter:

-first, set up /etc/conf.d/net  (modules="wpa_supplicant" and wpa_supplicant_ra0="-Dwext", is i *think* all you have to do - i never set it up this way)

-second, 'cd /etc/init.d' and 'ln -s net.lo net.ra0'

Once that's sorted, start your net.ra0 script up and wireless should kick off. Note that you will still need that wpa_supplicant.conf, and you may want to tweak it a bit so that it's accessible to normal users (more details on that within 'man wpa_supplicant.conf')

And of course if you want that script to run when your machine starts up, 'rc-update add net.ra0 default'

----------

## lesha_n

cach0rr0,

Thank for your help again. I got half-way through with your instructions, left the comp on during the day (in sleep mode) and had a power failure at home. Had a bunch of problems on boot, finally resolved all of them by booting into an older kernel and recompiling the current kernel (2.6.39-gentoo-r3) with modules, including the rt2860sta module downloaded from Ralink (same version as before, 2.4.0.0).

Trouble is, I cannot now reproduce the success I had with wpa_supplicant, it fails:

```

oka ~ # wpa_supplicant -Dwext -i ra0 -c /etc/wpa_supplicant/wpa_supplicant.conf

Trying to associate with 00:25:3c:0b:c4:09 (SSID='BELL618' freq=2422 MHz)

ioctl[SIOCSIWGENIE]: Operation not supported

Association request to the driver failed

Authentication with 00:25:3c:0b:c4:09 timed out.

```

Any ideas why it may happen?

Many thanks,

Aleksey

----------

## cach0rr0

i would check dmesg output after you modprobe the driver, i would be fairly surprised if loading the module did not throw some kind of error here (e.g. "unknown symbol in module rt2860sta.ko")

----------

## lesha_n

cach0rr0,

Loading the module results in these dmesg messages:

```

oka ~ # modprobe rt2860sta

(resulting messages, from dmesg | tail -n 40):

[41893.607104] rt2860 0000:02:00.0: setting latency timer to 64

[41893.608111]                                                                                                       

[41893.608112] 

[41893.608113] === pAd = ffffc900119e4000, size = 572224 ===

[41893.608114] 

[41893.608167] <-- RTMPAllocTxRxRingMemory, Status=0

[41893.608324] <-- RTMPAllocAdapterBlock, Status=0

[41893.608326] pAd->CSRBaseAddress =0xffffc90011700000, csr_addr=0xffffc90011700000!

```

Nothing I could desipher from that. Then running wpa_supplicant seems to give something useful:

```

oka ~ # wpa_supplicant -Dwext -i ra0 -c /etc/wpa_supplicant/wpa_supplicant.conf

Trying to associate with 00:25:3c:0b:c4:09 (SSID='BELL618' freq=2422 MHz)

ioctl[SIOCSIWGENIE]: Operation not supported

Association request to the driver failed

Authentication with 00:25:3c:0b:c4:09 timed out.

(resulting messages, from dmesg | tail -n 40):

[42190.320268] RX DESC ffff8800739e2000  size = 2048

[42190.327176] Key1Str is Invalid key length(0) or Type(0)

[42190.327195] Key2Str is Invalid key length(0) or Type(0)

[42190.327215] Key3Str is Invalid key length(0) or Type(0)

[42190.327234] Key4Str is Invalid key length(0) or Type(0)

[42190.329040] 1. Phy Mode = 5

[42190.329042] 2. Phy Mode = 5

[42190.342368] phy mode> Error! The chip does not support 5G band 3!

[42190.343082] RTMPSetPhyMode: channel is out of range, use first channel=1 

[42190.351196] 3. Phy Mode = 9

[42190.356043] MCS Set = ff ff 00 00 01

[42190.356046] <==== rt28xx_init, Status=0

[42190.356075] 0x1300 = 00064300

```

Any idea what to make of it?

Many thanks

----------

