Getting Started with RTAI on TS­-7000

From embeddedTS Manuals

Some Notes

Dr. Michael Neuhauser has written most of the code for the Adeos port to the Cirrus Logic EP9301 processor. Adriano Winter Bess and Ronald Gomes have made further modifications to port Adeos to Technologic System's TS7200 and TS7250 boards.

The development is not yet finished and we welcome any contributions or improvements. This guide has been written by Ronald Gomes.

Very quick review of RealTime, ADEOS and RTAI

Realtime systems are special applications that have to respect specific timing requirements and must be precise in their periodicity (small jitter) and/or be very fast in serving realtime events such as interrupts or IO signals (small latency). Hard realtime applications require latency and jitter accuracy of less than 10us (microseconds).

Adaptative Domain Environment for Operation Systems (Adeos) implements a layer between hardware and operation system software that allows multiple operation systems sharing the same hardware while running at the same time. A software pipeline is used to service interrupts and dispatch them to the proper destination; one of its applications is realtime.

Real Time Application Interface (RTAI) is a set of kernel modules that provide realtime services such as interprocess communication, a serial line driver, and an API for real time applications. RTAI services run under the Adeos kernel, so it is necessary to build and run Adeos first. The Adeos kernel is based on the Linux kernel, providing the ability to make it fully preemptable. The RTAI version used in this guide is magma/vulcano.

Useful Reading

Installing the realtime files

Before loading and running the realtime kernel, you should copy the necessary files to the file system in use on the target. These files include the Linux modules for the new kernel, realtime service modules, test files and documentation.

Technologic Systems does provide tarballs containing all the necessary files. You can download these tarballs from https://files.embeddedTS.com/ login as anonymous. There are available options for development or user environment installation for both ARM based boards. The first requires about 12MB, while the user files are about 6MB. They are loacated at the /rt/armts8 directory:

ts72xx_rtfiles_deb.tar.gz for TS72XX running debian development filesystem.

ts7200_rtfiles_obf_dev.tar.gz OR ts7200_rtfiles_obf_usr.tar.gz for TS7200 with on board flash fs.

ts7250_rtfiles_obf_dev.tar.gz OR ts7250_rtfiles_obf_usr.tar.gz for TS7250 with on board flash fs.

Extracting the tarball at / directory of your target system will install the 2.4.26vrs1cirrus121ts8rt files in /lib/modules, as well as the RTAI tests and documentation in /usr/realtime.

$ cd /
$ tar xzf ts72xx_rtfiles_deb.tar.gz

It would be better if the user were able to compile RTAI regarding his needs or at least select only the necessary files from the shipped tarball. For example, to save space and if you don't need real time support in user space, you can install only these modules: rtai_hal, rtai_up, rtai_fifos, rtai_sem. The footprint would be about 1.5 MB.

Running the ADEOS realtime kernel

You can obtain the realtime kernel from https://files.embeddedTS.com/ login as anonymous and download the files:

/rt/armts8/ ts7200_rtzimage OR /rt/armts8/ ts7200_rtvmlinux.bin for TS7200 boards.

/rt/armts8/ ts7250_rtzimage OR /rt/armts8/ ts7250_rtvmlinux.bin for TS7250 boards.

After downloading the realtime kernel, you can load it using redboot's load command then execute the kernel by using redboot's exec command. Below is an example of how to load and execute a kernel via one TFTP server:

$ load r b 0x00218000 h 192.168.0.11 /tftpdir/ts7250_rtvmlinux.bin
$ exec c "console=ttyAM0,115200 ip=dhcp root=/dev/hda1"

Running the RTAI test suite

You can verify if the realtime kernel is running by executing "uname r" this should print the kernel release version. If the release version ends in "-rt" then the realtime kernel is running.

$ 2.4.26-vrs1-cirrus-1-2-1-ts8-rt

Once you have the necessary files in your file system and the realtime kernel is running you can try the default test suite from RTAI. For example, go to /usr/realtime/testsuite/kern/latency/ and execute ./run.

If your output matches the output listed in the next session (Output of RTAI kernel latency test), then you have succeeded in building your realtime system and should be able to build your own RTAIbased realtime applications! If you want to become a RTAI expert, you should read the related documentation and API. It is outside the scope of this guide to explain how to program using the RTAI API.

Output of RTAI kernel latency test

ts7200:/usr/realtime/testsuite/kern/latency# ./run
*
* Type ^C to stop this application.
*
RTAI[hal]: mounted (PIPED).
Adeos: Domain RTAI registered.
RTAI[hal]: 3.2 mounted over Adeos 2.4r17c3/armep9301.
RTAI[hal]: compiled with gcc version 3.3.4.
RTAI[malloc]: kmalloced extent c5580000, size 131072.
RTAI[malloc]: loaded (global heap size=131072 bytes).
RTAI[sched_lxrt]: loaded (PIPED, UP, KERNEL SPACE).
RTAI[sched_lxrt]: timer=periodic (TIMER1),.
RTAI[sched_lxrt]: standard tick=100 hz, CPU freq=983040 hz.
RTAI[sched_lxrt]: timer setup=3052 ns, resched latency=3052 ns.

## RTAI latency calibration tool ##
# period = 1000000 (ns)
# avrgtime = 1 (s)
# check overall worst case
# do not use the FPU
# start the timer
# timer_mode is oneshot

RTAI Testsuite UP
latency (all data in nanoseconds)
RTH| lat min| lat avg| lat max| overruns| freq.cntr
RTD| 0| 15347| 113932| 0| 1000
RTD| 0| 1727| 113932| 0| 1000
RTD| 0| 1826| 113932| 0| 1000
RTD| 0| 1820| 113932| 0| 1000

CPU USE SUMMARY
# 0 > 5097
END OF CPU USE SUMMARY

RTAI[malloc]: kfreed extent c5580000, size 131072.
RTAI[malloc]: unloaded.
RTAI[sched_lxrt]: unloaded (forced hard/soft/hard transitions: traps 0, syscalls 0).
Adeos: Domain RTAI unregistered.
RTAI[hal]: unmounted.
WARNING: You may find some error when running the RTAI testsuite if you are using the onboard flash filesystem due missing or old libraries, specially those related to float point support. However, you can still install the RTAI modules in the kernel and develop your realtime application using RTAI API.

Browsing RTAI Magma API

The API documentation is included in the tarball for your convenience. The documentation is written in HTML. If you want to host it using Apache from the target system, check where the www root directory is and create a symbolic link to /usr/realtime/share/doc/rtai3.2/ html/api/ , as the following examples does:

$ ln s /usr/realtime/share/doc/rtai3.2/html/api/ /var/www/rtai
$ ln s /usr/realtime/share/doc/rtai3.2/html/api/ /www/apache/htdocs/rtai

You can then use your preferred web browser to view the API documentation at http://192.168.0.50/rtai/ (assuming your IP address is 192.168.0.50). Or you can just locally navigate within the documentation files if you can access them from your host PC.

Building the ADEOS realtime kernel

1. Getting TSLinux source (same file for TS72xx boards):

ftp server: oz.embeddedTS.com
user: anonymous
file: /linux/linux24-ts8-kernelsource.tar.gz

2. Getting ADEOS patch:

ftp server: oz.embeddedTS.com
user: anonymous
file: /rt/arm-ts8/ts72xx_ts8_adeos.patch

3. Patching the kernel: Copy the downloaded files to your development directory, extract the kernel source tarball and, inside the kernel directory, apply the patch:

$ tar zxvf linux24ts8kernelsource.tar.gz
$ cd linux24
$ patch p1 < ../ts72xx_ts8_adeos.patch

Now you have the kernel sources ready to be compiled. Note the additional adeos subdirectory, which contains some generic ADEOS sources.

4. Installing the crosscompile environment:

Obtain the cross toolchain at Technologic System website at:

https://files.embeddedTS.com/old/downloads/Linux/ARM/crosstool-linux-0.28rc39.tar.bz2

Install it in your preferred directory (this document assumes / as the installation directory). You also need to crosscompile and install the modutils for 2.4 kernel to succeed in the installation of the target modules. You can get the latest version of modutils at:

http://www.kernel.org/pub/linux/utils/kernel/modutils/v2.4/

If you get the 2.4.27 modutils version, you can use the following commands to compile and install it (assuming / as the crosscompile and modutils installation root).


$ tar xjf modutils2.4.27.tar.bz2
$ cd modutils2.4.27
$ ./configure --build=i386-linux --host=armlinux prefix=/usr/local/opt/crosstool/armlinux/gcc3.3.4-glibc-2.3.2
$ make
$ make install

5. Configuring and crosscompiling the kernel: First, check the CROSS_COMPILE and MOD_UTILS variables in your Makefile to confirm that they match the location of your development system. Using this guide definitions, they must be set to:

CROSS_COMPILE=/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/bin/arm-linux- MOD_UTILS=/usr/local/opt/crosstool/armlinux/gcc-3.3.4-glibc-2.3.2/sbin/depmod

After that, you can configure the source:

$ make ts7200_config OR $ make ts7250_config
$ make menuconfig

Go to General Setup section and set Adeos Support to builtin kernel option. Change anything else regarding yours needs, save configuration and exit menuconfig. For compiling, type:

$ make dep
$ make zImage && make modules

Now, you are able to install the modules in your preferred directory:

$ make modules_install INSTALL_MOD_PATH=/lib/modules

Building RTAI

1. Get the latest stable vulcano RTAI version from rtai website (www.rtai.org) or use the link below: https://www.rtai.org/

You can also try the vulcano version from CVS, but regarding it is under development and might have some errors. To install the vulcano source from CVS in your development directory, type:

$ cvs -d:pserver:anonymous@cvs.gna.org:/cvs/rtai co vulcano

2. Crosscompiling RTAI system

Once you have the crosscompile environment installed, you can type:

$ make ARCH=arm CROSS_COMPILE=/usr/local/opt/crosstool/arm-linux/gcc-3.3.4-glibc-2.3.2/bin/arm-linux-

The menuconfig will appear and you can set the Linux Build and Real Time Installation directories. Configure any other options you may need then save and exit. To install run the following command.

$ make install
WARNING: Read the message with subject rtai3.2 build error posted by Adriano Winter Bess to RTAI mailing list if you find related problems in the file base/include/asm/adeos_hal.h during the compilation step: https://mail.rtai.org/pipermail/rtai/2005-June.txt