[ltp] IR-DRIVER-TINY-HOWTO (Linux IrDA on a ThinkPad)

linux-thinkpad@www.bm-soft.com linux-thinkpad@www.bm-soft.com
Fri, 19 May 2000 17:04:46 +0200 (CEST)


Hi everybody.

I posted this to `linux-irda@pasta.cs.UiT.no' some time ago but
it might be useful on this list also...

First of all, I wanna thank the linux-irda people for their nice
software :-)

Unfortunately, I had problems setting up things on my IBM
ThinkPad 600E. It turned out that this was mainly due to outdated
and sometimes contradictory information contained in the various
READMEs and the IR-HOWTO.

Therefore, I'd like to contribute my experiences about setting up
the IRDA drivers / protocol stack on a ThinkPad (the explanations
about how to operate the `irport' and `nsc_fir' drivers hopefully
are of even more general usefulness).

The IR-DRIVER-TINY-HOWTO:

1) Get the newest kernel patch, apply and build the kernel and
the modules. This Tiny-howto talks about linux-2.2.14-irda1.

2) enable and configure the IR port using the PS2.EXE utility
under DOS. I set up the IR port as COM2 (io=0x2f8, irq=3).
Beware of port/irq conflicts. If you should use a different setup,
you have to use the respective values everywhere further down.

3) Low level drivers. I got both of the SIR drivers (the irtty
line discipline and the irport driver) to work. Whew - even FIR
works on my ThinkPad because the NSC PCx7338 (I'm not sure
whether it's actually a 87338 or a 97338) is supported - thanks
Dag.

3a) SIR using irtty. 

add the line

        alias tty-ldisc-11    irtty

to /etc/conf.modules and do a `depmod -a'. Now, you need the
`irattach' utility:

        irattach /dev/ttyS1 -s

After this, detection should start and IRDA devices within the
range should be reported by

        cat /proc/net/irda/discovery

Note that you have to specify a different /dev/ttyS? if you use a
IR port setup other than COM2.

3b) SIR using irport.

Make sure the IR port is not configured as an ordinary serial
device.

        setserial /dev/ttyS1 uart none

Then, load the irport driver (make sure the `irda' module is
already loaded)

        modprobe irda
        insmod irport io=0x2f8 irq=3

Note that the irport driver will register a network device,
`irda0', which must be marked UP. This can be done in two
different ways. Either using an ordinary

        ifconfig irda0 up

or alternatively, you may use the `irattach' utility:

        irattach irda0 -s

The `irattach' command also starts discovery, which can also be
done manually:

        echo 1 > /proc/sys/net/irda/discovery

(note the `sys'; the /proc/sys/net/irda/discovery special file is
used for starting/stoping discovery. The discovered devices are
reported at /proc/net/irda/discovery however!).

If you want to remove the irport module, you must mark the
`irda0' interface down before this becomes possible: if you
are using `irattach', you have to kill the respective process,
otherwise issue `ifconfig irda0 down'.

Automatic loading the irport driver may be facilitated by two
entries to /etc/conf.modules:

        alias irda0 irport
        options irport io=0x2f8 irq=3

Note that you still have to make sure that the IR port is not
configured as a serial port (unfortunately, common linux boot
scripts often do a `setserial' on all of the standard serial
ports, thereby registering them with the regular `serial'
driver...).

Also, discovery must be started by writing `1' to
/proc/sys/net/irda/discovery. Both of these can maybe taken care
of by appropriate `post-install' lines in /etc/conf.modules...

3c) FIR using the `nsc_fir' driver.

Make sure the IR port is not configured as an ordinary serial
device (common linux boot scripts try do a setserial on all
standard serial ports!).

        setserial /dev/ttyS1 uart none

Load the FIR driver (after making sure `irda' is loaded)

        modprobe irda
        insmod nsc_fir dongle_id=0x09

Note that the dongle_id (transceiver type) is not automatically
detected. Currently, the following are known:

0x08, HP HSDL-2300, HP HSDL-3600/HSDL-3610 (known but not yet
supported)
0x09, IBM31T1100 or Temic TFDS6000/TFDS6500
0x0d, HP HSDL-1100/HSDL-2100 

The ThinkPad has a IBM31T1100.

When successfully loaded, the FIR driver also registers a network
device, `irda0' which must be marked UP. Consult the section 3b
above about the necessary steps. Note that the required entries to
/etc/conf.modules differ, however:

        alias irda0 nsc_fir
        options irda0 dongle_id=0x09

4) Higher protocol layers.

I had no difficulties using IRCOMM for talking to my Nokia 8210 -
the setup is straightforward:

Add the line

        alias char-major-161 ircomm-tty

to /etc/conf.modules and do a `depmod -a'. Then, you have to
create a device special file

        mknod /dev/ircomm0 c 161 0

which is used like an `ordinary' serial device for subsequent
communication, i.e. with minicom, set the serial device to
/dev/ircomm0.

NOTES:

 - sometimes, while playing with the different drivers, the IR
port got mixed up. E.g. after loading the FIR driver and
unloading it again, subsequently testing the SIR drivers did
fail (everything seemed OK but no receiver interrupts occurred
anymore -> even IRDA device detection failed). In this case, a
suspend/resume cycle apparently reset the IR port to a working
state :-)

 - the role of the different devices was not obvious to me in the
beginning: when using irtty, DONT try minicom on ttyS1!! You have
to use /dev/ircomm0 which provides access to the IRCOMM protocol
layer. From there, data passes the protocol stack down
to the `irda0' network interface. The `irtty' line discipline is
hooked between the (`virtual' / `software' ) network device and
the serial port hardware at /dev/ttyS1.

 - AFAIK, the FIR driver uses four hardware resources: io, io2,
irq and a dma channel. However, there is no possibility to pass
the dma channel as a module parameter. Fortunately, for my setup
(io=0x2f8, io2=0xe2, irq=3, dma=3), the automatic
detection/configuration algorithm of the FIR driver recognizes
exactly this configuration. I don't know how to tell it what dma
channel to use in case I have to specify any of the io/io2/irq
manually :-(.

 - You may or may not use `irmanager' for loading modules and/or
setting up things. Note that you don't actually need any of the
irda-utilities when using irport (SIR) or nsc_fir (FIR). In
simple cases where you just want to talk to a printer or a mobile
phone, it is maybe not worth the effort of
getting/installing/configuring the irda-utilities. All you have
to do is adding entries to /etc/conf.modules for the drivers and
the protocol stack and

      insmod or modprobe the driver (make sure the serial
      driver is not using the IR port!)

      ifconfig irda0 up

      echo 1 > /proc/sys/net/irda/discovery

 - While discovery is enabled, APM would not suspend my machine
when it's otherwise idle (because of the IR port being used). Of
course, I'm still able to manually suspend. However,
in order to save battery and / or allowing the apm-bios to
suspend an idle machine, you may want to switch discovery off,
e.g. by 

        echo 0 > /proc/sys/net/irda/discovery

or

        ifconfig irda0 down
 

 - Some dialers (e.g. kppp) use the major device number to
determine whether a device is a valid serial/modem device.
Such programs fail to recognize /dev/ircomm0 :-( :-(
----- The Linux ThinkPad mailing list -----
The linux-thinkpad mailing list home page is at:
http://www.bm-soft.com/~bm/tp_mailing.html