Chapter 2. Minimal Linux

WHEN BUILDING AN EMBEDDED APPLICATION, the primary concern is almost always the size of the distribution and how much memory it will take. The device you’re building is usually much smaller physically than a general-purpose computer, and it usually has less memory and storage. Therefore, the embedded software must be much more efficient than software that runs on a general-purpose computer. Fortunately, a lot of research has been done to optimize software for storage and memory usage—because they were so much more expensive in years gone by.

This chapter explores some of the various ways to make a running Linux system as small as possible, and looks at the different methods available to the developer of an embedded appliance.

Before we delve into optimizing for size, we should take a look at how a typical Linux system works, and some interesting alternatives to the typical system.

A typical desktop Linux system has three major software layers—the Linux kernel, a C library, and application code (see Figure 2.1):

Figure 2.1. Layers in a typical desktop Linux system.


  • The kernel has sole and complete control over the hardware. Its drivers talk with the hardware on behalf of applications.

  • The next layer up from the kernel is the C library in a typical Linux system. Among other things, the C library translates POSIX API calls into a form that the kernel likes, and then calls the kernel, passing the parameters from the application code to the kernel.

  • Finally, farthest out from the hardware is the application code. The applications cause the Linux kernel (and thus the hardware—whether it’s a router, a personal organizer, or a camera) to perform the intended task.

When designing your embedded application, it’s important to realize that you can break this hierarchy. For example, your applications don’t have to use the C library to talk to the kernel; they can call the kernel interface directly—that’s what the C library itself does. This ties your code directly to the Linux kernel, making it less portable—but this may not matter to you in an embedded environment. You actually don’t have to have any application-layer code at all. It’s possible to run your application in the kernel itself as a kernel thread.

For the remainder of this chapter, we’ll assume that you’re going to use the standard three-layer approach: application, C library, kernel. It’s easily the most flexible and portable approach.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.59.187