KernelSourceDriver

How to setup Ubuntu to build a driver from source

Caveat

Please remember that the best solution is to get your driver integrated into Linus Torvald's kernel. There are a few reasons for this:

  • The Kernel ABI can change from time to time. Anytime it does, your driver will mysteriously no longer work if you compile your own, but the Ubuntu kernel folks will take care of it if it's integrated.
  • If you're giving this driver to others, noone using the development versions will be able to test your driver. If there are major kernel changes or systems changes, your driver can easily get ignored in the shuffle.
  • Getting the kernel upstream means that you have less work to do to get your driver into all of the various distributions out there. We are most successful when we grow the community.

Now that you've committed to ignoring all my advice, let's get on with it...

Install the main build environment

sudo apt-get install build-essential

This command will install gcc, make, and a small pile of other standard tools that you need for basic development.

Install the Kernel Headers

sudo apt-get install linux-headers-$(uname -r)

This command will install the headers into /usr/src, and setup the appropriate build link in /lib/modules/$(uname -r)

The kernel name includes the ABI number, so:

2.6.15-17-powerpc64-smp

Tells us that we're on ABI revision 17. Anytime that number increases, you've had an ABI bump, and you'll have to install a new set of linux headers on the new running kernel. The magic with $(uname -r) inserts the current header information into the currently running kernel.

If you're planning on distributing this driver

Ubuntu provides a number of different flavours of the Ubuntu Kernel. Ubuntu have kernels specialised for i386, i686, k7, powerpc, and amd64. For each of these, there is also have UP and SMP variants. You must provide a driver for each version of this kernel where your hardware might run. Again, see earlier advice about simply getting your driver integrated with the kernel so that we take care of this for you.

KernelSourceDriver (last edited 2008-08-06 16:29:07 by localhost)