As stated in Why is my Audio (Sound) Output not working?, to initialise the sound driver, you must run sudo modprobe snd_bcm2835
every time you want to output sound.
How do I get this to run on boot? (i.e. before logging in and without any input)
-
1This is another question that could be regarded off-topic. It may be better suited to U&L.Jivings– Jivings2012年06月27日 07:33:21 +00:00Commented Jun 27, 2012 at 7:33
-
3@Jivings: Just because it's on-topic on Unix & Linux doesn't make it off-topic for Raspberry Pi, does it?Oliver Salzburg– Oliver Salzburg2012年06月27日 08:37:52 +00:00Commented Jun 27, 2012 at 8:37
-
2@OliverSalzburg: I think that there's too much of an overlap in this particular question. Nothing about this question makes it specific for the Raspberry Pi.Jivings– Jivings2012年06月27日 08:47:38 +00:00Commented Jun 27, 2012 at 8:47
-
1Wouldn't the decision at meta.raspberrypi.stackexchange.com/questions/24/… mean that this question is fine here?Graham Wager– Graham Wager2012年10月01日 10:30:05 +00:00Commented Oct 1, 2012 at 10:30
-
1@Jivings Thanks, just wanted to clear that up for any future visitors as the comments were pointing towards closing the question. Maybe all the comments should be deleted instead?Graham Wager– Graham Wager2012年10月03日 09:05:27 +00:00Commented Oct 3, 2012 at 9:05
4 Answers 4
Loading modules at boot is a little different to running startup commands.
In Debian:
Add the module name as a new line in /etc/modules
In Arch Linux:
Add the module name to the module array in /etc/rc.conf
, the line should look like this:
modules=(snd_bcm2835)
Or for the new systemd configuration:
echo "snd_bcm2835" | sudo tee -a /etc/modules-load.d/snd_bcm2835.conf
-
I added
snd_bcm2835
to the/etc/modules
file on my Xbian but that created a loop at boot time. this seems not be allowed when starting OSMCrubo77– rubo772015年06月17日 15:55:07 +00:00Commented Jun 17, 2015 at 15:55 -
@rubo77 Interesting! Did you get to the bottom of it?Jivings– Jivings2015年06月22日 08:11:57 +00:00Commented Jun 22, 2015 at 8:11
-
Not sure. Maybe it was a coincident. The whole installation seems a bit broken by now...rubo77– rubo772015年06月22日 11:27:02 +00:00Commented Jun 22, 2015 at 11:27
Modprobe on Boot - Debian
To answer the specific question about sudo modprobe snd_bcm2835
, add the module to /etc/modules
and reboot. (You will need to be root
to do this.)
Starting services - Debian
Debian using initscripts to initialise the system, and you can use them to run arbitrary commands. You need to install a script similar to the following in /etc/init.d
.
#! /bin/sh
# /etc/init.d/blah
#
# Some things that run always
touch /var/lock/blah
# Carry out specific functions when asked to by the system
case "1ドル" in
start)
echo "Starting script blah "
echo "Could do more here"
;;
stop)
echo "Stopping script blah"
echo "Could do more here"
;;
*)
echo "Usage: /etc/init.d/blah {start|stop}"
exit 1
;;
esac
exit 0
You should ensure it is runnable and owned by root.
sudo chmod 755 /etc/init.d/blah
sudo chown root:root /etc/init.d/blah
Then you need to register it to run at startup.
sudo update-rc.d blah defaults
References
-
1Neither of these things are unique to Debian. Also, init scripts are not what you should be using to load modules. Only the first section is relevant to the question.Jivings– Jivings2012年06月27日 07:32:18 +00:00Commented Jun 27, 2012 at 7:32
-
Neither of them will work on Arch, not sure about QtonPi.Alex Chamberlain– Alex Chamberlain2012年06月27日 07:34:39 +00:00Commented Jun 27, 2012 at 7:34
-
-
Oh... why is your Arch answer different then?Alex Chamberlain– Alex Chamberlain2012年06月27日 07:35:53 +00:00Commented Jun 27, 2012 at 7:35
-
Because Arch defines a handy abstraction for startup events.Jivings– Jivings2012年06月27日 07:36:58 +00:00Commented Jun 27, 2012 at 7:36
There are loads of ways of running a command at start-up in Linux but my favoured approach is to create an initialisation script in /etc/init.d
and register it using update-rc.d
. This way the application is started and stopped automatically when the system boots / shutdowns.
See this post for a set of instructions on how to create one on the Raspberry Pi.
-
1Welcome to Raspberry Pi Beta! Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.Oliver Salzburg– Oliver Salzburg2012年10月01日 09:33:25 +00:00Commented Oct 1, 2012 at 9:33
-
How would you do it through
systemd
or other systems?ArchHaskeller– ArchHaskeller2012年10月02日 00:16:22 +00:00Commented Oct 2, 2012 at 0:16
My preferred approach would be to add the setup command to /etc/rc.local where it would be initialised at the end of boot, before you are asked to login.