Montag, 5. November 2007

Installing leJOS on OpenSuse 10.3 Linux

leJOS is a Java Environment for Lego Mindstorm robots. Especially the version supporting the latest model (NXT) seems to have a couple of installation issues. Thus I decided to document my findings about installing on a (OpenSuse 10.3) linux box:

The best installation instruction can be downloaded from a publishers errata page. There's a PDF describing the installation process on all supported platforms.
One prerequisite for the installation is, that you have ant installed on your machine. It can be easily installed using Yast.

However, when you follow the instruction there you will receive some errors, since the necessary header files for the Java native interface (JNI) are not found. You'll have to modify some build.xml files.
Open the build.xml file in the src/libnxt folder and add the following entries to the jlibnxt target:







After this also add them to goal "jbluez" in the file src/jbluez/build.xml.
Now leJOS should build without any errors.

Wacom Bamboo on OpenSuse 10.3

There's an open source project named linuxwacom that offers a driver also supporting the bamboo tablet. This article assumes that you have installed all the necessary development packages (kernel-sources,...) on your machine.

Download the latest tar-ball (in my case 0.7.9-1 development) and untar it on your machine. Change into the created directory (e.g. linuxwacom-0.7.9-1) and run the "configure" script. Go through all the error messages and warnings and install all missing packages via Yast.
The point is, that the required driver is not built by default. You have to add the option "--enable-wacom" to create it. However, if you add this option, you get a warning that the kernel build environment is not found, even you have installed the required kernel sources. The reason for this behavior is, that opensuse spreads the source files over several directories, whereas the configuration script assumes all files to be in one directory.
So you get the warning:


***
*** WARNING:
*** Unable to compile wacom.o without kernel build environment
*** wacom.o will not be built
***

Getting around this is a bit of a hack. First of all you have to modify the configure script so that it will find the /usr/src/linux directoy first. Open the script and search for "checking for kernel sources... ". In the next line is the variable WCM_KERNELDIR defined. Re-order the entries in this variable and make /usr/src/linux the first entry. If you now re-run the configure script with the --enable-wacom option you should get the following message:
...
checking for kernel sources...
/usr/src/linux
...

Kernel detection still fails! This is because the script fails to find the file ./include/linux/autoconf.h, since it is in a different directory.
Next, identify your kernel version and flavor by using the command "uname -r".
It shows something like this: 2.6.22.9-0.4-default
"default" is the important information.
Go to /usr/src/ and search for autoconf.h by using "find -L -name autoconf.h".
You will find the file in the directory "./linux-obj/i586/default/include/linux/autoconf.h". Thus create the appropriate link to this file in /usr/src/linux/include/linux (e.g. sudo ln -s /usr/src/linux-obj/i586/default/include/linux/autoconf.h )!

Now the configure script accepts your kernel sources but still wont find all required header files when compiling. You should get the result:

BUILD OPTIONS:
wacom.o - yes
wacdump - yes
xidump - yes
libwacomcfg - yes

Start building the package by a calling "make".
You'll get a relatively large list with error messages (and they wont be the last ones).
1. create a link to auto.conf : sudo ln -s /usr/src/linux-obj/i586/default/include/config
2. create a link to asm/linkage.h: sudo ln -s /usr/src/linux-obj/i586/default/include2/asm
3. create a link to the script fixdep: sudo ln -s /usr/src/linux-obj/i586/default/scripts/basic/fixdep
4. create a link to the script modpost: sudo ln -s /usr/src/linux-obj/i586/default/scripts/mod/modpost
5. create a link to utsrelease.h: sudo ln -s /usr/src/linux-obj/i586/default/include/linux/utsrelease.h
6. also create a link to Module.symvers


Here are all commands (you can create a script with these lines):

sudo ln -s /usr/src/linux-obj/i586/default/include/config/ /usr/src/linux/include/
sudo ln -s /usr/src/linux-obj/i586/default/include2/asm /usr/src/linux/include/asm
sudo ln -s /usr/src/linux-obj/i586/default/scripts/basic/fixdep /usr/src/linux/scripts/basic/
sudo ln -s /usr/src/linux-obj/i586/default/scripts/mod/modpost /usr/src/linux/scripts/mod/
sudo ln -s /usr/src/linux-obj/i586/default/include/linux/utsrelease.h /usr/src/linux/include/linux/
sudo ln -s /usr/src/linux-obj/i586/default/Module.symvers /usr/src/linux/
sudo ln -s /usr/src//linux-obj/i586/default/include/linux/autoconf.h
/usr/src/linux/include/linux/


Now (assuming that you have created the links in the correct directories) your driver should compile fine.

Go on with 3.5 from the projects documentation, but use "insmod ./wacom.ko" instead of "insmod ./wacom.o"!

I'd recommend to create the file /etc/udev/rules.d/10-wacom.rule with the following content:

# Convenience link for the common case of a single tablet.
KERNEL=="event[0-9]*", SYSFS{idVendor}=="056a", SYMLINK="input/wacom"

To create the extended devices that are necessary to recognize your tablet in the gimp (you have to configure them there anyway) you have to adapt your /etc/X11/xorg.conf file:

Section "InputDevice"
Driver "wacom"
Identifier "stylus"
Option "Device" "/dev/input/wacom"
Option "Type" "stylus"
Option "USB" "on" # USB ONLY
Option "Mode" "Absolute" # other option: "Absolute"
Option "Vendor" "WACOM"
Option "tilt" "on" # add this if your tablet supports tilt
Option "Threshold" "5" # the official linuxwacom howto advises this line
EndSection

Section "InputDevice"
Driver "wacom"
Identifier "eraser"
Option "Device" "/dev/input/wacom"
Option "Type" "eraser"
Option "USB" "on" # USB ONLY
Option "Mode" "Absolute" # other option: "Absolute"
Option "Vendor" "WACOM"
Option "tilt" "on" # add this if your tablet supports tilt
Option "Threshold" "5" # the official linuxwacom howto advises this line
EndSection

Section "InputDevice"
Driver "wacom"
Identifier "cursor"
Option "Device" "/dev/input/wacom"
Option "Type" "cursor"
Option "USB" "on" # USB ONLY
Option "Mode" "Relative" # other option: "Absolute"
Option "Vendor" "WACOM"
EndSection

Section "InputDevice"
Driver "wacom"
Identifier "pad"
Option "Device" "/dev/input/wacom"
Option "Type" "pad"
Option "USB" "on" # USB ONLY
Option "Vendor" "WACOM"
EndSection

Section "ServerLayout"
Identifier "Layout[all]"
InputDevice "Keyboard[0]" "CoreKeyboard"
InputDevice "Mouse[1]" "CorePointer"
InputDevice "cursor" "SendCoreEvents" # add these 3 lines
InputDevice "stylus" "SendCoreEvents"
InputDevice "eraser" "SendCoreEvents"
InputDevice "pad"
Option "Clone" "off"
Option "Xinerama" "off"
Screen "Screen[0]"
EndSection