You are not logged in.

#1 2011-11-25 18:37:42

twilight0
Member
From: Greece
Registered: 2011-05-01
Posts: 233
Website

Setserial custom initcpio hook

Hi, I 've just created a custom initcpio hook for setserial and like to share it, because I haven't found so far any relative information on how to create a custom hook.

I 've written it because I have a fir (fast infrared) device which needs to be set serial first, otherwise the nsc-ircc module cannot be autoloaded via udev in early userspace. And TBH I like to avoid using rc.local. So:

$ cat /lib/initcpio/install/setserial

#!/bin/bash

build() {
    SCRIPT="setserial"
    add_binary /usr/bin/setserial
}

help() {
    cat <<HELPEOF
    This hook sets the serial property for the irda port
HELPEOF
}

# vim: set ft=sh ts=4 sw=4 et:

I don't know if the last line is really necessary, because I used the udev hook as a guide. But since it is commented, It would probably make no difference.

$ cat /lib/initcpio/hooks/setserial

cat /lib/initcpio/hooks/setserial 
run_hook ()
{
    msg -n ":: Activating setserial for irda port"
    setserial /dev/ttyS1 uart none
    msg "done."
}

So far I tested the initcpio creation with the traditional gzip compression and it works, but haven't rebooted yet.

And for those who might be curious, these are the options for the nsc-ircc module in /etc/modprobe.d/nsc-ircc.conf

$ cat /etc/modprobe.d/nsc-ircc.conf

options nsc-ircc dongle_id=0x09 io=0x2f8 irq=3 dma=3

Proud Arch Linux user since 2007.

Offline

#2 2011-11-25 19:10:48

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Setserial custom initcpio hook

rc.sysinit has hooks as well. Seems like a better place for it as this isnt really needed for early userspace.

Offline

#3 2011-11-27 23:34:08

twilight0
Member
From: Greece
Registered: 2011-05-01
Posts: 233
Website

Re: Setserial custom initcpio hook

Reporting back, for those who might find this useful, it worked flawlessly. Proper port is setserial-ed, no errors during boot and nsc-ircc module loaded with no issues. Tested with irdadump. However, I haven't managed to get my fir working with LIRC.


Proud Arch Linux user since 2007.

Offline

#4 2011-11-28 00:02:56

twilight0
Member
From: Greece
Registered: 2011-05-01
Posts: 233
Website

Re: Setserial custom initcpio hook

falconindy wrote:

rc.sysinit has hooks as well. Seems like a better place for it as this isnt really needed for early userspace.

Yes, I agree, but by doing so everytime initscripts are updated to include new information, I also have to re-edit it.


Proud Arch Linux user since 2007.

Offline

Board footer

Powered by FluxBB