Mirko Holler March 2000: Installation & Examples
Mirko Holler March 2000: Installation & Examples
0. make sure you have gcc 2.7.2.3 or egcs 1.1.2 (2.91) or later installed.
RT-Linux installation.
make config
or
make menuconfig
or
make xconfig
Whatever you do, be sure to select the "hard real time" option in the
basic configuration (under "Processor type and features").
make dep
make bzImage
make modules
make modules_install
make install
for example:
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
promt
timeout=50
default=rtlinux
image=/boot/vmlinuz-<normalversion>
label=linux
initrd=/boot/initrd-<normalversion>
read-only
root=/dev/<yourroot>
image=/boot/vmlinuz-2.2.13-rtl2.0
label=rtlinux
read-only
root=/dev/<yourroot>
run lilo:
/sbin/lilo
shutdown -r now
You can verify whether the rt-linux symbols are in the kernel
make
make install
parport.c
#include <rtl.h>
#include <rtl_sync.h>
#include <time.h>
#include <pthread.h>
#include <asm/io.h>
#include <linux/kd.h>
pthread_t thread;
outb(0, 0x378);
interrupt handler
rtl_hard_enable_irq(7); pin2: 0V
return 0;
} If got an IRQ, re-enable IRQ
while (1)
{
pthread_wait_np();
outb(3, 0x378); periodic trigger
} pins 2 & 3: 5V
return 0;
}
int init_module(void) {
int status;
rtl_irqstate_t f;
rtl_no_interrupts(f);
void cleanup_module(void) {
rtl_free_irq(7); cleanup module
pthread_delete_np (thread); disable interrupt
}
Makefile
all: parport.o
include rtl.mk
clean:
rm -f *.o
You can compile the program. It is necessary that the file rtl.mk is present in the directory,
where you have the source code.
(This file can be found in directory /usr/src/rtlinux-2.0/rtl/rtl.mk)
cp /usr/src/rtlinux-2.0/rtl/rtl.mk .
make
Two modules are necessary to be able to run this program (rtl_sched & rtl_time)
(of course you must have booted the real-time kernel). Execute as root:
modprobe rtl_sched
lsmod
insmod parport.o
The following program will write 1kB data-blocks into a realtime-fifo while another “normal”
linux-program will read the data from that fifo.
fifo.c:
#include <rtl.h>
#include <rtl_sync.h>
#include <time.h>
#include <rtl_fifo.h>
pthread_t thread;
int status;
p . sched_priority = 1; 10 ms
pthread_setschedparam (pthread_self(), SCHED_FIFO, &p); 100 Hz
pthread_make_periodic_np (pthread_self(), gethrtime(), 10000000); //ns
while (1)
{
status = rtf_put(0, buf, 1024); //write as often as possible
if (status <= 0) //1 kB of data into rt_fifo
pthread_wait_np(); //if fifo is full: wait 10 ms
}
return 0;
}
int init_module(void) {
rtf_create(0, 1024*1024);
void cleanup_module(void) {
rtf_destroy(0);
pthread_delete_np (thread);
}
Makefile:
all: fifo.o
include rtl.mk
clean:
rm -f *.o
read.c
#include <stdio.h>
#include <fcntl.h>
char buf[BUFSIZE];
int main()
{
int fd0;
int n, c, d;
c = d = 0;
You can compile the write program. It is necessary that the file rtl.mk is present in the
directory, where you have the source code.
(This file can be found in directory /usr/src/rtlinux-2.0/rtl/rtl.mk)
cp /usr/src/rtlinux-2.0/rtl/rtl.mk .
make
Two modules are necessary to be able to run this program (rtl_time, rtl_sched, rtl_posixio,
rtl_fifo / of course you must have booted the real-time kernel). Execute as root:
modprobe rtl_fifo
lsmod
insmod fifo.o
./read
Stop the time the program needs to fill and empty the fifo and calculate the transfer-rate.