FireWire (an Apple trademark, also known by Sony's trademarked name, i.Link, or the generic IEEE 1394) is a personal computer and digital video serial bus interface standard offering high-speed communications and isochronous real-time data services. Up to 63 devices can be daisy-chained to one FireWire port.
FireWire works very well in connecting a MythTV backend to certain cable boxes (including the Motorola DCT-6200). MythTV 0.18 and up contains built-in support for changing channels on the DCT-6200 (generally reliable, although occasionally digits get dropped, however I have not noticed this with 0.19). Here is how to get a fully working FireWire setup going either with a single set top box, or several boxes by daisy chaining.
- 1 Dependencies
- 2 Needed kernel modules
- 3 Plugreport
- 4 Plugctl
- 5 Test-mpeg2
- 6 firewire_tester
- 7 /dev/raw1394 permissions
- 8 Adding To MythTV
- 9 Troubleshooting
- 10 Troubleshooting (Unconfirmed)
- 11 List of Firewire Cards
- 12 FCC regulations
- 13 Compiling raw1394 on systems that use the new firewire subsystem (Kernels >= 2.6.22)
- 14 Further Reading
- '--enable-firewire' when building mythbackend.
- libraw1394 (version must be <=1.2.1, 1.3.0 is BROKEN!)
Note to newbies: if --enable-firewire doesn't "take" when running the configure script in the build process -- i.e. you see "firewire support: no" -- then you probably don't have the three dependency libs installed. The first and third can be found at http://www.linux1394.org/, and the second (libavc1394) probably comes with your distribution.
For Fedora Core users, these are available via yum (sudo yum install libraw1394.i386 libavc1394.i386 libiec61883.i386 libiec61883-utils.i386), and installation will complete most of the configuration. Also, the mythtv-suite from the yum repository ATrpms does come pre-compiled with FireWire support, but does not include these 3 dependencies for full FireWire support.
For Mandrake/Mandriva users, the development packages are required in addition to the library packages and are available via urpmi (sudo urpmi libraw1394-devel libiec61883-devel libavc1394-devel).
Needed kernel modules
Check to see if all of the necessary modules are loaded:
mythbox:~# lsmod|grep 1394 dv1394 20728 0 raw1394 25120 2 eth1394 19856 0 ohci1394 32716 1 dv1394 ieee1394 353144 4 dv1394,raw1394,eth1394,ohci1394
If any of them are missing, you may need to tell your system to automatically load them at boot time. Note that the "eth1394" module isn't necessary for MythTV, but doesn't hurt if it's loaded.
If your distribution has an
/etc/modules file, you should be able to simply add the list of necessary modules, one per line, in that file. All modules in that file are automatically loaded each time the system boots. Here's an example chunk of text you can add to your
/etc/modules file that should do the trick. After adding, do a test reboot to make sure they were loaded as desired:
dv1394 raw1394 ohci1394 ieee1394
If your distribution does not have an
/etc/modules file, you may want to try one of the following:
- Some distributions have a directory of module auto-load files such as
/etc/modules/autoload.d/kernel-2.6or similar. This is distribution dependent.
The program plugreport lists all FireWire devices (on all buses):
Host Adapter 0 ============== Node 1 GUID 0x000e5cfffed720aa ------------------------------ oMPR n_plugs=1, data_rate=2, bcast_channel=63 oPCR online=1, bcast_connection=0, n_p2p_connections=0 channel=63, data_rate=2, overhead_id=0, payload=376 iMPR n_plugs=0, data_rate=2
Node and adapter should be apparent. If not, plugreport often outputs oMPR/iMPR errors for the adaptor, and it is usually (but not always) node 0.
To explain what the switches do for plugctl, -n will allow you to specify your node and -p will allow you to specify your host adapter. If you are using host adapter 0 then there is no need to use the -p switch. Gaining information to use with plugctl is done by using plugreport.
For the most reliable FireWire operation, use Point2Point/p2p. By default your n_p2p_connections will be set to '0'. This mode presented unreliable operation with dct6200's for recording and watching. Set p2p to 1.
Single STB (Set-Top Box) setup
plugctl -n 1 "oPCR.n_p2p_connections=1"
This will allow setting it so you maintain a stable connection by setting the Point2Point "Active".
Daisy chain setup
If you intend to use multiple STBs, daisy chain the FireWire connections. To daisy chain the dct6200 just plug the FireWire cable into the back of one port and into the computer then the second free FireWire port plug from one set top box to the other. Make sure each device is assigned to a unique channel
plugctl -n 1 "oPCR.channel=0" plugctl -n 1 "oPCR.n_p2p_connections=1" plugctl -n 2 "oPCR.channel=1" plugctl -n 2 "oPCR.n_p2p_connections=1"
It is important to set the unique channel first, followed by the p2p. Missing this step will cause it to be non functional.
Example commands to enable broadcast setup:
plugctl -n 1 "oPCR.channel=63" plugctl -n 1 "oPCR.bcast_connection=1"
The ideal place to add the plugctl settings for any of the above methods would be to the mythbackend start up script.
This tool is very simple to use and at first glance is never a good idea to assume things are working. As said above with plugctl you can have your n_p2p_connections=0 set and it may work the first 3-5 tries but then it will start to fail. It would be a good idea to test it at least 10 times. I tested it myself 50 times total to verify it was reliable. test-mpeg2 is only able to test P2P connections.
- If it is needed to use test-mpeg2, invoke the command I find it makes it easier to use it with .mpg vs .ts
> test-mpeg2 -r 1 > test.mpg
If test-mpeg2 doesn't come with your system, you may be able to find it in the libiec61883/examples directory. If you don't have that directory (i.e. you didn't have to download and make libiec61883 in the first place), then look above in the Dependencies section for the url to the source. Gentoo users should emerge libiec61883 with USE="examples".
firewire_tester will help determine which connection type one should use with mythtv as well as being able to stabilize broadcast connections. It's included in mythtv's contrib directory.
- Compile firewire_tester.
In order to use the program you will need to compile the program. You will need the libraw1394 and libiec61883 headers installed. On Fedora, simply execute this command:
> yum install libraw1394-devel libiec61883-devel
Compile the program as follows:
> gcc -Wall -o firewire_tester firewire_tester.c -liec61883 -lraw1394
On some systems, you may have to add the following line to the top of firewire_tester.c
> #include <getopt.h>
You will probably want to copy the executable to /usr/local/bin.
- Test P2P Connection.
In the example below, 2 of the 5 tests failed. This indicates this STB isn't going to be stable using a P2P connection with mythtv. If all came back successful you should be able to setup mythtv to use P2P.
> $ firewire_tester -p -n 2 -r 5 > Action: Test P2P connection 5 times, node 2, channel 2 > P2P: Testing...Failed > P2P: Testing...Success, 138 packets received > P2P: Testing...Failed > P2P: Testing...Success, 416 packets received > P2P: Testing...Success, 232 packets received
- Stablize Broadcast Connection.
If P2P isn't working, next step is to attempt to stabilize broadcast connections as seen below. If it comes back as being successful then setup mythtv to use a broadcast connection. It will be required to re-run this command if the STB or mythbackend server are ever rebooted to restabilize it.
> $ firewire_tester -B -n 2 > Action: Attempt to fix broadcast connection 1 times, node 2 > Broadcast: Testing...Failed > P2P: Testing...Failed > P2P: Testing...Failed > P2P: Testing...Failed > P2P: Testing...Success, 227 packets received > Broadcast: Testing...Failed > P2P: Testing...Failed > P2P: Testing...Success, 326 packets received > Broadcast: Testing...Failed > P2P: Testing...Failed > P2P: Testing...Success, 265 packets received > Broadcast: Testing...Failed > P2P: Testing...Failed > P2P: Testing...Success, 356 packets received > Broadcast: Testing...Success, 422 packets > Broadcast: Testing...Success, 382 packets > Broadcast: Testing...Success, 449 packets > Broadcast: Testing...Success, 419 packets > Broadcast: Testing...Success, 460 packets > Broadcast Fix: Success
- Test Broadcast Connection
> $ firewire_tester -b -n 2 -r 5 > Action: Test broadcast 5 times, node 2, channel 61 > Broadcast: Testing...Success, 189 packets > Broadcast: Testing...Success, 253 packets > Broadcast: Testing...Success, 258 packets > Broadcast: Testing...Success, 194 packets > Broadcast: Testing...Success, 298 packets
Always make sure to check permissions on /dev/raw1394. Here are a few ways to fix this, depending on your distribution and type of mythtv setup.
You should check the permissions on your device node with ls:
> $ ls -l /dev/raw1394 > crw-rw---- 1 root video 171, 0 Aug 11 21:08 /dev/raw1394
The following techniques are a long-term replacement for using chmod 666 after every reboot and then restarting the back-end.
Method 1: Change group access
Using ls determine group membership of the firewire device. You should then include the mythtv user in that group.
> $ gpasswd -a mythtv <GROUP_NAME>
Method 2: modify udev rules
The following changes permissions
- Open a terminal and do the following
> nano /etc/udev/rules.d/10-raw.rules
- Then enter the following information into the file being creating.
> KERNEL=="raw[0-9]*", NAME="%k", GROUP="mythtv", MODE="0666" OWNER="mythtv"
This rule makes the device node read/write by anyone so it shouldn't matter who the owner and group is at that point. Some may consider the udev technique 'hackish', but it shouldn't matter on a dedicated mythtv box
Adding To MythTV
Run mythtv-setup. Select "Capture Cards". Select (New Capture Card) from the list. The type should be "Firewire."
For the settings you want to tell it to use the port you're plugged into. (Systems with multiple FireWire interfaces (such as on board and add-in cards) have multiple host adapters/ports) The node should be the node you got from plugreport. This is also the same as what you pass to the -n argument for plugctl and -r for test-mpeg2. For most people you'll want to use a p2p connection. If you can't get p2p working select broadcast.
The default speed of 100mpbs should be fine, but some combinations of boxes and FireWire cards need 400mbps. For example, my 6200 with a Agere Systems FW323 card requires that 400mbps be used for the highest reliability.
Once you have setup your capture card, be sure to pair it with a Video Source under the Input Connections menu.
Also note that the port and node settings in mythtv-setup are among those that only kick in after mythbackend is restarted.
If tuning a 5C=0 station and MythTV is not consistent in grabbing the MPEG stream try shutting down the computer and unplugging the cable box power and disconnect the FireWire cable from one end. Once both are powered down turn them all back on and reconnect the FireWire cable. This should reset/clear any FireWire plug settings and allow MythTV to properly set them.
- Note: The above can be caused by not setting to bcast or p2p before tuning as stated above.
Finally, there is a bug in the Linux kernel that causes some FireWire chips/doitdonsetups (?) to overflow their buffer and cause excessively high CPU usage. There was a bug in MythTV itself but I believe it has been patched(?). The bug though will cause dropped data in the mpeg stream resulting in many errors during playback.
If you encounter stream errors playing back LiveTV from the firewire while testing, ensure you haven't reniced mythfrontend below 0. When I use nice -n -2 mythfrontend, I cannot properly playback from my firewire capture card. --mmead 18:26, 27 April 2006 (UTC)
For information relating to 5C check source here 
It seems that some FireWire cards are not 100% reliable in mythtv, even when they are reliable using test-mpeg2. If test-mpeg2 works but you can't watch LiveTV, try the following.
- With mythbackend running, try test-mpeg2 and see if you get data. With my copy of libiec61883 (1.0.0) you must redirect test-mpeg2 to a file. Let it run 10-30 seconds and ^C the program. ls -l the file and see if there's any data there. If there is no data, unplug your FireWire cable and plug it in again. Try test-mpeg2 a couple times to see if you get data now. If not, unplug your FireWire cable, remove power from your cable box, plug your cable box back in and give it enough time to start up again, and plug in your FireWire cable. Run plugreport to ensure your node hasn't changed. Run test-mpeg2 and see if you get data. If you still don't get data go over your kernel setup again and make sure everything is setup properly and you have the proper permissions.
If you have the problem I do where firewire isn't reliable, it looks like you need to use a different FireWire card.
- Another solution is to test the results of test-mpeg2 for a non-zero result
- because the next capture typically works. There is a script - Firewire Priming
- that can be used to test the firewire connection before each channel change.
- Observed a problem with the kernel (2.6.20 - standard IEEE-1394 Stack) locking up when I accidentally set two ports on the same PCI-E Firewire card to different bandwidths. Setting both ports to the same bandwidth resolved this.
- The new (aka Juju) IEEE-1394/Firewire stack does not work out of the box with MythTV.
List of Firewire Cards
|Firewire Manufacturer||Chipset #||Tuner Make and Model #||Comments|
|VIA Technologies||VT6306||Motorola DCT6412||Channel change and capture work, but require "priming" the port with p2p=1, channel=63, bcast=0 and a short capture with test-mpeg2 to get it started. Some channels don't work (encrypted?). If firewire is replugged quickly, port can change to 0 or 1. Unsuccessful getting the second firewire port to work.|
|VIA Technologies (Asus onboard)||VT6306||Motorola DCT6200||Unable to get reliable channel changing or recording. Port number can change after physical resets.|
|NEC||D72874GC||Motorola DCT6412||Capture would hang firewire subsystem. Required hard reset to get working again.|
|LSI / Agere Systems||FW323 (rev 61)||Motorola DCT6200|| Channel change is reliable. Capture is not. Seems that test-mpeg2 always works but sometimes data doesn't start flowing until after myth's timeout, resulting in missed recordings and flakey livetv.
Similar setup - Attempted both P2P and Broadcast, same results - reliable channel changing, but very unreliable capture. Priming/soft reseting did not help - requires disconnecting the FireWire cable and physically resetting to get a reliable capture.
|Creative Audigy||??? (rev ?)||Motorola DCT6200|| Channel change and capture is reliable in broadcast mode if primed before running frontend. DCT6200 will occasionally "move" to node 1 instead of node 0 depending on poweron sequence.. A firewire_tester -R seems to reset it.
Similar setup - P2P consistently unreliable. Priming/soft reseting did not help. Forced to use broadcast
|LSI / Agere Systems||FW323 (rev 61)||Two Motorola DCT6200 daisy chained with broadcast|| I use 6200ch (without the -s switch) to change the channel. It is generally reliable but fails silently (so the channel stays the same as the previous) once every 20-30 changes.
With the following lines in /etc/rc.d/rc.local, FireWire connections other than the channel changing, as noted above, are 100% reliable. Note that both 6200ch and firewire_tester are in the doc/contrib directory of the tarball (or its equivalent in prepackaged binaries).
echo "Jumpstarting FireWire" /usr/local/bin/firewire_tester -v -b -n 1 # 'plugreport' says one box is on node 1 /usr/local/bin/firewire_tester -v -B -n 1 /usr/local/bin/firewire_tester -v -b -n 3 # The other is on node 3 /usr/local/bin/firewire_tester -v -B -n 3
|Texas Instruments TSB82AA2 IEEE-1394b Link Layer Controller & Creative Labs SB Audigy FireWire Port||(rev 01) TI & (rev 04) Audigy||Handles 6200, 3214, 6416 daisychained (Via P2P with seperate channels)||As above states firewire_tester I did not prefer it that much over my own script. I will see about getting it into the contrib as it does P2P vs bcast and seems far more reliable. As for being reliable I never missed a beat once I got my script done with either of the firewire controllers. However I am now in a area that has partial 5C. Now I use the external channel changer and hauppauge + firewire capture so it is no longer daisychain.|
|Adaptec PCI||NEC uPD72874 (rev 01)||Motorola DCT6200|| Works most of the time with a priming script, but not 100% reliable - sometimes it misses channel changes (using 6200ch), sometimes it times out before it's able to recieve data. "Good enough" for live tv viewing, but not really stable enough to rely on for timed recordings (it will miss about 25% of them).
Same computer, same setup, moved the PCI card to a different PCI slot, now is very stable, no priming script needed ~
|Adaptec PCI||NEC uPD72874 (rev 01)||2xDCT6200||These 2 DCT6200s are only stable doing broadcast connections. Requires using firewire_tester to stabilize the broadcast connection if the server or a STB is rebooted. Internal channel changer works 100%|
|LSI / Agere Systems||FW323 (rev 61)||1xDCT6200||This STB is stable with both P2P and broadcast connections.|
|Texas Instruments on an Intel DG33BU motherboard and Texas Instruments on a Gigabyte GA-G33-DS2R motherboard||TSB43AB22/A (Intel MB) and TSB43AB23 (Gigabyte MB)||Motorola DHC3200||Capture works with by stabilizing with firewire_tester with both P2P (not completely reliable) and broadcast mode. Comcast SF Bay Area no channels were 5C'd initially, and now most premium channels (HBO, Encore, etc.) are encrypted as well as the local CBS affiliate (KPIX).|
|LSI / Agere Systems||FW323 (rev 61)||DCT6200&DCT6214||STB is stable in P2P and broadcast. test-mpeg2 doesn't work but "firewire_tester -n 0 -B" primes fine and channel changes are %100.|
|LSI / Agere Systems||FW323 (rev 05)||DCH3416||Agere Systems|
|VIA Technologies||Not sure||DCH6200||Linux 126.96.36.199. Works fine with broadcast only. STB from TimeWarnerCable San Diego.|
|VIA Technologies (Sunix PCI FW3010C)||VT6306||Motorola DCT6416||Linux 188.8.131.52-69. Works in broadcast mode only.|
|(Please add your example Hardware stats here! Also see Firewire Cablebox Compatability)|
The FCC has passed a regulation that if you are in the United States, and you have a HD subscription and a HD cable box, they have to on your request replace or upgrade your cable box with working FireWire.
Page 50, section 4
- (4) Cable operators shall:
- (i) Effective April 1, 2004, upon request of a customer, replace any leased high definition set-top box, which does not include a functional IEEE 1394 interface, with one that includes a functional IEEE 1394 interface or upgrade the customer's set-top box by download or other means to ensure that the IEEE 1394 interface is functional.
If you are having troubles with your local cable provider, you have a couple of choices
- File a complaint
- Take them to small claims court
- Vote with your wallet
- Submit complaint to Attorney General
Be aware that the above has been diluted by Congress granting numerous "waivers" to companies that argue, for example, that the FCC regulations are unfair for competition in their area. In that case the only choice is to pick a different provider...
Compiling raw1394 on systems that use the new firewire subsystem (Kernels >= 2.6.22)
To compile the old drivers you are going to need the following: Kernel headers for your kernel Kernel source for your kernel
for me, I needed to "yum install kernel-headers-184.108.40.206-41.fc7" and I downloaded kernel-220.127.116.11-41.fc7.src.rpm
install the kernel source with "rpm -ivh kernel-18.104.22.168-41.fc7.src.rpm" run rpmbuild to prep the kernel sources "rpmbuild -bp --target=i686 /usr/src/redhat/SPECS/kernel-2.6.spec" now edit the /usr/src/redhat/BUILD/kernel-2.6.22/linux-2.6.22.i686/drivers/ieee1394/Makefile to look like this:
# # Makefile for the Linux IEEE 1394 implementation # ieee1394-objs := ieee1394_core.o ieee1394_transactions.o hosts.o \ highlevel.o csr.o nodemgr.o dma.o iso.o \ csr1212.o config_roms.o obj-m += ieee1394.o obj-n += pcilynx.o obj-m += ohci1394.o obj-m += video1394.o obj-m += raw1394.o obj-m += sbp2.o obj-m += dv1394.o obj-m += eth1394.o
make -C /lib/modules/22.214.171.124-41.fc7/build M=/usr/src/redhat/BUILD/kernel-2.6.22/linux-2.6.22.i686/drivers/ieee1394 modules make -C /lib/modules/126.96.36.199-41.fc7/build M=/usr/src/redhat/BUILD/kernel-2.6.22/linux-2.6.22.i686/drivers/ieee1394 modules_install
In all of the above, substitute your relevant directories RPM files and or kernel versions and I'll leave the blacklisting of the new drivers and loading of the old drivers as an exercise for the student (see http://wiki.linux1394.org/JujuMigration#head-312acc378e9f8174ecab678e16fd83d718de0dd8 for details).