Book Image

Mastering Embedded Linux Programming - Second Edition

By : Chris Simmonds
Book Image

Mastering Embedded Linux Programming - Second Edition

By: Chris Simmonds

Overview of this book

Embedded Linux runs many of the devices we use every day, from smart TVs to WiFi routers, test equipment to industrial controllers - all of them have Linux at their heart. Linux is a core technology in the implementation of the inter-connected world of the Internet of Things. The comprehensive guide shows you the technologies and techniques required to build Linux into embedded systems. You will begin by learning about the fundamental elements that underpin all embedded Linux projects: the toolchain, the bootloader, the kernel, and the root filesystem. You’ll see how to create each of these elements from scratch, and how to automate the process using Buildroot and the Yocto Project. Moving on, you’ll find out how to implement an effective storage strategy for flash memory chips, and how to install updates to the device remotely once it is deployed. You’ll also get to know the key aspects of writing code for embedded Linux, such as how to access hardware from applications, the implications of writing multi-threaded code, and techniques to manage memory in an efficient way. The final chapters show you how to debug your code, both in applications and in the Linux kernel, and how to profile the system so that you can look out for performance bottlenecks. By the end of the book, you will have a complete overview of the steps required to create a successful embedded Linux system.
Table of Contents (17 chapters)

A better way of managing device nodes

Creating device nodes statically with mknod is quite hard work and inflexible. There are other ways to create device nodes automatically on demand:

  • devtmpfs: This is a pseudo filesystem that you mount over /dev at boot time. The kernel populates it with device nodes for all the devices that the kernel currently knows about, and it creates nodes for new devices as they are detected at runtime. The nodes are owned by root and have default permissions of 0600. Some well-known device nodes, such as /dev/null and /dev/random, override the default to 0666. To see exactly how this is done, take a look at the Linux source file: drivers/char/mem.c and see how struct memdev is initialized.
  • mdev: This is a BusyBox applet that is used to populate a directory with device nodes and to create new nodes as needed. There is a configuration file, /etc/mdev...