Captain's Universe Home
Captain's Universe Home
Cosmic Ray Muon DetectorTeleGarden Pages
Time on MarsBryophyllum Plants
Jupiter Radio AstronomyAncient Pages
Salzburg Tourist GuideEarth Magnetometer
  H O M E     AJAX & MORE     LINUX & MORE     RTAI     XENOMAI     ADEOS IPIPE      
    JAVA & BROWSERS     *NIX     ELECTRONICS     REVIEWS     ARTEMIA     FAIRY SHRIMP      


Xenomai - RTAI: Loading the xeno_16550A real time serial port driver

Also see:
Xenomai: Hard Real Time Serial Port (RS232) Example with RTDM (Real Time Driver Model)
RTAI 3.3: Hard Real Time Serial Port (RS232) Example with RTDM (Real Time Driver Model)

In order to use the serial devices "rtser0", "rtser1", "rtser2", "rtser3" etc., you need to load the xeno_16550A.ko or xeno_16550A.o, rtai_16550A.ko or rtai_16550A.o kernel module with parameters.

You must tell the hard real time serial port driver which address to use, which irq and optionally the size of the FIFO and at which number the "rtser"-devices should start (default 0).


The rest of this page just mentions Xenomai, but it equally applies to RTAI aswell.

First have a look at the boot messages in the kernel log or "dmesg" for something like this:
 ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
 ttyS1 at I/O 0x2f8 (irq = 3) is a 16550A
So you've got the addresses of the serial ports and the interrupt numbers. Now you can load the xeno_16550A module with:
# cd /usr/realtime/modules/
# insmod ./xeno_16550A.ko ioaddr=0x3f8 irq=4 tx_fifo=10 start_index=0
or e.g. for the other port:
# insmod ./xeno_16550A.ko ioaddr=0x2f8 irq=3
or e.g. for both ports at the same time:
# insmod ./xeno_16550A.ko ioaddr=0x3f8,0x2f8 irq=4,3 tx_fifo=10,20 start_index=0


Kernel module command line arguments/parameters: multiple values for one parameter are separated by a comma ",":
modprobe xeno_16550A ioaddr=<io1>[,<io2>...] irq=<irq1>[,<irq2>...]
                     [tx_fifo=<len1>[,<len2>...]] [start_index=<index>]

Arguments:
    ioaddr      - I/O addresses of devices (e.g. 0x3f8 for ttyS0), separated by comma
    irq         - interrupt numbers of devices (e.g. 4 for ttyS0), separated by comma
    tx_fifo     - Transmitter FIFO sizes in bytes of devices, default is 16, separated by comma
    start_index - First device instance number to be used, default is 0 => rtser0


If you get an error like this:
insmod: error inserting './xeno_16550A.ko': -1 Device or resource busy
you need to disable the kernel serial port driver with
setserial /dev/ttyS0 uart none
-or-
setserial /dev/ttyS1 uart none
If you need to enable the kernel serial driver again, do this:
setserial /dev/ttyS0 uart 16550A


Jan wrote on the Xenomai maillist:
[...] when your 16550A driver is compiled into the kernel, you have to
provide some hardware parameters via the boot command line to configure
at least one port:

8250.nr_uarts=0		(to keep Linux away from using the UARTs)
xeno_16550A.ioaddr=0x3f8 (first UART)
xeno_16550A.irq=4	(first UART)

Of course, you can also increase 8250.nr_uarts and move the 16550A
driver to some other port [...]


Just another thing I encountered: If you use rt_dev_ioctl with RTSER_RTIOC_WAIT_EVENT to wait (block) for a serial port interrupt, make sure you are in primary mode (hard real time):
// switch to primary mode (hard real time)
ret = rt_task_set_mode(0, T_PRIMARY, NULL);
if (ret) {
  printf(RTASK_PREFIX "error while rt_task_set_mode, code %d\n",ret);
  goto exit_read_task;
}
// be careful not to do printf or any other syscall here. Otherwise
// rt_dev_ioctl returns with -EPERM = -1, because we're not in hard
// real time anymore (primary mode)
ret = rt_dev_ioctl(write_fd, RTSER_RTIOC_WAIT_EVENT, &rx_event );
if (ret) {
  printf(RTASK_PREFIX "error while RTSER_RTIOC_WAIT_EVENT, code %d\n",ret);
  goto exit_read_task;
}


Last-Modified: Tue, 11 Jul 2006 19:53:37 GMT

Google
 
Web www.captain.at
go to top
© 1996-2010 . All rights reserved.
No reproduction, distribution, publishing or transmission of the copyrighted materials at this site is permitted. Policy
go to top