Neuros OSD 1.0:setting-up-wireless-support

From The Neuros Technology Wiki

Jump to: navigation, search

More specifically, Asus now sells their ASUS WL-167G dongles with RT73 chip inside, which require a different driver, still from serialmonkey though. This driver was checked in into Neuros SVN tree (/kernel/drivers/usb/net/rt73) on April 2007 but it's not working yet. Work is in progress on it. There's a new article that details progress with that driver.

Also the instructions here refer to the old developer boards and some things are not up to date anymore with the current production OSDs. So you might want to skip the part about downgrading the kernel. Also I don't think you need to do the struct packing trick anymore, since the new serialmonkey drivers have "arm" and "armdebug" targets that fix that problem. Also wireless tools and wireless extensions are already part of the current SVN tree so you don't need to worry about them.

It still contains some valid information though.

DCP 2421 2.JPG



At this moment only the RT25USB-SRC-V2.0.7.0 driver from Ralink is succesfully ported and reported to be working with an ASUS WL-167G USB dongle on 2.6.5-it0. This tutorial gives enough information to easily use the ASUS WL-167G on your OSD, but also gives enough information for everyone who wants to port another driver.

So what do you need:

  • kernel 2.6.5-it0 with wireless extensions enabled, this is due to the broken USB Host driver in 2.6.15 (instructions below)
  • dongle with RT2570 chipset, see serialmonkey for a list
  • the source code of the dongle driver. I've succesfully 'ported' the RT25USB-SRC-V2.0.7.0 driver from Ralink
  • and some version of wireless tools to send commands to the dongle, available here
  • wireless support has only been tested with the developer OSD (green PCB). If you have the yellow/orange one shipped from thinkgeek then you could be the first to get wireless working on a BETA sample!

The broken USB Host driver is expected to be fixed by the manufacturer around 9/12. Until this time you will have to downgrade your OSD to a 2.6.5 kernel... and probably has the consequence that you can't play any video/audio :P

The right kernel

Due to limited support for USB Host devices we need to downgrade the kernel. I used revision 204 from trunk. You can download it with the following command:

svn co -r 204 svn://

Just follow the instructions in the README files to build it. You should however enable wireless extensions during the linux kernel configuration:

Device Drivers -> Network Device Support -> wireless LAN (non-hamradio) -> Wireless LAN drivers (non-hamradio) & Wireless Extensions

Another problem with this kernel is that the USB driver misses power control... This means that the driver can't enable the power on the USB Host port itself. What you need to do for this is physically connect R180. You can find it on the top of the board behind the USB Host port itself. I used a small piece of aluminium foil and some tape :-).

The RT2570 Driver

The most recent version of this driver can be found at serialmonkey. I however used version RT25USB-SRC-V2.0.7.0 available at Ralink. I've also made the the ported RT25USB-SRC-V2.0.7.0 driver available. I will explain about this porting in detail below.

When you downloaded the ported driver go to its directory and type:

make all

This builds the module rt2570.ko. Copy this module to #BSP_ROOT#/lib/modules/2.6.5-it0/extra/

When you want the to port the driver yourself then the first thing you should do is change the Makefile. There are 2 Makefiles available, one for the 2.4 kernel and the other for the 2.6 kernel, so rename Makefile.6 to Makefile. Just add the following lines to the top of it:

ifndef PRJROOT
    $(error You must first source the BSP environment: "source neuros-env")
-include $(PRJROOT)/.config/bsp_config
include $(PRJROOT)/scripts/

Somewhat lower you can see:

make -C /lib/modules/$(shell uname -r)/build SUBDIRS=$(shell pwd) modules

Change this into:

make -C $(ROOTFS)/tmp/lib/modules/2.6.5-it0/build SUBDIRS=$(shell pwd) modules

This was the easy part. The arm-linux-gcc compiler has a default aligment of 4 bytes. This basically means that the following struct:

struct example{
 uint8_t type;
 uint8_t data;

Takes up not the expected 2 bytes of space but 4 bytes of space. Setting this aligment can be easily done with the #pragma directive, but the GNU C compiler only recognizes it but does not support it. So what we should do is use the packed attribute:

struct example{
 uint8_t type;
 uint8_t data;
} __attribute__((__packed__));

Now the struct uses 2 bytes also when compiled for the OSD. The problem is that the RT2570 driver uses structs for Hardware I/O. So when compiled with the arm-linux-compiler all these structs are changed in size and all communication with hardware becomes unstable. The driver starts complaining about failed sanity checks etc. So what we need to do now is rewrite all these structs in all the source files of the driver. Beware that the packed attribute cannot be used in combination with typedef:

typedef struct{
 uint8_t type;
} example;

Should be changed in something like:

struct _example{
 uint8_t type;
 uint8_t data;
} __attribute__((__packed__));
typedef _example example;

I used the following regular expression (credits goto Thomas) for the Ralink driver:


    \1\2\3 __attribute__((__packed__));^ptypedef struct \2 \4;^ptypedef struct \2 \*\6;^p

Then you still need to change some things by hand.

Wireless Tools

Next thing to do is getting the wireless tools to manipulate the device. Go here: and download the latest version. Compiling the tools is somewhat easier. Paste the following 5 lines to the top of the Makefile:

ifndef PRJROOT
    $(error You must first source the BSP environment: "source neuros-env")
-include $(PRJROOT)/.config/bsp_config
include $(PRJROOT)/scripts/

And add the following line somewhat lower:

CC = arm-linux-gcc

Now build and install it:

make all
make install

The ifrenamen, iwconfig, iwlist, iwevent, iwgetid, iwpriv and iwspy are placed in #BSP_ROOT#/rootfs/fs/sbin. This caused my root.cramfs file to become too large. So I removed all of them except iwlist and iwconfig.

Using the driver

After copying the rt2570.ko module to the modules/extra directory burn the kernel and cramfs to the device. Read the details about it here. Now boot up the device to run some basic tests. Load the module with insmod:

insmod /lib/modules/2.6.5-it0/extra/rt2570.ko

When you are using kernel 2.6.5-ito then you will also need to load the USB driver by hand:

insmod /lib/modules/2.6.5-it0/kernel/drivers/usb/host/dm320/hc_dm320.ko

Now you should see something like:

USB HC dev alloc 1408 bytes
Using /lib/modules/2.6.5-it0/extra/rt2570.ko
RTUSB  <7>enter rtusb init( )
idVendor = 0xb05, idProduct = 0x1706
RTUSB  <7>BulkOutMaxPacketSize  64
drivers/usb/core/usb.c: registered new driver rtusb

Now startup the wireless network:

ifconfig eth0 down #to be sure ethernet is disabled
iwconfig rausb0 essid YOURSSID
ifconfig rausb0 address up
route add default gw

Just wait a little while so the device can connect to the wireless network. You should see something like this:

RTUSB  <7><==SIOCSIWFREQ[cmd=0x8b04] (Channel=6)
RT25usb  Driver version 2.0.7
RTUSB  <7> !!!!!set Rx control = 1
RTUSB  <7>RTMPSetPhyMode(=0)
RTUSB  <7> !!!!!set Rx control = 7e

Use commands like 'iwconfig rausb0' and 'iwlist rausb0 scan' to see more details. I have already managed to setup a connection with a WEP encrypted network (not really recommended nowadays... :P):

iwconfig rausb0
         Mode:Managed  Frequency=24.37 MHz  Access Point: 00:12:17:60:72:B8
         Bit Rate=54 Mb/s
         RTS thr:off   Fragment thr:off
         Encryption key:ABCD-1234-56 [3]
         Link Quality=98/70  Signal level:-21 dBm  Noise level:-86 dBm
         Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
         Tx excessive retries:0  Invalid misc:0   Missed beacon:0

Wireless at startup

First we should make sure that both the USB Host driver and RT2570 driver are loaded at startup. So edit #BSP_root#/rootfs/fs/etc/init.d/rcS and search for the following:

   MODULES_USB_HOST="hc_dm320 scsi_mod sg sd_mod usb-storage"
   if [ "${LOAD_USB_HOST_MODULES}x" = "1x" ]
       for MODULE in ${MODULES_USB_HOST}
        if [ -e ${MODULE_DIR}/${MODULE}.ko ]
             ${MODPROBE} ${MODULE}

change this into:

   MODULES_USB_HOST="hc_dm320 scsi_mod sg sd_mod usb-storage rt2570"
   if [ "${LOAD_USB_HOST_MODULES}x" = "1x" ]
       for MODULE in ${MODULES_USB_HOST}
          ${MODPROBE} ${MODULE}

Now both drivers will be loaded on startup. Next thing to do is configuring the wireless device upon startup. So edit #BSP_root#/rootfs/fs/usr/local/rc.local and add the following lines at the end of the file but before /usr/local/bin/osdmain:

/sbin/iwconfig rausb0 channel 6 essid YOURSSID mode managed
/sbin/ifconfig rausb0 address up
/sbin/route add default gw

We also want to make sure eth0 doesn't hang upon DHCP request when there is no cable connected. So goto the U-Boot environment and be sure ip is set to something like:


and not:



Please post your problems on the google groups.

Personal tools