RTAI and RTnet from sources

RTAI installation on Debian (from sources)

For automated installation from built-in packages, go here.

Debian utils packages installation
su -
aptitude update && aptitude safe-upgrade
aptitude install kernel-package \
build-essential dh-make module-assistant \
libncurses5-dev zlib1g-dev dh-kpatches \
fakeroot autoconf
Udev
RTAI modules create devices rtai_sham et rtf*. You need to add them to udev:
touch /etc/udev/rules.d/92-rtai.rules
Edit this file as follow:
ACTION!="add|change", GOTO="rtai_end"
KERNEL=="rtf*", MODE="0666"
KERNEL=="rtai*", MODE="0666"
LABEL="rtai_end"
Memlock Size
Amount of locked memory in address space is 32Kb under Debian. You need to increase it for real-time use. Edit /etc/security/limits.conf and add this line at the end :
* hard memlock 8192
Add user to src group
Add your user account to src group in order to have access to directory /usr/src
adduser your_user_name src
Close your session and then reconnect for changes applying.

Get sources packages
Use normal user account (non root account) for these steps.
cd
mkdir rtai
cd rtai
Get kernel sources
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
ln -s linux-2.6.30.5/ /usr/src/linux
Get RTAI sources
wget http://trainsim.ebvmultimedia.net/dl/rtai_3.7.1.orig.tar.gz
tar zxf rtai_3.7.1.orig.tar.gz
Get Debian patch
wget http://trainsim.ebvmultimedia.net/dl/rtai_3.7.1-2.diff.gz
cd rtai-3.7.1/
gunzip -c ../rtai_3.7.1-2.diff.gz | patch -p1 --dry-run
gunzip -c ../rtai_3.7.1-2.diff.gz | patch -p1
chmod u+x debian/rules
RTAI packages building
dpkg-buildpackage -rfakeroot -uc
Followings files will be created under parent 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

RTAI packages installation
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
Kernel modules building
cd /usr/src/linux
make-kpkg clean
time fakeroot make-kpkg --initrd \
--append-to-version -rtai \
--revision r1 \
--added-patches rtai \
--config menuconfig \
kernel-image \
kernel-headers \
kernel-source
Kernel configuration
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 processor according to your computer :
Processor type and features ---> Processor family ---> ...
If you have a multi-core processor (SMP), don't choose a processor family without TSC (time stamp counter).


NOTE: No need to deactivate High Memory Support for RTAI 3.7.1 and superiors.
NOTE: No need to deactivate Symmetric multi-processing support for single processor computer for RTAI 3.7.1 and superiors.
At end, save configuration and quit menuconfig.
Kernel packages installation
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 multiprocessor computer (SMP system), dedicate last core/CPU to real-time tasks could increse performances.
Edit /boot/grub/menu.lst and add parameter isolcpus at the end of RTAI kernel line. Paramter value is the number of last processor (counter start from 0) : 1 for dual-core, 3 for quad-core
kernel /vmlinuz-2.6.30.5-rtai root=/dev/sda5 ro isolcpus=1
Reboot your computer.
reboot
Boot with RTAI kernel.
RTAI kernel modules building
cd /usr/src
tar jxf rtai-source.tar.bz2
cd /usr/src/linux
fakeroot make-kpkg --append-to-version -rtai --added-modules rtai \
--config menuconfig modules_image
RTAI kernel modules Configuration
Increse processors number :
Machine (x86) ---> Number of CPUs (SMP-only) ---> 8
Base system ---> Other features ---> Mathfuns support in kernel ---> enabled
Keep other defaults values, save configuration and quit menuconfig.

RTAI kernel modules installation
cd /usr/src
su
dpkg -i rtai-modules-2.6.30.5-rtai_3.7.1-2+r1_i386.deb
Regenerate Linux kernel dependancies
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
RTAI Tests
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




RTnet

Installation


Perform RTAI installation first.
cd /usr/src
wget http://trainsim.ebvmultimedia.net/dl/rtnet-0.9.11.tar.bz2
tar xvjf rtnet-0.9.11.tar.bz2
cd rtnet
make menuconfig
Choose RTAI in configuration.
make
su
make install
run mknod /dev/rtnet c 10 240
Tests
/sbin/rtnet start
rtping