Jump to content

As of July 17, 2015, the LabJack forums here at forums.labjack.com are shut down. New registrations, topics, and replies are disabled. All forums are in a read-only state for archive purposes.

Please visit our current forums at labjack.com/forums to view and make new posts. To post on the current forums, use your labjack.com login account. Your old LabJack forums login credentials have been retired. There are no longer separate logins for labjack.com and LabJack forums.


Photo

Blacklisting LabJack within kernel no longer required?


  • Please log in to reply
3 replies to this topic

#1 NewbieLabJack

NewbieLabJack
  • Members
  • 8 posts

Posted 30 June 2006 - 12:25 PM

This may already be known to you all, maybe not. Regardless I shall describe what I recently discovered, as much as a documentation resource for me as well as help to you guys.

I have managed to get the Labjack installed together with the usbhid module loaded without having to recompile the kernel. From what I can ascertain this is most likely a result of improvents within the kernel itself.

This is really useful because whenever a kernel patch is applied by your distros update software I believe it is necessary to recompile the kernel, to reinstate the LabJack into the usb blacklist. Since updates can come at least once every 3 months this can be a real pain.

Anyway, a couple of steps need to be performed within the boot sequence which can be achieved by editing one file. The way I accomplished it is as follows...

I am running a fully up to date version of SUSE 10.0

My current kernel is
fqzps0j-04y212:~> uname -r
2.6.13-15.10-default

Make sure you have compiled the driver as per the standard instructions and test it works, by removing the usbhid driver if necessary. I guess 'modprobe -r usbhid' or 'rmmod usbhid' (as root) does the trick for that.

The usbhid module needs to be unloaded at boot, the labjack.ko module then needs to be loaded and then the usbhid module is reinstated. An editable boot script exists within SUSE called /etc/init.d/boot.local. The location and/or name of this file can vary between distributions so it's best to check your distro FAQs for this, I believe a common name on other distros is rc.local but this could be completely wrong ;)

This code is at the end of my /etc/init.d/boot.local file...

# Setup the labjack driver. The usbhid needs to be removed before it's
# loaded. This is reinstated immediately afterwards. It is done this
# way to prevent the labjack driver being hijacked by the usbhid driver
mkdir /dev/usb
mknod --mode=a=rw /dev/usb/labjack0 c 180 240
sleep 1
modprobe -r usbhid
sleep 1
insmod /usr/local/linux-labjack/driver/linux-2.6/labjack.ko
sleep 1
insmod /lib/modules/2.6.13-15.10-default/kernel/drivers/usb/input/usbhid.ko


The mkdir and mknod commands are necessary for me because SUSE simply doesn't remember the creation of the directory and node after a reboot for some reason. If anyone has suggestions on why this is then I'm all ears.

Obviously you will probably have to change the path to the labjack.ko to match your install path for the LabJack driver. Same goes for usbhid.ko since your kernel version is unlikely to be exactly the same as mine.

You may have to change the sleep values to a larger number. If the usbhid module is reloaded before the labjack module then the labjack will remain hijacked by the usbhid driver. As a general guide, the slower your machine the bigger the sleep number. As a reference my CPU is a P4-M running at 1.4Ghz and I have never had any problems with the value 1, however without the sleep commands I always get problems!

It shouldn't matter if you have the LabJack plugged in before you boot up or after the machine has fully booted, the LabJack should work fine.

After you have changed your file, reboot your machine and check if your LabJack is running as expected. Obviously if you have previously blacklisted the LabJack then the test is of no use :)

OK, the proof for any doubters out there...

(as root) fqzps0j-04y212:/ # lsmod | grep labjack
labjack 16656 0
usbcore 112512 9 slusb,usbhid,labjack,usb_storage,dvb_usb_digitv,dvb_usb,ehci_hcd,uhci_hcd

(as root) fqzps0j-04y212:/ # lsmod | grep usbhid
usbhid 43616 0
usbcore 112512 9 slusb,usbhid,labjack,usb_storage,dvb_usb_digitv,dvb_usb,ehci_hcd,uhci_hcd

(as user) fqzps0j-04y212:~> locate hid-core.c
/usr/src/linux-2.6.13-15.10/drivers/usb/input/hid-core.c

(as user) fqzps0j-04y212:~> grep -i cd5 `locate hid-core.c`
(as user) fqzps0j-04y212:~>

The grep command basically scans for the addition that LabJack Support described in this (and many other) post... https://forums.labja...?showtopic=1251

(as user) fqzps0j-04y212:~> /usr/local/linux-labjack/test/firmware-revision
version: 1.100000

(as user) fqzps0j-04y212:~> /usr/local/linux-labjack/test/list-all

Found 1 LabJacks!

Info:

productID, serialNum, localID, powerList, calMatrix

1, xxxxxxxxx, 0, 9999,
(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 )


The serial number was changed to x's by me, but you can see it working fine.

Cheers guys

PS If this information has already been spread around the forum then please forgive me, I searched but couldn't find anything similar.

#2 NewbieLabJack

NewbieLabJack
  • Members
  • 8 posts

Posted 23 July 2006 - 09:16 AM

I just had an automated security update issued to my kernel which caused a slight problem. Here is my updated /etc/init.d/boot.local file which gets rid of this problem... # Setup the labjack driver. The usbhid needs to be removed before it's # loaded. This is reinstated immediately afterwards. It is done this # way to prevent the labjack driver being hijacked by the usbhid driver mkdir /dev/usb mknod --mode=a=rw /dev/usb/labjack0 c 180 240 sleep 1 modprobe -r usbhid sleep 1 insmod /usr/local/linux-labjack/driver/linux-2.6/labjack.ko sleep 1 insmod /lib/modules/`uname -r`/kernel/drivers/usb/input/usbhid.ko Have any of you tried it out? I'd be interested to hear from anyone that has tried this, successful or otherwise. Cheers

#3 olaola

olaola
  • Members
  • 2 posts

Posted 01 February 2007 - 02:07 PM

Someone have tried this procedure on a 2.4 series kernel??? I'm trying in Debian 3.1 but it seem to not work.

#4 NewbieLabJack

NewbieLabJack
  • Members
  • 8 posts

Posted 14 February 2007 - 04:15 PM

Olaola,

Sorry to hear you have had problems with this, but maybe the following will help.

I have recently upgraded my machine and as a result had to setup the labjack drivers again. SUSE was a really excellent distro, but since the Novell-Microsoft business deal I decided it was time for a change. Having heard nothing but praise for Ubuntu I decided to install its close brother Kubuntu, but having KDE or Gnome (or even Xfce et. al.) should make no difference.

Now since Debian is the granddaddy of Ubuntu, amongst many other distros, the following guide may be more relevant and helpful to you. All of the system files should be the same so you can pretty much follow this verbatim.

Before I start, plug your labjack directly into your computer if possible and not through a usb hub. My initial trials always gave a result of 0.000000 for the firmware-revision test. But once I plugged it directly into the machine it was fine. On a subsequent reboot it then proceeded to work fine on the usb hub with no further changes.

If you have a laptop (especially a dell) they underpower their USB ports to extend their battery life (and makes for better marketing info I guess). USB standard is 500mA, some dell models run at 200mA. I highly recommend using a powered usb hub if you are in this situation.

Dollar signs $ indicate your prompt, do not type them. (Sorry, being thorough as I don't know if you are new to Linux)

Steps
=====
* Get the latest labjack driver from http://www.labjack.c...-labjack.tar.gz

* I usually keep all my drivers/projects that need to be compiled from source in /usr/local/sourcecompile which allows my own user (not root) to compile from. To do this
$ sudo mkdir /usr/local/sourcecompile
$ sudo chown <userid>:<groupid> /usr/local/sourcecompile
e.g. sudo chown johndoe:johndoe /usr/local/sourcecompile
To get your userid:groupid enter, and it'll be the two names (in order) before the file size
$ ls -l ~/.bashrc

* Give you full and everyone else read permissions
$ sudo chmod 755 /usr/local/sourcecompile

* Copy your downloaded tarfile to the created directory. Move to the directory where the tar file is and enter
$ cp linux-labjack.tar.gz /usr/local/sourcecompile/

* Unzip the tarfile
$ cd /usr/local/sourcecompile/
$ tar -zxvf linux-labjack.tar.gz

* Follow the instructions for your kernel in /usr/local/sourcecompile/linux-labjack/INSTALL. Stop just before testing it (just before the line --> # ./firmware-revision)

Just read the linux-2.4 install instructions
I BELIEVE YOUR PROBLEM IS FOLLOWING MY CODE VERBATIM!!
THIS IS MOST LIKELY YOUR SOLUTION...
You need to replace the line
/usr/local/sourcecompile/linux-labjack/driver/linux-2.6/labjack.ko
with
/usr/local/sourcecompile/linux-labjack/driver/linux-2.4/labjack.o
in the file example /etc/rc.local supplied below


* Edit the file (as root) /etc/rc.local
$ sudo kedit /etc/rc.local
or
$ sudo <<your-editor>> /etc/rc.local

* Make the changes as follows (do not include the equal signs!!)
==========================================================
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Added 14-FEB-2007 START
# Setup the labjack driver.
# The usbhid needs to be removed before the labjack driver is loaded.
# The usbhid driver is reinstated immediatedly afterwards.
# These steps prevent the labjack driver being hijacked by the usbhid module
mkdir /dev/usb
mknod --mode=a=rw /dev/usb/labjack0 c 180 240
sleep 1
modprobe -r usbhid
sleep 1
insmod /usr/local/sourcecompile/linux-labjack/driver/linux-2.6/labjack.ko
sleep 1
insmod /lib/modules/`uname -r`/kernel/drivers/usb/input/usbhid.ko
# Added 14-FEB-2007 END

exit 0
=============================================================

* Make sure that the file has the execution bit set. This was already done in Kubuntu, but may be disabled in Debian. Enter
$ ls -l /etc/rc.local

If the output doesn't look like... (the -rwxr-xr-x)
-rwxr-xr-x 1 root root 960 2007-02-14 21:38 /etc/rc.local

then enter
$ sudo chmod 755 /etc/rc.local

* Reboot your machine (doesn't matter if your labjack is plugged in or not)

* When you log back in enter (making sure that the labjack has been plugged in for about 15 seconds)
$ /usr/local/sourcecompile/linux-labjack/test/firmware-revision

You should get something like version: 1.100000
If it's all zeros then either the kernel hasn't loaded or the device node has not been created.

Troubleshooting
===============
* Enter
$ ls -l /dev/usb/labjack*

You should get...
crw-rw-rw- 1 root root 180, 240 2007-02-14 21:45 /dev/usb/labjack0

If you don't then there is something in your system that is preventing the device node from being created
Google is your best bet from here

* Enter
$ sudo lsmod | grep -i labjack

You should get...
labjack 19472 0
usbcore 134912 10 usbhid,labjack,dvb_usb_digitv,dvb_usb,usb_storage,hci_usb,libusual,ehci_hcd,uhci
_hcd

If you don't then there is a problem loading your driver
Google is your best bet from here

* If both the node and the driver are loaded, and you have your labjack directly connected to your machine then I'm afraid that I cannot help any further. It must be a change in the 2.6 kernel that allows this to happen.
Check the 'System Logfile' section to help point you in the right direction.

* Are you SURE that the driver and liblabjack compiled properly?
- Does /usr/local/sourcecompile/linux-labjack/driver/linux-2.4/labjack.o exist? Also check the owner/group/permissions of the file. Mine supplied below for reference.
-rw-r--r-- 1 <userid> <groupid> 26083 2007-02-14 20:53 /usr/local/sourcecompile/linux-labjack/driver/linux-2.6/labjack.ko

- Does /usr/lib/liblabjack.so exist? Also check the owner/group/permissione of the file. Mine supplied below for reference.
-rwxr-xr-x 1 root root 75220 2007-02-14 20:58 /usr/lib/liblabjack.so

* Did you replace (in my supplied /etc/rc.local above) the following line...
insmod /usr/local/sourcecompile/linux-labjack/driver/linux-2.6/labjack.ko
with...
insmod /usr/local/sourcecompile/linux-labjack/driver/linux-2.4/labjack.o


For the record
==============
Running Kubuntu (6.10), kernel 2.6.17-11-generic

System Logfile
==============
* If it hasn't worked out then reboot again and login, but do nothing for about a minute. Then check the system log by entering
$ tail -100 /var/log/messages

A whole heap of information will appear, look for something like the following, which shows the /etc/rc.local file doing its job. It unloads the usbhid module, loads the labjack module (a second later), then reloads the usbhid module (a second after that). After that it's loading some other USB devices. You'll most likely identify your problem by looking in your system log file.

Feb 14 21:45:23 <<myhostname>> kernel: [17179613.944000] usbcore: deregistering driver usbhid
Feb 14 21:45:23 <<myhostname>> kernel: [17179613.944000] usbcore: deregistering driver hiddev
Feb 14 21:45:24 <<myhostname>> kernel: [17179615.120000] /usr/local/sourcecompile/linux-labjack/driver/linux-2.6/labjack.c: LabJack USB #0 now attached to major 180 minor 240
Feb 14 21:45:24 <<myhostname>> kernel: [17179615.120000] usbcore: registered new driver labjack
Feb 14 21:45:24 <<myhostname>> kernel: [17179615.120000] /usr/local/sourcecompile/linux-labjack/driver/linux-2.6/labjack.c: Labjack USB Driver <http://www.labjack.com/> v0.35
Feb 14 21:45:25 <<myhostname>> kernel: [17179616.124000] usbcore: registered new driver hiddev
Feb 14 21:45:25 <<myhostname>> kernel: [17179616.128000] input: ASUS LCM as /class/input/input7
Feb 14 21:45:25 <<myhostname>> kernel: [17179616.128000] input: USB HID v1.10 Device [ASUS LCM] on usb-0000:00:1d.7-7
Feb 14 21:45:25 <<myhostname>> kernel: [17179616.136000] input: Logitech USB-PS/2 Optical Mouse as /class/input/input8
Feb 14 21:45:25 <<myhostname>> kernel: [17179616.136000] input: USB HID v1.10 Mouse [Logitech USB-PS/2 Optical Mouse] on usb-0000:00:1d.7-2.7
Feb 14 21:45:25 <<myhostname>> kernel: [17179616.136000] usbcore: registered new driver usbhid
Feb 14 21:45:25 <<myhostname>> kernel: [17179616.140000] drivers/usb/input/hid-core.c: v2.6:USB HID core driver


Hope it works for you, please tell me if it works or not because it would be useful to know should I be tempted to give Debian a go.
good luck


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users