Using a git driver development tree

From LinuxTVWiki
Jump to navigation Jump to search

Compiling a Git repository

The git driver repositories contain the full Linux kernel tree. So, before working with a driver, a full kernel compilation should be done. The easiest way is to run:

 $ make oldconfig

This will use your kernel old configuration, asking you only about the new features that have added (or moved), when compared with your original kernel version.

The first build will take some time. In order to do it, just run:

 $ make

After having the kernel built (and tested), subsequent compilations can be done by running:

 make M=drivers/media/

or, if the driver is currently at staging, by running:

 make M=drivers/staging/

With the above commands, only the media (or staging) drivers will be recompiled, if they got changed, saving you some time on testing the new driver features.

 NOTE: if you added new files or changed the files dependencies, you may need to do a full make. In this case, just run:
   $ make

Installing the new kernel

If this is the first time you're compiling the drivers, or if kernel version changed from your previous build, you should run a full drivers installation with:

 # make modules_install install

Be sure to be root when installing the drivers.

Installing the new drivers on your kernel

After the first installation, you may just copy the new drivers with this small script:

 for i in `find drivers/media -name *.ko`; do
         if [ $i -nt /lib/modules/`uname -r`/kernel/$i ]; then
                 sudo install -m 644 -c -D $i /lib/modules/`uname -r`/kernel/$i || exit -1
         fi
 done
 NOTE: if your kernel version changed, you'll need to re-build the kernel again, with
   $ make olconfig
   $ make

Removing the already loaded modules

This is probably the trickiest part. You can, of course, just reboot the machine, but this may take some time, so Mauro Chehab wrote a script that unloads all kernel modules from the memory. There's a rmmod.pl version that works with git and with all kernels that put the media drivers at the right location.