# Getting lirc_serial to run before serial...

## ekoman

Well, the heading says it all I guess. I'm trying to get lirc to work on my genkernel Stage2 installation on a mini-itx, letting the kernel autodetect all hardware at each boottime (which is fine for me).

I have installed lirc and set LIRC_OPTS in make.conf so that it compiles all the drivers. I got a packard bell receiver on my COM1-port (ttyS0 that is) and it works fine when trying on Windows.

On boot, the ttyS0 is however loaded before the lirc_serial driver - here is some dmesg stuff:

```
Serial: 8250/16550 driver $Revision: 1.90 $ 48 ports, IRQ sharing enabled

ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

[...more stuff...]

lirc_dev: IR Remote Control driver registered, at major 61

lirc_serial: no version for "lirc_unregister_plugin" found: kernel tainted.

lirc_serial: port 03f8 already in use

lirc_serial: use 'setserial /dev/ttySX uart none'

lirc_serial: or compile the serial port driver as module and

lirc_serial: make sure this module is loaded first
```

How can I make the lirc_serial run before the ttyS0 initialization?

Further, on lirc, the lircd.conf-file doesn't exist after emerge:ing it. Where should I tell the baudrate, the icq, the address etc for lirc_serial? Or does lirc_serial read stuff from /dev/ttyS0 (/dev/tts/0?), the latter knowing about the irq/address/etc? But then again, due to the error message above, lirc_serial indeed seems to look at the correct port (0x03f8)!

How are the lirc_serial and the serial module to be viewed? Is lirc_serial a replacement of the ordinary serial kernel module or does the former depend on certain properties of the latter?

----------

## widan

 *ekoman wrote:*   

> 
> 
> ```
> Serial: 8250/16550 driver $Revision: 1.90 $ 48 ports, IRQ sharing enabled
> 
> ...

 

I would say a replacement, since it tries to use the hardware port directly. Try to add that line to /etc/serial.conf:

```
/dev/ttyS0 uart none
```

Else you could try to edit the LIRC init script and change the depend statements:

```
depend() {

        before serial

}
```

----------

## ekoman

Thank you for your reply.

Strange - there is no /etc/serial.conf file at all! So what I did: I created a new one with the 

```
/dev/ttyS0 uart none
```

 line in it. I rebooted but same thing: same stuff in dmesg.

But it sounds strange that I don't have a serial.conf file, doesn't it? Strangely enough, I don't have the setserial command - something I remember from Debian.

I do however have the lircd init script so adding that line sounds like a nice way to do things. However, there is no depend section in /etc/init.d/lircd - this is all I have atm:

```
#!/sbin/runscript

# Copyright 1999-2004 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

# $Header: /var/cvsroot/gentoo-x86/app-misc/lirc/files/lircd,v 1.6 2004/09/26 21

:27:07 lanius Exp $

start() {

        ebegin "Starting lircd"

        start-stop-daemon --start --quiet --exec /usr/sbin/lircd -- ${LIRCD_OPTS

}

        eend $?

}

stop() {

        ebegin "Stopping lircd"

        start-stop-daemon --stop --quiet --exec /usr/sbin/lircd

        eend $?

}
```

----------

## widan

 *ekoman wrote:*   

> Strange - there is no /etc/serial.conf file at all! So what I did: I created a new one with the 
> 
> ```
> /dev/ttyS0 uart none
> ```
> ...

 

You need to emerge setserial. It will bring the serial.conf and /etc/init.d/serial script with it.

 *ekoman wrote:*   

> I do however have the lircd init script so adding that line sounds like a nice way to do things. However, there is no depend section in /etc/init.d/lircd

 

Simply add it before the start() function. But it won't work if you don't have the serial init script, so you need to emerge setserial, and "rc-update add serial default". And since your serial driver seems to be autoloaded (or built-in) rather than explicitely loaded by the serial script, you will want to have serial running before lirc, so that setserial can tell the kernel to free the serial port before lirc accesses it. So you want to add instead:

```
depend() {

        after serial

}
```

----------

## ekoman

Strange - I can't get it to work! I have emerged setserial, modified /etc/serial.conf and rebooted, and this is what I get from dmesg:

```
Serial: 8250/16550 driver $Revision: 1.90 $ 48 ports, IRQ sharing enabled

ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

...stuff...

lirc_dev: IR Remote Control driver registered, at major 61

lirc_serial: no version for "lirc_unregister_plugin" found: kernel tainted.

lirc_serial: port 03f8 already in use

lirc_serial: use 'setserial /dev/ttySX uart none'

lirc_serial: or compile the serial port driver as module and

lirc_serial: make sure this module is loaded first

```

And this is the only (uncommented) line I got in /etc/serial.conf:

```
/dev/ttyS0 uart none
```

I got a /etc/init.d/serial script and it seems to refer to /etc/serial.conf so that should make it uart none.

I also got a /etc/init.d/lircd which begins with a "depend() { after serial }"

Strangely, I don't have a /etc/lircd.conf but that is just remote control mapping - right?

I have tried the following stuff:

```
olive ~ # ps -dA

PID TTY          TIME CMD

[stuff - but no lircd]

olive ~ # ls -l /dev/li*

crw-rw----  1 root root 61, 0 Aug 17 06:32 /dev/lirc0

srw-rw-rw-  1 root root     0 Aug 17 06:34 /dev/lircd

/dev/lirc:

total 0

lrwxrwxrwx  1 root root 10 Aug 17 06:11 0 -> /dev/tts/0

olive ~ # lircd -d /dev/lircd -H default -n

lircd 0.7.0[9162]: could not open config file '/etc/lircd.conf'

lircd 0.7.0[9162]: Illegal seek

lircd 0.7.0[9162]: lircd(any) ready
```

So now when I press remote stuff - nothing happens. When running as daemon and checking ps:

```
olive ~ # lircd -d /dev/lircd -H default

olive ~ # ps -dA

  PID TTY          TIME CMD

[plenty of processes]

 9164 ?        00:00:00 lircd
```

Shouldn't /dev/lircd be under TTY there? (I have also tried the above with /dev/lirc0 and /dev/lirc/0 and /dev/ttyS0 too but getting the same error message).

I have also tried mode2 for different /dev-nodes - no error when I do /dev/lirc0 but no output when pressing RC buttons:

```
olive ~ # mode2 -d /dev/lirc0

olive ~ # mode2 -d /dev/lirc/0

This program is only intended for receivers supporting the pulse/space layer.

Note that this is no error, but this program simply makes no sense for your

receiver.

In order to test your setup run lircd with the --nodaemon option and

then check if the remote works with the irw tool.

olive ~ # mode2 -d /dev/lircd

mode2: error opening /dev/lircd

mode2: No such device or address
```

Help!

----------

## widan

Ok, try to do it manually:

```
rmmod lirc_serial

setserial /dev/ttyS0 uart none

modprobe lirc_serial
```

And see if that works. If it does, then we'll try to get it working automatically at boot.

Btw, a quick way to get it to work, if you don't use serial ports for any other thing except the IR receiver, is to disable serial port support in the kernel... not very clean, but it should work.

----------

## ekoman

Okay, I tried the commands above and didn't get any error messages. But still I get the same output - doesn't work! I'm leaning towards my serial port being broken hardware-wise.... Extremely irritating this!

An idea sprungs to mind: perhaps I could ask you, widan, or somebody else, to log into my system through SSH and play around a little? Asking me to press the remote when you tell me to do that...

Btw: I did use the genkernel option on this one, making an autohardware detect at each boot. I got another VIA motherboard - EPIA 800 - and perhaps it would be feasible to connect this mobo to the harddisk instead, i.e using the linux system that is currently working for my EPIA 5000 board? (The 800 is basically a 5000 board but with a slightly faster processor).

----------

## widan

Your serial port isn't broken. It's just that two drivers are trying to claim the same hardware. What you can try is remove the serial port driver from the kernel (I'm assuming the only device using serial ports is the remote receiver - which will be handled by the lirc driver instead of the normal serial). With genkernel, you will need to add "--menuconfig" to the genkernel options, to be able to change the kernel configuration a little. In the menu, you need to uncheck that option:

```
Device drivers  --->

  Character devices  --->

    Serial drivers  --->

      < > 8250/16550 and compatible serial support
```

With a kernel without support for serial ports, there won't be another driver claiming the I/O ports, so the lirc driver should be able to access them.

----------

## ekoman

Dang, that means I really have to recompile the whole kernel again - as I didn't have the --menuconfig option when installing the system... Right? Or are there other ways to load/unload kernel modules without having to redo the whole kernel compiling thingie?

Ohwell, that will have to wait til tomorrow. But I do feel it would be better to be able to load/unload the kernle modules mmanually and I've been thinking about how this is done with my current genkernel (without the --menuconfig option set).

Thanks HEAPS for the help. I'm sure this will fix things for me!

----------

## widan

You could try to "rmmod serial", but it seems this particular option is set as built-in by genkernel, rather than module  :Sad: . So yes, you will likely need to build a new kernel.

----------

## ekoman

To paraphrase a famous ending song in a great movie, I'll be looking at this aspect of life from the bright side - although kernel compiling takes plenty of time (esp on this 500MHz proc), I will have the time to go out and grab a pizza meanwhile!

I bet it's the serial driver that is in the way. I make sure to load it as a module when compiling the kernel tonite.

----------

## Per Olav

 *widan wrote:*   

> 
> 
> ```
> Device drivers  --->
> 
> ...

 

Thank you. This solved my problem with lirc_serial.

----------

## Pajarico

ekoman: Did it work for you?

----------

## wwonderllama

For what it's worth, this fixed the situation for me too.

----------

## Samoth

This thread really helped me getting my homebuilt serial lirc adapter working. Thanks a lot.

One question though(for anyone that is watching this thread), I tryed to change the dependencies on lircd so that it would start *after* serial(I still had the kernel module built in). For some reason this change wasn't recognized. Why? Is there some command to cache the dependencies of services(like rc-update)?

Thanks a lot.

----------

