K8055/K8061 Driver inside the Linux Kernel Tree

This is a note to let you know that I’ve just added a driver for the Velleman K8055/K8061 USB board to the linux kernel.

The code interacts with the USB subsystem of the kernel and the COMEDI (comedi.org/).
The driver can manage all features what the boards has to offer + support up to 48! boards.

At this time you will need to patch the latest (next-)kernel to get the driver to build properly.
For a HOWTO take a look at kernel.org/pub/linux/kernel/ … hes/README

Path and name of the driver module:
linux/drivers/staging/comedi/drivers/vmk80xx.c

In the future you will only need a linux kernel to control your board…no internet conn. required to get a driver or lib :wink:

It would be nice if you could post your experiences with this driver or send me an email.

thanks,

Manuel Gebele

Nice work, i’m sure this will be very useful to fellow linux users

One small question, where does the 48 board restriction come from? Mind that my understanding of linux driver development is rather basic, it’s been a while since I’ve even read about it + all the kernel differences :slight_smile:

#define VMK8055_MAX_BOARDS 16
static struct vmk80xx_usb vm_boards[VMK8055_MAX_BOARDS];

Leads me to think that the limit is 16 board instances. Of course 48 is 3x16 so maybe there’s something i’m missing…

Very interesting stuff

Thanks :stuck_out_tongue:

#define VMK8055_MAX_BOARDS 16 static struct vmk80xx_usb vm_boards[VMK8055_MAX_BOARDS];
This piece of code stems by the first patch file. At this time the driver had support up to 16 boards.

The newest patch (staging-comedi-vmk80xx-add-k8061-support.patch) contains an update:

#define VMK80XX_MAX_BOARDS COMEDI_NUM_BOARD_MINORS static struct vmk80xx_usb vmb[VMK80XX_MAX_BOARDS];
NOTE: COMEDI_NUM_BOARD_MINORS = 0x30 = 48

Here is a link to the complete (including all patches) drivers source code:
file-upload.net/download-166 … 0xx.c.html

Hope this helps.

P.S.
You will find all patches in the gregkh’s staging tree kernel.org/pub/linux/kernel/ … 5-staging/
There are three patches:
staging-comedi-add-vmk80xx-usb-driver.patch
staging-comedi-vmk80xx.c-get-the-driver-to-build-properly.patch
staging-comedi-vmk80xx-add-k8061-support.patch

thanks,
Manu

Hello,

Could this be working for the K8047 (on Linux)?

Regards,
Kriss

Sorry for the delay, I was on vacation.

No, this driver only supports the K8055/VM-110 and the K8061/VM-140 board.
But sure one day…

thanks,
Manu

This topic needs an update.

The above links to the patch files are out of date.

Now the driver is available in the newest testing kernel.
For HTTP: kernel.org/pub/linux/kernel/v2.6/testing/
For FTP: ftp://ftp.kernel.org/pub/linux/kernel/v2.6/testing/

Look for the linux-2.6.31-rc1.tar.bz2 respective linux-2.6.31-rc1.tar.gz file.

thanks,
Manu

Hi folks,

This should be the last update for that topic. Finally the driver was included to the newest stable kernel (2.6.31.5).
lxr.free-electrons.com/source/dr … xx.c?a=arm

BTW, maybe someone should add an info to the ordering page -similar to the k8055 library.

Thanks,
Manuel Gebele

Nice work, a link to your driver will be added today to the K8055 product page!

Hi Manuel

Good work, I bought a VM110 from Maplin’s a couple of days ago and I already have flashing LEDs!

It works almost out of the box with Ubuntu 9.10 (Karmic); the kernel comes with the staging drivers built, and libcomedi-dev is in the repositories. However, I didn’t get a /dev/comedi0, and it seems that the usbhid module is claiming the device. I have the following couple of workarounds in place:

$ cat /etc/modprobe.d/comedi.conf 
options comedi comedi_autoconfig=0 comedi_num_legacy_minors=1

And a setup script which I run before starting work. I’ve hardcoded the USB device ID here; I’m sure there must be a better way to extract the right one from /sys but haven’t got around to it yet:

$ cat vm110_setup
#!/bin/bash

if [ `id -u` -gt 0 ]
then
	echo "Must be root"
	exit 1
fi

modprobe -r vmk80xx
modprobe -r comedi

usbid="4-1:1.0"
echo "$usbid" > /sys/bus/usb/drivers/usbhid/unbind

modprobe comedi
modprobe vmk80xx
comedi_config /dev/comedi0 vmk80xx

If there’s an easier workaround then I’d be happy to hear about it!

cheers
Chris

Hi Chris and sorry for the delay!

Comedi does not create a corresponding device file under ‘/dev’ (/dev/comedi0) per default.
So, you need to do that. Either, as you writes, with a config file to load comedi at startup
or you call:

modprobe comedi comedi_num_legacy_minors=1

While working with Comedi I don’t have any problems in combination with usbhid. In case of
need you could put an entry to ‘/etc/modprobe.d/blacklist’ to disallow modprob’ing usbhid.

Greetz
-M-G-

Thanks, I did try that, but unfortunately I have a USB keyboard which needs it!

cheers
Chris

If you need usbhid for your keyboard, then you should try to tell
the usbhid module that there is no need for its use only in case
of vmk80xx.

Keywords:
usb quirks; udev

Take a look at ubuntuforums.org/showthread.php?t=1175001
If it does still not work, then you should insist on your solution.

BTW,
there is no need for ‘comedi_autoconfig=0’ since comedi sets this
global variable automatically to zero.

-M-G-

This looks cool… I’ve got the board plugged in, the module loaded and I have a /dev/comedi0.

Now how do I use the thing? :smiley:

Can you point me to any sample code, please? I’ve tried searching for the last couple of days but I guess this is all too new.

Much appreciated, many thanks…!

Hi and welcome to the forum.

There is more than one way to use the thing :wink:

As you maybe already know, vmk80xx based on Comedi,
or interacts with Comedi, respectively. Comedi itself
provides a library (Comedilib) which allows you to do
some useful with the corresponding data acquisition card.
For instance, read from or write to an analog channel,
counter or something else.

Comedilib is implemented in C, so you need to be familiar
with the C programming language. Take a look at
comedi.org/doc/index.html to get an overview
about the application development with Comedilib.

BTW,
some time ago I started to code a OO Perl module for
Comedilib. If you familiar with Perl I am sure the following
will help you:
search.cpan.org/~gebele/Comedi-Lib-0.24/Lib.pm

Thanks and good luck,
Manuel Gebele

Thanks for the response MG.
I did actually start looking down the lines you suggest, but, given the example program…

[code]#include <stdio.h> /* for printf() */
#include <comedilib.h>

int subdev = 0; /* change this to your input subdevice /
int chan = 0; /
change this to your channel /
int range = 0; /
more on this later /
int aref = AREF_GROUND; /
more on this later */

int main(int argc,char *argv[])
{
comedi_t *it;
lsampl_t data;

it=comedi_open("/dev/comedi0");

comedi_data_read(it,subdev,chan,range,aref, & data);

printf("%d\n",data);

return 0;
}[/code]
I realised I didn’t know what channels, for example, map to which inputs and outputs on the K8055 board (I assume that’s how it works but haven’t had a great deal of time to devote to it, which is why I was hoping there was some simple example code kicking around :wink: I’ll keep reading the comedi docs!

Many thanks!

Yes, I think this would be a good starting point.
Note that Comedilib has also a demo directory
which contains many useful examples.

Thanks,
-M-G-

Hi

I am trying to enable a Velleman Card k8055 with Comedi , with a bash
script but it sends me

root@virk-desktop:/home/virk# ./k8055_setup.sh
Configure failed!: No such device
Check kernel log for more information
Possible reasons for failure:
Unknown

This is the script (k8055_setup.sh)

Someone can help me?
Thanks

[code]#!/bin/bash

if [ id -u -gt 0 ]
then
echo “Must be root”
exit 1
fi

modprobe -r vmk80xx
modprobe -r comedi

modprobe comedi
modprobe vmk80xx
comedi_config /dev/comedi0 vmk80xx [/code]

Hi,

have you read the post from mallux on page 1 of this topic? He used
a setup script similar to yours, but it also prevents that the ‘usbhid’
module claims the device.

#!/bin/bash

if [ `id -u` -gt 0 ]
then
   echo "Must be root"
   exit 1
fi

modprobe -r vmk80xx
modprobe -r comedi

usbid="4-1:1.0"
echo "$usbid" > /sys/bus/usb/drivers/usbhid/unbind

modprobe comedi
modprobe vmk80xx
comedi_config /dev/comedi0 vmk80xx

Note that the device ID is hardcoded, so you need to
determine your devid.

Thanks,
-M-G-

How come the driver for the k8055 is still not in the kernel 2.6.34-gentoo-r1 ??
What exact kernel to use ?
There is no ebuild for compiling the comedi and k8055 drivers ?

With this driver, will it be detected by labview for linux ?
Without this driver and using libk8055, will it be usable with labview for linux ?

Is there any .vi to use with k8055 and labview 8.5 for linux ?

Thank you