Thursday, January 4, 2007

Setup Netgear MA111 Wireless USB for Linux

Background
Someone happened to pass me an USB WIFI adapter sometime ago. The item was left idle on my desk for a while until recently I give a try on my new 2.4.33 kernel. Inside Netgear MA111 is a Prism chipset. There is an open source driver for this chipset from www.linux-wlan.com.


Getting Started
I took the following steps to complete the installation:

1. Download the source linux-wlan-ng-0.2.5.tar.gz to /usr/local/src
2. cd /usr/local/src; tar xvzf linux-wlan-ng-0.2.5.tar.gz
3. To make the module run "make config"
This will ask you one by one which module to compile:
-------------- Linux WLAN Configuration Script -------------

The default responses are correct for most users.

Build Prism2.x PCMCIA Card Services (_cs) driver? (y/n) [n]:
Build Prism2 PLX9052 based PCI (_plx) adapter driver? (y/n) [n]:
Build Prism2.5 native PCI (_pci) driver? (y/n) [y]:
Build Prism2.5 USB (_usb) driver? (y/n) [y]:
...

4. make all; make install - The driver and configuration programs are copied to the rightful place in your OS directory.


Create the Installer
1. Below is a shell script I create to make the installer to distribute to other system:
tar cvzf linux-wlan-ng-0.2.5.i386.tgz \
/etc/wlan \
/sbin/wlanctl-ng \
/sbin/nwepgen \
/sbin/wlancfg \
/sbin/prism2dl \
/lib/modules/2.4.33.4/linux-wlan-ng

2. If you want to create a kernel with WLAN installer, here the script:
tar czf kernel24-wlan-ng-i386.tgz \
/lib/modules/2.4.33.4 /boot/System.map-2.4.33.4 /boot/vmlinuz-2.4.33.4 \
/usr/src/redhat/RPMS/i386/modutils-* \
/etc/wlan \
/sbin/wlanctl-ng \
/sbin/nwepgen \
/sbin/wlancfg \
/sbin/prism2dl \
/lib/modules/2.4.33.4/linux-wlan-ng


Configuration
After you have install the new driver, you need to load it. According to the README found in linux-wlan-ng-0.2.5.tar.gz, the simplest way to do this is to add the following commands to your rc.local file:

modprobe prism2_pci [or prism2_usb/prism2_plx]
wlanctl-ng wlan0 lnxreq_ifstate ifstate=enable
wlanctl-ng wlan0 lnxreq_autojoin ssid=linksys authtype=opensystem
ifconfig wlan0 netmask broadcast
route add default wlan0

The ssid can be empty if you do not have any, e.g.
wlanctl-ng wlan0 lnxreq_autojoin ssid= authtype=opensystem

Also add "alias wlan0 prism2_usb" for wlan0 to /etc/modules.conf.


Start up Automatically
I have tried this method and it works fine. But a better method is to load the driver using rc script. linux-wlan-ng-0.2.5.tar.gz comes with a rc script (linux-wlan-ng-0.2.5/etc/rc.wlan). You can copy and rename this file to /etc/rc.d/init.d/wlan. A minor modification to the content of the file is needed; edit /etc/rc.d/init.d/wlan on a) line 3 - change rc.wlan to wlan, b) line 5 - remove a hidden space at the end of chkconfig line. Save the file then run "chkconfig --add wlan; chkconfig wlan on" to enable it.

To test it run "service wlan start". However I realized that running it on the command line is OK, but when I restart the machine, the driver wasn't loaded automatically, after some debugging, I noted the problem was due to the standard USB core need more time to start up before loading prism driver. The workaround is insert "sleep 5" into /etc/rc.d/init.d/wlan at line 40.


Join a Wireless Network
When the drive is loading, it will attempt to associate with any access point within range. However, it is highly recommended to set up a configuration specifically for your network, using the following method:

This example assumes your network name/SSID is "linksys"
1. cp /etc/wlan/wlancfg-DEFAULT /etc/wlan/wlancfg-linksys
2. edit /etc/wlan/wlan.conf and change the SSID_wlan0 line to SSID_wlan0="linksys"
3. edit /etc/wlan/wlancfg-linksys, and make any necessary changes necessary to support your network, such as WEP and whatnot.

Again, if you do not use SSID just leave
SSID_wlan0 blank.


Unresolved Problem
There is a problem I encounter which I have yet to find an answer, I hope you (reader of the article) can help me to get a solution. When I reboot the machine somehow the rc script is not executed by OS during unloading process; because of that the machine will hang on BIOS state. I believe it is caused by the USB adapter not properly shutdown (the LED light is still on).


References
1.
linux-wlan-ng-0.2.5/REAME
2. Netgear MA111 USB Wireless Howto
3. Jacek Pliszka's wireless hints: 802.11b / Wi-Fi Linux USB
4. Wireless LAN resources for Linux
5. HOWTO Prism2 USB on Gentoo
6. Linux and Wireless LANs
7. Linux and WireLess Mobile AdHoc Networks - MANETs
8. Linux and Wireless LAN Access Points (Routers) - WLAN APs
9. Wireless LAN Sniffer Applications for Linux
10. Adding an External WireLess Antenna to a Laptop or Notebook
11. Adding a WireLess miniPCI Card to a Laptop or NoteBook
12. Prism II Access Point Mini-Howto
13. A Linux Wireless Access Point HOWTO
14. Installing and Configuring HostAP
15. Inside a Linksys Wap11
16. Atmel Wireless LAN Driver for Linux
17. The Linux ORiNOCO Driver
18. Prism2 USB 802.11b devices under Linux
19. Getwifi
20. Wireless Networking in the Developing World



This article is copyrighted by Victor Wu