# Problem with ralink 2760 (rt2860sta)

## dj_bushido

So my kernel is compiled with the drivers for ralink added in, and yet I still get these errors:

```
 [32;01m*[0m Starting ra0

 [32;01m*[0m   Loading networking modules for ra0

 [32;01m*[0m     modules: apipa arping ccwgroup macchanger macnet rename iwconfig essidnet iptunnel ifconfig system dhcpcd ip6to4

 [32;01m*[0m       iwconfig provides wireless

 [32;01m*[0m       ifconfig provides interface

 [32;01m*[0m       dhcpcd provides dhcp

 [32;01m*[0m   Configuring ra0 for MAC address 00:1F:1F:39:6F:26 ...

[A[72C  [34;01m[ [32;01mok[34;01m ][0m

 [32;01m*[0m   Configuring wireless network for ra0

 [32;01m*[0m   Scanning for access points

 [32;01m*[0m     Found "Whackamole" at 00:1E:E5:EC:55:5B (managed, encrypted)

 [32;01m*[0m     Found "juluka" at 00:25:9C:4B:EC:AC (managed, encrypted)

 [31;01m*[0m   ra0 does not support setting the mode to "managed"

 [33;01m*[0m   ra0 does not support setting keys

 [33;01m*[0m   or the parameter "mac_key_Whackamole" or "key_Whackamole" is incorrect

 [31;01m*[0m   ra0 does not support setting the mode to "managed"

 [33;01m*[0m   WEP key is not set for "juluka" - not connecting

 [31;01m*[0m   Couldn't associate with any access points on ra0

 [31;01m*[0m   Failed to configure wireless for ra0

[A[72C  [34;01m[ [31;01m!![34;01m ][0m

[A[72C  [34;01m[ [31;01m!![34;01m ][0m
```

And: 

```
Error for wireless request "Set Mode" (8b06) : SET failed on device ra0 ; Network is down.
```

I can bring the interface up with ifconfig ra0 up, but when I try to apply changes through iwconfig (essid, key) it doesn't actually change anything. iwconfig ra0 never shows any changes after I apply them. Also, rt2860sta is loaded on boot.

----------

## d2_racing

Hi, can you post this :

```

# emerge --info

# cat /etc/conf.d/net

# ifconfig -a

# iwconfig

# ifconfig ra0 up

# iwlist scan

# dmesg | tail

```

----------

## dj_bushido

Also, just as a preface, I do have an Ubuntu installation running that I can chroot into for net access, although not wireless.

emerge --info

```
Portage 2.1.7.17 (default/linux/amd64/10.0/desktop, gcc-4.3.4, glibc-2.10.1-r1, 2.6.31-gentoo-r10 x86_64)

=================================================================

System uname: Linux-2.6.31-gentoo-r10-x86_64-AMD_Athlon-tm-_II_X2_240_Processor-with-gentoo-1.12.13

Timestamp of tree: Sat, 27 Mar 2010 18:00:01 +0000

app-shells/bash:     4.0_p35

dev-lang/python:     2.6.4-r1

sys-apps/baselayout: 1.12.13

sys-apps/sandbox:    1.6-r2

sys-devel/autoconf:  2.63-r1

sys-devel/automake:  1.10.3

sys-devel/binutils:  2.18-r3

sys-devel/gcc:       4.3.4

sys-devel/gcc-config: 1.4.1

sys-devel/libtool:   2.2.6b

virtual/os-headers:  2.6.30-r1

ACCEPT_KEYWORDS="amd64"

ACCEPT_LICENSE="* -@EULA"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-O2 -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/share/X11/xkb"

CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/sandbox.d /etc/terminfo"

CXXFLAGS="-O2 -pipe"

DISTDIR="/usr/portage/distfiles"

FEATURES="assume-digests distlocks fixpackages news parallel-fetch protect-owned sandbox sfperms strict unmerge-logs unmerge-orphans userfetch"

GENTOO_MIRRORS="http://distfiles.gentoo.org/ "

LDFLAGS="-Wl,-O1"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_CONFIGROOT="/"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

SYNC="rsync://rsync.gentoo.org/gentoo-portage"

USE="X a52 aac acl acpi alsa amd64 berkdb bluetooth branding bzip2 cairo cdr cli consolekit cracklib crypt cups cxx dbus dri dts dvd dvdr eds emboss encode evo fam firefox flac fortran gdbm gif gnome gpm gstreamer gtk hal iconv ipv6 jpeg ldap libnotify mad mikmod mmx mng modules mp3 mp4 mpeg mudflap multilib ncurses nls nptl nptlonly ogg opengl openmp pam pcre pdf perl png ppds pppd python qt3support quicktime readline reflection sdl session spell spl sse sse2 ssl startup-notification svg sysfs tcpd thunar tiff truetype unicode usb vorbis x264 xml xorg xulrunner xv xvid zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" ELIBC="glibc" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" RUBY_TARGETS="ruby18" USERLAND="GNU" VIDEO_CARDS="fglrx" 

Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, FFLAGS, INSTALL_MASK, LANG, LC_ALL, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PORTDIR_OVERLAY

```

ifconfig -a

```
lo        Link encap:Local Loopback  

          inet addr:127.0.0.1  Mask:255.0.0.0

          inet6 addr: ::1/128 Scope:Host

          UP LOOPBACK RUNNING  MTU:16436  Metric:1

          RX packets:24 errors:0 dropped:0 overruns:0 frame:0

          TX packets:24 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:1704 (1.6 KiB)  TX bytes:1704 (1.6 KiB)

ra0       Link encap:Ethernet  HWaddr 00:1f:1f:39:6f:26  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:5 errors:0 dropped:0 overruns:0 frame:0

          TX packets:19 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:1499 (1.4 KiB)  TX bytes:0 (0.0 B)

          Interrupt:21 

sit0      Link encap:IPv6-in-IPv4  

          NOARP  MTU:1480  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)

```

ifconfig ra0 up was null.

iwconfig ra0

```
ra0       RT2860 Wireless  ESSID:""  Nickname:"RT2860STA"

          Mode:Auto  Frequency=2.412 GHz  

          Link Quality=10/100  Signal level:0 dBm  Noise level:-97 dBm

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

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

```

/etc/conf.d/net

```
# This blank configuration will automatically use DHCP for any net.*

# scripts in /etc/init.d.  To create a more complete configuration,

# please review /etc/conf.d/net.example and save your configuration

# in /etc/conf.d/net (this file :]!).

config_eth0=( "dhcp" )

config_ra0=( "dhcp" )

#modules_ra0=( "rt2860sta" )

#Wireless section

modules=( "iwconfig" )

#modules_ra0=( "rt2860sta" )

#WEP Key

key_Whackamole="[1] 30c5e996103704da056571c49 key [1] enc open"

preferred_aps=( "Whackamole" )
```

It should be noted that whenever I add in the "rt2860sta" to modules, the system complains about not finding it, but when added to modules loaded at boot, it is fine.

And the iwlist ra0 scan:

```
ra0       Scan completed :

          Cell 01 - Address: 00:1E:E5:EC:55:5B

                    ESSID:"Whackamole"

                    Mode:Managed

                    Channel:6

                    Quality:81/100  Signal level:-58 dBm  Noise level:-97 dBm

                    Encryption key:on

                    Bit Rates:18 Mb/s

```

I also didn't set the channel in the iwconfig command line. is that a problem?

----------

## dj_bushido

Ok, so after plugging around on the internet, this can be fixed. What happens is that the interface is brought down before making changes to it, and the ralink driver doesn't like that. Make this change to fix it:

In /lib/rcscripts/net/iwconfig.sh:

    Find the line "iwconfig_set_mode" and where it says "interface_down "${iface}"", comment out that line by adding a "#" at the beginning. Also, make sure that your WEP keys are correct as well!

----------

## StringCheesian

On ~amd64 (baselayout 2, openrc), to make rt2860sta work I have to find this code in "/lib64/rc/net/iwconfig.sh":

```
iwconfig_set_mode()

{

        local mode="$1"

        [ "${mode}" = "$(iwconfig_get_mode)" ] && return 0

        # Devicescape stack requires the interface to be down

        _down

        iwconfig "${IFACE}" mode "${mode}" || return 1

        _up

}
```

And comment out the "_down" and "_up" so it looks like this:

```
iwconfig_set_mode()

{

        local mode="$1"

        [ "${mode}" = "$(iwconfig_get_mode)" ] && return 0

        # Devicescape stack requires the interface to be down

        # ...but rt2860sta needs it to be up

        #_down

        iwconfig "${IFACE}" mode "${mode}" || return 1

        #_up

}
```

I forget where I learned this - I thought there was a gentoo bugzilla entry, but now I can't find it. Maybe we should file a new one.

----------

## d2_racing

I'm not sure if it's a good idea, because on the next upgrade of OpenRC or anything else, maybe you will loose some configs files.

----------

