Set up WMB for Linux

From DSWiki

Jump to: navigation, search

If you develop homebrew for the DS under Linux, you'll probably be sick of

  • Swapping your CF card between your GBAMP and your card reader all the time
  • Emulators that work crappy in Wine

Thanks to TBBle, the first problem is currently being solved, because he's working on libnifi, which is a library that lets your computer talk to the DS regardless of your wireless card (and perhaps also your OS).

The library is still under development, but it already enables WMB under Linux. That means you can just download your homebrew projects to your DS via WiFi (provided you have FlashMe). This is of course much less painful than CF-swapping.

This guide tells you how to set it up.

Contents

[edit] Ingredients

You need:

  • 1 Computer
  • 1 Linux of your favorite flavour
  • 1 Ralink rt2500 card (one of these) PCI, PCMCIA or miniPCI (rt2500) are expected to work, USB (rt2570) is untested)
  • 1 DS with FlashMe (Without FlashMe only official demos will work)
  • No fear of compiling kernel modules

[edit] Setting it up

First, you may need to install some missing packages. Make sure you have

  • gcc
  • the sources/headers for your kernel (ubuntu: sudo apt-get install linux-source-2.6.xx linux-headers-$(uname -r) )
  • CVS
  • iproute2
  • wireless-tools
  • libiw with headers (the package is called libiw-dev under Debian or Ubuntu, and is from the wireless-tools source)
  • If you find something else that belongs to this list, please add it.

[edit] Setting up the Linux Kernel

If you compile the Linux kernel yourself you need to enable the options:

* Networking
 * Wireless
  * Improved wireless configuration API
  * Generic IEEE 802.11 Networking Stack

and

* Device Drivers
 * Network device support
  * Wireless LAN
   * Wireless LAN (IEEE 802.11)

Otherwise the Ralink driver module won't compile.

[edit] Compile the rt2500 driver from CVS

libnifi uses some functions of the rt2500 driver that are not yet in the stable driver releases, so we have to get the bleeding edge driver straight from CVS. Just follow these steps as root:

 cd /usr/src
 mkdir rt2500-cvs
 cd rt2500-cvs
 cvs -d:pserver:anonymous@rt2400.cvs.sourceforge.net:/cvsroot/rt2400 login

Hit enter at the password query, then download the source with:

 cvs -z3 -d:pserver:anonymous@rt2400.cvs.sourceforge.net:/cvsroot/rt2400 co -P source

Compile the source:

 cd source/rt2500/Module
 make

After this, the file rt2500.ko exists in the directory. Before installing it, make sure an old version of it is not loaded by entering

 ifconfig ra0 down
 rmmod rt2500

Then copy the rt2500.ko to the right place in your kernel modules directory, normally

 cp rt2500.ko /lib/modules/`uname -r`/extra/

For me, this is

 cp rt2500.ko /lib/modules/2.6.12-10-386/extra/

Now update the module dependencies with:

 depmod -a

Now,

 modprobe rt2500

and play a hoihoi. On reboot or device insertion, hotplug or udev should pick up the module for the device and autoload it.

Then enter

 iwconfig

And see if the card shows up. It should be called ra0.

Remark: The version string of the CVS driver does not seem to get updated, so if modinfo gives you an old date, this does not necessarily mean that your CVS driver was not loaded.

[edit] Compile libnifi

If everything went fine so far, go to the libnifi bzr page and download all .c and .h files and the Makefile to the same directory. Enter it and type

 make

to build it.

[edit] Set up your card

Your card has to be set to a certain mode to work. TBBle provided a script to do this, which can be fond on the libnifi page. Copy it into a file, save it as rt2500 and run it as root with

 ./rt2500.sh ra0 13

If necessary, replace ra0 by the name of your Ralink Card's interface name. This script has to be run every time after the module is loaded because the settings get lost when unloading the module

[edit] Go!

If this also went well, things are looking really good. Now you can test if you can download files to your DS. For example, you can get a demo. You probably have some homebrew programs of your own, but just because it's soooo cute, here is the link to Sushi the Cat. The *.nds file has to be <= 4MB.

Turn on your DS and tap "DS Download Play". Then run the program with:

 ./beacontest <ndsfile> ra0

You have to be root to run beacontest, as it uses raw sockets to the card, and you can't do that unless you're root. It normaly looks something like this:

 NDS length mismatch... The end is nigh!
 Configured interface ra0 (00:01:02:03:04:05) on channel 13
 wlan initited
 Association accepted
 Ready to send RSA after 8 sends
 Ready to send DATA after 2 sends

The "NDS length mismatch... The end is nigh!" isn't normal (< TBBle> Either the test is bad, the .nds is bad, or someone's appending stuff to the .nds that the header doesn't mark...), but it seems still to work (no critical error).

The program should now appear in the list. Download it and enjoy!

[edit] Developing with it

I find it quite handy to include wmb in my Makefile so I can just enter

 make wmb

and my projects get compiled and wmb'ed.

For this, I added a wmb target like this:

 wmb: all
       sudo <path-to-beacontest> $(TARGET).nds ra0

OK, I hope this tutorial work for you. If not, well, figure out the error and add the info to this page :-)

Bye, Tob

Personal tools