Embedded Linux Primer: A Practical, Real-World Approach
By Christopher Hallinan
Publisher: Prentice Hall
Pub Date: September 18, 2006
Print ISBN-10: 0-13-167984-8
Print ISBN-13: 978-0-13-167984-9
Pages: 576
Table of Contents | Index
Comprehensive Real-World Guidance for Every Embedded Developer and Engineer
This book brings together indispensable knowledge for building efficient, high-value, Linux-based
embedded products: information that has never been assembled in one place before. Drawing on
years of experience as an embedded Linux consultant and field application engineer, Christopher
Hallinan offers solutions for the specific technical issues you're most likely to face, demonstrates
how to build an effective embedded Linux environment, and shows how to use it as productively as
possible.
Hallinan begins by touring a typical Linux-based embedded system, introducing key concepts and
components, and calling attention to differences between Linux and traditional embedded
environments. Writing from the embedded developer's viewpoint, he thoroughly addresses issues
ranging from kernel building and initialization to bootloaders, device drivers to file systems.
Hallinan thoroughly covers the increasingly popular BusyBox utilities; presents a step-by-step
walkthrough of porting Linux to custom boards; and introduces real-time configuration via
CONFIG_RT one of today's most exciting developments in embedded Linux. You'll find especially
detailed coverage of using development tools to analyze and debug embedded systems including
the art of kernel debugging.
Compare leading embedded Linux processors
Understand the details of the Linux kernel initialization process
Learn about the special role of bootloaders in embedded Linux systems, with specific emphasis
on U-Boot
Use embedded Linux file systems, including JFFS2 with detailed guidelines for building Flash-
resident file system images
Understand the Memory Technology Devices subsystem for flash (and other) memory devices
Master gdb, KGDB, and hardware JTAG debugging
Learn many tips and techniques for debugging within the Linux kernel
Embedded Linux Primer: A Practical, Real-World Approach
By Christopher Hallinan
Publisher: Prentice Hall
Pub Date: September 18, 2006
Print ISBN-10: 0-13-167984-8
Print ISBN-13: 978-0-13-167984-9
Pages: 576
Table of Contents | Index
Comprehensive Real-World Guidance for Every Embedded Developer and Engineer
This book brings together indispensable knowledge for building efficient, high-value, Linux-based
embedded products: information that has never been assembled in one place before. Drawing on
years of experience as an embedded Linux consultant and field application engineer, Christopher
Hallinan offers solutions for the specific technical issues you're most likely to face, demonstrates
how to build an effective embedded Linux environment, and shows how to use it as productively as
possible.
Hallinan begins by touring a typical Linux-based embedded system, introducing key concepts and
components, and calling attention to differences between Linux and traditional embedded
environments. Writing from the embedded developer's viewpoint, he thoroughly addresses issues
ranging from kernel building and initialization to bootloaders, device drivers to file systems.
Hallinan thoroughly covers the increasingly popular BusyBox utilities; presents a step-by-step
walkthrough of porting Linux to custom boards; and introduces real-time configuration via
CONFIG_RT one of today's most exciting developments in embedded Linux. You'll find especially
detailed coverage of using development tools to analyze and debug embedded systems including
the art of kernel debugging.
Compare leading embedded Linux processors
Understand the details of the Linux kernel initialization process
Learn about the special role of bootloaders in embedded Linux systems, with specific emphasis
on U-Boot
Use embedded Linux file systems, including JFFS2 with detailed guidelines for building Flash-
resident file system images
Understand the Memory Technology Devices subsystem for flash (and other) memory devices
Master gdb, KGDB, and hardware JTAG debugging
Learn many tips and techniques for debugging within the Linux kernel
Maximize your productivity in cross-development environments
Prepare your entire development environment, including TFTP, DHCP, and NFS target servers
Configure, build, and initialize BusyBox to support your unique requirements
About the Author
Christopher Hallinan, field applications engineer at MontaVista software, has worked for more than
20 years in assignments ranging from engineering and engineering management to marketing and
business development. He spent four years as an independent development consultant in the
embedded Linux marketplace. His work has appeared in magazines, including Telecommunications
Magazine, Fiber Optics Magazine, and Aviation Digest.
Embedded Linux Primer: A Practical, Real-World Approach
By Christopher Hallinan
Publisher: Prentice Hall
Pub Date: September 18, 2006
Print ISBN-10: 0-13-167984-8
Print ISBN-13: 978-0-13-167984-9
Pages: 576
Table of Contents | Index
Copyright
Prentice Hall Open Source Software Development Series
Foreword
Preface
Acknowledgments
About the Author
Chapter 1. Introduction
Section 1.1. Why Linux?
Section 1.2. Embedded Linux Today
Section 1.3. Open Source and the GPL
Section 1.4. Standards and Relevant Bodies
Section 1.5. Chapter Summary
Chapter 2. Your First Embedded Experience
Section 2.1. Embedded or Not?
Section 2.2. Anatomy of an Embedded System
Section 2.3. Storage Considerations
Section 2.4. Embedded Linux Distributions
Section 2.5. Chapter Summary
Chapter 3. Processor Basics
Section 3.1. Stand-alone Processors
Section 3.2. Integrated Processors: Systems on Chip
Section 3.3. Hardware Platforms
Section 3.4. Chapter Summary
Chapter 4. The Linux KernelA Different Perspective
Section 4.1. Background
Section 4.2. Linux Kernel Construction
Section 4.3. Kernel Build System
Section 4.4. Obtaining a Linux Kernel
Section 4.5. Chapter Summary
Chapter 5. Kernel Initialization
Section 5.1. Composite Kernel Image: Piggy and Friends
Section 5.2. Initialization Flow of Control
Section 5.3. Kernel Command Line Processing
Section 5.4. Subsystem Initialization
Section 5.5. The init Thread
Section 5.6. Chapter Summary
Chapter 6. System Initialization
Section 6.1. Root File System
Section 6.2. Kernel's Last Boot Steps
Section 6.3. The Init Process
Section 6.4. Initial RAM Disk
Section 6.5. Using initramfs
Section 6.6. Shutdown
Section 6.7. Chapter Summary
Chapter 7. Bootloaders
Section 7.1. Role of a Bootloader
Section 7.2. Bootloader Challenges
Section 7.3. A Universal Bootloader: Das U-Boot
Section 7.4. Porting U-Boot
Section 7.5. Other Bootloaders
Section 7.6. Chapter Summary
Chapter 8. Device Driver Basics
Section 8.1. Device Driver Concepts
Section 8.2. Module Utilities
Section 8.3. Driver Methods
Section 8.4. Bringing It All Together
Section 8.5. Device Drivers and the GPL
Section 8.6. Chapter Summary
Chapter 9. File Systems
Section 9.1. Linux File System Concepts
Section 9.2. ext2
Section 9.3. ext3
Section 9.4. ReiserFS
Section 9.5. JFFS2
Section 9.6. cramfs
Section 9.7. Network File System
Section 9.8. Pseudo File Systems
Section 9.9. Other File Systems
Section 9.10. Building a Simple File System
Section 9.11. Chapter Summary
Chapter 10. MTD Subsystem
Section 10.1. Enabling MTD Services
Section 10.2. MTD Basics
Section 10.3. MTD Partitions
Section 10.4. MTD Utilities
Section 10.5. Chapter Summary
Chapter 11. BusyBox
Section 11.1. Introduction to BusyBox
Section 11.2. BusyBox Configuration
Section 11.3. BusyBox Operation
Section 11.4. Chapter Summary
Chapter 12. Embedded Development Environment
Section 12.1. Cross-Development Environment
Section 12.2. Host System Requirements
Section 12.3. Hosting Target Boards
Section 12.4. Chapter Summary
Chapter 13. Development Tools
Section 13.1. GNU Debugger (GDB)
Section 13.2. Data Display Debugger
Section 13.3. cbrowser/cscope
Section 13.4. Tracing and Profiling Tools
Section 13.5. Binary Utilities
Section 13.6. Miscellaneous Binary Utilities
Section 13.7. Chapter Summary
Chapter 14. Kernel Debugging Techniques
Section 14.1. Challenges to Kernel Debugging
Section 14.2. Using KGDB for Kernel Debugging
Section 14.3. Debugging the Linux Kernel
Section 14.4. Hardware-Assisted Debugging
Section 14.5. When It Doesn't Boot
Section 14.6. Chapter Summary
Chapter 15. Debugging Embedded Linux Applications
Section 15.1. Target Debugging
Section 15.2. Remote (Cross) Debugging
Section 15.3. Debugging with Shared Libraries
Section 15.4. Debugging Multiple Tasks
Section 15.5. Additional Remote Debug Options
Section 15.6. Chapter Summary
Chapter 16. Porting Linux
Section 16.1. Linux Source Organization
Section 16.2. Custom Linux for Your Board
Section 16.3. Platform Initialization
Section 16.4. Putting It All Together
Section 16.5. Chapter Summary
Chapter 17. Linux and Real Time
Section 17.1. What Is Real Time?
Section 17.2. Kernel Preemption
Section 17.3. Real-Time Kernel Patch
Section 17.4. Debugging the Real-Time Kernel
Section 17.5. Chapter Summary
Appendix A. GNU Public License
Preamble
Terms and Conditions for Copying, Distribution and Modification
No Warranty
Appendix B. U-Boot Configurable Commands
Appendix C. BusyBox Commands
Appendix D. SDRAM Interface Considerations
Section D.1. SDRAM Basics
Section D.2. Clocking
Section D.3. SDRAM Setup
Section D.4. Summary
Appendix E. Open Source Resources
Source Repositories and Developer Information
Mailing Lists
Linux News and Developments
Open Source Insight and Discussion
Appendix F. Sample BDI-2000 Configuration File
Index
Copyright
Many of the designations used by manufacturers and sellers to distinguish their products are claimed
as trademarks. Where those designations appear in this book, and the publisher was aware of a
trademark claim, the designations have been printed with initial capital letters or in all capitals.
The author and publisher have taken care in the preparation of this book but make no expressed or
implied warranty of any kind and assume no responsibility for errors or omissions. No liability is
assumed for incidental or consequential damages in connection with or arising out of the use of the
information or programs contained herein.
The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or
special sales, which may include electronic versions and/or custom covers and content particular to
your business, training goals, marketing focus, and branding interests. For more information, please
contact:
U.S. Corporate and Government Sales
(800) 382-3419
For sales outside the United States, please contact:
International Sales
Visit us on the Web: www.prenhallprofessional.com
Copyright
©
2007 Pearson Education, Inc.
All rights reserved. Printed in the United States of America. This publication is protected by copyright,
and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a
retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying,
recording, or likewise. For information regarding permissions, write to:
Pearson Education, Inc.
Rights and Contracts Department
One Lake Street
Upper Saddle River, NJ 07458
Fax: (201) 236-3290
Text printed in the United States on recycled paper at R.R. Donnelley in Crawfordsville, Indiana.
First printing, September, 2006
Library of Congress Cataloging-in-Publication Data:
Hallinan, Christopher.
Embedded Linux primer : a practical, real-world approach / Christopher Hallinan.
p.cm.
Includes bibliographical references.
ISBN 0-13-167984-
8 (pbk. : alk. paper) 1. Linux. 2. Operating systems (Computers) 3. Embedded computer systems
Programming. I. Title.
QA76.76.O63H34462 2006
005.4'32dc22
2006012886
Dedication
To my mother Edythe, whose courage, confidence, and grace have been an inspiration to us all.
Prentice Hall Open Source Software
Development Series
Arnold Series Editor Robbins
"Real world code from real world applications"
Open Source technology has revolutionized the computing world. Many large-scale projects are in
production use worldwide, such as Apache, MySQL, and Postgres, with programmers writing
applications in a variety of languages including Perl, Python, and PHP. These technologies are in use
on many different systems, ranging from proprietary systems, to Linux systems, to traditional UNIX
systems, to mainframes.
The Prentice Hall Open Source Software Development Series is designed to bring you the best
of these Open Source technologies. Not only will you learn how to use them for your projects, but
you will learn from them. By seeing real code from real applications, you will learn the best practices
of Open Source developers the world over.
Titles currently in the series include:
Linux
®
Debugging and Performance Tuning: Tips and Techniques
Steve Best
0131492470, Paper, ©2006
Understanding AJAX: Using JavaScript to Create Rich Internet Applications
Joshua Eichorn
0132216353, Paper, ©2007
Embedded Linux Primer
Christopher Hallinan
0131679848, Paper, ©2007
SELinux by Example
Frank Mayer, David Caplan, Karl MacMillan
0131963694, Paper, ©2007
UNIX to Linux
®
Porting
Alfredo Mendoza, Chakarat Skawratananond, Artis Walker
0131871099, Paper, ©2006
Linux Programming by Example: The Fundamentals
Arnold Robbins
0131429647, Paper, ©2004
The Linux
®
Kernel Primer: A Top-Down Approach for x86 and PowerPC Architectures
Claudia Salzberg, Gordon Fischer, Steven Smolski
0131181637, Paper, ©2006
Foreword
Computers are everywhere.
This fact, of course, is not a surprise to anyone who hasn't been living in a cave during the past 25
years or so. And you probably know that computers aren't just on our desktops, in our kitchens, and,
increasingly, in our living rooms holding our music collections. They're also in our microwave ovens,
our regular ovens, our cellphones, and our portable digital music players.
And if you're holding this book, you probably know a lot, or are interested in learning more about,
these embedded computer systems.
Until not too long ago, embedded systems were not very powerful, and they ran special-purpose,
proprietary operating systems that were very different from industry-standard ones. (Plus, they were
much harder to develop for.) Today, embedded computers are as powerful as, if not more than, a
modern home computer. (Consider the high-end gaming consoles, for example.)
Along with this power comes the capability to run a full-fledged operating system such as Linux.
Using a system such as Linux for an embedded product makes a lot of sense. A large community of
developers are making it possible. The development environment and the deployment environment
can be surprisingly similar, which makes your life as a developer much easier. And you have both the
security of a protected address space that a virtual memory-based system gives you, and the power
and flexibility of a multiuser, multiprocess system. That's a good deal all around.
For this reason, companies all over the world are using Linux on many devices such as PDAs, home
entertainment systems, and even, believe it or not, cellphones!
I'm excited about this book. It provides an excellent "guide up the learning curve" for the developer
who wants to use Linux for his or her embedded system. It's clear, well-written, and well-organized;
Chris's knowledge and understanding show through at every turn. It's not only informative and
helpfulit's also enjoyable to read.
I hope you both learn something and have fun at the same time. I know I did.
Arnold Robbins
Series Editor
Preface
Although many good books cover Linux, none brings together so many dimensions of information and
advice specifically targeted to the embedded Linux developer. Indeed, there are some very good
books written about the Linux kernel, Linux system administration, and so on. You will find references
right here in this book to many of the ones that I consider to be at the top of their categories.
Much of the material presented in this book is motivated by questions I've received over the years
from development engineers, in my capacity as an embedded Linux consultant and my present role
as a Field Application Engineer for Monta Vista Software, the leading vendor of embedded Linux
distributions.
Embedded Linux presents the experienced software engineer with several unique challenges. First,
those with many years of experience with legacy real-time operating systems (RTOSes) find it
difficult to transition their thinking from those environments to Linux. Second, experienced
application developers often have difficulty understanding the relative complexities of a cross-
development environment.
Although this is a primer, intended for developers new to embedded Linux, I am confident that even
developers who are experienced in embedded Linux will find some useful tips and techniques that I
have learned over the years.
Practical Advice for the Practicing Embedded Developer
This book contains my view of what an embedded engineer needs to know to get up to speed fast in
an embedded Linux environment. Instead of focusing on Linux kernel internals, the kernel chapter in
this book focuses on the project nature of the kernel and leaves the internals to the other excellent
texts on the subject. You will learn the organization and layout of the kernel source tree. You will
discover the binary components that make up a kernel image, and how they are loaded and what
purpose they serve on an embedded system. One of my favorite figures in the book is Figure 5-1,
which schematically illustrates the build process of a composite kernel image.
In the pages of this book, you will learn how the build system works and how to incorporate into the
Linux kernel your own custom changes that are required for your own projects. You will discover the
mechanism used to drive the configuration of different architectures and features within the Linux
kernel source tree and, more important, how to modify this system to customize it to your own
requirements. We also cover in detail the kernel command-line mechanism. You will learn how it
works, how to configure the kernel's runtime behavior for your requirements, and how to extend this
functionality to your own project. You will learn how to navigate the kernel source code and how to
configure the kernel for specific tasks related to an embedded system. You will learn many useful tips
and tricks for your embedded project, from bootloaders, system initialization, file systems, and Flash
memory to advanced kernel- and application-debugging techniques.
Intended Audience
This book is intended for programmers with a working knowledge of programming in C. I assume
that you have a rudimentary understanding of local area networks and the Internet. You should
understand and recognize an IP address and how it is used on a simple local area network. I also
assume that you have an understanding of hexadecimal and octal numbering systems, and their
common usage in a text such as this.
Several advanced concepts related to C compiling and linking are explored, so you will benefit from
having at least a cursory understanding of the role of the linker in ordinary C programming.
Knowledge of the GNU make operation and semantics will also prove beneficial.
What This Book Is Not
This book is not a detailed hardware tutorial. One of the difficulties the embedded developer faces is
the huge variety of hardware devices in use today. The user manual for a modern 32-bit processor
with some integrated peripherals can easily exceed 1,000 pages. There are no shortcuts. If you need
to understand a hardware device from a programmer's point of view, you will need to spend plenty of
hours in your favorite reading chair with hardware data sheets and reference guides, and many more
hours writing and testing code for these hardware devices!
This is also not a book about the Linux kernel or kernel internals. In this book, you won't learn about
the intricacies of the Memory Management Unit (MMU) used to implement Linux's virtual memory-
management policies and procedures; there are already several good books on this subject. You are
encouraged to take advantage of the "Suggestions for Additional Reading" section found at the end of
every chapter.
Conventions Used
Filenames and code statements are presented in Courier. Commands issued by the reader are
indicated in bold Courier. New terms or important concepts are presented in italics.
When you see a pathname preceded with three dots, this references a well-known but unspecified
top-level directory. The top-level directory is context dependent but almost universally refers to a
top-level Linux source directory. For example, /arch/ppc/kernel/setup.c refers to the setup.c file
located in the architecture branch of a Linux source tree. The actual path might be something like
~/sandbox/linux.2.6.14/arch/ppc/kernel/setup.c.
Organization of the Book
Chapter 1, "Introduction," provides a brief look at the factors driving the rapid adoption of Linux in
the embedded environment. Several important standards and organizations relevant to embedded
Linux are introduced.
Chapter 2, "Your First Embedded Experience," introduces the reader to many concepts related to
embedded Linux upon which we build in later chapters.
In Chapter 3, "Processor Basics," we present a high-level look at the more popular processors and
platforms that are being used to build embedded Linux systems. We examine selected products from
many of the major processor manufacturers. All of the major architecture families are represented.
Chapter 4, "The Linux Kernel: A Different Perspective," examines the Linux kernel from a slightly
different perspective. Instead of kernel theory or internals, we look at its structure, layout, and build
construction so you can begin to learn your way around this large software project and, more
important, learn where your own customization efforts must be focused. This includes detailed
coverage of the kernel build system.
Chapter 5, "Kernel Initialization," details the Linux kernel's initialization process. You will learn how
the architecture- and bootloader-specific image components are concatenated to the image of the
kernel proper for downloading to Flash and booting by an embedded bootloader. The knowledge
gained here will help you customize the Linux kernel to your own embedded application
requirements.
Chapter 6, "System Initialization," continues the detailed examination of the initialization process.
When the Linux kernel has completed its own initialization, application programs continue the
initialization process in a predetermined manner. Upon completing Chapter 6, you will have the
necessary knowledge to customize your own userland application startup sequence.
Chapter 7, "Bootloaders," is dedicated to the booloader and its role in an embedded Linux system.
We examine the popular open-source bootloader U-Boot and present a porting example. We briefly
introduce additional bootloaders in use today so you can make an informed choice about your
particular requirements.
Chapter 8, "Device Driver Basics," introduces the Linux device driver model and provides enough
background to launch into one of the great texts on device drivers, listed as "Suggestions for
Additional Reading" at the end of the chapter.
Chapter 9, "File Systems," presents the more popular file systems being used in embedded systems
today. We include coverage of the JFFS2, an important embedded file system used on Flash memory
devices. This chapter includes a brief introduction on building your own file system image, one of the
more difficult tasks the embedded Linux developer faces.
Chapter 10, "MTD Subsystem," explores the Memory Technology Devices (MTD) subsystem. MTD is
an extremely useful abstraction layer between the Linux file system and hardware memory devices,
primarily Flash memory.
Chapter 11, "BusyBox," introduces BusyBox, one of the most useful utilities for building small
embedded systems. We describe how to configure and build BusyBox for your particular
requirements, along with detailed coverage of system initialization unique to a BusyBox environment.
Appendix C, "BusyBox Commands," lists the available BusyBox commands from a recent BusyBox
release.
Chapter 12, "Embedded Development Environment," takes a detailed look at the unique requirements
of a typical cross-development environment. Several techniques are presented to enhance your
productivity as an embedded developer, including the powerful NFS root mount development
configuration.
Chapter 13, "Development Tools," examines many useful development tools. Debugging with gdb is
introduced, including coverage of core dump analysis. Many more tools are presented and explained,
with examples including strace, ltrace, top, and ps, and the memory profilers mtrace and dmalloc.
The chapter concludes with an introduction to the more important binary utilities, including the
powerful readelf utility.
Chapter 14, "Kernel Debugging Techniques," provides a detailed examination of many debugging
techniques useful for debugging inside the Linux kernel. We introduce the use of the kernel debugger
KGDB, and present many useful debugging techniques using the combination of gdb and KGDB as
debugging tools. Included is an introduction to using hardware JTAG debuggers and some tips for
analyzing failures when the kernel won't boot.
Chapter 15, "Debugging Embedded Linux Applications," moves the debugging context from the kernel
to your application programs. We continue to build on the gdb examples from the previous two
chapters, and we present techniques for multithreaded and multiprocess debugging.
Chapter 16, "Porting Linux," introduces the issues related to porting Linux to your custom board. We
walk through a simple example and highlight the steps taken to produce a working Linux kernel on a
custom PowerPC board. Several important concepts are presented that have trapped many
newcomers to Linux kernel porting. Together with the techniques presented in Chapters 13 and 14,
you should be ready to tackle your own custom board port after reading this chapter.
Chapter 17, "Linux and Real Time," provides an introduction to one of the more exciting
developments in embedded Linux: configuring for real time via the CONFIG_RT option. We cover the
features available with RT and how they can be used in a design. We also present techniques for
measuring latency in your application configuration.
The appendixes cover the GNU Public License, U-Boot Configurable Commands, BusyBox Commands,
SDRAM Interface Considerations, resources for the open source developer, and a sample
configuration file for one of the more popular hardware JTAG debuggers, the BDI-2000.
Follow Along
You will benefit most from this book if you can divide your time between the pages of this book and
your favorite Linux workstation. Grab an old x86 computer to experiment on an embedded system.
Even better, if you have access to a single-board computer based on another architecture, use that.
You will benefit from learning the layout and organization of a very large code base (the Linux
kernel), and you will gain significant knowledge and experience as you poke around the kernel and
learn by doing.
Look at the code and try to understand the examples produced in this book. Experiment with
different settings, configuration options, and hardware devices. Much can be gained in terms of
knowledge, and besides, it's loads of fun!
GPL Copyright Notice
Portions of open-source code reproduced in this book are copyrighted by a large number of individual
and corporate contributors. The code reproduced here has been licensed under the terms of the GNU
Public License or GPL.
Appendix A contains the text of the GNU General Public License.
Acknowledgments
I am constantly amazed by the graciousness of open source developers. I am humbled by the talent
in our community that often far exceeds my own. During the course of this project, I reached out to
many people in the Linux and open source community with questions. Most often my questions were
quickly answered and with encouragement. In no particular order, I'd like to express my gratitude to
the following members of the Linux and open source community who have contributed answers to my
questions:
Dan Malek provided inspiriation for some of the contents of Chapter 2, "Your First Embedded
Experience."
Dan Kegel and Daniel Jacobowitz patiently answered my toolchain questions.
Scott Anderson provided the original ideas for the gdb macros presented in Chapter 14, "Kernel
Debugging Techniques."
Brad Dixon continues to challenge and expand my technical vision through his own.
George Davis answered my ARM questions.
Jim Lewis provided comments and suggestions on the MTD coverage.
Cal Erickson answered my gdb use questions.
John Twomey advised on Chapter 3, "Processor Basics."
Lee Revell, Sven-Thorsten Dietrich, and Daniel Walker advised on real time Linux content.
Many thanks to AMCC, Embedded Planet, Ultimate Solutions, and United Electronic Industries for
providing hardware for the examples. Many thanks to my employer, Monta Vista Software, for
tolerating the occasional distraction and for providing software for some of the examples. Many
others contributed ideas, encouragement, and support over the course of the project. To them I am
also grateful.
I wish to acknowledge my sincere appreciation to my primary review team, who promptly read each
chapter and provided excellent feedback, comments, and ideas. Thank you Arnold Robbins, Sandy
Terrace, Kurt Lloyd, and Rob Farber. Many thanks to Arnold for helping this newbie learn the ropes of
writing a technical book. While every attempt has been made to eliminate mistakes, those that
remain are solely my own.
I want to thank Mark L. Taub for bringing this project to fruition and for his encouragement and
infinite patience! I wish to thank the production team including Kristy Hart, Jennifer Cramer, Krista
Hansing, and Cheryl Lenser.
And finally, a very special and heartfelt thank you to Cary Dillman who read each chapter as it was
written, and for her constant encouragement and her occasional sacrifice throughout the project.
Chris Hallinan
About the Author
Christopher Hallinan is currently field applications engineer for Monta Vista Software, living and
working in Massachusetts. Chris has spent more than 25 years in the networking and
communications marketplace mostly in various product development roles, where he developed a
strong background in the space where hardware meets software. Prior to joining Monta Vista, Chris
spent four years as an independent Linux consultant providing custom Linux board ports, device
drivers, and bootloaders. Chris's introduction to the open source community was through
contributions to the popular U-Boot bootloader. When not messing about with Linux, he is often found
singing and playing a Taylor or Martin.
Chapter 1. Introduction
In this chapter
Why Linux? page 2
Embedded Linux Today page 3
Open Source and the GPL page 3
Standards and Relevant Bodies page 5
Chapter Summary page 7
The move away from proprietary operating systems is causing quite a stir in the corporate
boardrooms of many traditional embedded operating system (OS) companies. For many well-founded
reasons, Linux is being adopted as the operating system in many products beyond its traditional
stronghold in server applications. Examples of these embedded systems include cellular phones, DVD
players, video games, digital cameras, network switches, and wireless networking gear. It is quite
possible that Linux is already in your home or your automobile.
1.1. Why Linux?
Because of the numerous economic and technical benefits, we are seeing strong growth in the
adoption of Linux for embedded devices. This trend has crossed virtually all markets and
technologies. Linux has been adopted for embedded products in the worldwide public switched
telephone network, global data networks, wireless cellular handsets, and the equipment that operates
these networks. Linux has enjoyed success in automobile applications, consumer products such as
games and PDAs, printers, enterprise switches and routers, and many other products. The adoption
rate of embedded Linux continues to grow, with no end in sight.
Some of the reasons for the growth of embedded Linux are as follows:
Linux has emerged as a mature, high-performance, stable alternative to traditional proprietary
embedded operating systems.
Linux supports a huge variety of applications and networking protocols.
Linux is scalable, from small consumer-oriented devices to large, heavy-iron, carrier-class
switches and routers.
Linux can be deployed without the royalties required by traditional proprietary embedded
operating systems.
Linux has attracted a huge number of active developers, enabling rapid support of new
hardware architectures, platforms, and devices.
An increasing number of hardware and software vendors, including virtually all the top-tier
manufacturers and ISVs, now support Linux.
For these and other reasons, we are seeing an accelerated adoption rate of Linux in many common
household items, ranging from high-definition television sets to cellular handsets.
1.2. Embedded Linux Today
It might come as no surprise that Linux has experienced significant growth in the embedded space.
Indeed, the fact that you are reading this book indicates that it has touched your own life. It is
difficult to estimate the market size because many companies still build their own embedded Linux
distributions.
LinuxDevices.com, the popular news and information portal founded by Rich Lehrbaum, conducts an
annual survey of the embedded Linux market. In its latest survey, they report that Linux has
emerged as the dominant operating system used in thousands of new designs each year. In fact,
nearly half of respondents reported using Linux in an embedded design, while the nearest competing
operating system was reportedly used by only about one in every eight respondents. Commercial
operating systems that once dominated the embedded market were reportedly used by fewer than
one in ten respondents. Even if you find reason to dispute these results, no one can ignore the
momentum in the embedded Linux marketplace today.
1.3. Open Source and the GPL
One of the fundamental factors driving the adoption of Linux is the fact that it is open source. The
Linux kernel is licensed under the terms of the GNU GPL
[1]
(General Public License), which leads to
the popular myth that Linux is free.
[2]
In fact, the second paragraph of the GNU GPL declares: "When
we speak of free software, we are referring to freedom, not price." The GPL license is remarkably
short and easy to read. Among the most important key characteristics:
[1]
See Appendix A, "GNU Public License," for the complete text of the license.
[2]
Most professional development managers agree: You can download Linux without charge, but there is a cost (often a
substantial one) for development and deployment of any OS on an embedded platform. See Section 1.3.1, "Free Versus
Freedom," for a discussion of cost elements.
The license is self-perpetuating.
The license grants the user freedom to run the program.
The license grants the user the right to study and modify the source code.
The license grants the user permission to distribute the original code or his modifications.
The license grants these same rights to anyone to whom you distribute GPL software.
When a software work is released under the terms of the GPL, it must forever carry that license.
[3]
Even if the code is highly modified, which is allowed and even encouraged by the license, the GPL
mandates that it must be released under the same license. The intent of this feature is to guarantee
access to everyone, even of modified versions of the software (or derived works, as they are
commonly called).
[3]
If all the copyright holders agreed, the software could, in theory, be released under a new license, a very unlikely scenario
indeed!
No matter how the software was obtained, the GPL grants the licensee unlimited distribution rights,
without the obligation to pay royalties or per-unit fees. This does not mean that a vendor can't
charge for the GPL softwarethis is a very reasonable common business practice. It means that once
in possession of GPL software, it is permissible to modify and redistribute it, whether it is a derived
(modified) work or not. However, as defined by the GPL license, the author(s) of the modified work
are obligated to release the work under the terms of the GPL if they decide to do so. Any distribution
of a derived work, such as shipment to a customer, triggers this obligation.
For a fascinating and insightful look at the history and culture of the open source movement, read
Eric S. Raymond's book referenced at the end of this chapter.
1.3.1. Free Versus Freedom
Two popular phrases are often repeated in the discussion about the free nature of open source: "free
as in freedom" and "free as in beer." (The author is particularly fond of the latter.) The GPL license
exists to guarantee "free as in freedom" of a particular body of software. It guarantees your freedom
to use it, study it, and change it. It also guarantees these freedoms for anyone to whom you
distribute your modified code. This concept has become fairly widely understood.
One of the misconceptions frequently heard is that Linux is "free as in beer." Sure, you can obtain
Linux free of cost. You can download a Linux kernel in a few minutes. However, as any professional
development manager understands, certain costs are associated with any software to be
incorporated into a design. These include the costs of acquisition, integration, modification,
maintenance, and support. Add to that the cost of obtaining and maintaining a properly configured
toolchain, libraries, application programs, and specialized cross-development tools compatible with
your chosen architecture, and you can quickly see that it is a nontrivial exercise to develop the
needed software components to deploy your embedded Linux-based system.