How to Obtain, Build and Install V4L-DVB Device Drivers: Difference between revisions

From LinuxTVWiki
Jump to navigation Jump to search
(→‎Compilation Errors: remove May 2007, kernel 2.6.17 compilation error to talk page)
(→‎Even More Errata: remove Nov 2007 answer to user question to talk page)
Line 178: Line 178:
make clean
make clean


Another reason for this issue is because your symbolic link for /lib/modules/<kernel-version>/build is broken. Before running make, remove the link and create a new pointing to the right location.


For your example above,
rm /lib/modules/2.6.15-27-desktop64-smp/build
ln -s /usr/src/kernels/2.6.15-27-desktop64-smp/build /lib/modules/2.6.15-27-desktop64-smp/build

and then, the remaining steps should work fine.


'''Note: On Ubuntu 8.04 (Hardy Heron),''' installation had the same error as above but was solved somewhat differently.
'''Note: On Ubuntu 8.04 (Hardy Heron),''' installation had the same error as above but was solved somewhat differently.

Revision as of 21:44, 28 February 2009

The LinuxTV project hosts the latest set of Linux kernel driver modules for V4L-DVB devices. This page contains information to help an "end user" install these device drivers in a GNU/Linux system.

Note: This article assumes you have already physically installed the hardware device into, or connected it to, your system. (Refer to the manufacturer's instructions for such details)

.

Software Requirements

Kernel Support

The LinuxTV V4L-DVB drivers will work only in conjunction with relatively modern 2.6 kernels; specifically, the V4L-DVB tree is currently backwards compatible with vanilla kernels from currently 2.6.16 onwards.

In the past, backwards compatibility meant 2.6.12 and greater, but, as time has progressed, the number of significant (and progressive!) changes introduced within the drivers have made it extremely difficult, if not impossible, to provide as thorough compatibility between the newest V4L-DVB releases and older kernels. Consequently, as mentioned above, in order to install a recent snapshot of the V4L-DVB drivers onto your system, you will need to be utilizing a kernel 2.6.16 or greater.

If you have configured the kernel manually, please note that some capabilities should be enabled like EVDEV. You should also investigate installing the "udev" package (for kernels >= 2.6.15) which automatically populates the /dev directory when devices are found. Stock kernels should have everything required.

Additional Software Requrirements

In order to be able to build the V4L-DVB kernel driver modules, you will need:

  • kernel-source or kernel-headers
  • make
  • gcc

If these packages are not currently installed on your system, you should do so now.

You May Also Wish to Install Mercurial

Using Mercurial (Hg) provides several advantages for the end user:

  • easy to switch between LinuxTV driver snapshots
  • easy upgrading in the future
  • an advanced method (i.e. hg bisect) for finding the source commit that introduces a bug/error into the driver source
  • blah blah blah

Some Linux distributions already include Hg within their package repositories The following provides examples of how to install the Mercurial software package for some distributions (Note that [sudo] means that you only have to specify "sudo" if you aren't root, otherwise omit it.):

  • On Debian-based distributions use the following command to install all required software:
$ [sudo] apt-get install mercurial linux-headers-$(uname -r) build-essential
  • On Gentoo-based distributions use the following command to install mercurial. Other dependencies are installed in main system tree.
$ [sudo] emerge mercurial
  • On Fedora it's just as easy:
$ [sudo] yum install mercurial
$ [sudo] urpmi mercurial

If your distribution doesn't include Mercurial, you can download a binary package or retrieve the source and build it yourself. Note: Mercurial requires python 2.3 or greater.

Retrieving the Latest V4L-DVB Source Code

After installing all required software, download a copy of the latest source code from LinuxTV. You can do that either by:

Tarball

Grabbing a copy available as a compressed Tarball (both bz2 and gz formats), from http://linuxtv.org/repo This is likely the pathway the most end users will take, in particular those who do not anticipate reinstalling the device drivers very often. Note: you will have to uncompress the source code.

Using Mercurial

If you have choosen to install Mercurial, the source code for the V4L-DVB kernel modules is available via an Hg tree on LinuxTV using the following command:

hg clone http://linuxtv.org/hg/v4l-dvb

This creates a directory called v4l-dvb in the current working directory.

Similarly, if you also wish to retrieve the dvb-apps source tree, you can do so with:

hg clone http://linuxtv.org/hg/dvb-apps

To Update the Hg Sources at Some Future Point in Time

Update your local copy of the source code later on with the following command (entered from the previously created v4l-dvb directory; i.e. cd v4l-dvb):

hg pull -u http://linuxtv.org/hg/v4l-dvb

Then, when that job completes, you can get your local copy ready to compile by entering the following command:

 hg update

Build and Installation Instructions

Regardless of the method you used to acquire the V4L-DVB source code, the process of building the driver modules, and then installing them, is the same.

Optional Pre-Compilation Steps

These options are applicable only in certain situations approaching a new build of the driver set, or for experienced users wishing to streamline the build process to consist of only those components they want to install.

  • make rmistall ... you would use this to remove the currently installed driver set (located within the relevant /lib/modules/["kernel "version"]/kernel/drivers/media directory to which they were installed)
  • make distclean ... cleans up the build configuration environment ... noteworthy is that it will set things up such that a following "make" build process will be against "/usr/src/[uname -r version]” kernel source
  • make menuconfig ... select only those components you wish to build and install

Building/Compiling the Modules

Start by changing into the directory that contains the previously downloaded source:

cd v4l-dvb

Build/compile the modules from source with:

make

If you run into any problems here, see the errata section below. Failing that, contact the developers via irc.freenode.net on #linuxtv or on #dvb. Note that errors that prevent building a particular V4L-DVB snapshot do indeed surface from time to time, but these are usually corrected quickly upon notification from a bug report. In addition, Hans Verkuil has set up a daily automated build of the V4L-DVB source upon all supported kernels and upon several architectures; the results of these tests are published on the Linux-media mailing list under a message with a subject heading prefix "[cron job]". In general, if the source builds correctly, it is likely that the driver will work, though this is not a guarantee.

Also heed attention to any notes provided by the output of the build process; in particular, it will list the kernel requirements of some specific drivers included within the V4L-DVB snapshots.

Installing the Modules

The next step is to install the kernel driver modules by executing:

sudo make install

The command above will prompt you for your root password, and then copy *.ko module files into your /lib/modules kernel directories.

Out with the Old, In with the New

Before trying to use the device with your newly installed driver set, you should remove from system memory any older versions of related modules that may have been loaded by the running kernel; otherwise, you will likely run into various mismatch errors as a result of your system trying to work from a mixture of old and new modules.

To achieve a clean slate state, you could either:

1. Reboot: Perhaps the most straightforward thing to do at this point, particularly for Linux newbies, is to just restart your system; the reboot will, obviously, clear out the old modules loaded into memory and, as an added bonus, create a fresh running environment under which the new modules should have been automagically loaded into systeym memory.

Or, on the other hand,

2. Take care of business yourself: More experienced users might prefer to use more eloquent approaches. For example, using

sudo make unload

will essentially (and similar as to manually using "rmmod" commands) remove all older modules for the device that might be currently loaded in memory by the running kernel. After which, one can then load, from the newly installed device driver set, the appropriate modules for the device using relevant

modprobe driver_name 

commands.

Note: in cases where loading more then one module is necessary, the order in which you load the modules can matter!


Note: If you should try "make unload" followed by an appropriate modprobe command but encounter errors in relation to unresolved symbols, please try a system reboot before filing an error report. Irregardless of what caused the unresolved symbols errors, usually, after performing the reboot, you will find that the install was actually successful and the drivers will work as intended

Regardless of which approach you take to remove the old modules and to insert the new ones, the end result should be the same. Correctly installed modules will usually show some info in your system log (consult the output from the "dmesg" command or directly review your log file) indicating that they have been successfully loaded into system memory and that the device is now correctly configured for operation. Likewise, any module loading errors will also likely be reported in your system log.

A Note on Firmware

Some devices will also require a firmware, which is uploaded from the host PC to the device, in order to operate.

In some cases, when the device is correctly recognized, the associated drivers provide information as to which firmware file is required -- look in the system log output.

In other cases, obtaining the correct firmware is not so straightforward a task. The very first thing you need to know is what device you're using; see "Gathering Information About Your Unidentified/Unsupported Device". Once you have established the device's identity, you can then move on to obtaining the correct firmware. In addition, information in wiki articles (eg. such as DVB-T USB Devices) will cite the appropriate firmware required. If you're still at a loss, a Google search may shed light on what file you need. Note, however, that not all supported devices have easily available firmware (eg. Hauppauge HVR 1100 & 1300). Firmware for such cards could be loaded via temporary installation in a Mirosoft Windows System with the manufacturer-supplied drivers.

In any regard, once you find and obtain the necessary firmware for your device, copy it into the appropriate directory. The location of this directory depends on your distribution, but normally it's one of these:

  • /lib/firmware
  • /usr/lib/hotplug/firmware

A Note For Advanced User Users

Perhaps useful only for developers, after building the modules as per usual ("make"), and without needing to install them, you can:

  • remove all older modules from memory at once (using "make unload") and
  • then insert all newly built modules into memory at once for the running kernel by trying "make load"

To perform the previous two commands above ("make unload" and "make load") in a single step, you can use "make reload"

Though it is highly recommended that you avoid using either the make load or make reload options, as they will end up inserting _ALL_ V4L-DVB device drivers into memory, and that may introduce you to some instability.

Further Documentation

Move to Talk Page

Errata

Compilation for Kernels before 2.6.22

On old kernels (2.6.22 and older) there is a set of device drivers which will not compile as they require later kernel for the devices to be supported, and this will result in compilation errors. These can be fixed by disabling the compilation of unneeded (ones that require newer kernel) modules

make allmodconfig

Still it seems that for kernels older than 2.6.20 the compatibility may have been broken. ( If you figure out a way to compile on 2.6.17 put it here.)

Loading Modules

After running the "make install" command, you might end up with *.ko files and their older compressed version *.ko.gz in the same directory. In this case, the modprobe command might fail (example with the saa7134 module):

sudo modprobe saa7134
FATAL: Error inserting saa7134 (/lib/modules/2.6.17-8mdv/kernel/drivers/media/video/saa7134/saa7134.ko):\ 
Unknown symbol in module, or unknown parameter (see dmesg)

The dmesg then returns a list of 'unknown symbol' error messages because of compatiblity issues between the new *.ko module files and the old *.ko.gz ones:

Unknown symbol ir_codes_pinnacle_color
Unknown symbol ir_codes_encore_enltv
Unknown symbol ir_codes_proteus_2309
Unknown symbol ir_rc5_timer_keyup
Unknown symbol ir_codes_asus_pc39
Unknown symbol ir_rc5_timer_end
Unknown symbol ir_codes_pinnacle_grey

All conflicting *.ko.gz files must be removed. The following command line can help you locate these conflicting files in all your installed kernels:

for file in `find /lib/modules -name "*.ko"`; do if -e $file.gz ; then echo "$file.gz should be removed"; fi; done

Usually all conflicting module files resulting of v4l-dvb installation will be located in:

/lib/modules/[your kernel version]/kernel/drivers/media

Once the conflicting *.ko.gz have been moved elsewhere or renamed (to *.ko.gz.disabled for example), use the v4l-dvb reload command and, to be safe, also add a "depmod" step in order to rebuild modules dependencies):

make reload
depmod -a

Your modules should now be loaded correctly.


Even More Errata

First, try this step

cd /var/v4l-dvb (or wherever you put the download)
make distclean
make clean


Note: On Ubuntu 8.04 (Hardy Heron), installation had the same error as above but was solved somewhat differently. First you must install the linux-headers and the linux kernel source. To do so, type the following (and those are back ticks, not single quotes, people!)

 sudo apt-get install linux-headers-`uname -r` linux-source

You'll notice that the source code is installed as a tar file in the /usr/src directory. This is not particularly useful. Let's untar it, do so by typing:

 sudo tar xjf /usr/src/linux-source-`uname -r`.tar.bz2 -C /usr/src

And then create a symbolic link to the source (if there isn't already one) by typing:

 cd /usr/src
 sudo rm linux
 sudo ln -s /usr/src/linux-source-`uname -r` linux

Finally, let's make sure we have the /lib/modules/`uname -r`/build directory pointing to THE HEADERS... NOT THE KERNEL SOURCE. This is the million dollar hurdle, and it bears repeating. The /lib/modules/<your kernel version>/build should point to the correct linux-headers, not the source code of the kernel. (Yes, weird, I know) Type:

 cd /lib/modules/`uname -r`
 sudo rm build
 sudo ln -s /usr/src/linux-headers-`uname -r` build

Now you can go to your v4l source directory that you downloaded using hg, and do a

 rm v4l/.version
 make

and all should be good with the world. This was a supreme PITA, so I am hopeful that this will save somebody their sanity.

If you are having problems with a module not compiling, and it is not important to you, do a

find . -name my_bad_module_name.c -print

Then go to the directory that contains it. You will find a Makefile. Edit it and put a # at the start of the line that has the module name.