[Home]Debian Squeeze Compile RTAI

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Difference (from prior major revision) (no other diffs)

Changed: 5c5
* [Linuxcnc.org: Debian Lenny Compile RTAI]
* [Linuxcnc.org: Debian Lenny Compile RTAI]

Building EMC2 and RTAI kernel packages in Debian testing

I use the following for reference:

The current instructions on the above linuxcnc.org link do not work for me; the --added-patches parameter was removed from

 make-kpkg in debian/testing sometime in early 2009.

These notes are net yet finished or complete.

Starting

Hopefully, you are using a full-functional Debian install on real hardware, preferably the same architecture as you intend to use these packages on. Realtime operations are not possible in a virtual machine, and cross-compiling can introduce problems beyond the scope of this article.

Update and get necessary packages

su -
aptitude update && aptitude safe-upgrade
aptitude install \\
         kernel-package \\
         build-essential \\
         dh-make \\
         module-assistant \\
         libncurses5-dev \\
         zlib1g-dev \\
         dh-kpatches \\
         fakeroot \\
         autoconf

Configuration

Udev

RTAI modules create rtai_shm and rtf* devices when they are loaded. We need to create a Udev rule file for these devices.

touch /etc/udev/rules.d/92-rtai.rules

Edit /etc/udev/rules.d/92-rtai.rules with your favorite editor.

ACTION!="add|change", GOTO="rtai_end"

KERNEL=="rtf*",                 MODE="0667"
KERNEL=="rtai*",                MODE="0666"

LABEL="rtai_end"

Memlock Size

The default amount of the maximum locked-in-memory address space size is 32 KB in Debian Lenny. But this is not enough for some applications. For example the memlock size has to be more than 2048 KB for EMC2. Therefore increase the memlock size if you get the segmentation fault because of the inadequate memlock size.

Edit /etc/security/limits.conf with your favorite editor. Add the following line
*       hard    memlock 8192

Adding the user to the src group

Add your user account to the src group. This is needed to have the write access for /usr/src directory.
adduser your_user_name src

Logout and re-login for the change to take effect.

Getting the source packages

Use your normal user account to do the followings

cd
mkdir rtai
cd rtai

Getting the sources

Getting the kernel source

wget ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.30.5.tar.bz2
tar xjf linux-2.6.30.5.tar.bz2 -C /usr/src

Getting the RTAI source

NOTE: rtai_3.7.1.orig.tar.gz is the daily snapshot (07 Sep 2009) of the RTAI's Vulcano repository. The name of the source tarball must be as <packagename>_<upstream_version>.orig.tar.gz to Debianize

wget http://linuxcnc.org/experimental/lenny/rtai_3.7.1.orig.tar.gz
tar zxf rtai_3.7.1.orig.tar.gz

Getting the Debianization patch

The patch file contains all the changes to Debianize the original RTAI source.

This patch from http://packages.debian.org/sid/rtai does not completely work.

I've made a patch of my own, available at http://dl.coldelectrons.com/rtai_3.7.1-2.1.diff.gz

wget http://linuxcnc.org/experimental/lenny/rtai_3.7.1-2.1.diff.gz
cd rtai-3.7.1/
gunzip -c ../rtai_3.7.1-2.1.diff.gz | patch -p1 --dry-run
gunzip -c ../rtai_3.7.1-2.1.diff.gz | patch -p1
chmod u+x debian/rules

Building the packages

The RTAI packages

Building the RTAI packages

dpkg-buildpackage -rfakeroot -uc

The following files will be built in the upper directory:

    * librtai1_3.7.1-2_i386.deb
    * librtai-dev_3.7.1-2_i386.deb
    * rtai_3.7.1-2.diff.gz
    * rtai_3.7.1-2.dsc
    * rtai_3.7.1-2_i386.changes
    * rtai_3.7.1-2_i386.deb
    * rtai-doc_3.7.1-2_all.deb
    * rtai-source_3.7.1-2_i386.deb

Installing the RTAI packages

cd ..
su
dpkg -i librtai1_3.7.1-2_i386.deb
dpkg -i librtai-dev_3.7.1-2_i386.deb
dpkg -i rtai-source_3.7.1-2_i386.deb
exit

The kernel packages

Building the kernel packages

cd /usr/src/linux-2.6.30.5
make-kpkg clean

make-kpkg (AFAIK) is still considered broken by debian-devs, and currently lacks a way to handle patches.

Luckily, when we installed rtai-source previously, it places in /usr/src/kernel-patches not only the patches we need, but also a script to handle the patching. This doesn't seem to matter much, because make-kpkg is broken. You could also manually patch the kernel source - I don't think it makes much difference right now.

../kernel-patches/i386/apply/rtai

If you're building for amd64, change the arch in the above line.

time fakeroot make-kpkg --initrd \
         --append-to-version -rtai \
         --revision r1 \
         --added-patches rtai \
         --config menuconfig \
         kernel-image \
         kernel-headers \
         kernel-source

Configuring the kernel

 Enable loadable module support ---> enabled [*]
 Loadable module support ---> Module versioning support ---> disabled
 Processor type and features ---> HPET Timer Support ---> disabled
 Processor type and features ---> Interrupt pipeline ---> enabled [*]
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> enabled [*]
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Deprecated /proc/acpi files ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Deprecated power /proc/acpi directories ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Future power /sys interface ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Deprecated /proc/acpi/event support ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> AC Adapter ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Battery ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Button ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Video ---> module [M]
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Fan ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Dock ---> enabled [*]
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Processor ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Disable ACPI for systems before Jan 1st this year ---> 0
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Debug Statements ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> PCI slot detection driver ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Container and Module Devices ---> disabled
 Power management and ACPI options ---> ACPI (Advanced Configuration and Power Interface) Support ---> Smart Battery System ---> disabled
 Power management and ACPI options ---> APM (Advanced Power Management) BIOS support ---> disabled
 Power management and ACPI options ---> CPU Frequency scaling ---> disabled

Choose the most suitable processor family for your machine. For example, for a Pentium-III processor: Processor type and features ---> Processor family ---> Pentium-III / Celeron(Coppermine) / Pentium-III Xeon

If you have a multi cores CPU or SMP system, don't choose a processor family which has no TSC (time stamp counter). This means that for example you can not choose 586/K5/5x86/6x86/6x86MX as Processor family if you have a dual cores CPU. In conclusion, choose the most suitable processor family for your machine.

NOTE: No need to disable High Memory Support for RTAI 3.7.1 and newer

NOTE: No need to disable Symmetric multi-processing support for the uniproccesor machine for RTAI 3.7.1 and newer. But if you don't have a multi cores CPU or SMP system, you can disable it to improve the performance

NOTE: I've been told in the EMC-developers list that RTAI 3.7.1 and newer does not need Module Versioning Support to be disabled.

NOTE: Because make-kpkg does not do proper hooks to generate an initrd, I like to configure my kernel with the filesystem I'm using built-in. I also like to pare down the modules and drivers to the minimum - after all, do I really need telephony, DVB, infiniband, etc., on a system that's strictly going to be my CNC controller? There may be no real benefit, except that on the older machines I'm using it may cut the compile time down.

After to finish all changes, save and exit from menuconfig.

Installing the kernel packages

cd /usr/src
su
dpkg -i linux-image-2.6.30.5-rtai_r1_i386.deb
dpkg -i linux-headers-2.6.30.5-rtai_r1_i386.deb
rm linux
ln -s linux-headers-2.6.30.5-rtai linux

NOTE: If you have a SMP system, dedicate the last core/CPU to the realtime tasks, resulting in a significant increase in performance.

Edit /boot/grub/menu.lst and add isolcpus parameter to the end of the kernel line of the RTAI kernel.

This is the kernel line for my dual core machine

kernel /vmlinuz-2.6.30.5-rtai root=/dev/sda5 ro isolcpus=1

Boot with the new RTAI kernel.

The RTAI kernel modules package

Building the RTAI kernel modules package

cd /usr/src
tar jxf rtai-source.tar.bz2
cd /usr/src/linux

You can use make-kpkg:
fakeroot make-kpkg --append-to-version -rtai --revision r1 --added-modules rtai --config menuconfig modules_image

Or you can use modules-assistant, but without the ability to configure rtai:
m-a a-i rtai

Configuring the RTAI kernel modules

If the total number of CPUs/cores is more than 2, increase the value of CONFIG_RTAI_CPUS parameter. It's a good idea to set this value to 8 if you want to distribute your deb package.

Machine (x86) ===> Number of CPUs (SMP-only) ===> 8

For EMC2 2.3 and newer, enable CONFIG_RTAI_MATH parameter. Base system ===> Other features ===> Mathfuns support in kernel ===> enabled

Default values are OK for other parameters. Save and exit. [edit] Installing the RTAI kernel modules package

cd /usr/src
su
dpkg -i rtai-modules-2.6.30.5-rtai_3.7.1-2.1+r1_i386.deb

Regenerate the kernel module dependencies

The package, as made with my patch, should put rtai-modules under /lib/modules/`uname -r`/...

Do we need to do this?
cd /usr/src/linux
cp Module.symvers Module.symvers.old
cat /usr/realtime/modules/Module.symvers >> Module.symvers
ln -s /usr/realtime/modules/ /lib/modules/2.6.30.5-rtai/rtai

depmod -a

Testing RTAI

cd /usr/realtime/testsuite/user/latency; time ./run
cd /usr/realtime/testsuite/user/preempt/; time ./run
cd /usr/realtime/testsuite/user/switches/; ./run
cd /usr/realtime/testsuite/kern/latency/; time ./run
cd /usr/realtime/testsuite/kern/preempt/; time ./run
cd /usr/realtime/testsuite/kern/switches/; ./run

If you have a problem with test results, see [RTAI Latency Test]

Your RTAI system is ready now. You can continue from Debian Lenny Compile EMC2


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited July 8, 2012 12:31 am by Archivist (diff)
Search:
Published under a Creative Commons License