D-Link DWL-122 Wireless USB Adapter GNU/Linux HOWTO      2003.12.22 @ 8:48:47 PM
I've got a D-Link DWL122 Wireless USB Adapter this weekend for $29.99. Not only the price was good, but it also stated "Mac OSX supported", which sort of encouraged me to go ahead and give it a try.

I asked Mr. Goggle, who told me right away it uses a Prism2 chipset, and that it is supported by linux-wlan-ng version 0.2.1-pre13 or later, thanks to a patch written by Andrew Beresford.

(Gentoo users use "emerge". More info at the end of this document)

Installation was long but smooth. It requires kernel sources and a locally compiled kernel, as any precompiled kernel with sources will cause dependency errors when executing depmod:
/sbin/depmod -a
depmod: *** Unresolved symbols in /lib/modules/2.4.20/net/p80211.o
depmod: *** Unresolved symbols in /lib/modules/2.4.20/usb/prism2_usb.o

I realized it would be rather hard for an inexperienced user to get this device to work. That is the reason why I wanted to write something about it. So here is a quick HOWTO:

- First become root and cd into your src directory:
su -
cd /usr/src

- Get the latest kernel source from www.kernel.org. I used 2.4.23 when I wrote this article, but it also works on 2.6
wget ftp://ftp.kernel.org/pub/linux/kernel/v2.4/linux-2.4.23.tar.bz2

- Uncompress your kernel and make a symlink so that it can be accessible as /usr/src/linux
tar -jxf linux-2.4.23.tar.bz2
rm linux
ln -s linux-2.4.23 linux

- cd into your new kernel and compile it:
make menuconfig (spend a few minutes here configuring your kernel properly, one of the pleasures of opensource)
make dep
make bzImage
make modules
make modules_install
make install
cp arch/i386/boot/bzImage /boot/vmlinuz-2.4.23
cp System.map /boot/System.map-2.4.23

Note for kernel 2.6 users: Install the module-init-tools package, enable on your kernel Device Drivers -> Networking support -> Wireless LAN (non-hamradio) -> [*] Wireless LAN drivers (non-hamradio) & Wireless Extensions.
And compile your kernel with "make && make modules && make modules_install" instead

- Create the right entries in your bootloader. This instructions will depend on the bootloader and distro you are using. In my case it is GRUB running on Debian, therefore the configuration file is located at /boot/grub/menu.lst. It would be /boot/grub/grub.conf in RedHat and /etc/lilo.conf for LILO users. All you have to do in all cases is create a new section as follows (for lilo users, it is slightly different):
title Linux kernel 2.4.23
root (hd0,0)
kernel /boot/vmlinuz-2.4.23 root=/dev/hda2

(make sure you set the right root parameters, check your existing menu options for clues. Lilo users must now execute lilo)

- Reboot your machine choosing the new kernel and log in as root again.

- Get the latest linux-wlan-ng drivers (0.2.1-pre16 in this case), uncompress and configure as follows:
wget ftp://ftp.linux-wlan.org/pub/linux-wlan-ng/linux-wlan-ng-0.2.1-pre16.tar.gz
tar -zxf linux-wlan-ng-0.2.1-pre16.tar.gz
cd linux-wlan-ng-0.2.1-pre16
-------------- Linux WLAN Configuration Script -------------
The default responses are correct for most users.
Build Prism2.x PCMCIA Card Services (_cs) driver? (y/n) [y]: n
Build Prism2 PLX9052 based PCI (_plx) adapter driver? (y/n) [n]: n
Build Prism2.5 native PCI (_pci) driver? (y/n) [n]: n
Build Prism2.5 USB (_usb) driver? (y/n) [n]: y
Linux source directory [/usr/src/linux]:
The kernel source tree is version 2.4.23.
Alternate target install root directory on host []:
Module install directory [/lib/modules/2.4.23]:
It looks like you have a System V init file setup.
Prefix for build host compiler? (rarely needed) []:
Build for debugging (see doc/config.debug) (y/n) [n]:
Configuration successful.

- Compile and install with:
make all
make install

- That's all. Now you can tail /var/log/messages -f and plug in your Wifi usb adapter. You will see something like this:
Dec 22 19:40:01 laptop kernel: hub.c: new USB device 00:07.2-2, assigned address 2
Dec 22 19:40:01 laptop kernel: usb.c: USB device 2 (vend/prod 0x2001/0x3700) is not claimed by any active driver.
Dec 22 19:40:04 laptop /etc/hotplug/usb.agent: Setup prism2_usb for USB product 2001/3700/132
Dec 22 19:40:05 laptop /etc/hotplug/wlan.agent: WLAN startup on null (null)
Dec 22 19:40:05 laptop kernel: prism2_init: prism2_usb.o: 0.2.1-pre16 Loaded
Dec 22 19:40:05 laptop kernel: prism2_init: dev_info is: prism2_usb
Dec 22 19:40:05 laptop kernel: usb.c: registered new driver prism2_usb
Dec 22 19:40:05 laptop /etc/hotplug/wlan.agent: WLAN p80211 starting!
Dec 22 19:40:05 laptop /etc/hotplug/wlan.agent: WLAN register on wlan0 (prism2_usb)
Dec 22 19:40:05 laptop /etc/hotplug/wlan.agent: WLAN wlan0 registered.
Dec 22 19:40:05 laptop /etc/hotplug/net.agent: invoke ifup wlan0
Dec 22 19:40:05 laptop wland[1071]: wland daemon init successful
Dec 22 19:40:05 laptop wland[1071]: netlink socket opened and bound successfully
Dec 22 19:40:05 laptop /etc/hotplug/wlan.agent: /sbin/prism2dl not found, aborting firmware download.
Dec 22 19:40:06 laptop kernel: ident: nic h/w: id=0x8026 1.0.0
Dec 22 19:40:06 laptop kernel: ident: pri f/w: id=0x15 1.1.3
Dec 22 19:40:06 laptop kernel: ident: sta f/w: id=0x1f 1.7.1
Dec 22 19:40:06 laptop kernel: MFI:SUP:role=0x00:id=0x01:var=0x01:b/t=1/1
Dec 22 19:40:06 laptop kernel: CFI:SUP:role=0x00:id=0x02:var=0x02:b/t=1/1
Dec 22 19:40:06 laptop kernel: PRI:SUP:role=0x00:id=0x03:var=0x01:b/t=1/4
Dec 22 19:40:06 laptop kernel: STA:SUP:role=0x00:id=0x04:var=0x01:b/t=1/12
Dec 22 19:40:06 laptop kernel: PRI-CFI:ACT:role=0x01:id=0x02:var=0x02:b/t=1/1
Dec 22 19:40:06 laptop kernel: STA-CFI:ACT:role=0x01:id=0x02:var=0x02:b/t=1/1
Dec 22 19:40:06 laptop kernel: STA-MFI:ACT:role=0x01:id=0x01:var=0x01:b/t=1/1
Dec 22 19:40:06 laptop kernel: Prism2 card SN: 000000000000
Dec 22 19:40:11 laptop /etc/hotplug/wlan.agent: WLAN wlan0 brought up successfully.
Dec 22 19:40:11 laptop /etc/hotplug/wlan.agent: WLAN bringing up layer 3+ with /sbin/ifup
Dec 22 19:40:11 laptop kernel: linkstatus=CONNECTED

- Now you need to configure your network accordingly with your access point. Edit /etc/wlan/wlan.conf and set your SSID as follows:

- This means you will need a /etc/wlan/wlancfg-mywlan file. You can use the included wlancfg-DEFAULT for reference. You might want to try first with the default configuration, disabling WEP on your access point, but do not forget to enable it once you know it works:
cp /etc/wlan/wlancfg-DEFAULT /etc/wlan/wlancfg-mywlan

Note: When enabling WEP make sure there are NO spaces/tabs after "=" in the line dot11WEPDefaultKey0=00:01.... otherwise it WILL NOT WORK !!!. I have submitted this info, and hopefully will be corrected in future versions.

- Configure now your IP:
ifconfig wlan0 netmask
route add -net default gw

Note: This IP configuration will work with most default configurations. Make sure you set the right local (wlan0) and gateway (gw) ip addresses. You may even have DHCP enabled on your access point, in that case you can obtain your ip automatically with dhclient

Note2: I have just installed Gentoo on my laptop and emerge takes care of evrything. All you have to do is:
USE="usb -pci" emerge linux-wlan-ng

(make sure first that emerge -s linux-wlan-ng shows version 0.2.1-pre13 or later)

Note3: Make sure CONFIG_PACKET and CONFIG_FILTER are enabled in your kernel if you expect DHCP to work.

Update: For notes on a 64-bit 2.6 kernel, check out this article:

That should get you going. Enjoy

All knowledge and software published in this website is released under the GNU General Public License (GPL)