Search:  
Gentoo Wiki

HOWTO_ADEOS-IPIPE_and_Xenomai

This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Contents

Background

Here is another Gentoo Wiki HOW-TO describing how to add hard real-time capability to your Gentoo installation! You can find its predecessor here on the Gentoo Wiki at HOWTO ADEOS-based RTAI/fusion on Gentoo. You can also find something similar at HOWTO RTAI and COMEDI on 2.6 Kernel.

Why another? RTAI and related projects are actively developed. Since writing HOWTO ADEOS-based RTAI/fusion on Gentoo, Philippe Gerum et al have made numerous improvements and changes. Changes include new names. What was RTAI/fusion is now Xenomai; what was ADEOS is now ADEOS-IPIPE. See Xenomai project for details. This wiki page addresses the new generation: ADEOS-IPIPE and Xenomai.

Introduction

This mini HOW-TO describes how to install Xenomai and its kernel dependency ADEOS-IPIPE. Together these packages make your Gentoo installation hard real-time capable. The HOW-TO does not describe how this works, just how to install it on Gentoo! See end for references and links to other sites explaining how exactly it works and how to use it.

Version Numbers

This HOW-TO applies to Xenomai version 2.0.3, ADEOS-IPIPE version 1.1-03, kernel base version 2.6.15 with genpatches 15-3. The following table summarises the software components and their versions. (Links to tarballs and patches provided in table below but no need to download directly; Gentoo's Portage system will download to the right place for you!)

Software Component Version Number
Xenomai 2.0.3
ADEOS-IPIPE 1.1-03
Kernel 2.6.15
Genpatches 15-3

IPIPE version tracks Xenomai. IPIPE 1.1-03 is the patch shipped with the Xenomai 2.0.3 tarball, though you can use later IPIPE versions if you prefer.

These version numbers will no doubt quickly become out-of-date. Nevertheless, adapting the ebuild scripts to newer versions is relatively trivial. The process itself remains unchanged.

Tip: Xenomai 2.1.x Branch

After having said version bumping is relatively trivial, moving to the 2.1 series requires more than number changes. Starting with the 2.1 series, Xenomai merges kernel modules with the kernel tree.

See HOWTO Xenomai 2.1.x Branch for new instructions.

Short Story

For those reasonably familiar with Gentoo and its package installation system called Portage, this section gives a brief overview. If already familiar with the details concerning setting up third-party ebuild scripts, this short version of the story might give sufficient prompting. You can read more about installing third-party ebuild scripts here on the wiki, see HOWTO Installing 3rd Party Ebuilds.

The basic aim: to set up two ebuild scripts and merge two new packages. Proceed as follows in generally the order listed. Some steps can run in parallel or switch order, e.g. you can download the scripts in any order. However, the general sequence is important; you cannot use the ebuild scripts before downloading them, of course. In fact, some of the ordering is critical. You must merge IPIPE first because Xenomai expects to find IPIPE artifacts during its configuration phase. It fails otherwise.

  1. Give yourself root access
  2. Make sure you know where the local Portage tree resides;
    • create the local Portage tree and
    • add it to /etc/make.conf if not already there
  3. Install ADEOS-IPIPE
    1. Download the sys-kernel/ipipe-sources ebuild script [1]
    2. Create the package digest (also downloads the source tarball)
    3. Merge and compile the new ipipe-sources
      • using emerge ipipe-sources
      • followed by genkernel along with options
        • --kerneldir=/usr/src/linux-2.6.15-ipipe-r1
        • --menuconfig for text-based configuration menus
        • all for all build steps
    4. Merge any other kernel packages your system might need
      • not forgetting to override the kernel source directory using
        • KERNEL_DIR=/usr/src/linux-2.6.15-ipipe-r1 emerge packages
    5. Configure boot loader for new kernel
    6. Reboot computer, boot new kernel
  4. Install Xenomai
    1. Download the sys-libs/xenomai ebuild script [2]
    2. Download the patch [3]
    3. Create the package digest (also downloads the sources)
    4. Merge and compile the new system libraries
  5. Run tests

You may notice that the installation process for IPIPE and Xenomai follows the same basic pattern, that of setting up and running a local ebuild script.

Long Story

This section of the HOW-TO gives step-by-step instructions. It consists of command-line listings with running commentary. These are the instructions I used on my Gentoo box. Hopefully they will also work for you! Only command-line tools were used for sake of clarity. It goes without saying, you can also use other tools including graphical ones which perform equivalent functions. You do not need to use mkdir for example; use some other way to make a directory if you prefer.

Give Yourself Root Access

Either login as root user or su yourself. Latter generally preferred because overuse of root logins can sometimes open up your system to abuse. At a terminal or console, enter su - to become root user.

user@host ~ $ su -
Password:
host ~ # 

Here user and host stands for your user and host names.

Set Up Your Local Portage Tree

Gentoo's main Portage tree (its system of packages together with source-installation instructions) comes from the Internet when you run emerge sync. However, Portage also lets you overlay custom sets of packages. This typically resides at /usr/local/portage and appears in /etc/make.conf as a line reading:

PORTDIR_OVERLAY="/usr/local/portage"

If your Gentoo box does not yet have a local Portage tree, this is the time to add it! Edit your /etc/make.conf, add the line above, then make the top-level local Portage directory.

host ~ # mkdir /usr/local/portage

Download Ebuild Script for ADEOS-IPIPE

Start by installing and running ADEOS-IPIPE. Xenomai depends on ADEOS at build-time and at run-time. You cannot therefore install Xenomai without first installing and running IPIPE! That means installing a new kernel patched with IPIPE and booting it.

Download the ebuild script for installing IPIPE. It belongs in the local Portage tree under subdirectory sys-kernel/ipipe-sources. Create this subdirectory first.

host ~ # cd /usr/local/portage
host portage # mkdir -p sys-kernel/ipipe-sources
host portage # 

Note the -p command-line option creates any missing parents. In this instance, it makes two new directories: sys-kernel and a new subdirectory within it, ipipe-sources. This is where the new IPIPE ebuild script will live. Change directory there and download the script.

How to download the script? Various ways! Copy it from this wiki page or right-click here and Save Link As. Save the script somewhere then move it to local Portage. Suppose I saved ipipe-sources-2.6.15-r1.ebuild in /tmp, I now enter the following to move it to its correct place under the local Portage tree.

host portage # cd sys-kernel/ipipe-sources
host ipipe-sources # mv /tmp/ipipe-sources-2.6.15-r1.ebuild .
host ipipe-sources # cd ~
host ~ # 

Create IPIPE Package Digest

Now that the ebuild script ipipe-sources-2.6.15-r1.ebuild exists in sys-kernel/ipipe-sources under the local Portage tree, downloading the sources and validating the build script becomes easy. Just enter the following command line. Note the back ticks.

host ~ # ebuild `equery w ipipe-sources` digest

It then automatically downloads the tarballs and patch files, computes their message digests and generates the package manifest. The end of the process looks like this:

>>> Generating digest file...
<<< adeos-ipipe-2.6.15-i386-1.1-03.patch
<<< genpatches-2.6.15-3.base.tar.bz2
<<< genpatches-2.6.15-3.extras.tar.bz2
<<< linux-2.6.15.tar.bz2
>>> Generating manifest file...
<<< files/digest-ipipe-sources-2.6.15-r1
<<< ipipe-sources-2.6.15-r1.ebuild
>>> Computed message digests.

host ~ # 

Your box is now ready to merge a new kernel source which incorporates the IPIPE real-time nanokernel.

Note that the equery w command reports a package's ebuild script. It turns package name ipipe-sources to the ebuild script location. If you enter this part by itself you get the following.

host ~ # equery w ipipe-sources
/usr/local/portage/sys-kernel/ipipe-sources/ipipe-sources-2.6.15-r1.ebuild
host ~ # 

Merge New Kernel Sources

Merging is the easy bit. It just unpacks and patches the sources into /usr/src. The new kernel source tree appears as /usr/src/linux-2.6.15-ipipe-r1.

host ~ # emerge ipipe-sources -pv

These are the packages that I would merge, in order:

Calculating dependencies ...done!
[ebuild  NS   ] sys-kernel/ipipe-sources-2.6.15-r1  -build -doc -symlink 0 kB [1]

Total size of downloads: 0 kB
Portage overlays:
 [1] /usr/local/portage
host ~ # emerge ipipe-sources

When the command above completes, the new kernel sources are ready for compiling.

Configure and Compile New Kernel Sources

You can compile the kernel sources manually or use Gentoo's genkernel tool for automatic generation of kernel image, modules and initial RAM-based filesystem. I recommend the latter; it works well and saves time.

host ~ # genkernel --kerneldir=/usr/src/linux-2.6.15-ipipe-r1 --menuconfig all

Specify the kernel sources directory explicitly using --kerneldir. Option --menuconfig brings up the kernel configuration menu.

One of the first things you might notice: a new kernel option under Processor type and features called Interrupt pipeline. IPIPE (interrupt pipe) is enabled by default.

Linux Kernel Configuration: Processor type and features
    Subarchitecture Type (PC-compatible)  --->                      
    Processor family (586/K5/5x86/6x86/6x86MX)  --->                
[*] Generic x86 support                                             
[*] HPET Timer Support                                              
[*] Symmetric multi-processing support                              
(8)   Maximum number of CPUs (2-255)                                
[*]   SMT (Hyperthreading) scheduler support                        
    Preemption Model (No Forced Preemption (Server))  --->          
[*] Preempt The Big Kernel Lock                                     
[*] Interrupt pipeline                                              

Best way to configure the new kernel: go to the bottom of the main configuration menu and select Load an Alternate Configuration File. This option allows you to load an existing configuration, one already suitably set up for your machine. If you use genkernel for kernel generation, you will find your previous configurations by name under /etc/kernels. So if you already have gentoo-sources-2.6.15-r1 running, just load the existing configuration at /etc/kernels/kernel-config-x86-2.6.15-gentoo-r1. Getting the standard kernel running first might be advisable. If things start to go awry, it gives you a point of reference. Basing your new real-time kernel on an existing configuration also makes it more likely to work first time.

Save the new kernel configuration and exit. The new kernel now compiles and installs under /boot. But do not reboot quite yet!

Merge Extra Kernel Packages

This may not be the end of compilation depending on your system. Some systems need extra kernel modules in additional packages, e.g. ATI graphics drivers, ALSA sound drivers, etc. If you forget to merge these extra kernel packages, the kernel will complain when your system boots. Some services or subsystems may also fail to run or work properly. If you can then get to a root command line, you can merge them post-boot and then reboot. Cleaner however if you merge the necessary packages first. Use commands such as the following. Note especially the KERNEL_DIR prefix. It tells emerge where to install the extra packages because Gentoo supports multiple kernel versions living under the same filesystem. The ipipe-sources do not automatically become your system's default kernel sources. Actually, symbolic link /usr/src/linux defines your system's default kernel sources. Portage's emerge tool only changes this special sym-link if you enable the symlink USE flag. However, you can override the default kernel directory using KERNEL_DIR along the following lines.

KERNEL_DIR=/usr/src/linux-2.6.15-ipipe-r1 emerge alsa-driver

Other examples include the svgalib package; it includes a kernel module called svgalib_helper.

Boot New Kernel

Add the new kernel to your boot loader's configuration and reboot Gentoo using the new kernel. Using genkernel, the kernel image and initial filesystem appear as /boot/kernel-genkernel-x86-2.6.15-ipipe-r1 and /boot/initramfs-genkernel-x86-2.6.15-ipipe-r1 respectively. Add these to your boot loader configuration, e.g. if using GRUB boot loader add an entry looking something like:

File: /boot/grub/grub.conf
title Gentoo Linux 2.6.15-ipipe-r1
	root (hd0,0)
	kernel /boot/kernel-genkernel-x86-2.6.15-ipipe-r1 real_root=/dev/hda1
	initrd /boot/initramfs-genkernel-x86-2.6.15-ipipe-r1

Of course, adjust (hd0,0) and /dev/hda1 to suit your system; this example specifies the boot device as first partition on first hard drive but your system may differ.

After booting, check that ADEOS-IPIPE is active. Its version number appears under the /proc filesystem. Try the following commands.

host ~ # ls /proc/ipipe/
Linux  version
host ~ # cat /proc/ipipe/version
1.1-03
host ~ # cat /proc/ipipe/Linux
Priority=100, Id=0x00000000
irq0-216: accepted
irq217: grabbed, sticky
irq218-238: accepted
irq256: grabbed, virtual
host ~ #

Download Xenomai Ebuild Script and Patch

Now almost repeat the previous process but for Xenomai this time. Differences include Xenomai being just a set of system libraries and extra kernel modules rather than an entire kernel source package. Therefore no reboot necessary. This how-to also includes an extra little patch to avoid some ugly warning messages when using Xenomai's shell scripts.

Download xenomai-2.0.3.ebuild and its dependency xenomai-2.0.3.patch. This is a system library so belongs under sys-libs Portage category. Add the script and patch to your local Portage tree as follows.

/usr/local/portage/sys-libs/xenomai:
drwxr-xr-x  files
-rw-r--r--  xenomai-2.0.3.ebuild

/usr/local/portage/sys-libs/xenomai/files:
-rw-r--r--  xenomai-2.0.3.patch

They need to appear as above at the right place under the local Portage tree. You can check it once downloaded and copied using equery w xenomai. The answer should be the full pathname of the sys-libs/xenomai ebuild script.

Digest the Xenomai Package

As with ADEOS-IPIPE, you need to set up the new package ready for merging. This step also downloads the source tarball, so you need an Internet connection.

host ~ # ebuild `equery w xenomai` digest

After downloading, the digest ends as follows.

>>> Generating digest file...
<<< xenomai-2.0.3.tar.bz2
>>> Generating manifest file...
<<< files/digest-xenomai-2.0.3
<<< files/xenomai-2.0.3.patch
<<< xenomai-2.0.3.ebuild
>>> Computed message digests.

host ~ # 

Merge Xenomai

host ~ # emerge xenomai

No need to reboot the system after merging Xenomai. However, you will need to update your shell environment. At the terminal, just enter source /etc/profile. This will update your PATH to include /usr/realtime/bin where Xenomai installs it shell scripts.

Run Tests

Xenomai comes with a useful test script called xeno-test. At version 2.0.3 however, it only runs successfully when you run it from the Xenomai real-time binary directory. Change directory to /usr/realtime/bin first then run xeno-test. You should see something like the following.

host ~ # cd /usr/realtime/bin
host bin # xeno-test
warning: CONFIG_CPU_FREQ=y may be problematic
running /usr/realtime/bin/xeno-test

Wed Feb 22 10:18:44 GMT 2006
running: cat /proc/cpuinfo
processor       : 0
vendor_id       : GenuineIntel
cpu family      : 15
model           : 2
model name      : Intel(R) Xeon(TM) CPU 3.06GHz
stepping        : 7
cpu MHz         : 3057.377
cache size      : 512 KB
physical id     : 0
siblings        : 1
core id         : 0
cpu cores       : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
bogomips        : 6123.16

processor       : 1
vendor_id       : GenuineIntel
cpu family      : 15
model           : 2
model name      : Intel(R) Xeon(TM) CPU 3.06GHz
stepping        : 7
cpu MHz         : 3057.377
cache size      : 512 KB
physical id     : 3
siblings        : 1
core id         : 0
cpu cores       : 1
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe cid
bogomips        : 6114.15


Wed Feb 22 10:18:44 GMT 2006
running: cat /proc/meminfo
MemTotal:      1035652 kB
MemFree:        341992 kB
Buffers:         76716 kB
Cached:         404248 kB
SwapCached:          0 kB
Active:         355444 kB
Inactive:       291004 kB
HighTotal:      130516 kB
HighFree:          260 kB
LowTotal:       905136 kB
LowFree:        341732 kB
SwapTotal:     1036152 kB
SwapFree:      1036152 kB
Dirty:               0 kB
Writeback:           0 kB
Mapped:         245268 kB
Slab:            36580 kB
CommitLimit:   1553976 kB
Committed_AS:   397780 kB
PageTables:       1924 kB
VmallocTotal:   114680 kB
VmallocUsed:      7784 kB
VmallocChunk:   106852 kB

Wed Feb 22 10:18:44 GMT 2006
running: cat /proc/ipipe/Linux
Priority=100, Id=0x00000000
irq0-216: accepted
irq217: grabbed, sticky
irq218-223: accepted
irq224: grabbed, virtual

Wed Feb 22 10:18:44 GMT 2006
running: cat /proc/ipipe/version
1.1-03

Wed Feb 22 10:18:44 GMT 2006
running: generate_loads 1
dd workload started, pids 16164

Wed Feb 22 10:18:44 GMT 2006
running: cat /proc/interrupts
           CPU0       CPU1
  0:     545839          0    IO-APIC-edge  timer
  1:       6016          0    IO-APIC-edge  i8042
  7:          0          0    IO-APIC-edge  parport0
  8:          2          0    IO-APIC-edge  rtc
  9:          0          0   IO-APIC-level  acpi
 14:      29223          0    IO-APIC-edge  ide0
 15:      83917          0    IO-APIC-edge  ide1
 16:        201          0   IO-APIC-level  uhci_hcd:usb4
 17:          5          0   IO-APIC-level  ehci_hcd:usb1
 18:         13          0   IO-APIC-level  uhci_hcd:usb2
 19:      42101          0   IO-APIC-level  uhci_hcd:usb3
 20:          3          0   IO-APIC-level  ohci1394
NMI:          0          0
LOC:     546184     546211
ERR:          0
MIS:          0

Wed Feb 22 10:18:44 GMT 2006
running: cat /proc/loadavg
0.02 0.48 0.63 2/133 16168

Wed Feb 22 10:18:44 GMT 2006
running: top -bn1c
top - 10:18:44 up 36 min,  4 users,  load average: 0.02, 0.48, 0.63
Tasks: 135 total,   2 running, 133 sleeping,   0 stopped,   0 zombie
Cpu(s):  3.8% us, 27.0% sy,  0.0% ni, 65.9% id,  3.3% wa,  0.0% hi,  0.0% si
Mem:   1035652k total,   693916k used,   341736k free,    76716k buffers
Swap:  1036152k total,        0k used,  1036152k free,   404248k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
16164 root      25   0  2572  544  472 R 97.8  0.1   0:00.51 dd if /dev/zero of
13525 root      15   0  112m  21m 5088 S  5.9  2.1   0:30.74 /usr/bin/X -noliste
    1 root      16   0  1440  484  424 S  0.0  0.0   0:01.43 init [3]

Wed Feb 22 10:18:44 GMT 2006
running: ./run -- -h -q -s -T 10
*
*
* Type ^C to stop this application.
*
*
== Sampling period: 100 us
running quietly for 10 seconds
---|--param|----range-|--samples
HSD|    min|   3 -  4 |        2
HSD|    min|   4 -  5 |        7
---|--param|----range-|--samples
HSD|    avg|   3 -  4 |        2
HSD|    avg|   4 -  5 |    32138
HSD|    avg|   5 -  6 |    66737
HSD|    avg|   6 -  7 |     1051
HSD|    avg|   7 -  8 |       41
HSD|    avg|   8 -  9 |        6
---|--param|----range-|--samples
HSD|    max|   6 -  7 |        2
HSD|    max|   7 -  8 |        6
HSD|    max|   8 -  9 |        1
HSH|--param|--samples-|--average--|---stddev--
HSS|    min|         9|      3.778|      0.441
HSS|    avg|     99975|      4.690|      0.488
HSS|    max|         9|      6.889|      0.601
---|------------|------------|------------|--------|-------------------------
RTS|        3898|        5111|        8598|       0|    00:00:10/00:00:10

Wed Feb 22 10:18:56 GMT 2006
running: ./run -- -h -q -s -T 10
*
*
* Type ^C to stop this application.
*
*
HSH|--param|----range-|--samples
HSD|    min|   2 -  3 |       10
HSH|--param|----range-|--samples
HSD|    avg|   2 -  3 |       10
HSH|--param|----range-|--samples
HSD|    max|   3 -  4 |        7
HSD|    max|   4 -  5 |        2
HSD|    max|   5 -  6 |        1
HSH|--param|--samples-|--average--|---stddev--
HSS|    min|        10|      2.000|      0.000
HSS|    avg|        10|      2.000|      0.000
HSS|    max|        10|      3.400|      0.699
---|------------|------------|------------|--------|-------------------------
RTS|        2099|        2366|        5953|       0|    00:00:10/00:00:10

Wed Feb 22 10:19:09 GMT 2006
running: cat /proc/interrupts
           CPU0       CPU1
  0:     552059          0    IO-APIC-edge  timer
  1:       6017          0    IO-APIC-edge  i8042
  7:          0          0    IO-APIC-edge  parport0
  8:          2          0    IO-APIC-edge  rtc
  9:          0          0   IO-APIC-level  acpi
 14:      29283          0    IO-APIC-edge  ide0
 15:      85022          0    IO-APIC-edge  ide1
 16:        201          0   IO-APIC-level  uhci_hcd:usb4
 17:          5          0   IO-APIC-level  ehci_hcd:usb1
 18:         13          0   IO-APIC-level  uhci_hcd:usb2
 19:      42301          0   IO-APIC-level  uhci_hcd:usb3
 20:          3          0   IO-APIC-level  ohci1394
NMI:          0          0
LOC:     552402     552432
ERR:          0
MIS:          0

Wed Feb 22 10:19:09 GMT 2006
running: cat /proc/loadavg
0.35 0.52 0.64 19/165 17304

Wed Feb 22 10:19:09 GMT 2006
running: top -bn1c
top - 10:19:10 up 36 min,  4 users,  load average: 0.35, 0.52, 0.64
Tasks: 135 total,   2 running, 133 sleeping,   0 stopped,   0 zombie
Cpu(s):  3.7% us, 27.3% sy,  0.0% ni, 65.7% id,  3.2% wa,  0.0% hi,  0.0% si
Mem:   1035652k total,   696256k used,   339396k free,    76884k buffers
Swap:  1036152k total,        0k used,  1036152k free,   404420k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
16164 root      25   0  2572  544  472 R 72.8  0.1   0:24.55 dd if /dev/zero of
 3382 root      18  -4  1672  500  316 S  1.6  0.0   0:00.91 /sbin/udevd --daemo
17309 root      18   0  2024 1024  724 R  1.6  0.1   0:00.02 top -bn1c
host bin # 

This Xenomai test script places test loading on the system by running dd. You will notice a marked increase in system load. However, the script does not kill the load on exit. You will still notice an extra unnecessary load when the command prompt returns. Run the test many times and you will get many extra dd processes. The dd processes do eventually exit by themselves. However you can kill them manually using

host bin # killall dd
host bin # 

This assumes you are not, or someone else is not, running dd for another reason!

You can run other tests by changing directory to the Xenomai real-time test suite subdirectories then entering xeno-load. It loads the Xenomai kernel modules then runs the test program; xeno-load looks for .runinfo in the current working directory which tells it which modules to load and which binary to run. Example follows.

host ~ # cd /usr/realtime/testsuite/latency/
host latency # xeno-load

Running Without Root Privileges

Normally, Xenomai requires root privileges in order to run. The reason? Running hard real-time software requires special modules active within the running kernel. The xeno-load script inserts the necessary modules before running a given piece of software, unloads the modules upon exit. Ordinary users cannot insert kernel modules. This creates a minor problem but not one you cannot easily work around. A number of solutions exist.

One way is to allow module insertion via sudo. The xeno-load script runs insmod via sudo! Just add the following line to your /etc/sudoers; it grants access to module insertion without password entry for all members of the wheel group who log in locally.

%wheel localhost=NOPASSWD: /sbin/insmod

After adding this, local members of wheel can run xeno-load as they would any ordinary program.

Module insertion is not the only root-privilege issue. Hard real-time tasks also require memory locking to prevent swapping out to secondary storage. Swapping out requires use of operating system functions outside the real-time domain, therefore must not happen in real time. Real-time tasks normally avoid swapping by allocating physical rather than virtual memory, i.e. by page locking which is a privileged function. Root user can lock any amount of memory pages but not so for ordinary users. Run ulimit to see your user locking limits. Notice max locked memory.

user@host ~ $ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
file size               (blocks, -f) unlimited
pending signals                 (-i) 8187
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 8187
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
user@host ~ $ 

In this instance, my Linux box will allow only 32 kilobytes of locked memory per process. This offers more than enough lockable space for most applications but not enough for real-time processes wishing to lock their entire memory space.

As a multi-user system, Linux imposes these limitations on processes so as to provide sufficient resources without allowing overuse or abuse. You can increase default resource limits by editing /etc/security/limits.conf. Add lines like the following.

@wheel soft memlock 10000
@wheel hard memlock 100000

These assign soft memory lock limit of 10,000 kilobytes, 10 megabytes; processes can increase their soft limits if necessary. Processes can decrease their hard limits but never increase them, so 100 megabytes maximum. These limits apply to members of the wheel group. The @ symbol indicates a group. You can also assign limits to individual users or everyone. One final note however: the login process assigns the initial limits which subsequent processes inherit. Therefore, after altering the limits, you will need to login again before the new limits can apply.

Ebuild Scripts

ADEOS-IPIPE

Listing below gives the ebuild script for installing ADEOS-IPIPE on Gentoo. Its package category is sys-kernel because it installs kernel sources. Therefore it should appear under the Portage tree at sys-kernel/ipipe-sources. You can also download the script here.

File: ipipe-sources-2.6.15-r1.ebuild
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /cvs/xenomm/xenomm/portage/sys-kernel/ipipe-sources/ipipe-sources-2.6.15-r1.ebuild,v 1.2 2006/02/10 22:59:12 royratcliffe Exp $

ETYPE="sources"
K_WANT_GENPATCHES="base extras"
# Note that the patch version number and the package revision do not
# necessarily coincide!  Compare gentoo-sources and other kernel
# ebuild scripts.  In our case, package revision numbers correspond
# to kernel version, Gentoo patch version, ADEOS-IPIPE version and
# patch number as follows.
#
#             | kernel | genpatches | ipipe
#   ----------+--------+------------+-------
#   2.6.14-r1 | 2.6.14 | 14-4       | 1.0-11
#   2.6.14-r2 | 2.6.14 | 14-8       | 1.1-02
#   2.6.15-r1 | 2.6.15 | 15-3       | 1.1-03
#
# See
#	http://dev.gentoo.org/~dsd/genpatches/
#	http://download.gna.org/adeos/patches/v2.6/i386/
#	http://download.gna.org/xenomai/stable/
K_GENPATCHES_VER="3" # used by gentoo-sources-2.6.15-r1
IUSE=""
inherit kernel-2
detect_version
#
#	detect_arch
#
# Ignore architecture issues at this stage; the ebuild's initial
# revision supports x86 architecture only.  Not tested with any other.

#           _____  ______ ____   _____     _____ _____ _____ _____  ______
#     /\   |  __ \|  ____/ __ \ / ____|   |_   _|  __ \_   _|  __ \|  ____|
#    /  \  | |  | | |__ | |  | | (___ ______| | | |__) || | | |__) | |__
#   / /\ \ | |  | |  __|| |  | |\___ \______| | |  ___/ | | |  ___/|  __|
#  / ____ \| |__| | |___| |__| |____) |    _| |_| |    _| |_| |    | |____
# /_/    \_\_____/|______\____/|_____/    |_____|_|   |_____|_|    |______| 1.1-03
#

IPIPE_MAJOR_NUMBER="1"
IPIPE_MINOR_NUMBER="1"
IPIPE_PATCH_NUMBER="03"
IPIPE_ARCH_STRING="${IPIPE_MAJOR_NUMBER}.${IPIPE_MINOR_NUMBER}-${IPIPE_PATCH_NUMBER}"
IPIPE_PATCH="adeos-ipipe-${PV}-i386-${IPIPE_ARCH_STRING}.patch"
IPIPE_PATCH_URI="http://download.gna.org/adeos/patches/v2.6/i386/${IPIPE_PATCH}"
UNIPATCH_LIST="${DISTDIR}/${IPIPE_PATCH}"
#
#	UNIPATCH_STRICTORDER="yes"
#
# Perhaps patch ordering is a legitimate concern.  The IPIPE patch
# applies to the vanilla kernel.  So logically this patch should apply
# first.  Also logically however, the Gentoo patches also apply to the
# vanilla kernel!  Provided the patches do not interfere with one
# another, let them run in any order.  These versions have no problems.

KEYWORDS="x86"
HOMEPAGE="http://home.gna.org/adeos/ http://dev.gentoo.org/~dsd/genpatches/"
DESCRIPTION="Kernel sources including Gentoo patchset on top of ADEOS-IPIPE nanokernel"
SRC_URI="${KERNEL_URI} ${GENPATCHES_URI} ${ARCH_URI} ${IPIPE_PATCH_URI}"

Xenomai

You can also download the script here.

File: xenomai-2.0.3.ebuild
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /cvs/xenomm/xenomm/portage/sys-libs/xenomai/xenomai-2.0.3.ebuild,v 1.1 2006/02/22 10:28:56 royratcliffe Exp $

inherit eutils

DESCRIPTION="Pervasive, interface-agnostic, hard real-time support"
HOMEPAGE="https://gna.org/projects/xenomai/"
SRC_URI="http://download.gna.org/xenomai/stable/${P}.tar.bz2"
IUSE="nucleus-ishield native-mps rtai-skin posix-skin vxworks-skin psos-skin uitron-skin rtdm-skin vrtx-skin user-vm uart-16550A udev"
KEYWORDS="x86"

DEPEND=">=ipipe-sources-2.6.15-r1"

src_unpack() {
	unpack ${A}
	epatch ${FILESDIR}/${P}.patch || die "epatch failed"
}

# On purpose, this ebuild does not use econf, emake or einstall.  The
# good reason: these specify --prefix=/usr without any way to
# override.  However, this ebuild allows Xenomai to apply its default
# prefix of /usr/realtime.  Therefore compile and install using the
# usual sequence of
#
#	./configure
#	make
#	make DESTDIR=image install

src_compile() {
        local myconf=""
        use rtai-skin && myconf="${myconf} --enable-rtai-skin --enable-rtai-fifo --enable-rtai-shm --enable-rtai-sem "
        ./configure ${myconf} \
                $(use_enable vxworks-skin) \
                $(use_enable posix-skin) \
                $(use_enable nucleus-ishield) \
                $(use_enable psos-skin) \
                $(use_enable uitron-skin) \
                $(use_enable rtdm-skin) \
                $(use_enable vrtx-skin) \
                $(use_enable uart-16550A) \
                $(use_enable user-vm) \
                $(use_enable udev) \
                $(use_enable native-mps) || die "configure failed"
	make || die "make failed"
}

src_install() {
	make DESTDIR=${D} install || die "make install failed"
	# Installation makes symbolic links to source locations in
	# /var/tmp/portage which disappears after installation, so remove
	# the unwanted sym-links.
	rm ${D}/usr/realtime/build ${D}/usr/realtime/source ${D}/usr/realtime/symbols

	dodir /etc/env.d
	>>${D}/etc/env.d/00xenomai echo "ROOTPATH=/usr/realtime/bin"
	>>${D}/etc/env.d/00xenomai echo "PATH=/usr/realtime/bin"
	>>${D}/etc/env.d/00xenomai echo "LDPATH=/usr/realtime/lib"
	>>${D}/etc/env.d/00xenomai echo "MANPATH=/usr/realtime/man"
}

You can also download the patch here. If you cut the patch from the wiki page, make sure you cut everything between the pre and /pre tags.

File: xenomai-2.0.3.patch
diff -Naur -x '*~' xenomai-2.0.3/scripts/xeno-info xenomai-2.0.3-new/scripts/xeno-info
--- xenomai-2.0.3/scripts/xeno-info	2005-10-08 17:00:42.000000000 +0100
+++ xenomai-2.0.3-new/scripts/xeno-info	2005-12-06 20:42:48.000000000 +0000
@@ -54,7 +54,7 @@
 -e 's/\.so$//' | awk -F'[.-]'   '{print "Linux C Library        " \
 $(NF-2)"."$(NF-1)"."$NF}'
 
-ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -1 | awk \
+ldd -v > /dev/null 2>&1 && ldd -v || ldd --version |head -n 1 | awk \
 'NR==1{print "Dynamic linker (ldd)  ", $NF}'
 
 ls -l /usr/lib/lib{g,stdc}++.so  2>/dev/null | awk -F. \
diff -Naur -x '*~' xenomai-2.0.3/scripts/xeno-load.in xenomai-2.0.3-new/scripts/xeno-load.in
--- xenomai-2.0.3/scripts/xeno-load.in	2005-10-08 17:00:42.000000000 +0100
+++ xenomai-2.0.3-new/scripts/xeno-load.in	2005-12-06 20:42:47.000000000 +0000
@@ -56,7 +56,7 @@
 fi
 
 if test $target_name = default; then
-  target_name=`cut -s -d: -f1 $run_info_file | head -1`
+  target_name=`cut -s -d: -f1 $run_info_file | head -n 1`
   if test "x$target_name" = x; then
      echo "xeno-load: no target defined in $run_info_file"
      exit 2
diff -Naur -x '*~' xenomai-2.0.3/scripts/xeno-test.in xenomai-2.0.3-new/scripts/xeno-test.in
--- xenomai-2.0.3/scripts/xeno-test.in	2005-10-10 12:10:48.000000000 +0100
+++ xenomai-2.0.3-new/scripts/xeno-test.in	2005-12-06 20:42:48.000000000 +0000
@@ -88,7 +88,7 @@
     loudly cat /proc/interrupts
     loudly cat /proc/loadavg
     [ -n "$prepost" ] && loudly $prepost
-    loudly top -bn1c | head -$(( 12 + $workload ))
+    loudly top -bn1c | head -n $(( 12 + $workload ))
 }
 
 

Troubleshooting

What should I do if...

Wrong Module Versions

This can happen if you compile your kernel with one version of the compiler but Xenomai with another! Check your logs using

tail /var/log/messages

or

dmesg | tail

You will see messages about version magic is such-and-such but should be some other such-and-such! You select the current compiler version using gcc-config. Use

gcc-config -l

to list which compiler versions you have installed.

Solution: either recompile the kernel or Xenomai with matching compiler version. Thereafter, you can insert the modules without problems.

References and Links

Gna!

Xenomai

Adeos

Feedback

Concerns or Compliments? Please use the Discussion section.

Retrieved from "http://www.gentoo-wiki.info/HOWTO_ADEOS-IPIPE_and_Xenomai"

Last modified: Thu, 09 Nov 2006 06:59:00 +0000 Hits: 9,100