You are not logged in.

#1 2006-07-03 16:06:49

maxwevers
Member
Registered: 2006-06-30
Posts: 29

executing commands before modules are loaded?

Hi!

I'm searching for a way to execute some commands before the modules are loaded.

I have a Thinkpad 600E and I need to activate my soundcard via

    # echo 'activate' > /sys/devices/pnp0/00:06/resources 
    # echo 'activate' > /sys/devices/pnp0/00:07/resources 

as it won't get activated via BIOS.

This needs to be done before the modules get loaded, else the snd-cs4236 won't see the card.

Offline

#2 2006-07-03 16:09:04

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: executing commands before modules are loaded?

I suppose you could add that to the initscripts (rc.sysinit) before the modules are loaded.

Offline

#3 2006-07-03 16:19:51

maxwevers
Member
Registered: 2006-06-30
Posts: 29

Re: executing commands before modules are loaded?

Thx! Didn't see that one  lol

Finally I got sound on the Thinkpad 600E .... a miracle!!!  :shock:

Offline

#4 2006-07-03 16:55:36

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: executing commands before modules are loaded?

just remember that you made that change so that when initscripts get updated you can redo your little mod... big_smile

Offline

#5 2006-07-03 17:00:52

tomk
Forum Fellow
From: Ireland
Registered: 2004-07-21
Posts: 9,835

Re: executing commands before modules are loaded?

I think modprobe.conf would be a better place to do this, as it is preserved when module-init-tools is upgraded. Check out man modprobe.conf, in particular the install command.

Offline

#6 2006-07-04 02:40:44

iBertus
Member
From: Greenville, NC
Registered: 2004-11-04
Posts: 2,228

Re: executing commands before modules are loaded?

This seems like a good idea. I posted the info for install below so you don't have to look it up:

     install modulename command...
              This is the most powerful primitive in modprobe.conf:  it  tells
              modprobe  to run your command instead of inserting the module in
              the kernel as normal.  The command can  be  any  shell  command:
              this  allows  you to do any kind of complex processing you might
              wish.  For example, if the module "fred" worked better with  the
              module  "barney"  already installed (but it didn't depend on it,
              so modprobe won't automatically load it), you could say "install
              fred   /sbin/modprobe  barney;  /sbin/modprobe  --ignore-install
              fred", which would do  what  you  wanted.   Note  the  --ignore-
              install,  which  stops  the  second modprobe from re-running the
              same install command.  See also remove below.

              You can also use install to make up modules which  don't  other-
              wise exist.  For example: "install probe-ethernet /sbin/modprobe
              e100 || /sbin/modprobe eepro100", which will try first the  e100
              driver,  then  the eepro100 driver, when you do "modprobe probe-
              ethernet".

              If you use the string "$CMDLINE_OPTS" in the command, it will be
              replaced  by any options specified on the modprobe command line.
              This can be useful because users expect "modprobe fred opt=1" to
              pass  the  "opt=1" arg to the module, even if there's an install
              command in the configuration file.  So our above example becomes
              "install  fred  /sbin/modprobe  barney; /sbin/modprobe --ignore-
              install fred $CMDLINE_OPTS"

Offline

#7 2006-07-04 09:53:54

maxwevers
Member
Registered: 2006-06-30
Posts: 29

Re: executing commands before modules are loaded?

It does not seem to work from modprobe.conf:

install /bin/echo 'activate' > /sys/devices/pnp0/00:06/resources
install /bin/echo 'activate' > /sys/devices/pnp0/00:07/resources 
options snd-cs4236 index=0 port=0x530 cport=0x538 irq=5 dma1=1 dma2=0 isapnp=0

No error messages at all ... devices are just not activated

adding this:

/sbin/rmmod snd-cs4236
/bin/echo 'activate' > /sys/devices/pnp0/00:06/resources
/bin/echo 'activate' > /sys/devices/pnp0/00:07/resources
/sbin/modprobe snd-cs4236
/sbin/modprobe snd-pcm-oss
/sbin/modprobe snd-mixer-oss
/sbin/modprobe snd-seq-oss
/bin/sleep 2
/usr/sbin/alsactl restore

to rc.local does the trick. But its just an "ugly" workaround.

Offline

#8 2006-07-04 10:21:29

brain0
Developer
From: Aachen - Germany
Registered: 2005-01-03
Posts: 1,382

Re: executing commands before modules are loaded?

maxwevers wrote:

It does not seem to work from modprobe.conf:

install /bin/echo 'activate' > /sys/devices/pnp0/00:06/resources
install /bin/echo 'activate' > /sys/devices/pnp0/00:07/resources 
options snd-cs4236 index=0 port=0x530 cport=0x538 irq=5 dma1=1 dma2=0 isapnp=0

No error messages at all ... devices are just not activated

adding this:

/sbin/rmmod snd-cs4236
/bin/echo 'activate' > /sys/devices/pnp0/00:06/resources
/bin/echo 'activate' > /sys/devices/pnp0/00:07/resources
/sbin/modprobe snd-cs4236
/sbin/modprobe snd-pcm-oss
/sbin/modprobe snd-mixer-oss
/sbin/modprobe snd-seq-oss
/bin/sleep 2
/usr/sbin/alsactl restore

to rc.local does the trick. But its just an "ugly" workaround.

You did it wrong:

install snd-cs4236 /bin/echo 'activate' > /sys/devices/pnp0/00:06/resources; /bin/echo 'activate' > /sys/devices/pnp0/00:07/resources; /sbin/modprobe --ignore-install snd-cs4236

something like this should work.

Offline

#9 2006-07-04 10:38:41

maxwevers
Member
Registered: 2006-06-30
Posts: 29

Re: executing commands before modules are loaded?

Stupid me. Thx! Works great now!

Offline

Board footer

Powered by FluxBB