1. RTAI
Installation on Ubuntu
2. A
Hello World Linux system call (arm)
3. Changing
default text and font size in Matlab
4. Redirecting
X display in Linux
1.RTAI
3.4 Installation with Linux Kernel 2.6.17 on Ubuntu 6.10
1). compile Linux
kernel (Ubuntu, gcc version 4.1.2)
Get linux kernel
source:
# cd /usr/src
# wget http://www.kernel.org/pub/linux/kernel/v2.6/li
nux-2.6.17.3.tar.bz2
#
tar -xjvf linux-2.6.17.3.tar.bz2
#
ln –s linux-2.6.17.3 linux
Get RTAI 3.4 source (rtai-3.4.tar.bz2) from https://www.rtai.org/RTAI/,
copy to /usr/src
#
tar –xjvf rtai-3.4.tar.bz2
Patch the Linux kernel
#
cd /usr/src/linux
#
patch –p1 < /usr/src/rtai3.4/base/arch/i386/patches/hal-linux-2.6.17-i38
6-1.3-08.patch
Configure and compile the kernel
# apt-get install kernel-package libncurses5-dev //download package
needed for kernel compilation
# vi /usr/src/linux/Makefile in line 308 add
-fno-stack-protector to CFLAGS :=
# make menuconfig //make sure Module
versioning support and CONFIG_REGPARM are not set
# make-kpkg clean //under
directory /usr/src/linux
# make-kpkg --initrd
--append-to-version=-rtai kernel_image kernel_headers
// it takes some time
# cd /usr/src; ls –l //
two deb files are generated
# dpkg -i linux-image-2.6.17.3-rtai
_2.6.17.3- rtai -10.00.Custom_i386.deb< /p>
# dpkg -i linux-headers-2.6.17.3- rtai
_2.6.17.3- rtai -10.00.Custom_i386.deb< /p>
# vi /boot/grub/menu.lst //
verify the new kernel is installed
# reboot
2). compile and
install RTAI 3.4
#
vim /usr/src/rtai-3.4/base/include/rtai_posix.h and remove the declaration of pthread_condattr_setclock and pthread_condattr_getclock
#
export LD_LIBRARY_PATH=/usr/realtime/lib:$LD_LIBRARY_PATH
o:p># cd /usr/src/rtai
# make
# make install
3). Test RTAI
#
vi /usr/realtime/bin/rtai-load and change #!/bin/sh to #!/bin/bash in the first
line
OR
link /bin/sh to /bin/bash (it is linked to /usr/dash in Ubuntu 6.10)
# cd /usr/realtime/testsuite/kern/latency/
# ./run
If everything all right, you will get sth.
like:
## RTAI latency calibration tool ##
# period = 100000 (ns)
# avrgtime = 1 (s)
# do not use the FPU
# start the timer
# timer_mode is oneshot
RTAI Testsuite - KERNEL latency (all data
in nanoseconds)
RTH| lat min| ovl min| lat avg| lat max| ovl max| overruns
RTD| ;
-956| ; -956| ; 308| ; 3535| ;
3535|
; 0
RTD| -1037| -1037| ; 299| ;
3462|
; 3535|
; 0
Devices created by following this
installation procedure will disappear at each machine rebooting. A short script
containing the following can solve the problem:
for n in `seq 0 9`; do
; f=/dev/rtf$n
; if test \! -c $f; then
;
mknod -m 666 $f c 150 $n
; fi
done
2.The
Hello World System Call in Linux 2.6.11 with Intel XScale Processor (ARM) .
steps in creating
a system call.
First of all, one
should have the kernel source code.
Below is for
creating a system call named "mycall" in arm architecture in
linux 2.6.11.
More details can
be found in http://www.linuxjournal.com/article/3326.
1). in
/usr/src/linux/arch/arm/kernel/calls.S, add .long sys_mycall
2).
Randomly choose a
file (I chose arch/arm/kernel/sys_arm.c.) and add
the following
asmlinkage int
sys_mycall (int a, int b) {
printk("calling
sys_mycall\n");
return(a+b);
}
3).
in
/usr/src/linux/include/asm/unistd.h, add a number for the call following
the existing
definitions. It must be one bigger than the last one in the file.
In my example, it
is
#define
__NR_mycall
(__NR_SYSCALL_BASE+281)
4).
compile the kernel
and restart with the new kernel.
5).write a test
file, for example,
#include
<errno.h>
#include
<linux/unistd.h>
/* for _syscallX macros/related stuff */
//#include <linux/kernel.h>
_syscall2(int,
mycall, int,a, int,b);
main(){
printf("the sum of 4+3 is
%d\n",mycall(4,5));
}
compile using gcc
-I /usr/src/linux/include testcall.c -o testcall
3.Changing
default axis and tex font sizes in matlab
Create a file named startup.m with the
following and put it under matlab\work
% axis and text font size
set(0,'defaultaxesfontsize',20);
set(0,'defaulttextfontsize',20);
set(0,'defaultlinelinewidth',1.5);
set(0,'defaultLineMarkerSize',13);
set(0,'defaultlinelinewidth',1.5);
4.Redirecting
X display in Linux
Two machines
host1, host2. Host1 is a linux machine; host2 can be a linux machine or a
windows machine installed with cygwin Xwindows (started by startxwin.bat)
We intend to run a
GUI application in host1 using telnet or ssh, and see its GUI on host2.
1) In host2, type
# xhost +host1 (
or simply xhost + to allow accept redirection from any machines)
2) In host1 type
# ssh host1 (or telnet)
# export DISPLAY=host2:0
Then run any GUI
application in host1, such as firefox, and the GUI will be displayed in host2
If both machines
(host1 and host2) are installed with fedora core, the step can be omitted