User Tools

Site Tools



This guide will help you compile and install all the packages needed to use RTAI with Comedi, ScicosLab and qRtaiLab on an Ubuntu Jaunty machine. Always check if newer versions can be found on their websites, and adjust commands as required.



sudo apt-get install cvs subversion build-essential


sudo apt-get install kernel-package linux-source libncurses5-dev


sudo apt-get install libtool automake


sudo apt-get install bison flex


sudo apt-get install libboost-dev libboost-program-options-dev libgsl0-dev


sudo apt-get install libgtk2.0-dev libgail18 gfortran


sudo apt-get install libqt4-dev libqwt5-qt4-dev

Getting the source code

Kernel sources ([]):

cd /usr/src

sudo wget

sudo tar xjvf linux-

sudo ln -s linux- linux

RTAI ([] cvs-version):

cd /usr/src

sudo cvs co magma

sudo ln -s magma rtai

RTAI ([] tar.gz-version). You have to use version 3.7 or newer, because older versions are not compatible with gcc 4.3.3:

cd /usr/src

sudo wget --no-check-certificate

sudo tar xjvf rtai-3.8.tar.bz2

sudo ln -s rtai-3.8 rtai

COMEDI ([]):

cd /opt

sudo cvs -d login

sudo cvs -d co comedi

sudo cvs -d co comedilib

sudo cvs -d co comedi_calibrate

sudo cvs -d co comedi-nonfree-firmware

ScicosLab ([]):

cd /opt

sudo wget

QRTAILab ([] svn - version):

cd /opt

sudo svn co qrtailab


QRTAILab ([] tar.gz - version):

cd /opt

sudo wget

sudo tar xvzf QRtaiLab-0.1.9.tar.gz

Kernel creation

Patching the kernel

Patch the Linux kernel so it will run in real time mode:

cd /usr/src/linux

sudo su

patch -p1 < /usr/src/rtai/base/arch/x86/patches/hal-linux-

Getting your kernel configuration

At first you should find out which architecture are you using:

dpkg --print-architecture

For i386: A sample config-file for i386 is available from [ here]:

cd /usr/src/linux

sudo wget

sudo cp config-2.6.28-rtai_i386 .config

But it’s better if you just copy the configuration file from your running kernel:

sudo cp /boot/gedit config-`uname -r` .config

For amd64: Sorry, there is no sample config file.

Kernel configuration

Go ahead and configure your kernel before you compile it:

cd /usr/src/linux

sudo make menuconfig

Run lspci on a separate console window, refer to it to select the appropriate option on the kernel configuration, mostly related to manufacturer (e.g.: SATA Controller from Intel or VIA). Check and change if needed the following points:

*Inside Processor type and features: Symmetric multi-processing support (multiprocessor) Processor family *Inside Device Drivers: Network device support → Ethernet (XXXX Mbit) Network device support → Wlan Graphics support → /dev/agpgart (AGP Support) Sound card support → Advanced Linux Sound Architecture → PCI sound devices

We used a server with two Xeon 1.7 GHz processors, so we checked that:

[*] Symmetric multi-processing support 


(X) Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon

looked like this:

Processor family (Pentium-4/Celeron(P4-based)/Pentium-4 M/older Xeon

Compiling the kernel

cd /usr/src/linux

sudo make-kpkg clean

sudo make-kpkg --initrd kernel_image kernel_headers kernel_source

Kernel installation


cd /usr/src

sudo dpkg -i linux-headers-

sudo dpkg -i linux-image-


cd /usr/src

sudo dpkg -i linux-headers-

sudo dpkg -i linux-image-

Reboot in the new compiled RTAI kernel.

sudo reboot

Installing RTAI

You need to do this twice do to dependencies.


cd /usr/src/rtai

sudo make menuconfig

Be sure that the directories are correct: *Installation: /usr/realtime *Kernel source: /usr/src/linux *Under Machine, choose number of CPUs (check running cat /proc/cpuinfo and verifying how many processors are listed, we chose 2)

Note: with kernel 2.26.3 it was also required to unselect “In-Kernel C++ Support” under “Add-Ons”

Compile RTAI:

sudo make

sudo make install

sudo sed -i 's/\(PATH=\"\)/\1\/usr\/realtime\/bin:/' /etc/environment

Now run 'export PATH=/usr/realtime/bin:$PATH' for each open shell or do a logout and login.

Test RTAI:

cd /usr/realtime/testsuite/kern/latency


Type ctrl-c to stop execution.

= Installing Comedi= In order to install Comedi, you need to install Comedilib and Comedi-calibrate.


cd /opt/comedilib

sudo sh

sudo ./configure --with-udev-hotplug=/lib --sysconfdir=/etc

sudo make

sudo make install


cd /opt/comedi_calibrate

sudo autoreconf -i -B m4

sudo ./configure

sudo make

sudo make install

To calibrate your card, use comedi_calibrate, or comedi_soft_calibrate if you have a M-series NI card.


cd /opt/comedi

sudo sh

sudo ./configure --with-linuxdir=/usr/src/linux --with-rtaidir=/usr/realtime --enable-pci --disable-pcmcia

sudo make

sudo make install

sudo make dev

This is necessary for pcmcia-daq-cards (enable pcmcia in past configure command):

sudo su

echo 'options comedi comedi_num_legacy_minors=4' > /etc/modprobe.d/comedi


Installing RTAI + Comedi

Now you can go ahead and reinstall RTAI with Comedi support.


cd /usr/src/rtai

sudo make menuconfig

Under “Add-Ons”, select:

[*] Real Time COMEDI support in user space

Menu RTAI-Lab:

[*] RTAI Lab 

Adjust EFLTK installation directory (default is /usr/local). Exit menuconfig and save configuration. Now do:

sudo cp /opt/comedi/include/linux/comedi.h /usr/local/include/

sudo cp /opt/comedi/include/linux/comedilib.h /usr/local/include/

sudo ln -s /usr/local/include/comedi.h /usr/local/include/linux/comedi.h

sudo ln -s /usr/local/include/comedilib.h /usr/local/include/linux/comedilib.h

sudo make

sudo make install


Create a shell script



and copy the following with “Crtl+Shift v”:

insmod /usr/realtime/modules/rtai_hal.ko
insmod /usr/realtime/modules/rtai_lxrt.ko 
insmod /usr/realtime/modules/rtai_up.ko        # or rtai_lxrt.ko
insmod /usr/realtime/modules/rtai_fifos.ko
insmod /usr/realtime/modules/rtai_sem.ko
insmod /usr/realtime/modules/rtai_mbx.ko
insmod /usr/realtime/modules/rtai_msg.ko
insmod /usr/realtime/modules/rtai_netrpc.ko ThisNode=""
insmod /usr/realtime/modules/rtai_shm.ko
insmod /usr/realtime/modules/rtai_tasklets.ko
modprobe comedi
modprobe kcomedilib
modprobe comedi_fc
modprobe ni_pcimio
insmod /usr/realtime/modules/rtai_comedi.ko

Close it, make it executable and run it:

sudo chmod 777

sudo sh 

Finally, run the test:

cd /usr/realtime/testsuite/kern/latency


Type ctrl-c to stop execution.

ScicosLab + RTAI-Lab add-ons

Install ScicosLab:

cd /opt

sudo dpkg -i /tmp/scicoslab-gtk_4.3-3_i386.jaunty.deb

Install RTAI-Lab add-ons as root and as user:

cd /usr/local/src/rtai/rtai-lab/scilab/
sudo make install # to install rtmain.c in /usr/realtime/share/rtai/scicos
cd ../scicoslab/macros
sudo su -c "make install"
make user


installing_rtai_comedi_scicoslab_qrtailab_on_ubuntu_9.04.txt · Last modified: 2017/01/03 21:29 by admin