Contents |
Introduction
This page is probably the most up-to-date description of how to set up FireWire audio with Ubuntu.
Ubuntu 11.04 ("Natty Narwhal") completed the migration to the new FireWire driver stack, and the legacy firewire stack was removed with the 2.6.37 kernel. Refer to FireWire Stacks Explained for more details.
Older Releases
For completeness, this guide still documents ALL the steps needed to configure an older system to use a FireWire device. However, most of these extra configuration steps are no longer required, beyond what is needed to use any other soundcard with JACK in realtime mode.
Newer Releases
UbuntuStudio 12.04 LTS ("Precise Pangolin") ships with the lowlatency kernel, and the 'audio' group is preconfigured with proper security and user settings, so it should 'just work'.
If you are using Ubuntu 11.04 ("Natty Narwhal") or a later release, its configuration should be verified.
To use your FireWire device, enter the procedure at Set IRQ Priorities.
Supported FireWire Audio Devices
Refer to this list of currently supported devices.
Note: This wiki has two other entries which are relevant to Firewire:
Firewire describes the use of IEEE 1394 firewire video devices.
Preparing UbuntuStudio for Firewire is mostly out of date, but describes the use of IEEE 1394 firewire sound cards and cameras.
Complete FireWire Audio configuration procedure
Ubuntu Studio Controls
Note: Do not perform this step if you have Ubuntu 10.10 ("Maverick Meerkat") or a later release.
Enable raw1394 and related permissions using Ubuntu Studio Controls. UbuntuStudioControls has a graphical guide.
Users and Groups
Note: Do not perform this step if you have Ubuntu 10.10 ("Maverick Meerkat") or a later release.
Enable your username to access Audio and Video devices.
- In the System menu, open Users and Groups. Click on the keyring icon and enter your password when prompted.
In Karmic and earlier:
- Click on your username, then click Properties.
- Click on the User Privileges tab.
- Make sure the boxes labeled 'Use audio devices' and 'Use video devices' are checked.
- Click 'OK' and exit.
In Lucid and newer:
- The 'video' group is no longer needed, as firewire devices are now assigned to the audio group. Also, when Jack is installed it should add your username to 'audio', so this step now usually takes care of itself.
Reboot and Test
Note: Do not perform this step if you have Ubuntu 10.10 ("Maverick Meerkat") or a later release.
Plug in your FireWire audio interface and turn it on. (Note: Maverick users - depending on your setup, raw1394 may not be needed. See Driver Confusion at the bottom of this page.)
You will need either to unload and reload the raw1394 kernel module or to reboot for the permissions settings to take effect. There are instances where it seems to be necessary to reboot with the interface connected when using the legacy firewire stack. Also, there is currently a bug in Ubuntu Studio Controls that results in firewire permissions being overwritten with certain updates. If this happens, run Ubuntu Studio Controls, disable raw1394 permissions, re-enable them, unload and reload raw1394 or reboot.
If you are using Maverick and the new Juju firewire driver stack, do not plug in your firewire device until the computer is fully booted up. Booting with your device plugged in and turned on can cause problems with the new driver stack.
- Open a terminal and run:
ls -al /dev/raw1394
You should see something like this:
crw-rw---- 1 root video 171, 0 2009-10-16 05:30 /dev/raw1394
'video' must be shown in this report. (In Lucid, this will be 'audio'.)
- Then run:
groups
You should see something like this:
<username> adm dialout fax cdrom tape audio dip video plugdev lpadmin sambashare admin netdev
Audio and video must be listed in this report. (again, 'video' isn't needed in Lucid and newer.)
Set IRQ Priorities
Note: This step is not applicable unless you have Ubuntu 10.10 ("Maverick Meerkat") or a later release, with a realtime, lowlatency, or a kernel at 2.6.39 or later.
One of the biggest advantages of a realtime kernel is the ability to prioritize IRQ's. This feature can increase the stability of applications which need to capture data with low latencies.
UbuntuStudio 12.04 LTS ("Precise Pangolin") ships with the lowlatency kernel preconfigured to support realtime irq priorities. This feature is also available in the lowlatency kernel, as of 2.6.39, but you might need to add 'threadirqs' (without the quotes) to the boot command line to enable this feature (if not using UbuntuStudio).
The real-time IRQ priorities are set during system boot by the /etc/init.d/rtirq script. By default, sound cards and USB devices are given a high priority but firewire devices are not. If the firewire driver and jackd cannot process the incoming data quickly enough, then jackd will discard the data buffers and notify the audio application of the overrun event (usually called an xrun).
To reduce the risk of overruns, you need to change this configuration file:
sudo gedit /etc/default/rtirq
The priorities are set, in order from highest to lowest, by these two lines:
RTIRQ_NAME_LIST="rtc snd usb i8042" RTIRQ_NONE_THREADED="rtc snd"
You need to ensure the firewire device receives higher priority for its interrupt handler than everything other than the real time clock, so you should put the name of the firewire driver second in both the lists, i.e. insert firewire in the second place of these lists, so they look like this:
RTIRQ_NAME_LIST="rtc firewire snd usb i8042" RTIRQ_NONE_THREADED="rtc firewire snd"
Note: This assumes you are using the new firewire stack with an internal controller. If you need to use the old stack, use the ohci1394 driver instead. If your firewire card is handled by an external controller (e.g. a PC-Card), you need to code the name of the card controller module (e.g. yenta). If you are not sure, then read FireWire stacks explained for more information.
Reboot your system (or just run sudo service rtirq start) to assign your new IRQ priorities. sudo service rtirq status will show you the current status: the firewire irq should appear second on the list, probably with an RTPRIO of 85.
There are more IRQ adjustments that can be made and may be beneficial, but they are not easily automated by the rtirq script. To learn how to tweak things even further, see http://subversion.ffado.org/wiki/IrqPriorities for more detailed information.
Start Jack
Before running jackd and your audio capture application, you should stop any programs that might contend for system resources. Many users find it helpful to stop all networking activity and, in particular, polling for wireless networks can cause unexpected xruns.
Open the jack control gui application. On newer systems this is the QjackCtl entry in the Audio Production menu. On older systems, it is Jack Control in the Sound & Video/Audio Production menu.
- Click 'Setup'. Here are some good settings to start with:
- Driver: firewire (This selects the ffado driver stack)
- Interface: hw:0
Audio:Duplex
- Check Realtime
- Priority: (default)
- Frames/Period: 128
- Sample Rate: 44100
- Periods/Buffer: 3
- Click 'OK', then click 'Start'. After a few seconds Jack Control should display CPU percentage, RT should be yellow and blinking, and x-runs should be at 0/0.
Note: You should adjust your Sample Rate to match the clock rate of your firewire device! e.g. 44100 for CD quality audio, 48000 for video work, higher for studio quality.
- The default priority is claimed elsewhere to be 10, but this will usually be OK. A higher number will reduce the risk of xruns, but you need a lower priority than that of the irq driver
- Frames/Period can be lowered as well. A lower number will yield lower latencies and use more processor power. If you start getting xruns, increase this number and accept a higher latency.
- Setting Frames/Period to 64 and Periods/Buffer to 3 should result in a round-trip latency of just under 10ms, which is generally considered negligible.
Have Fun and Happy Audio Production!
For ideas on where to go from here, see UbuntuStudio/Audio
FireWire stacks explained
It is easy to be confused by this topic, so here is how to make sense of what you have available on your system.
Which stack am I using?
In Ubuntu Maverick, the new Juju firewire driver stack is enabled by default, but the legacy stack is also present and can be used if needed. To check which driver stack is enabled, run this command:
lsmod | grep 'firewire\|1394'
On Lucid or older, it should return something like this: (these modules make up the Legacy firewire driver stack)
~$ lsmod | grep 'firewire\|1394' dv1394 18602 0 ohci1394 30338 1 dv1394 raw1394 25814 0 ieee1394 95219 3 dv1394,ohci1394,raw1394
On Maverick or newer, it should return this: (these modules make up the new Juju firewire driver stack)
~$ lsmod | grep 'firewire\|1394' firewire_ohci 24679 0 firewire_core 54327 1 firewire_ohci crc_itu_t 1739 1 firewire_core
Only one driver stack should be loaded at a time so they will not cause conflicts. If both sets of drivers had been loaded accidently, you can check which one is actually in control of the hardware by
~$ grep 'firewire\|1394' /proc/interrupts
Most Maverick users should be able to use the Juju stack, and should not enable raw1394. Users who need to use use multiple firewire devices (known as daisy-chaining) must enable the legacy stack if using Maverick.
The legacy stack has been removed from Natty.
Switching between stacks
We can switch between driver stacks (without rebooting) using the modprobe command. To unload the Juju stack, run this command:
sudo modprobe -r firewire-ohci
Then, to load the Legacy stack:
sudo modprobe ohci1394 && sudo modprobe raw1394
If you want to unload the Legacy stack, do:
sudo modprobe -r dv1394 video1394 ohci1394 raw1394
And to load the Juju stack:
sudo modprobe firewire-ohci
Selecting the stack to load at boot time
To select which firewire stack is loaded at boot time:
sudo gedit /etc/modprobe.d/blacklist-firewire.conf
By default in Maverick, the legacy stack is blacklisted and the Juju stack is enabled:
blacklist ohci1394 blacklist sbp2 blacklist dv1394 blacklist raw1394 blacklist video1394 #blacklist firewire-ohci #blacklist firewire-sbp2
To enable the legacy stack, modify this file as follows:
#blacklist ohci1394 #blacklist sbp2 #blacklist dv1394 #blacklist raw1394 #blacklist video1394 blacklist firewire-ohci blacklist firewire-sbp2
Then, rebuild the initramfs:
sudo update-initramfs -k all -u
And on subsequent boots the legacy stack will be loaded.
For more information, see: https://ieee1394.wiki.kernel.org/index.php/Juju_Migration https://wiki.ubuntu.com/Kernel/SwitchFirewireStack