3-Day Linux Device Driver Development

 

Course Description

This course teaches attendees to develop device drivers for Linux.

 

This course acquaints developers with the issues essential for Linux device driver development. The course progresses through a number of topics. Each topic is presented along with a supporting laboratory exercise before moving on to the next topic.

Overview

This three day course provides practice with the key steps in developing Linux device drivers. The course shows attendees how device drivers work with the Linux kernel, how to compile and load drivers, and how to debug drivers.

 

Attendees will spend approximately 50 percent of the class time actually gaining hands-on experience with these topics.

 

Course Objectives

Attendees will learn:

Who Should Attend:

The course is designed for software engineers who are new to Linux device drivers. Attendees should have experience with C, be able to perform basic Unix commands, and have some experience with the basic GNU tools of gcc, gdb, and make. The Linux Development Fundamentals, Tools & Techniques course is a good prerequisite to this course.

Duration

Three days

Course Materials

The workshop materials include a comprehensive student workbook and CD. The workbook contains all of the slides used in the course as well as hands-on lab exercises.

 

The CD contains the lab exercise code as well as a large amount of Linux software.

Course Workshop and Set-up:

The workshop makes use of standard PC's with a desktop Linux distribution for development. The course will make use of PC's and PC devices as examples.

Device Driver Development Outline

How To Configure And Install The Kernel

The kernel source code
Configure and build a new kernel
Install the new kernel

How Loadable Modules Work

Benefits of loadable module
Correct use of insmod, modprobe, rmmod, and lsmod
Passing parameters to a module
The GPL and Linux

Compiling

Identifying important header files
Writing a simple module
Compiling modules
Loading/unloading modules
Exporting symbols from a loadable module
Creating stacked loadable modules

Tracing and Debugging

printk for debugging
Device information in /proc and /sys
strace to track system calls
ksyms
Debuggers, e.g., gdb, and kgdb

Character Devices

Classes of device files
Major and minor numbers
Creating device files with mknod
Registering character device file
Listing character device driver methods
Dynamic major/minor numbers

Data: User To/From Kernel

Important functions for accessing user space
Shared Memory
Issues with accessing user space from kernel space

Blocking and Wait Queues

Schedule()
Wait Queues
Safe sleeping
Poll()

I/O ports and interrupts

Uses of I/O ports and IRQs
Platform dependency issues
Functions used for reading and writing I/O ports
Interrupt Handler functions
Restrictions on kernel code running in interrupt context

Accessing PCI hardware

Code to detect PCI devices
Resource conflicts
Vendor/device IDs
I/O mapping
DMA

Network Drivers

The net_device structure
Naming scheme
Network driver methods

Block Device Drivers

Block device drivers
Header files
Registering block drivers
The block_device_operations structure
Special methods