Xenomai
Compile mainline kernel with Xenomai patches
for Ubuntu 10.10 with the newest, stable components available 1st of May 2011:
Install ccache
Because often a lot of compilation runs will be needed, to get a good kernel, install ccache as described at:
http://blog.dholbert.org/2008/09/ccache-much-speedier-firefox-builds.html
With ccache the second compilation (with different .config settings) needs only 15 minutes instead of 65 minutes (on a core duo with 2.54 GHz).
Test a precompiled kernel 2.6.37 on your hardware
(You can skip this step, if know that it works on your hardware and if you have a working .config file)
Install the Ubuntu kernel 2.6.37, as described at: http://www.ramoonus.nl/2011/01/linux-kernel-2-6-37-installation-guide-for-ubuntu-linux/
I did this, to get a .config file, that is definitly working and has all the drivers, that I need. Boot the new kernel, check if it is working correctly. This step is only needed, if you do not have a 2.6.37 kernel (or a little bit older) yet, but a newer kernel.
Download and pre-configure kernel 2.6.37 without Xenomai on your hardware
Follow the instructions at: https://wiki.ubuntu.com/KernelTeam/GitKernelBuild
BUT use kernel 2.6.37.6 from kernel.org instead.
> cd ~ > wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.37.6.tar.bz2 > tar xfj linux-2.6.37.6.tar.bz2 > cd linux-2.6.37.6 > cp /boot/config-`uname -r` .config > make oldconfig
Now change some settings, e.g. set your processor to the one you have, switch off the option CONFIG_DEBUG_KERNEL and adjust any other settings to your needs:
> make menuconfig
Compile kernel 2.6.37 without Xenomai on your hardware
(You can skip this step, if you know how to compile and install a kernel for Ubuntu 10.10)
Compile the kernel and build debian packages.
> CONCURRENCY_LEVEL=3 fakeroot make-kpkg --initrd --append-to-version=-custom3 kernel_image kernel_headers
Install it and test, whether it works:
> cd .. > sudo dpkg -i *.deb > sudo init 6
After reboot, select your new kernel in the boot manager and test it.
> uname -r
must show the version number of the new kernel now.
Delete these packages, to gain space:
> cd ~ > rm *.deb
Compile kernel 2.6.37 with Xenomai
Now download and unpack xenomai:
> cd ~ > wget http://download.gna.org/xenomai/stable/xenomai-2.5.6.tar.bz2 > tar xfj xenomai-2.5.6.tar.bz2
Change into the xenomai directory and apply the xenomai patches:
> cd ~/xenomai-2.5.6 > ./scripts/prepare-kernel.sh --linux=../linux-2.6.37.6
Now configure the kernel. Set the following options:
Section Power Management and ACPI options:
- ACPI -> Processor (OFF) - APM -> CPU Idle driver for Intel processors (OFF)
- APM (OFF)
- CPU frequency scaling (OFF)
Section Bus Options:
- - Message signaled interrupts (CONFIG_PCI_MSI) (OFF)
Section Processor Type and Features:
- Enable -fstack-protector buffer overflow detection (OFF) (only, if compiling for 32 bit target)
Section Real-time sub-system:
- - Nucleus (Module)
The following two settings are needed for the labtop DELL E6400. They might be unnecessary on other machines. (Use them only, if the latency is too high without them.There is the risk, that some peripherals stop to work.) Section Real-time sub-system:
- Nucleus -> Machine -> Enable SMI workaraound (ON)
- Nucleus -> Machine -> Enable SMI workaraound -> Globally disable SMI (ON)
> cd ~/linux-2.6.37.6 > make menuconfig
Compile the kernel and build debian packages. Make sure, to use a new version string.
> CONCURRENCY_LEVEL=3 fakeroot make-kpkg --initrd --append-to-version=-xenomai kernel_image kernel_headers
Add the following lines to the file /etc/modules:
xeno_nucleus xeno_posix xeno_native
Disable the power management daemon:
Gnome-Menu:
System ->
Preferences ->
Startup-Applications ->
Power Management DaemonAdd the following line to the file /etc/default/grub:
GRUB_CMDLINE_LINUX="quiet acpi_osi=Linux acpi_backlight=vendor"
and run:
> sudo update-grub
If you don't do it, you get a lot of acpi error messages in the system log.
Install it and test, whether it works:
> cd .. > sudo dpkg -i *.deb > sudo init 6
After reboot, select your new kernel in the boot manager and test it.
> uname -r
must show the version number of the new kernel now.
Testing Xenomai
Some of the Xenomai test scripts only run with the bash shall and not with the dash shell, that is the Ubuntu default. To change from dash to bash, type:
> dpkg-reconfigure bash
Compile the Xenomai test suite:
> cd ~/xenomai-2.5.6 > ./configure --enable-dlopen-skins > make > sudo make install
First test:
> cd /usr/xenomai/bin > sudo ./clocktest
Example output:
== Tested clock: 0 (CLOCK_REALTIME) CPU ToD offset [us] ToD drift [us/s] warps max delta [us] --- -------------------- ---------------- ---------- -------------- 0 -97184.0 -0.001 0 0.0 1 -97183.9 0.009 0 0.0
Second test:
> cd /usr/xenomai/bin > sudo ./latency
Example output:
== Sampling period: 100 us == Test mode: periodic user-mode task == All results in microseconds warming up... RTT| 00:00:01 (periodic user-mode task, 100 us period, priority 99) RTH|----lat min|----lat avg|----lat max|-overrun|---msw|---lat best|--lat worst RTD| -1.834| -1.794| -0.176| 0| 0| -1.834| -0.176 RTD| -1.994| -1.781| -0.222| 0| 0| -1.994| -0.176 RTD| -2.134| -1.763| 3.591| 0| 0| -2.134| 3.591 RTD| -1.998| -1.771| 0.201| 0| 0| -2.134| 3.591 RTD| -2.006| -1.709| 3.339| 0| 0| -2.134| 3.591 RTD| -2.127| -1.696| 2.100| 0| 0| -2.134| 3.591 RTD| -2.026| -1.689| 4.257| 0| 0| -2.134| 4.257 RTD| -1.971| -1.314| 3.004| 0| 0| -2.134| 4.257 RTD| -1.980| -1.318| 3.695| 0| 0| -2.134| 4.257 ---|-----------|-----------|-----------|--------|------|------------------------- RTS| -2.134| -1.648| 4.257| 0| 0| 00:00:10/00:00:10
Third test:
> cd /usr/xenomai/bin > sudo ./xeno-test
Final remarks
The overall latency is very good, the worst case latency is less than 10 e-6 seconds.
But some things are not perfect yet.
1. there are two warnings during startup:
[ 0.013043] Enabling APIC mode: Flat. Using 1 I/O APICs [ 0.013388] ..TIMER: vector=0x30 apic1=0 pin1=2 apic2=-1 pin2=-1 [ 0.013999] ..MP-BIOS bug: 8254 timer not connected to IO-APIC [ 0.013999] ...trying to set up timer (IRQ0) through the 8259A ... [ 0.013999] ..... (found apic 0 pin 2) ... [ 0.024691] ....... works. ... [ 1.877475] e1000e 0000:00:19.0: (unregistered net_device): Failed to initialize MSI interrupts. Falling back to legacy interrupts.
2. The control of the back-light with the function keys doesn't work any longer.
Now the good news:
There is an easy workaround. You can change the brightness from the command line with the following command:
sudo setpci -s 00:02.0 F4.B=7F
Instead of 7F you can use any value between 00 and FF.
3. The clocktest program sometimes shows a time offset of +- 500 µs, but this problem disappears by itself after some minutes.
4. The time, that is measured by the latency test is sometimes negative (-1 to -2.2 micro seconds).
Back to FrontPage