Embedded Linux device drivers

Kernel device drivers expose the underlying hardware to the rest of the system. Devices running embedded Linux or Android almost always need to interface with novel configurations of hardware, and so it is often necessary for engineers working in the embedded and Android space to be familiar with the device driver infrastructure within the Linux kernel.

This course contains the background information necessary to be able to write, configure and debug device driver code. Throughout, there is an emphasis on the techniques that are applicable to embedded systems such as platform independence, cross development and efficient use of resources. All the lab exercises are cross-compiled and tested on an ARM based development board, the BeagleBone Black.

Download course details as a PDF
Click here for information about booking a course

Duration

4 days

Price

£2000 (excluding VAT)

Upcoming courses

None scheduled: contact us to request a quote

Prerequisites

Essential

  • good understanding of the C language

Recommended

  • familiarity with Linux development and command-line tools

Course materials

All students will receive:

  • A printed copy of the presentations and lab notes
  • A USB flash drive containing worked solutions to the problems, plus electronic copies of the course materials
  • A free copy of the trainer's book, “Mastering Embedded Linux Programming”

Hands-on labs

An essential part of the training are the lab sessions, which take approximately 50% of the time. We normally work in pairs using a modern development board such as the Beaglebone. Each group will also need a laptop or desktop to run the system development tools. We will provide a bootable USB memory stick with an appropriate version of Linux and cross tool-chain so there is no need to install Linux beforehand.

Outline

Developing for embedded Linux

  • Getting and configuring a cross toolchain
  • Linux bootloaders: U-Boot

The Linux kernel

  • Where to get the kernel source
  • Board support packages
  • Kernel configuration options
  • Building and loading a kernel

Kernel modules

  • Writing a module and compiling "out of tree"
  • Loading and testing on the target
  • Passing parameters
  • Modules and the GPL license

Device driver basics

  • Types of device driver
  • Different ways for applications to interact with the driver
  • Building and testing a simple character device driver

Kernel debugging

  • Review of printk and the magic sysrq key
  • Interactive debugging using kgdb
  • What to do when the board won't boot

Sysfs and proc

  • Classes of driver: /sys/class
  • Driver attributes
  • Extending the proc file system

Wait queues

  • Waiting for things to happen
  • Sleeping and waking

Kernel locking

  • Mutual exclusion using kernel mutexes
  • Spinlocks
  • Atomic operations

Time and timers

  • Getting the system time: high resolution timers
  • Delays and sleeps
  • Kernel timers

Interrupts

  • Installing an interrupt handler
  • Synchronising using using spin_lock_irq
  • Deferred processing using tasklets and work queues

Accessing hardware

  • Overview of device tree and how to extract information from them
  • Mapping in device memory: ioremap
  • DMA buffers: coherent and stream mappings
  • Memory barriers

Sharing memory

  • mmap: sharing device registers
  • mmap: sharing DMA buffers
  • get_user_pages: how to access user memory