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

Module compilation woes (U12 + Ubuntu 8.10)


  • Please log in to reply
11 replies to this topic

#1 elvis

elvis
  • Members
  • 6 posts

Posted 25 March 2009 - 04:07 PM

Dear All,
I'm struggling to compile the U12 module under Ubuntu 8.10, with the standard kernel 2.6.27. The last few lines of the make messages are attached below. I've checked that the kernel headers are installed in /usr/src/linux-headers-2.6.27-11-generic/, that I am booted into the correct kernel, and that /lib/modules/2.6.27-11-generic exists. The kernel sources are installed (and untar-ed in /usr/src/linux-source-2.6.27/). Can anybody see why the build is hiccuping on bounds.c?

Frustratingly, I remember the compilation working first time under Fedora 9. I've trawled through Google and the archives of this forum, and am running out of ideas, so any suggestions will be much appreciated.

-Tim

GFS Network Block Device (GNBD) [M/n/y] m
GFS file system support (GFS_FS) [M/n/y/?] m
Toshiba ACPI laptop driver (TLSUP) [N/m/y] n
Ralink 2860 Wireless device support (RT2860) [M/n/y] (NEW) 
Realtek 8187se Wireless device support (RTL8187SE) [M/n/y] (NEW) 
#
# configuration written to .config
#
make[1]: Leaving directory `/usr/src/linux-headers-2.6.27-11-generic'
make[1]: Entering directory `/usr/src/linux-headers-2.6.27-11-generic'
  CHK	 include/linux/version.h
  CHK	 include/linux/utsrelease.h
  UPD	 include/linux/utsrelease.h
make[2]: *** No rule to make target `kernel/bounds.c', needed by `kernel/bounds.s'.  Stop.
make[1]: *** [prepare0] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.27-11-generic'
make: *** [default] Error 2


#2 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 26 March 2009 - 11:58 AM

Looks like you compiling both the kernel and the U12 driver at the same time. If you're going this route try modifying the Makefile for the U12 kernel module so that the KDIR path points to your /lib/modules/2.6.27-11-generic directory. The default /lib/modules/$(shell uname -r)/build directory is more appropriate for standalone compiling.

#3 elvis

elvis
  • Members
  • 6 posts

Posted 26 March 2009 - 05:23 PM

Hmm. I wasn't aiming to compile anything but the LabJack driver module, but I agree it does look as if it is trying to compile all kernel modules. The Labjack linux-2.6/Makefile is unmodified, and the KDIR path indeed points to my /lib/modules/2.6.27-11-generic directory, which in turn points to /usr/src/linux-headers-2.6.27-11-generic and /usr/src/linux-headers-2.6.27-11.

My (unmodified) makefile reads

KDIR := /lib/modules/$(shell uname -r)/build 

obj-m := labjack.o

default:
	$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:
	rm -fr *.mod.c *.o *.ko .labjack.* .tmp_versions

As far as I understand, this will execute a recursive make, picking up the Makefile in /lib/modules/2.6.27-11-generic/build, which appears to be the kernel makefile. Sooo... do I need to compile all kernels? In which case, what's the right way to install the source code? Or is something else wrong?

#4 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 26 March 2009 - 07:55 PM

No you do not need to compile all kernel modules. You should only need to run our Makefile to compile the U12 kernel module alone. In Ubuntu, I think you only need the Linux headers to compile the U12 kernel module. Having both the headers and source might be causing some confusion when compiling. Try getting rid of the /usr/src/linux-source-2.6.27/ directory and see if that helps. Also, in the labjack.c file remove line 43 in the code which is "#include <linux/config.h>". The config.h file was removed from the kernel some time ago.

#5 elvis

elvis
  • Members
  • 6 posts

Posted 27 March 2009 - 08:33 AM

Thanks for the reply. I've done as you suggested, but with no luck I'm afraid. I have also reinstalled the header packages just to be sure of a clean installation, but the build still fails with the same message, "make[2]: *** No rule to make target `kernel/bounds.c', needed by `kernel/bounds.s'. Stop." A Google search on this error message turned up other people with problems compiling drivers under Ubuntu, but in those cases the problem was solved by installing the full kernel source.

#6 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 27 March 2009 - 05:25 PM

I've been searching online as well and have not found anything else to have you try. I don't have time today, but over the weekend I'll try to reproduce the problem myself and get back to you.

#7 elvis

elvis
  • Members
  • 6 posts

Posted 27 March 2009 - 06:29 PM

Phew - I solved it. I added this line to the Makefile:

PWD := $(shell pwd)
I don't pretend to understand the makefile, but I suppose $(PWD) wasn't being defined in the original makefile, and so all the linux header code in $(KDIR) was being compiled rather than the code in the LabJack driver directory.

The remainder of the installation went exactly as explained in the help-files. A mknod was needed to create the device file, and the test applications are now working. Blacklisting in the HID module was not needed.

Many thanks to Labjack support for taking the time to look into this.
-Tim

#8 elvis

elvis
  • Members
  • 6 posts

Posted 28 March 2009 - 02:24 PM

I spoke too soon. The HID module does indeed conflict with the Labjack module, and must be removed with rmmod. For some reason I didn't need to do that yesterday.

#9 elvis

elvis
  • Members
  • 6 posts

Posted 29 March 2009 - 08:35 AM

Well, after much tinkering I've got things working very nicely. The labjack module loads and creates the device files automatically, and the usbhid module doesn't conflict. No kernel recompilation was needed. In case this is useful for anybody else (and for when I need to do it again myself), I've written a summary. I hope I haven't missed anything out. Note that this will only work with a recent kernel, >=2.6.22. I'm using Ubunto 8.10 with kernel 2.6.27.

> Check that the linux-headers are installed
> Download and unzip the labjack driver:

cd ~/tmp
wget http://www.labjack.com/files/linux-labjack.tar.gz
tar -zxf linux-labjack.tar.gz

> Add the following line to the Makefile, after KDIR := /lib/modules/$(shell uname -r)/buiild
PWD := $(shell pwd)
> Coment out config.h in labjack.c
//#include <linux/config.h>

cd linux-labjack/driver/linux-2.6
nano -w Makefile
nano -w labjack.c

> Build the labjack module (no sudo meeded) & install it

make
sudo cp labjack.ko /lib/modules/`uname -r`/
sudo depmod -ae

> Stop the USBHID module from claiming the Labjack, by adding the following lines to /etc/modprobe.d/options
# Exception for Labjack driver
options usbhid quirks=0xcd5:0x0001:0x4

sudo nano -w /etc/modprobe.d/options

> Make a script to create the labjack device files, by creating a file containing the following lines
# Create device files if necessary when labjack module is loaded
install labjack mkdir -p /dev/usb; if [ ! -e /dev/usb/labjack0 ]; then mknod --mode=a=rw /dev/usb/labjack0 c 180 240; fi; /sbin/modprobe --ignore-install labjack

sudo nano -w /etc/modprobe.d/labjack

> Build and install the library

cd ~/tmp/linux-labjack/liblabjack
make
sudo cp liblabjack.so /usr/lib

> Build and run the test applications

cd ~/tmp/linux-labjack/test
make
./list-all

From now on the Labjack module will load automatically. All you need to do is plug it in and run your application.

-Tim

#10 RonS

RonS
  • Members
  • 2 posts

Posted 02 October 2009 - 04:03 AM

Thanks a lot for the instructions above Tim (elvis)!

The following did not work for me under Ubuntu 9.04 (Jaunty) (quirks does not work):

> Stop the USBHID module from claiming the Labjack, by adding the following lines to /etc/modprobe.d/options

# Exception for Labjack driver
options usbhid quirks=0xcd5:0x0001:0x4


To fix it I had to load the labjack module *before* the usbhid module:
- blacklist usbhid by adding the following line to /etc/modprobe.d/blacklist.conf
blacklist usbhid

- Add the following 2 lines to /etc/modules:
labjack
usbhid
- That's it!

Is there a better (cleaner) to do the above?

#11 hakelm

hakelm
  • Members
  • 9 posts

Posted 22 December 2010 - 12:53 PM

Where did the source go?
wget http://www.labjack.c...-labjack.tar.gz
gives me a 404.
Thanks for any advice
hakelm

#12 LabJack Support

LabJack Support
  • Admin
  • 8677 posts

Posted 26 December 2010 - 01:02 PM

See if this is what you want:

http://labjack.com/s...ac-os-x-drivers


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users