Installing RTLinux

This guide is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
(c) Phil Wilshire 2000

Modified by Victor Yodaiken for RTLinux2.2
Modified and corrected by Phil Wilshire

===========================================
1.0. UNPACK THE KIT.
===========================================

1.1. Get a clean kernel from: ftp.us.kernel.org.

1.2. Get the patch file FOR THAT KERNEL.

1.3. Move your current copy of /usr/src/linux (if it is not a link) to:

/usr/src/oldlinux

Check with:

ls -l /usr/src

Links look like this:

ls -l /usr/src/linux
lrwxrwxrwx 1 root root 17 Aug 17 1998 /usr/src/linux -> va-linux-2.0.34-1

(In this case, just delete the link and do the untar.)

If you have to move a tree do:

cd /usr/src
mv linux oldlinux

1.4. Create a working directory. I use: /usr/src

cd /usr/src

(You may need to do this as root.)

This will allow you as a user to access this.

(NOTE: Do most of your work as a regular user... it's safer.)

1.5. Untar the RTLinux tarball into: /opt/rtl

For example, if the tarball is in: /opt/download/rtl/rtlinux-2.2.tgz

cd /usr/src/
tar xvzf /opt/download/rtl/rtlinux-2.2.tgz

This will create: /usr/src/rtlinux-2.2

Loosen up the restrictions on this dir:

chmod -R a+rw rtlinux-2.2

1.6. Look in the INSTALL file and follow the instructions. For example:

********************INSTALL*****************************

1. put a fresh copy of Linux 2.2.14 in this directory under the name "linux".

2. cd linux
patch -p1 < ../kernel_patch

********************************************************

This means take the linux-2.2.14.tar.gz tarball and put it where the install guide suggests, i.e., if the tarball is in: /opt/download/linux/linux-2.2.14.tar.gz

cd /usr/src/rtlinux-2.2
tar xvzf /opt/download/linux/linux-2.2.14.tar.gz

===========================================
2.0. PATCH THE KERNEL
===========================================

2.1. Run the patch.

Now you can patch.

cd /usr/src/rtlinux-2.2/linux
patch -p1 < ../kernel_patch

2.2. Check for Rejects.

There should be no none nada rejects.

Here is an example of a reject...

--------------------------

Patching file arch/i386/kernel/irq.c using Plan A...
Hunk #1 failed at 39.
Hunk #2 succeeded at 236.
Hunk #3 succeeded at 280.

Hunk #21 succeeded at 1324.
1 out of 21 hunks failed--saving rejects to arch/i386/kernel/irq.c.rej

----------------------------------

You find any rejects like this:

cd /usr/src/rtlinux-2.2/linux
find ./ -name *.rej
./arch/i386/kernel/irq.c.rej

You can only patch once (well sort of), so start again if you trip up.

Cleanup.

cd /usr/src/rtlinux-2.2/
rm -rf linux
tar xvzf /opt/download/linux/linux-2.2.14.tar.gz

===========================================
3.0. CONFIGURE AND COMPILE THE KERNEL
===========================================

3.1. Look at what's running.

Now we need to configure and compile the patched kernel. First, we need to look at what's running:

[wilshire@demosbc2 linux]$ /sbin/lsmod
Module Size Used by
3c59x 18952 1

Then we need to configure our new kernel. We see the modules used and make sure that we configure the new kernel for the same ones.

3.2. Configure the kernel.

cd /usr/src/rtlinux-2.2/linux
make menuconfig

Check options as required:

Code maturity level options ---> yes

Processor type and features ---> (PPro/6x86MX) Processor family

[*] Symmetric multi-processing support

Loadable module support --->
[*] Enable loadable module support
[ ] Set version information on all symbols for modules
[ ] Kernel module loader
General setup
---> accept defaults
Plug and Play support ---> accept defaults
Plug and Play support ---> accept defaults
Networking options ---> accept defaults
SCSI support ---> accept defaults

Network device support --->
Ethernet (10 or 100Mbit) --->
[*] 3COM cards
<M> 3c590/3c900 series (592/595/597) "Vortex/Boomerang" support

(in this case)

And finally:

Kernel hacking --->
[*] Magic SysRq key

(This may come in handy.)

Right. Having done all this...

Save the configuration.
Build the kernel.

3.4. Compile the kernel

[wilshire@demosbc2 linux]$ make dep; make clean; make bzImage

Go for a cup of tea , read your mail, write a manual... 10 minutes or so. You will end up with a new Kernel, a new Symbol.map, etc.

BEFORE you do anything else: Set your system up to use this new kernel.

Go to root.

su

3.5. Make/Install the modules

Make the modules.

make modules; make modules_install

Watch the result here.

[root@pasrack3 linux]# make modules_install
Installing modules under /lib/modules/2.2.14-rtl2.2/net
Installing modules under /lib/modules/2.2.14-rtl2.2/misc

The /lib/modules/2.2.14-rtl2.2 shows you that just about every thing is well.

===========================================
4.0. SET UP BOOT / LILO
===========================================

Copy the boot image to the right place.

cp arch/i386/boot/bzImage /boot/bzImageRTL20

Copy the Symbol.map to the right place.

cp Symbol.map /boot/Symbol.mapRTL20

Make the new symbol.map "active."

rm /boot/Symbol.map
ln -s /boot/Symbol.mapRTL22 /boot/Symbol.map

Edit /etc/lilo.conf. It should look like...

===========================================

boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50

image=/boot/bzImageRTL22
label=linuxRTL22
root=/dev/hda1
append="mem=126M"
read-only

image=/boot/bzImage
label=linux
root=/dev/hda1
append="mem=126M"
read-only

===========================================

(But keep another copy around, just in case.)

Run Lilo.

[root@demosbc2 linux]# /sbin/lilo
Added linuxRTL22 *
Added linux

===========================================
5.0. BOOT
===========================================

Now is the time to reboot.

Having rebooted we need to move the linux source link to our new source
tree.

We also should create an rtl tree.

rm /usr/src/linux
ln -s /usr/src/rtlinux-2.2/linux /usr/src/linux
rm /usr/src/rtl
ln -s /usr/src/rtlinux-2.2 /usr/src/r
tl

===========================================
6.0. MAKE THE MODULES
===========================================

Now we can make the rtl modules.

Check and adjust the date.

[root@demosbc2 rtl]# date
Wed Nov 10 23:14:18 PST 1999
[root@demosbc2 rtl]# date 11111452
Thu Nov 11 14:52:00 PST 1999

cd /usr/src/rtlinux-2.2/rtl
make

Now you need to become root and do "make install":

[root@demosbc2 rtl]# make install

Testing for the mbuff device... mknod /dev/mbuff c 10 254
Testing for FIFOs... already existent.

Installing modules in /lib/modules/2.2.14-rtl2.2/misc
/sbin/depmod -a
Installing man pages to /usr/local/man
Installing header /usr/include/rtlinux
install -c -m 644 rtl.mk /usr/include/rtlinux;

===========================================

Set up your path. Try:

lsmod

If you get:

[root@demosbc2 fp]# lsmod
bash: lsmod: command not found

Do this:

export PATH=/sbin:/$PATH

Then try again.

[root@demosbc2 fp]# lsmod
Module Size Used by
3c59x 19176 1

That's it for the main install.

===========================================
7.0. RUN THE EXAMPLES
===========================================

Now for the examples.

==================== fp =====================

cd examples
cd fp
make
mv rt_process.o fp_tasks.o

export PATH=/sbin:$PATH <- only if /sbin is not in your path
chmod a+x ../../insrtl <- you need to do this only once
chmod a+x ../../rmrtl
<- and you need to do this only once
cd ../../; ./insrtl
cd examples/fp
make test

[root@demosbc2 fp]# make test
insmod fp_tasks.o
./fptest
<--- use ^C to quit this
make: *** [test] Interrupt

[root@demosbc2 fp]# lsmod
Module Size Used by
fp_tasks 892 0 (unused)
rtl_fifo 5944 0 (unused)
rtl_posixio 6952 0 [rtl_fifo]
rtl_sched 35364 0 [fp_tasks rtl_posixio]
rtl_time 8424 0 [fp_tasks rtl_sched]
3c59x 19176 1

[root@demosbc2 fp]# rmmod fp_tasks

===========================================

[root@demosbc2 examples]# cd ../frank
[root@demosbc2 frank]# make
[root@demosbc2 frank]# make test
.....
FIFO 2: Zappa
FIFO 1: Frank
FIFO 2: Zappa
FIFO 2: Zappa
FIFO 2: Zappa
FIFO 1: Frank
......

frank_app: now sending commands to stop RT-tasks

This all works.

===========================================

[root@demosbc2 frank]# cd ../hello
[root@demosbc2 hello]# make

[root@demosbc2 hello]# make test

This is the simplest RTL program.

First we remove any existing rtl-modules. You may see error warnings from "make" - ignore them.

Type <return> to continue.

rmmod sound
rmmod: module sound not loaded
make: [test] Error 1 (ignored)
rmmod rt_process
rmmod: module rt_process not loaded
make: [test] Error 1 (ignored)
rmmod frank_module
rmmod: module frank_module not loaded
make: [test] Error 1 (ignored)
(cd ../../; ./rmrtl)

Now insert the fifo and scheduler.

Type <return> to continue.

(cd ../../; ./insrtl)

Now start the real-time tasks module.

Type <return> to continue.

Now, let's stop the application.

Type <return> to finish.

[root@demosbc2 hello]#

======= look on the console to see any messages =======

cd ../measurements
make
make test

min: 9152, max: 17632

Do this to interrupt:

^C

make: *** [test] Interrupt

[root@pasrack3 measurements]#

To look at some stuff, try this:

./monitor > m.out&
sleep(25)
./histplot m.out m.res
cat m.res | more

===========================================

Example Reboot Problem.

I'm running RedHat and my ethernet card doesn't work now.

Solution #1:

Something to do with:

cat /proc/version >/lib/modules/2.2.14-RTL2.2/.rhkmvtag

But this still does not work. I am working on it.

So,

Solution #2:

Add:

# load up eth0
/sbin/modprobe eth0

to:

/etc/rc.d/rc.sysinit

near the end.