

One driver may control multiple devices of the same kind. A device driver maybe written to control physical devices such as a UART or an MMC controller, or it may represent a virtual device such as the null device ( /dev/null ) or a ramdisk. The kernel has frameworks designed to make it easy to write a device driver, which is the piece of code that mediates between the kernel above and the hardware below. In this chapter we will cover the following topics:Īs I mentioned in Chapter 4, Configuring and Building the Kernel, one of the functions of the kernel is to encapsulate the many hardware interfaces of a computer system and present them in a consistent manner to user space programs.

There are many good books and articles that will help you to write device drivers, some of which are listed at the end of this chapter. However, remember that this is not a book dedicated to writing kernel device drivers and that the information given here is to help you navigate the territory but not necessarily to set up home there. There are many places to find out how to write a device driver, but few to tell you why you would want to and the choices you have in doing so. For example, you can manipulate GPIO pins and LEDs using files in sysfs, and there are libraries to access serial buses, including SPI (Serial Peripheral Interface) and I 2 C (Inter-Integrated Circuit). In many cases, you will find that there are device drivers provided for you, and you can achieve everything you want without writing any kernel code.

Your system will probably have some novel pieces of hardware, and you will have to work out a way of accessing them. As a developer of embedded systems, you need to know how these device drivers fit into the overall architecture and how to access them from user space programs. Kernel device drivers are the mechanism through which the underlying hardware is exposed to the rest of the system. The following installments present this excerpt on Embedded Linux device drivers:Īdapted from Mastering Embedded Linux Programming – Second Edition, by Chris Simmonds.Ĭhapter 9. In this excerpt, Chapter 9, from the book, the author describes how kernel device drivers interact with system hardware and how developers can write device drivers and use them in their applications.
