Thursday, 10 May 2012

RT5370 - Cheap micro usb wireless dongle on R-Pi

(N.B. - Note @ 27/July/2012. - I just downloaded and burned the 'Wheezy' image from the Raspberry Pi site.  This works with the below dongle out of the box - you don't need to install the firmware, so you can start at step 6.  Image used 2012-07-15-wheezy-raspbian.zip)

I took a chance on the cheapest micro wireless dongle I could find on ebay (£4.50) (3/2/13 - Just got one of these for £3.89, and can confirm it works fine - seems to be the same as the one I originally used.   - The original supplier on Ebay put price up to something stupid! http://www.ebay.co.uk/itm/310574944823)  -  It worked very well in windows, but I really wanted it for the Pi.  It was relatively straightforward to setup.  Obviously you need a working connection of some sort to download the required files. - I did this by bridging my wireless connection on windows7 with the (otherwise unused) wired connection and plugging the Pi.

1. - The package firmware-ralink from the Debian Squeeze install doesn't work - it doesn't contain the right firmware.
2. -  edit /etc/sources - add in wheezy as a source instead of squeeze.

deb http://ftp.uk.debian.org/debian/ wheezy main non-free
###deb http://www.debian-multimedia.org squeeze main non-free

3. - sudo apt-get update

4. - sudo apt-get install firmware-ralink

5. - Before you forget, reverse the comments in sources.list so that you put it back to squeeze and run apt-get update for good measure.

6. - Plug in the wireless dongle.

7. - Should be able to see it in lsusb:-


Bus 001 Device 004: ID 148f:5370 Ralink Technology, Corp. RT5370 Wireless Adapter


8. - edit /etc/network/interfaces


auto wlan0
iface wlan0 inet dhcp
   wireless-essid YourEssID
   wireless-mode managed
   wireless-key xxxxx

9. - sudo ifup wlan0

If all has worked, we should now be assigned a wireless IP address, and can unplug the ethernet. - Reboot to test.

10. - I then wanted a static IP for this. - This is simply configured in interfaces:-


auto wlan0
iface wlan0 inet static
    wireless-essid YourEssID
    wireless-mode managed
    wireless-key xxxxx
    address 192.168.2.75
    netmask 255.255.255.0
    network 192.168.2.0
    broadcast 192.168.2.255
    gateway 192.168.2.1

Note that I'm using WEP here (because some legacy kit doesn't support WPA) - might be slightly different for WPA.



18 comments:

  1. For wpa:
    Remove wireless-essid/wireless-mode/wireless-key

    Add:

    wpa-ssid yourssid
    wpa-psk yourkey

    ReplyDelete
  2. i would like to mention that you don't need to edit your apt sources.

    just

    wget http://ftp.de.debian.org/debian/pool/non-free/f/firmware-nonfree/firmware-ralink_0.35_all.deb (or another source of your choice)

    and

    dpkg -i firmware-ralink_0.35_all.deb

    does the job too.

    ReplyDelete
    Replies
    1. as the link doesn't work anymore - visit
      http://ftp.de.debian.org/debian/pool/non-free/f/firmware-nonfree/ and pick up the latest firmware-ralink_0.??_all.deb

      Regards

      Delete
  3. Didn't you need a powered USB Hub ?

    ReplyDelete
  4. I don't have a powered hub, and the raspberry Pi happily runs the wireless dongle and a wireless keyboard/mouse combo.

    ReplyDelete
  5. Thanks this got mine working.

    Does your lsmod show rt2800usb or rt2870sta?

    Everybody says it is suppose to have rt2870sta but I can't find it...
    I tried blacklisting rt2800usb and the other similar but then nothing works.

    ReplyDelete
    Replies
    1. It shows rt2800usb as below:-


      root@raspberrypi:~# lsmod
      Module Size Used by
      ipv6 213340 18
      fuse 52556 1
      arc4 764 2
      rt2800usb 9148 0
      rt2800lib 37652 1 rt2800usb
      crc_ccitt 932 1 rt2800lib
      rt2x00usb 6532 1 rt2800usb
      rt2x00lib 26104 3 rt2800usb,rt2800lib,rt2x00usb
      mac80211 182800 3 rt2800lib,rt2x00usb,rt2x00lib
      cfg80211 124592 2 rt2x00lib,mac80211

      Delete
  6. Thanks for the tut, but having trouble. Go through all the steps, everything goes alright until I run sudo ifup wlan0 and nothing really happens?

    Have I set up the network interfaces right?
    I have this wireless stick http://www.7dayshop.com/catalog/product_info.php?cPath=777_9&products_id=112046 recommended from the wiki as working in Wheezy

    http://cl.ly/HsAc
    http://cl.ly/Hrz1


    Should also point out that this is the first time I've ever really used linux/command line

    ReplyDelete
    Replies
    1. That dongle doesn't look the same as the one I got from Ebay, though I suspect that it's loaded some modules for this card since it is trying to get an address via DHCP, but I'm no expert....

      I'd start from the beginning. Do 'lsusb' and find out what device is acutally used in this dongle. - e.g. RT5370.

      Then, use 'lsmod' to see if it's loaded a module for it.

      Next try 'iwlist', or 'iwlist wlan0' to see if it thinks it can see any access points - at least that way you know it can 'see' the wlan.

      Also try 'dmesg' to see if that gives any further output which is helpful to your debugging.

      Finally, check that your router / access point is accessible to all MAC addresses? Failing that, try the forum on raspberrypi.org.

      Delete
  7. this article so far has been my only hope as I've been spent 2-3 hours trying to get this damned dongle to work. Please edit this line to include that you are editing /etc/apt/sources.list.. I .. think this is right.

    ReplyDelete
  8. ok so believe that I followed your instructions and recognized a few points.

    1) the steps outlined here will not allow for you to use the wireless device in xwin.

    2) The step that includes "rolling back" whatever adjustments you did with regards to setting the sources from wheezy to squeeze does not actually cause this to work. (Doing this actually caused the wireless device to stop working)

    3) The device will work with the specific list of tasks after loading xwin. If you load xwin and log out (if you've installed gnome network manager) will mean the network device is inaccessible.

    Light is still green, but you must unplug the network device to be able to interrupt ping / iwconfig, etc..

    Anyway, I really appreciate the work you put into this.. I would pay you 20 bucks if you could help me figure out how to get this working in xwin.

    Xwin managed to find my local network if I didn't edit the /etc/network/interfaces file, but it was not able to connect.

    I have spent about 6 hours on this, and being able to access the internet through the shell has been about as good as it gets. I'm not even going to start on the whole hope that I could get raspbmc to work to make this into a htpc.

    ReplyDelete
    Replies
    1. Zack. I think I'm a little confused over terminology here. I think where you say 'xwin' you mean xwindows, rather than 'xwin' X-server running on a PC for example. That being the case, then I think you first need to confirm that the wireless device is actually getting an IP address assigned (by DHCP), and that you are initially able to ping your router.

      For example ifconfig should show something similar to :-
      wlan0 Link encap:Ethernet HWaddr 7c:dd:90:0b:40:2f
      inet addr:192.168.2.75 Bcast:192.168.2.255 Mask:255.255.255.0

      If this works, and you have an assigned IP address, can you ping your router or anything else on the network? If that works, at least you know you have a connection.....

      Then, to connect to the internet, there needs to be a default route which points to your router. - in my case, router has named itself 'BTHomehub.com', and this is set as the default route seen here.

      root@raspberrypi:~# netstat -r
      Kernel IP routing table
      Destination Gateway Genmask Flags MSS Window irtt Iface
      default BThomehub.home 0.0.0.0 UG 0 0 0 wlan0
      192.168.2.0 * 255.255.255.0 U 0 0 0 wlan0


      I guess it's possible that DHCP hasn't set this, or you have it configured static.

      I'm unfamiliar with how you might force this to be recognised by Gnome network manager if it's not working once in xwindows I'm afraid. - I suspect you've already got the basics working as above, but unsure. Maybe try posting on the forum on the raspberry pi site as this is unlikely to be specific to the wlan adaptor you are using. - Good luck.

      Delete
    2. So I was completely mistaken, switching the sources.list back to squeeze and running sudo apt-get update did not remove the wifi abilities. I statically set the IP address and currently am logged in to the Pi via SSH. As far as the xwindows problem, I will likely consult the pi forum for any additional information about how to get this working in xwindows. Thank you so much for the article!

      Delete
    3. Hi - I am having problems trying to connect a RPi to the Internet via a wireless Dongle. I can do up to Step 8 fine. however I then get a warning message 'unknown mime-type for "/etc/network/interfaces" -- using "application/octet-stream". There is also an error message 'no write permission for file "/etc/network/interfaces".

      Any help is appreciated!

      Delete
    4. Sounds like you are not using a suitable command to edit the /etc/network/interfaces file. - Try:-
      sudo vi /etc/network/interfaces

      Delete
  9. pi@raspberrypi /etc/network $ sudo ifup wlan0
    wpa_supplicant: /sbin/wpa_supplicant daemon failed to start
    run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
    Internet Systems Consortium DHCP Client 4.2.2
    Copyright 2004-2011 Internet Systems Consortium.
    All rights reserved.
    For info, please visit https://www.isc.org/software/dhcp/

    Cannot find device "wlan0"
    Bind socket to interface: No such device
    Failed to bring up wlan0.

    Any idea what im doing wrong?

    ReplyDelete
    Replies
    1. I suspect that for some reason, the device isn't being seen. You can check with 'lsusb' and 'lsmod' to see if you have the same device as stated here. With the latest build of debian, no additional steps were needed to get this recognised as stated.

      Delete

Note: only a member of this blog may post a comment.