Skip to content

Sound on pfSense 2.0.1

pfSense is a free, open source customized distribution of FreeBSD tailored for use as a firewall and router.

I got it running inside an Alix2d2 board.

Alix2d2

Sometimes, with the help of a cron daemon and mpg123, I use this device as alarm clock. I attached a USB soundcard and loaded the proper kernel modules to get It working. Then, I installed mpg123 from the PKG repos. As last step, I added the “cron” package with the pfSense package manager.

First, copy the neccesary modules to /boot/kernel/. You can grab a copy of these kernel modules from here

First, copy the modules to /boot/kernel
[shell]
admin@pfsense:~ # uname -a
FreeBSD pfsense.libcrack.so 8.1-RELEASE-p6 FreeBSD 8.1-RELEASE-p6 #0: Mon Dec 12 18:59:41 EST 2011 root@FreeBSD_8.0_pfSense_2.0-snaps.pfsense.org:/usr/obj./usr/pfSensesrc/src/sys/pfSense_wrap.8.i386 i386
admin@pfsense:~ #
admin@pfsense:~ #
admin@pfsense:~ # cp sound.ko snd_uaudio.ko /boot/kernel/
admin@pfsense:~ # chmod +x /boot/kernel/*.ko
[/shell]

To load audio and USB audio support run:

[shell]
admin@pfsense:~ # kldload sound.ko
admin@pfsense:~ # kldload snd_uaudio.ko
[/shell]

To load these modules at startup, add then to the loader.conf file:

[shell]
admin@pfsense:~ # /etc/rc.conf_mount_rw
admin@pfsense:~ # echo ‘sound_load="YES"’ >> /boot/loader.conf
admin@pfsense:~ # echo ‘snd_uaudio_load="YES"’ >> /boot/loader.conf
admin@pfsense:~ # /etc/rc.conf_mount_ro
[/shell]

You can check the sound status with kldstat,/dev/sndstat, etc.

[shell]
admin@pfsense:~ # kldstat
Id Refs Address Size Name
1 11 0xc0400000 e67264 kernel
2 1 0xc1268000 e688 snd_uaudio.ko
3 3 0xc1277000 57824 sound.ko
4 1 0xc2c7c000 5000 glxsb.ko
admin@pfsense:~ #
admin@pfsense:~ #
admin@pfsense:~ #
admin@pfsense:~ # cat /dev/sndstat
FreeBSD Audio Driver (newpcm: 32bit 2009061500/i386)
Installed devices:
pcm0: <USB audio> (play/rec) default
admin@pfsense:~ #
admin@pfsense:~ #
admin@pfsense:~ #
admin@pfsense:~ # dmesg
.
.
.
uaudio0: <vendor 0x0c76 USB Headphone Set, class 0/0, rev 1.10/1.00, addr 2> on usbus0
uaudio0: Play: 48000 Hz, 2 ch, 16-bit S-LE PCM format
uaudio0: Record: 48000 Hz, 1 ch, 16-bit S-LE PCM format
uaudio0: No midi sequencer
pcm0: <USB audio> on uaudio0
[/shell]

Check the FS status. If you are running pfSense on a router board like me, you will need to remount
the FS as read-write (as I did then copying the kernel modules to /boo/kernel).

[shell]
admin@pfsense:/root # mount -v
/dev/ufs/pfsense0 on / (ufs, local, noatime, read-only, synchronous, fsid 8c96e64e3f8508d2)
devfs on /dev (devfs, local, fsid 00ff000101000000)
/dev/md0 on /tmp (ufs, local, fsid 38799f4f7c7ee5f7)
/dev/md1 on /var (ufs, local, fsid 38799f4f184009c1)
/dev/ufs/cf on /cf (ufs, local, noatime, read-only, synchronous, fsid e199e64e8a800d63)
devfs on /var/dhcpd/dev (devfs, local, fsid 01ff000101000000)

admin@pfsense:/root # df -h
Filesystem Size Used Avail Capacity Mounted on
/dev/ufs/pfsense0 443M 141M 266M 35% /
devfs 1.0K 1.0K 0B 100% /dev
/dev/md0 38M 208K 35M 1% /tmp
/dev/md1 58M 8.7M 45M 16% /var
/dev/ufs/cf 49M 731K 45M 2% /cf
devfs 1.0K 1.0K 0B 100% /var/dhcpd/dev
admin@pfsense:~ #
admin@pfsense:~ #
[/shell]

Add the mpg123 package with the pkg_add command.

[shell]
admin@pfsense:~ #
admin@pfsense:~ # pkg_add -r ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/ports/i386/packages-8.1-release/Latest/mpg123.tbz
Fetching ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/ports/i386/packages-8.1-release/Latest/mpg123.tbz… Done.
Fetching ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/ports/i386/packages-8.1-release/All/libltdl-2.2.6b.tbz… Done.
[/shell]

Try mpg123!

[shell]
admin@pfsense:~ # mpg123 -h
mpg123: Missing argument for option "h".
You made some mistake in program usage… let me briefly remind you:

High Performance MPEG 1.0/2.0/2.5 Audio Player for Layers 1, 2 and 3
version 1.12.1; written and copyright by Michael Hipp and others
free software (LGPL/GPL) without any warranty but with best wishes

usage: mpg123 [option(s)] [file(s) | URL(s) | -]
supported options [defaults in brackets]:
-v increase verbosity level -q quiet (don’t print title)
-t testmode (no output) -s write to stdout
-w <filename> write Output as WAV file
-k n skip first n frames [0] -n n decode only n frames [all]
-c check range violations -y DISABLE resync on errors
-b n output buffer: n Kbytes [0] -f n change scalefactor [32768]
-r n set/force samplerate [auto]
-os,-ol,-oh output to built-in speaker,line-out connector,headphones
-a d set audio device
-2 downsample 1:2 (22 kHz) -4 downsample 1:4 (11 kHz)
-d n play every n’th frame only -h n play every frame n times
-0 decode channel 0 (left) only -1 decode channel 1 (right) only
-m mix both channels (mono) -p p use HTTP proxy p [$HTTP_PROXY]
-@ f read filenames/URLs from f -T get realtime priority
-z shuffle play (with wildcards) -Z random play
-u a HTTP authentication string -E f Equalizer, data from file
-C enable control keys –no-gapless not skip junk/padding in mp3s
-? this help –version print name + version
See the manpage mpg123(1) or call mpg123 with –longhelp for more parameters and information.
admin@pfsense:~ #
[/shell]

Finally, I added this cron entry for the alarm clock 😀

[shell]
40 09 * * * root /usr/local/bin/mpg123 /root/musica/*.mp3
[/shell]

Published inembeddedfreebsdpfsense