Device Driver Development

From LQWiki
Jump to navigation Jump to search

Getting Started

  1. Get a Linux system where you have root access
  2. Run, don't walk to get the Linux Device Drivers, 3rd ed or get it in PDF form, one file per chapter or the whole book as a tarred and compressed PDF
    1. Get this book's sample code and try and build some modules

OS Tools

  1. Find your kernel directory
    1. For my Fedora 8, this is in something like /usr/src/kernels/2.6.26.5-28.fc8-i686
  2. Go to the Documentation/kbuild directory, read and understand how kernel and device driver builds work
  3. See the file Documentation/Changes in the kernel dir to get a list of required tool versions

Online Resources

Building Sample Modules

Building kernel modules is different from source code in user-space. Assuming your kernel source is in /usr/src/kernel, a build command looks like

<source lang="bash"> make -C /usr/src/kernel M=`pwd` modules </source>

Building Your Device Driver

The Makefile

Environment Variables

If you are not running the kernel that you are building for, you can set the KERNELDIR variable to point to that kernel.

See also