CHAPTER 16Embedded Kernel Programming
In this chapter, you are introduced to Linux kernel programming on an embedded device such as a Beagle board. Kernel programming is an advanced topic that requires in-depth study of the source code for the Linux kernel; however, this chapter is structured as a practical step-by-step guide to the focused task of writing Linux loadable kernel modules (LKMs) that interface to general-purpose inputs/outputs (GPIOs). The first example is a straightforward “Hello World” module that can be used to establish a configuration for LKM development on the board. The second LKM example introduces interrupt service routines (ISRs) and interfaces a simple GPIO button and LED circuit to Linux kernel space. Two further examples are provided that introduce the kobject interface and the use of kernel threads to build kernel-space sysfs devices for the board. By the end of this chapter, you should be familiar with the steps required to write kernel code, and appreciate the programming constraints that such development entails.
EQUIPMENT REQUIRED FOR THIS CHAPTER:
- Beagle board (any model) running Linux 4.x.x or greater
Further details on this chapter are available at www.exploringbeaglebone.com/chapter16/
.
Introduction
As introduced in Chapter 3, a loadable kernel module (LKM) is a mechanism for adding code to, or removing code from, the Linux kernel at run time. LKMs are ideal for device drivers, enabling the kernel to communicate with the hardware without ...
Get Exploring BeagleBone, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.