Real Time Systems |
These notes are a replacement for the "Open RTLinux Installation Instructions" distributed by FSM Labs, Inc., tailored to fit the particular software and hardware configurations we will be using this course. Some of this work may already have been done for you on the systems in the lab, but you may need to do it over from scratch if the installed RTLinux kernel has been clobbered.
The notes are a compromise between completeness and accessibility. I've tried to keep them fairly short to allow you to get through them quickly, but that means I have to assume you are either using one of our lab machines (whicha have already been partially set up) or you know enough about general Linux installation and system administration to have previously set up your own machine with "vanilla" Linux. If you are using your own machine, to avoid surprises you should start with the same distribution we are using in the lab, i.e., Red Hat 9.0.
In short, the steps you need to follow to install RTLinux are:
These steps are explained in more detail below.
The source file versions you should use are
There may be copies already on the machine assigned to you in the lab, in directory /usr/src. Otherwise, If not, you can copy them from one of the CDs that will be provided in the lab. If you can't find one of the CDs, or are working from home, download the files from the course Website. For the purpose of the following explanation, we will assume the files are in the directory /usr/src.
Some of these steps, including specifically those involved in installing the kernel and kernel modules, require that you be operating with "root" privilege. However, it is generally a good idea to do the rest of the steps using an ordinary userid and then "su" to root to do just the few steps that require root privilege. This is especially important when you are working on a computer in the teaching lab, which may also be used by other members of the class, because when you are operating as root you run the risk of clobbering another person's files.
Extract the source files into a directory you have created for that purpose. Use bunzip and tar. This can be combined into one step using the "j" option with Gnu tar. For example:
cd /home/developer tar xjf /src/rtlinux-3[1].2-pre2.tar.bz2 ln -s rtlinux-3.2-pre2 rtlinux cd rtlinux tar xjf /usr/src/linux-2.4.20.tar.bz2 ln -s linux-2.4.20 linux
In the above example we put a copy of the Linux kernel sources into the rtlinux directory. We make our own copy because we will be patching (changing the source code) to fit RTLinux. It does not need to be in that location, but in any case we do need to create a symbolic link named "rtlinux" to the kernel source directory because that is the RTLinux Makefile expects.
RTLinux consists of a set of kernel modules, along with some patches to body of the Linux kernel. The patches are located in the directory rtlinux/patches. There are different patch sets for different Linux kernel versions. Apply the patch set that matches your kernel version, using the patch utility. For example:
cd linux patch -p1 < ../patches/kernel_patch-2.4.20-rtl3.2-pre2
(That's a digit one, not a lower-case L in the option "-p1".)
There should be no warnings or error messages if you have compatible kernel and patch file versions.
Warning: If you are sharing a machine with another person, you should edit the file Makefile in the linux directory, and change the defintion of EXTRAVERSION from "rtl3.2-pre2" to a string that is unlikely to be used by any of the other users of that machine.
The Linux kernel has many compilation parameters, which can be configured using one of three methods:
If you are reconfiguring and recompiling using an existing source directory tree (that you used before to compile a different configuration) you should do "make mrproper" to clean up the directory before configuring. On a freshly untarred source tree you should not need this step, but it will not hurt.
make mrproper make menuconfig
The "make menuconfig" step will show you a set of menus from which you must choose the options you want in your kernel. There are far too many configuration options to explain here. In short, you should turn off any items you don't need, and turn on the items you do need, for your specific hardware configuration and expected system use.
The only advice on configuration from the RTLinux developers is:
Enabling APM support is not recommended. APM BIOS calls may have unpredictable effect on real-time performance.
Please make sure to specify the correct CPU type for the target machine.
Try to keep your kernel small, by choosing only those options you absolutely need and by using modules (menuconfig option "M", not "*") for anything you will not always be using. A large kernel will take more physical memory and so generally will have poorer performance than a small kernel.
If your machine is the slave in one of the master-slave kernel debugging pairs in the lab it is important to select the option to support a serial device as console, under the char devices menu options.
You can save a set of configurations in a named file, and then reload it. I have such a saved onfiguration file that works for the type of machine in the lab for this course. The configuration I used to produce the kernel in the tarfile rtl.tbz that I provided to the class is in the file /home/developer/tpbconfig. If you load this you can save time, and skip the next few paragraphs. Otherwise, read on.
The kernel will come in a default configuration, determined by the people who put together the Red Hat 9.0 Linux distribution. It will include support for nearly everything, since it is intended for general use. For use in this course, you want a different kernel configuration. You will use "make menuconfig" )or "make xconfig") to choose that configuration. It will present you with a series of menus, from which you will choose the options you want to include. For most options you have three choices: (blank) leave it out; (M) compile it as a module, which will only be loaded if the feature is needed; (*) compile it into monolithically into the kernel, so it will always be there from the time the kernel first loads.
There are several things you want to accomplish with your reconfiguration:
Turn off module version checking. This is only needed in production systems, for safety. Turning it off will give you more freedom in testing and debugging modules.
Make sure support is compiled in for using a serial port as a console.
Reduce the size of the kernel, by leaving out unnecessary components. This is helpful for kernel development. A small kernel will take less time to compile and less time to load. It will also leave more memory for you to use, resulting in less page swapping and faster compilations.
Retain the modules necessary to use the hardware installed on your system. To do this without including just about everything conceivable, you need to know what hardware is installed on your system. You can find out about that in several ways.
All of the lab computers for this course have essentially the same hardware, and I will tell you about it. However, if you have a machine of your own you will need to figure out what hardware it has and what software OS features you need, so that you include all (and only) the necessary components in your kernel.
If you have a running Linux system with a working kernel, one way to find out about what hardware drivers you are using is to look at the system log file, /var/log/messages. Otherwise, check the hardare documentation for your system, or open up the box and read the labels on the components.
For my test system, I selected the following options from the kernel configuration menus of make menuconfig. Items marked with "(?)" are probably not strictly needed for what you are doing, but I included them because I thought I might want to use them. Lines from /var/log/messages that are clues the option is needed are given in some cases.
May 11 11:41:01 localhost kernel: Intel machine check architecture supported. May 11 11:41:02 localhost kernel: CPU: Intel Pentium II (Deschutes) stepping 02
May 11 11:41:03 localhost kernel: PCI: PCI BIOS revision 2.10 entry at 0xfb2a0, last bus=1
May 11 11:41:46 localhost kernel: parport0: PC-style at 0x378 (0x778) [PCSPP,TRISTATE]W have a parallel port, but I have no printer to attach to it. If you are using your own machine and want to use the printer, you would need this.
May 11 11:41:03 localhost kernel: isapnp: No Plug & Play device found
May 11 11:41:05 localhost kernel: Uniform Multi-Platform E-IDE driver Revision: 7.00beta-2.4 May 11 11:41:05 localhost kernel: PIIX4: IDE controller at PCI slot 00:07.1
May 11 11:41:46 localhost kernel: SCSI subsystem driver Revision: 1.00 May 11 11:41:46 localhost kernel: scsi0 : Adaptec AIC7XXX EISA/VLB/PCI SCSI HBA DRIVER, Rev 6.2.8 May 11 11:41:46 localhost kernel:May 11 11:41:46 localhost kernel: aic7850: Single Channel A, SCSI Id=7, 3/253 SCBs May 11 11:41:46 localhost kernel: blk: queue cfa8e614, I/O limit 4095Mb (mask 0xffffffff) May 11 11:42:02 localhost kernel: Vendor: FUJITSU Model: M2513-MCC3064SS Rev: 0030 May 11 11:42:02 localhost kernel: Type: Optical Device ANSI SCSI revision: 02
May 11 11:41:46 localhost kernel: 8139too Fast Ethernet driver 0.9.26 May 11 11:41:46 localhost kernel: eth0: RealTek RTL8139 Fast Ethernet at 0xd08e4000, 00:20:18:8a:10:29, IRQ 5
May 11 11:41:01 localhost kernel: Console: colour VGA+ 80x25
make dep make bzImage make modules
This will take a long time and produce lots of messages as it goes walks the source tree and compiles lots of files.
There may be some warnings, but there should should be no fatal compilation errors if you have done the previous steps correctly. If you do get some fatal compilation errors, you probably have selected an incompatible set of kernel configuration options. This does not happen often, but I've occasionally run into such problems. If it happens, try unselecting some of the options and repeating the process starting from "make mrproper".
As root, do "make modules_install", and then copy arch/i386/boot/bzImage to the /boot directory. Give it a name that is different from the standard installed kernel, e.g. rtlzImage:
make modules_install cp arch/i386/boot/bzImage /boot/rtlzImage
Warning: If you are sharing a machine with another person, you should choose a name that is different from the kernel versions installed previously by other users of the machine.
The idea is to let the boot loader know about the new kernel you have installed, so that it adds it to the menu of options it displays at boot time. The details depend on which of the Linux boot loaders one is using. For the machines in the lab for this course, the boot loader is grub.
To configure grub you edit the file /etc/grub.conf, which is a link to /boot/brug/grub.conf. It is not practical to give a full explanation of grub here. Fortunately, you don't need to understand much. You just need to add some lines to grub.conf, as illustrated below. If you want to know more about grub you can start with the man pages, and then move on to the Linux info pages.
title Kernel 2.4.20 with RTLinux patches root (hd0,0) kernel /rtlzImage ro root=/dev/hda1
You will need to replace "root (hd0,0)" and "root=/dev/hda1" by whatever filesystem name contains your root filesystem. You normally should be able to find and copy the value from an existing entry in grub.conf.
Warnings
Reboot the machine. At the boot loader menu, select the kernel you just compiled and installed. Watch the messages as the system boots. If there are any problems in booting, or if you are missing some functionality after the system comes up, you will need to go back and correct the problem. The correction usually will involve reconfiguring the kernel and repeating the above process.
Warning: There seems to be a small bug in the Makefile for this distribution of RTLinux. The Makefile refers to a directory "pwm" that is not included in the distribution. I worked around it by editing the Makefile to remove the two references to directory "pwm". Alternatively, you might try creating an empty directory with that name at the appropriate point the directory tree. If you don't, the following steps or a subsequent "make clean" may fail with a complaint about pwm not being found.
cd /home/developer/rtlinux cd linux/include ln -s linux/include/asm-i386 asm cd ../.. make menuconfig
The step "make menuconfig" (or, use "make config" if you prefer) will ask you to agree to a license that acknowledges the intellectual property rights of FSM Labs, including a patent as well as copyright. It will then ask you a lot of questions about whether you want to include various options. Some of the combinations are incompatible and will result in compilation or runtime errors. For this course we will start by using the default set of options, which are mutually compatible.
make make devices
To be able to run any programs or load any of othern kernel modules that use RTLinux you need to first load the RTLinux modules. There is a script to do this:
cd /home/developer/rtlinux scripts/insrtl
To run the examples go to the appropriate directory under rtlinux/examples and follow the instructions in the corresponding README file. The simplest example is hello.
These instructions are for the free distribution of RTLinux. There is some documentation in the README files and the rtlinux/doc directory. What you find there will be skimpy and perhaps not quite up to date with the source code. The owner of RTLinux, FSM Labs, is trying to earn money by selling a good version of RTLinux and good documentation. You can check out their web site to see what they are willing to give you for free. You can also use a search engine, with keyword sets like "RTLinux tutorial", "RTLinux introduction", "RTLinux instructions", or just "RTLinux". There are are many Web sites with information about RTLinux, including those of several university courses that use RTLinux. Just beware that whatever you are reading may be talking about different versions of RTLinux and the Linux kernel than you are using.
© 2003 T. P. Baker. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means without written permission. (Last updated by $Author: baker $ on $Date: 2003/05/30 17:05:31 $.) |