Home>Posts>Technology>Building the VT6656 Linux Driver for Ubuntu

Building the VT6656 Linux Driver for Ubuntu

By ·Categories: Technology·Published On: January 2nd, 2008·7.3 min read·

Please note: A new version of this driver is available that does not require patching. This driver is also GPL-licensed, making it suitable for eventual inclusion in the kernel. These instructions are now obsolete.  Download the updated driver source from Via Arena.

We’ve been carrying the VIA VNT6656G6A40 USB WiFi module for some time now. This is a nice, compact USB wireless module that is ideal for some applications due to the fact that it ships without the bulky plastic case and external USB connector that most consumer USB network devices do. Instead, you can simply wire it directly to an internal USB header and mount the circuit board wherever it fits inside the chassis.

The device is based on the VIA VT6656 802.11b/g chip. VIA has released several driver packages for this chip. If you run an ancient version of Fedora, you may be able to use one of the binary packages distributed with the Windows driver package; however, most users will instead need to compile the driver from source (and, in fact, you’ll also need to patch the source first).

That may sound intimidating to some users because many devices are supported by modern Linux distributions out-of-the-box. Sadly, VIA has chosen not to include a license with the VT6656 driver archive. Consequently, this device currently has no chance of being supported by popular Linux distributions due to the legal ambiguity surrounding the driver source code.

However, if you feel comfortable at the command-line prompt and are up for a little bit of work to get your device functioning, read on.

Fetching & Unpacking the Source

I’ll be building this driver on a machine running Ubuntu 7.04 (Feisty). First, create a temporary directory to work in and fetch the source archive from the VIA Arena distribution page:

$ mkdir vt6656
$ cd vt6656
$ wget 'http://www.viaarena.com/Driver/vt6656-linux-x86-src-v113.rar'

After you’ve downloaded the archive, unpack it:

$ unrar -y x vt6656-linux-x86-src-v113.rar
UNRAR 3.70 beta 3 freeware      Copyright (c) 1993-2007 Alexander Roshal

Extracting from vt6656-linux-x86-src-v113.rar

Creating    VT6656-Linux-x86-src-v113                                 OK
Extracting  VT6656-Linux-x86-src-v113/linux.txt                       OK
Extracting  VT6656-Linux-x86-src-v113/VT6656-Linux-x86-113-src-CPUPlatfrom.rar  OK
All OK
$ ls
VT6656-Linux-x86-src-v113  vt6656-linux-x86-src-v113.rar
$ cd VT6656-Linux-x86-src-v113

If you do not have the unrar program on your machine, install it:

$ sudo apt-get install unrar

This archive is a little unusual. The source files are inside another RAR archive, so we’ll need to unpack the inner archive as well:

$ ls
linux.txt  VT6656-Linux-x86-113-src-CPUPlatfrom.rar
$ unrar -y x VT6656-Linux-x86-113-src-CPUPlatfrom.rar
UNRAR 3.70 beta 3 freeware      Copyright (c) 1993-2007 Alexander Roshal
...
$ ls
driver   linux.txt  remove    utility                                   wpa_supplicant
include  Makefile   sta.wlan  VT6656-Linux-x86-113-src-CPUPlatfrom.rar

The included documentation file (linux.txt) appears to be grossly out of date, and is quite useless. Ignore it.

Preparing the System to Build Kernel Modules

Our next step is to build the driver. Like all kernel modules, you must have your kernel source (or a reasonable substitute, like the kernel headers package provided by Debian and Ubuntu) present on the machine in order to build. Many users will find that the Debian/Ubuntu-specific program module-assistant provides an easy way to prepare the machine for building kernel modules:

$ sudo apt-get install module-assistant
...
$ sudo module-assistant prepare
...

module-assistant installs the necessary linux-headers-* package, and creates a /usr/src/linux symlink to the correct directory. If you’d rather do this by hand, it’s easy enough:

$ sudo apt-get install linux-headers-$(uname -r)
$ ( cd /usr/src && sudo ln -s linux-headers-$(uname -r) linux )

Once that is done, you’re ready to build the driver.

Building

$ ls
driver   linux.txt  remove    utility                                   wpa_supplicant
include  Makefile   sta.wlan  VT6656-Linux-x86-113-src-CPUPlatfrom.rar
$ cd driver
$ make

After typing “make” and pressing enter, some text will scroll by on the screen. It may look like this:

make[1]: Entering directory `/usr/src/linux-headers-2.6.20-16-generic'
  CC [M]  /home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver/main_usb.o
  CC [M]  /home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver/card.o
...
  LD [M]  /home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver/vntwusb.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver/vntwusb.mod.o
  LD [M]  /home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver/vntwusb.ko
make[1]: Leaving directory `/usr/src/linux-headers-2.6.20-16-generic'

…but, then again, it may not. If you see text like that shown above, you’ve successfully compiled the driver. However, you may see some error messages instead. I’ve seen some of these:

Makefile:22: *** Linux kernel source not found.  Stop.

This means that the kernel source/headers are not installed and configured correctly.

make -C /lib/modules/2.6.20-16-generic/build SUBDIRS=/home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.20-16-generic'
  CC [M]  /home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver/main_usb.o
/home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver/main_usb.c: In function ‘vntwusb_found1’:
/home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver/main_usb.c:801: error: ‘struct net_device’ has no member named ‘get_wireless_stats’
make[2]: *** [/home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver/main_usb.o] Error 1
make[1]: *** [_module_/home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.20-16-generic'
make: *** [default] Error 2

The above error is a telling sign that the driver source is out of date with your kernel, a common problem for vendor-maintained source drivers. If your kernel is from the 2.6.20 series, you can use this trivial patch for the driver source. Apply it to your driver source thusly:

$ wget -O- '//www.onlogic.com/pub/vt6656-compile-with-2.6.20.patch' | patch -p2
--13:10:15--  //www.onlogic.com/pub/vt6656-compile-with-2.6.20.patch
           => `-'
Resolving www.onlogic.com... 72.3.249.30
Connecting to www.onlogic.com|72.3.249.30|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 565 [text/plain]

100%[========================================================================>] 565           --.--K/s

13:10:16 (313.72 KB/s) - `-' saved [565/565]
patching file main_usb.c

The patch introduces two new lines of code. I’m not much of a kernel hacker, so I can’t say with certainty that the fix is correct, but it did seem to work on the system I tested with.

Note that this fix is kernel-specific. I tested the same patch on an Ubuntu 7.10 (Gutsy) system (kernel version 2.6.22-14-generic), and the module failed to build. Time permitting, I’ll try to prepare a patch for this kernel version as well. The only permanent solution is for VIA to re-release the driver and include the missing license file, allowing distribution and kernel developers to maintain and ship the driver properly.

Testing & Installing

Linux kernel modules are binary files with a .ko extension. Once the driver has been built successfully, you can insert it with the insmod tool:

$ ls *.ko
vntwusb.ko
$ sudo insmod vntwusb.ko

However, you’ll probably want to install it so that it gets loaded at boot time:

$ sudo make install
make -C /lib/modules/2.6.20-16-generic/build SUBDIRS=/home/forest.bond/vt6656/VT6656-Linux-x86-src-v113/driver modules
make[1]: Entering directory `/usr/src/linux-headers-2.6.20-16-generic'
  Building modules, stage 2.
  MODPOST 1 modules
make[1]: Leaving directory `/usr/src/linux-headers-2.6.20-16-generic'
mkdir -p /lib/modules/2.6.20-16-generic/kernel/drivers/net
install -m 644 -o root vntwusb.ko /lib/modules/2.6.20-16-generic/kernel/drivers/net
/sbin/depmod -a || true

If you need to, you can un-install the driver like this:

$ sudo make uninstall
rm -f /lib/modules/2.6.20-16-generic/kernel/drivers/net/vntwusb.ko
/sbin/depmod -a

You may prefer to keep locally-built drivers like this one separate from those shipped with your distribution. If that is the case, you can do that like this:

$ sudo mkdir /lib/modules/$(uname -r)/kernel/local
$ sudo install -m 644 -o root vntwusb.ko /lib/modules/$(uname -r)/kernel/local
$ sudo depmod -a

Once the module has been installed, it can be loaded with modprobe (rather than using insmod):

$ sudo modprobe vntwusb

If the module is installed correctly, your system should automatically detect and load it at boot time. Once it has been loaded, you should be able to use the usual tools provided by the distribution to configure it (NetworkManager on Ubuntu).

Caveats & Conclusion

The VIA source package also includes a patched version of wpa-supplicant. I have not used this; I assume that the device driver does not behave like most other wireless drivers, making the patched version of wpa-supplicant necessary.

Compiling and using wpa-supplicant is not something I’ll cover here. Do be aware that WPA security may not be functional without this patched version.

I hope this post is helpful to folks trying to get this device working on their Linux machines.

Further Reading

LEARN MORE ABOUT
OS DEVELOPMENT

Share

About the Author: Forest Bond

Avatar
Forest had been the lead software developer at Logic Supply since April 2005 before starting his own software company, RapidRollout in 2009. He occasionally peeks back in with us from time to time, but dedicates his energy to developing open source software platforms. We maintain his posts here, but he no longer writes for our blog. To contact him, you can visit RapidRollout.
Follow OnLogic on LinkedIn

40 Comments

  1. Avatar
    Forest January 4, 2008 at 12:53 pm

    Just a reminder to anyone following these instructions:

    We’re only building in the “driver” subdirectory; be sure not to miss the “cd driver” command just before “make”, above.

  2. Avatar
    Forest January 7, 2008 at 2:41 pm

    I’ve heard complaints from some users that they are unable to successfully connect to a network using this driver, despite success scanning for local networks (using iwlist).

    I did successfully connect to an open 802.11b/g network, and was able to transfer data without problems, however, users should be aware that this driver may not necessarily be completely bug-free, and may have problems with certain network environments. In particular, radio interference and slightly odd network parameters may play a role in determining success.

  3. Avatar
    Joao January 16, 2008 at 9:18 pm

    I have tried to compile the driver for VT6655 in Feisty using the same technique described, but I’m not skilled enough to patch the source code and fix the errors.

    Can you help?

  4. Avatar
    Forest January 16, 2008 at 9:55 pm

    Hi Joao,

    What issues are you seeing?

  5. Avatar
    max January 27, 2008 at 5:56 pm

    Hi,

    any news about the gutsy patch?
    :)

  6. Avatar
    Forest January 28, 2008 at 6:05 pm

    Hi max,

    Sorry, I don’t have anything ready yet. We’ve been busy around here :)

    I’ll see what I can come up with a little later in the week.

  7. Avatar
    Forest February 4, 2008 at 4:20 pm

    The following patch does make the driver compile with the gutsy kernel (2.6.22-14-generic). I haven’t actually tested the functionality, though.

    http://www.logicsupply.com/pub/vt6656.gutsy.patch

  8. Avatar
    Joao February 5, 2008 at 4:56 pm

    I have dropped Feisty and installed Gutsy…

    These is what I get when trying to compile the VT6655 driver:

    make -C /lib/modules/2.6.22-14-generic/build SUBDIRS=/vt6655/VT6655-Linux-117-src-CPUPlatform-SAE/VT6655-Linux-117-src-CPUPlatform-SAE/viawget/driver modules
    make[1]: Entering directory `/usr/src/linux-headers-2.6.22-14-generic’
    […]

  9. Avatar
    Forest February 5, 2008 at 7:46 pm

    Hi Joao,

    I trimmed your post way down; I hope you don’t mind.

    It looks like this driver also has some API incompatibilities. That means that it needs to be patched to compile.

    I’ll try to get a patch put together at some point. Due to time limitations, however, this may not be possible until next week.

  10. Avatar
    Joao February 5, 2008 at 9:13 pm

    Hi

    Of course not.

    I would appreciate any help, thanks in advance!

  11. Avatar
    Chris March 3, 2008 at 6:33 pm

    I have patched the VT6655 driver for use on ubuntu 7.10 (kernel 2.6.22 [and up?])

    Forest, please email me for the patch, clean/fix it up, and post it here!

  12. […] process to the one described previously for the VT6656. You should follow the instructions from my previous post, but use the following commands to fetch, unpack, patch, and build the driver […]

  13. Avatar
    Riadh March 17, 2008 at 10:05 am

    when i execute the command #insmod vntwusb.ko
    i get the following:
    “vntwusb: version magic ‘2.6.16.29-xen SMP 686 REGPARAM gcc-4.0’ should be ‘2.6.16.29-xen SMP 686 REGPARAM gcc-3.4’ ‘”

    i d’ont know what to do.. please help

  14. Avatar
    Forest March 17, 2008 at 2:44 pm

    Hi Riadh,

    Which distribution are you on? The kernel you are running is not a standard kernel for either Ubuntu 7.04 or Ubuntu 7.10. Perhaps you compiled it yourself?

    The problem that you are seeing is that the default gcc version on your system (the one that is being used to compile the driver) is not the same version that was used to compile the kernel. Kernel modules must be compiled with the same gcc version that was used to compile the kernel itself.

    You may have luck by editing the Makefile and changing this:

    ifneq (,$(findstring egcs-2.91.66, $(shell cat /proc/version)))
    CC := kgcc gcc cc
    else
    CC := gcc cc
    endif

    test_cc = $(shell which $(cc) > /dev/null 2>&1 && echo $(cc))
    CC := $(foreach cc, $(CC), $(test_cc))
    CC := $(firstword $(CC))

    To this:

    CC = gcc-4.0

    Be sure that you have gcc-4.0 installed (apt-get install gcc-4.0).

    Hope this helps.

    -Forest

  15. Avatar
    Mirko G. May 14, 2008 at 6:16 am

    Hi to all,
    I have problems with this driver because my pc seems not to be able to get a IP address from wifi router even if it has DHCP on…