User Tools

Site Tools


installing_rtai_comedi_scicoslab_qrtailab_on_ubuntu_9.04

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

installing_rtai_comedi_scicoslab_qrtailab_on_ubuntu_9.04 [2017/01/03 21:29] (current)
admin created
Line 1: Line 1:
 +===== Introduction =====
 +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.
  
 +==== Dependencies ====
 +**General:​**
 +
 +<​code>​
 +sudo apt-get install cvs subversion build-essential
 +</​code>​
 +
 +**Kernel:**
 +
 +<​code>​
 +sudo apt-get install kernel-package linux-source libncurses5-dev
 +</​code>​
 +
 +**RTAI:**
 +
 +<​code>​
 +sudo apt-get install libtool automake
 +</​code>​
 +
 +**Comedi-lib:​**
 +
 +<​code>​
 +sudo apt-get install bison flex
 +</​code>​
 +
 +**Comedi-calibrate:​**
 +
 +<​code>​
 +sudo apt-get install libboost-dev libboost-program-options-dev libgsl0-dev
 +</​code>​
 +
 +**ScicosLab:​**
 +
 +<​code>​
 +sudo apt-get install libgtk2.0-dev libgail18 gfortran
 +</​code>​
 +
 +**Qrtailab:​**
 +
 +<​code>​
 +sudo apt-get install libqt4-dev libqwt5-qt4-dev
 +</​code>​
 +
 +==== Getting the source code ====
 +Kernel sources ([http://​www.kernel.org kernel.org]):​
 +
 +<​code>​
 +cd /usr/src
 +
 +sudo wget http://​www.kernel.org/​pub/​linux/​kernel/​v2.6/​linux-2.6.28.9.tar.bz2
 +
 +sudo tar xjvf linux-2.6.28.9.tar.bz2
 +
 +sudo ln -s linux-2.6.28.9 linux
 +</​code>​
 +
 +RTAI ([http://​www.rtai.org rtai.org] cvs-version):​
 +
 +<​code>​
 +cd /usr/src
 +
 +sudo cvs -d:​pserver:​anonymous@cvs.gna.org:/​cvs/​rtai co magma
 +
 +sudo ln -s magma rtai
 +</​code>​
 +
 +RTAI ([http://​www.rtai.org rtai.org] tar.gz-version). You have to use version 3.7 or newer, because older versions are not compatible with gcc 4.3.3:
 +
 +<​code>​
 +cd /usr/src
 +
 +sudo wget --no-check-certificate https://​www.rtai.org/​RTAI/​rtai-3.8.tar.bz2
 +
 +sudo tar xjvf rtai-3.8.tar.bz2
 +
 +sudo ln -s rtai-3.8 rtai
 +</​code>​
 +
 +COMEDI ([http://​www.comedi.org comedi.org]):​
 +
 +<​code>​
 +cd /opt
 +
 +sudo cvs -d :​pserver:​anonymous@cvs.comedi.org:/​cvs/​comedi login
 +
 +sudo cvs -d :​pserver:​anonymous@cvs.comedi.org:/​cvs/​comedi co comedi
 +
 +sudo cvs -d :​pserver:​anonymous@cvs.comedi.org:/​cvs/​comedi co comedilib
 +
 +sudo cvs -d :​pserver:​anonymous@cvs.comedi.org:/​cvs/​comedi co comedi_calibrate
 +
 +sudo cvs -d :​pserver:​anonymous@cvs.comedi.org:/​cvs/​comedi co comedi-nonfree-firmware
 +</​code>​
 +
 +ScicosLab ([http://​www.scicoslab.org scicoslab.org]):​
 +
 +<​code>​
 +cd /opt
 +
 +sudo wget http://​cermics.enpc.fr/​~jpc/​scilab-gtk-tiddly/​files/​scicoslab-gtk_4.3-3_i386.jaunty.deb
 +</​code>​
 +
 +QRTAILab ([http://​www.qrtailab.sf.net qrtailab.sf.net] svn - version):
 +
 +<​code>​
 +cd /opt
 +
 +sudo svn co https://​qrtailab.svn.sourceforge.net/​svnroot/​qrtailab/​trunk qrtailab
 +</​code>​
 +
 +or:
 +
 +QRTAILab ([http://​www.qrtailab.sf.net qrtailab.sf.net] tar.gz - version):
 +
 +<​code>​
 +cd /opt
 +
 +sudo wget http://​downloads.sourceforge.net/​qrtailab/​QRtaiLab-0.1.9.tar.gz
 +
 +sudo tar xvzf QRtaiLab-0.1.9.tar.gz
 +</​code>​
 +
 +==== Kernel creation =====
 +=== Patching the kernel ===
 +Patch the Linux kernel so it will run in real time mode:
 +
 +<​code>​
 +cd /​usr/​src/​linux
 +
 +sudo su
 +
 +patch -p1 < /​usr/​src/​rtai/​base/​arch/​x86/​patches/​hal-linux-2.6.28.9-x86-2.2-07.patch
 +</​code>​
 +
 +=== Getting your kernel configuration ===
 +At first you should find out which architecture are you using:
 +
 +<​code>​
 +dpkg --print-architecture
 +</​code>​
 +
 +**For i386:**
 +A sample config-file for i386 is available from [http://​hart.sourceforge.net/​files/​config-2.6.28-rtai_i386 here]:
 +
 +<​code>​
 +cd /​usr/​src/​linux
 +
 +sudo wget http://​hart.sourceforge.net/​files/​config-2.6.28-rtai_i386
 +
 +sudo cp config-2.6.28-rtai_i386 .config
 +</​code>​
 +
 +But it’s better if you just copy the configuration file from your running kernel:
 +
 +<​code>​
 +sudo cp /boot/gedit config-`uname -r` .config
 +</​code>​
 +
 +**For amd64:**
 +Sorry, there is no sample config file.
 +
 +=== Kernel configuration ===
 +Go ahead and configure your kernel before you compile it:
 +
 +<​code>​
 +cd /​usr/​src/​linux
 +
 +sudo make menuconfig
 +</​code>​
 +
 +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:
 +
 +<​code>​
 +[*] Symmetric multi-processing support ​
 +</​code>​
 +
 +and 
 +
 +<​code>​
 +(X) Pentium-4/​Celeron(P4-based)/​Pentium-4 M/older Xeon
 +</​code>​
 +
 +looked like this:
 +
 +<​code>​
 +Processor family (Pentium-4/​Celeron(P4-based)/​Pentium-4 M/older Xeon
 +</​code>​
 +
 +=== Compiling the kernel ===
 +
 +<​code>​
 +cd /​usr/​src/​linux
 +
 +sudo make-kpkg clean
 +
 +sudo make-kpkg --initrd kernel_image kernel_headers kernel_source
 +</​code>​
 +
 +=== Kernel installation ===
 +
 +**i386:**
 +
 +<​code>​
 +cd /usr/src
 +
 +sudo dpkg -i linux-headers-2.6.28.9-rtai_2.6.28.9-rtai-10.00.Custom_i386.deb
 +
 +sudo dpkg -i linux-image-2.6.28.9-rtai_2.6.28.9-rtai-10.00.Custom_i386.deb
 +</​code>​
 +
 +**amd64:**
 +
 +<​code>​
 +cd /usr/src
 +
 +sudo dpkg -i linux-headers-2.6.28.9-rtai_2.6.28.9-rtai-10.00.Custom_amd64.deb
 +
 +sudo dpkg -i linux-image-2.6.28.9-rtai_2.6.28.9-rtai-10.00.Custom_amd64.deb
 +</​code>​
 +
 +Reboot in the new compiled RTAI kernel.
 +
 +<​code>​
 +sudo reboot
 +</​code>​
 +
 +==== Installing RTAI ====
 +You need to do this twice do to dependencies.
 +
 +**RTAI #1**
 +
 +<​code>​
 +cd /​usr/​src/​rtai
 +
 +sudo make menuconfig
 +</​code>​
 +
 +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:**
 +
 +<​code>​
 +sudo make
 +
 +sudo make install
 +
 +sudo sed -i '​s/​\(PATH=\"​\)/​\1\/​usr\/​realtime\/​bin:/'​ /​etc/​environment
 +</​code>​
 +
 +Now run '​export PATH=/​usr/​realtime/​bin:​$PATH'​ for each open shell or do a logout and login.
 +
 +
 +**Test RTAI:**
 +
 +<​code>​
 +cd /​usr/​realtime/​testsuite/​kern/​latency
 +
 +./run
 +</​code>​
 +
 +Type ctrl-c to stop execution.
 +
 += Installing Comedi=
 +In order to install Comedi, you need to install Comedilib and Comedi-calibrate.
 +
 +**Comedilib:​**
 +
 +<​code>​
 +cd /​opt/​comedilib
 +
 +sudo sh autogen.sh
 +
 +sudo ./configure --with-udev-hotplug=/​lib --sysconfdir=/​etc
 +
 +sudo make
 +
 +sudo make install
 +</​code>​
 +
 +**Comedi-calibrate:​**
 +
 +<​code>​
 +cd /​opt/​comedi_calibrate
 +
 +sudo autoreconf -i -B m4
 +
 +sudo ./configure
 +
 +sudo make
 +
 +sudo make install
 +</​code>​
 +
 +To calibrate your card, use comedi_calibrate,​ or comedi_soft_calibrate if you have a M-series NI card.
 +
 +**Comedi:**
 +
 +<​code>​
 +cd /opt/comedi
 +
 +sudo sh autogen.sh
 +
 +sudo ./configure --with-linuxdir=/​usr/​src/​linux --with-rtaidir=/​usr/​realtime --enable-pci --disable-pcmcia
 +
 +sudo make
 +
 +sudo make install
 +
 +sudo make dev
 +</​code>​
 +
 +This is necessary for pcmcia-daq-cards (enable pcmcia in past configure command):
 +
 +<​code>​
 +sudo su
 +
 +echo '​options comedi comedi_num_legacy_minors=4'​ > /​etc/​modprobe.d/​comedi
 +
 +exit
 +</​code>​
 +
 +==== Installing RTAI + Comedi ====
 +Now you can go ahead and reinstall RTAI with Comedi support.
 +
 +**RTAI #2**
 +
 +<​code>​
 +cd /​usr/​src/​rtai
 +
 +sudo make menuconfig
 +</​code>​
 +
 +Under “Add-Ons”,​ select:
 +
 +<​code>​
 +[*] Real Time COMEDI support in user space
 +</​code>​
 +
 +Menu RTAI-Lab:
 +
 +<​code>​
 +[*] RTAI Lab 
 +</​code>​
 +
 +Adjust EFLTK installation directory (default is /​usr/​local). Exit menuconfig and save configuration. Now do:
 +
 +<​code>​
 +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
 +</​code>​
 +
 +**Test RTAI**
 +
 +Create a shell script
 +
 +<​code>​
 +cd
 +
 +nano load_rtai.sh
 +</​code>​
 +
 +and copy the following with “Crtl+Shift v”:
 +
 +<​code>​
 +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="​127.0.0.1"​
 +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
 +</​code>​
 +
 +Close it, make it executable and run it:
 +
 +<​code>​
 +sudo chmod 777 load_rtai.sh
 +
 +sudo sh load_rtai.sh ​
 +</​code>​
 +
 +Finally, run the test:
 +
 +<​code>​
 +cd /​usr/​realtime/​testsuite/​kern/​latency
 +
 +./run
 +</​code>​
 +
 +Type ctrl-c to stop execution.
 +
 +=== ScicosLab + RTAI-Lab add-ons ===
 +Install ScicosLab:
 +
 +<​code>​
 +cd /opt
 +
 +sudo dpkg -i /​tmp/​scicoslab-gtk_4.3-3_i386.jaunty.deb
 +</​code>​
 +
 +Install RTAI-Lab add-ons as root and as user:
 +
 +<​code>​
 +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
 +</​code>​
 +
 +===== References =====
 +
 +**RTAI installation:​** http://​qrtailab.sourceforge.net/​rtai_installation.html
 +
 +**RTAI + Kubuntu 9.04 + ScicosLab + Qrtailab:** https://​www.rtai.org/​RTAILAB/​RTAI-KubuntuJaunty-ScicosLab-Qrtailab.txt
installing_rtai_comedi_scicoslab_qrtailab_on_ubuntu_9.04.txt · Last modified: 2017/01/03 21:29 by admin