Wednesday, January 16, 2013

DWL-G122 Rev. A2 Wireless Adapter on Linux

Finding working drivers for D-Link DWL-G122 Rev. A2 USB Wireless Adapter to use in Linux Mint 14 (32-bit) based on Ubuntu 12.10.

The adapter is only compatible with WPA and WEP security modes; not compatible with WPA2.  PSK can be used.  This adapter could not connect to a router running in 802.11g/n mixed mode; but does associate with a router set in 802.11g mode.

On Mint/Ubuntu, attempts to use the native p54usb kernel module, and the necessary isl3887usb firmware placed in the correct /lib/firmware path resulted in dmesg log lines "authentication with AA:BB:CC:DD:EE:FF timed out" despite success registering drivers to the interface.  See firmware installation instructions at There appears to be a newer version of the isl3887usb firmware available here,, which I did not try

I had success using the old method I had running on an earlier edition of Ubuntu. Ie. load ndiswrapper

Use ndiswrapper kernel module and install Windows drivers from D-Link website.  However, D-Link Support website does not list Rev. A2 (as of 2013-01) but the correct driver is available on their FTP server at:

Encountered "FATAL: Module ndiswrapper not found." when trying to sudo modprobe ndiswrapper or when trying to install Windows drivers for the adapter via ndisgtk.  Downloading and installing ndiswrapper-dkms_1.58~rc1-0ubuntu1_all.deb worked. Older version ndiswrapper-dkms_1.57-1ubuntu1_all.deb did not.  Follow procedures at

Probably want to blacklist p54usb if you want to get ndiswrapper to work.

Monday, January 14, 2013

Yet another blog post about tethering your Android-powered phone to a router via USB.

This post summarizes my experience with flashing my router's stock firmware to an opensource firmware to enable it to use the USB port as the WAN connection. The Internet (WAN) connection is provided by an Android-powered smartphone via USB tethering.

Specifically, I have a D-Link DIR-825 Wireless N router. HW Rev. B1. It has one USB port. The phone is a Samsung Galaxy S 4G (SGH-T959W); it is not the same as a Samsung Galaxy Vibrant. My cellular provider is Mobilicity and my phone number is.... j/k. I'm not releasing that. 

So I first tried flashing the DD-WRT firmware to my DIR-825. This is a very nice firmware: nice GUI and excellent features, most of which I don't know how to use. It can bridge the various interfaces such as WiFi to the LAN, it can act in a Wireless Distribution System, it has various hotspots for potential revenue-generation using landing pages to share Internet, it has awesome graphs for monitoring bandwidth and usage, and it has support for various USB devices from printers, to storage, to 3G USB modems.

And that's where I got stuck.  I had DD-WRT v24-sp2 (03/19/12) std r18777 installed on the router. I enabled Core USB Support under the Services menu along with USB Storage Support. Set the WAN Connection Type to "3G/UMTS/4G/LTE" and input the APN settings for Mobilicity. Then I plugged in the Galaxy S 4G into the USB port, via a USB cable of course, and enabled USB tethering on the phone which is running Gingerbread 2.3.6.

This did not work; router clients did not have Internet connectivity. I SSH'd into the router and ran cat /proc/bus/usb/devices
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 3 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=02(comm.) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=04e8 ProdID=6881 Rev= 4.00
S: Manufacturer=SAMSUNG
S: Product=SAMSUNG_Android
S: SerialNumber=T959f1f202cd
C:* #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr= 96mA
A: FirstIf#= 0 IfCount= 2 Cls=02(comm.) Sub=06 Prot=00
I:* If#= 0 Alt= 0 #EPs= 1 Cls=02(comm.) Sub=02 Prot=ff Driver=(none)
E: Ad=86(I) Atr=03(Int.) MxPS= 8 Ivl=32ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=(none)
E: Ad=8b(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=0a(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
As you can see, no drivers were attached to the device; whereas before enabling tethering on the phone, the Interface line said I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage indicating the usb-storage driver was bound.

From looking through the DD-WRT wiki at I didn't find any Samsung devices supported. I had hoped that DD-WRT would support this phone as there were a few Android smartphones listed in addition to all the USB rocket sticks. But alas, there seems to be no compatibility with the Galaxy S 4G.

Because I don't give up easily and knew that the desired result is feasible, I looked for more solutions. First, I tested USB tethering this phone to a Linux LiveCD (Linux Mint 14) and looked at the modules it enabled. Running lsmod from a terminal window listed rndis_host and cdc_ether, which I had read about somewhere before. A quick search in Google and I found a number of webpages/blog posts referencing these modules and a forum post on OpenWRT's forum.

They are:
Starting with OpenWRT Backfire 10.03.1 final flashed to the D-Link DIR-825 and following the instructions in the forum post linked above, I had everything required. However, once I connected the Galaxy S 4G to the router and enabled USB tethering in Android, I still didn't have Internet connectivity.

From SSH on the router, I ran dmesg | grep usb and got this
usb 1-1: new high speed USB device using ar71xx-ehci and address 1
usb 1-1: configuration #1 chosen from 1 choice
usb 1-1: USB disconnect, address 1
usb 1-1: new high speed USB device using ar71xx-ehci and address 2
usb 1-1: configuration #1 chosen from 1 choice
usb 1-1: bad CDC descriptors

instead of
usb 1-1: new high speed USB device using ar71xx-ehci and address 2
usb 1-1: configuration #1 chosen from 1 choice
usb0: register 'rndis_host' at usb-ar71xx-ehci-1, RNDIS device, aa:cc:b6:36:b3:97

Additionally, cat /proc/bus/usb/devices was similar to the above result where "Driver=(none)"

So I decided to test my other Android phone, a Motorola RAZR HD running ICS 4.0.4. This phone produced the desired result with rndis_host being bound to the device as a driver. But I had no intentions of tethering the Motorola on a limited data plan to the router.

Finally, after downloading and installing the newest version of OpenWRT, Attitude Adjustment 12.09-rc1, and the new versions of the packages as listed in the above linked articles, from:
I plugged in the Samsung Galaxy S 4G to the router and everything worked!  Next step is to flash the ROM on the Galaxy S 4G to ICS or JB and see if it still functions.

Recommended: If you have software on your NAT'ed internal computers that use UPnP to automatically configure the router to for example, expose a port and redirect external traffic to that internal device, then you should install the miniupnpd package as well.  The version available at the time I setup Attitude Adjustment 12.09-rc1 and seems to work with it is 1.6.20110730-6.  Specifically for DIR-825, the package is here. Although there might be newer versions that are also compatible.

This discussion explains why someone may want to install the UPnP package instead of setting up portforwarding redirects (and related rules) in /etc/firewall.user. This wiki page explains setting up Universal Plug'n'Play and NAT-PMP on OpenWrt and the instructions for installing the package is the same as the 3rd link in the first list above.

Possible explanation for why the newer version of OpenWRT works while the older version, 10.03.1, does not?
Thread about potential solution using similar modules in DD-WRT to achieve the same goal: