Tải bản đầy đủ (.pdf) (445 trang)

Pro Linux Embedded Systems doc

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (6.86 MB, 445 trang )

Sally
Linux Embedded Systems
THE EXPERT’S VOICE
®
IN LINUX
Pro
Linux Embedded
Systems
Gene Sally
Companion
eBook
Available
Your complete guide to developing
embedded Linux systems
BOOKS FOR PROFESSIONALS BY PROFESSIONALS
®
US $49.99
Shelve in:
Linux
User level:
Intermediate–Advanced
www.apress.com
SOURCE CODE ONLINE
Companion eBook

See last page for details
on $10 eBook version
ISBN 978-1-4302-7227-4
9 781430 272274
54999
Pro


Pro Linux Embedded Systems
Dear Reader,
The tools that you need to succeed with your next embedded Linux project are
hiding in plain sight. So in this book I'll reveal them so you can see for yourself
how to use Linux and open source software to deliver an embedded device.
While you probably have plenty of knowledge about Linux on enterprise serv-
ers and desktops, I'll show you how you can in fact use that same set of skills, and
the same tools to you already know, to create embedded projects in Linux. And
that's not just the development tools, such as Eclipse or your favorite editor, but
also the languages you already know. You'll soon discover that embedded devel-
opment is no longer the province of just C and assembler!
Linux is becoming a common default choice for new embedded commer-
cial projects, with hardware vendors providing board-level support for Linux by
default. That's great news for you as the developer, because this level of "out of
the box" support for Linux on many new devices means that you can often skip
getting Linux running on the board, and go straight to the most interesting parts
of your application development!
This book focuses on the systems and application level tasks that every
embedded engineer must tackle once Linux is up and running in order to deliver
a product. It explains how a system boots so that you can make it faster for your
application, how to build the basic set of software to boot a board, how to config-
ure and build the kernel, and how to be a good citizen when participating in open
source projects. Topics such as minimizing boot time and reducing resource
requirements of Linux receive special treatment.
Lastly, if you're new to embedded development, here's some more good news:
it's just more fun than other types of software engineering. Enjoy!
Gene Sally
RELATED TITLES
www.it-ebooks.info
www.it-ebooks.info

Pro Linux Embedded
Systems












■ ■ ■
Gene Sally

www.it-ebooks.info

ii
Pro Linux Embedded Systems
Copyright © 2010 by Gene Sally
All rights reserved. No part of this work may be reproduced or transmitted in any form or by
any means, electronic or mechanical, including photocopying, recording, or by any
information storage or retrieval system, without the prior written permission of the copyright
owner and the publisher.
ISBN-13 (pbk): 978-1-4302-7227-4
ISBN-13 (electronic): 978-1-4302-7226-7
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every

occurrence of a trademarked name, we use the names only in an editorial fashion and to the
benefit of the trademark owner, with no intention of infringement of the trademark.
President and Publisher: Paul Manning
Lead Editor: Michelle Lowman
Technical Reviewer: William von Hagen
Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary
Cornell, Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie,
Duncan Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke,
Dominic Shakeshaft, Matt Wade, Tom Welsh
Coordinating Editor: Jim Markham
Copy Editor: Tiffany Taylor
Compositor: Bronkella Publishing LLC
Indexer: nSight Indexers
Artist: April Milne
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail
orders-

, or visit .
For information on translations, please contact Apress directly at 2855 Telegraph Avenue,
Suite 600, Berkeley, CA 94705. Phone 510-549-5930, fax 510-549-5939, e-mail
,
or visit
.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or
promotional use. eBook versions and licenses are also available for most titles. For more
information, reference our Special Bulk Sales–eBook Licensing web page at

The information in this book is distributed on an “as is” basis, without warranty. Although

every precaution has been taken in the preparation of this work, neither the author(s) nor
Apress shall have any liability to any person or entity with respect to any loss or damage
caused or alleged to be caused directly or indirectly by the information contained in this work.
The source code for this book is available to readers at
.
www.it-ebooks.info
■ CONTENTS
iii

For Tammi and our sons, Jonah, Benjamin, and Adam
.

www.it-ebooks.info
■ CONTENTS

iv
Contents at a Glance
Contents at a Glance iv
Contents v
About the Author xvi
About the Technical Reviewer xvii
Acknowledgments xviii
Introduction xix
■Chapter 1: A bout Embedded Linux 1
■Chapter 2: C onfiguring the Software Environment 25
■Chapter 3: Target Emulation and Virtual Machines 55
■Chapter 4: Starting Your Project 63
■Chapter 5: G etting Linux for Your Board 83
■Chapter 6: Creating a Linux Distribution fr om Scratch 107
■Chapter 7: B ooting the B oard 143

■Chapter 8: C onfiguring the Application Development Environment 169
■Chapter 9: A pplication Development 197
■Chapter 10: Debugging Applications 215
■Chapter 11: Kernel Configuration and Development 237
■Chapter 12: Real Time 257
■Chapter 13: Using Open Source Software Projects 273
■Chapter 14: BusyBox 293
■Chapter 15: System Design 309
■Chapter 16: System Tuning 335
■Chapter 17: Deploying Applications 363
■Chapter 18: Handling Field Updates 383
www.it-ebooks.info
■ CONTENTS
v
Contents
Contents at a Glance iv
Contents v
About the Author xvi
About the Technical Reviewer xvii
Acknowledgments xviii
Introduction xix
■Chapter 1: A bout Embedded Linux 1
Why Use Embedded Linux? 2
Technical Reasons to Use Embedded Linux 2
Commercial Reasons to Use Embedded Linux 7
10,000-Foot Embedded Linux Development Flyover 9
Target Hardware 9
Obtaining Linux 10
Booting Linux 10
Development Environment 10

System Design 11
Anatomy of an Embedded Linux System 11
Boot Loader 12
Kernel 13
Root File System 13
Your Application 14
Cross-Compiler 14
Tools of the Trade 15

www.it-ebooks.info
■ CONTENTS

vi
Where to Get Help 19
University of Google 19
Mailing Lists and Newsgroups 19
Vendor-Sponsored Resources 20
Trade Group and Community Interest Sites 21
IRC 23
Next Up 23
■Chapter 2: C onfiguring the Software Environment 25
Host Environment 26
Linux 26
Windows 29
Host Services 43
Turn Off Your Firewall 44
TFTP 44
DHCP 45
NFS 47
PXE 50

Cabling 51
Serial (for Console) 51
Network 51
Avoiding an Angry Visit from IT 52
Dual-Homed Host 52
■Chapter 3: Target Emulation and Virtual Machines 55
Why Target Emulation? 55
Emulation via QEMU 56
Compiling QEMU 56
Using QEMU to Emulate a Target 58
Using QEMU to Compile under Emulation 60

www.it-ebooks.info
■ CONTENTS
vii
Virtualization Software for x86 Hosts 61
Approaches to Virtualization 61
Summary 62
■Chapter 4: Starting Your Project 63
Most Boards Include a Linux Distribution 64
What to Do After Unpacking the Board 65
Have Linux? Boot It! 66
Assess the Kernel 73
Understand the RFS 76
Suitability for Your Project 80
Cross-Compiler 81
Moving Forward 82
■Chapter 5: G etting Linux for Your Board 83
Obtaining Linux from the Board Vendor 84
Questions You Should Ask Your Board Vendor 84

Now That You’re a Customer… 87
Open Source Embedded Distributions 87
Why Embedded Linux Distribution Builders Exist 88
Should You Use One? 88
Popular Open Source Embedded Distributions 89
Getting Linux from Commercial Vendors and Consultants 102
Do You Need a Commercial Vendor? 102
What You Should Expect 103
Roundup of Vendors 104
What’s Next 106
■Chapter 6: Creating a Linux Distribution from Scratch 107
Cross-Compiler Basics 108
A Note about Building Software 109
Get Comfortable with the Command Line 110
www.it-ebooks.info
■ CONTENTS

viii
Overview of Building a GCC Cross-Compiler 111
The C Library 112
Gathering Sources 112
Building GCC 117
Building Toolchains with Crosstool-NG 130
Creating the Root File System 131
Configuring the Environment 132
Building and Installing BusyBox 132
Libraries 133
Creating Device Nodes and Directories 134
Finishing Touches 134
Building the Kernel 135

Troubleshooting Booting Problems 138
Distributing the Distribution 140
Wrapping Up 141
■Chapter 7: B ooting the B oard 143
Booting a Linux System Is a Three-Act Play 143
The Boot Loader 143
Kernel-Land vs. Userland 146
Boot Loaders 147
About Flash Memory 152
Kernel Startup 153
The Kernel Entry Point 154
Userland Startup 161
BusyBox Init 165
Your Init 165
What’s Next 167


www.it-ebooks.info
■ CONTENTS
ix
■Chapter 8: C onfiguring the Application Development Environment 169
Pick the Right Tool for the Job 169
Know Your Application 169
Hardware Constraints 170
What to Use for Development 172
C 172
C++ 173
Java 173
Non-Traditional Embedded Languages 175
Python 175

TCL 177
Shell Scripting 178
PHP 179
Performance and Profiling Tools 180
Profiling 180
Leak Detection 184
Static Analysis 187
IDE 188
Your Editor + Make + Shell 188
Eclipse 191
What’s Next 196
■Chapter 9: A pplication Development 197
Coding for Portability 198
System Differences 199
FIFO 199
Getting the Tools 201
Making Make Work 201
Running the Code on the Target 205
More Complex Projects 206
www.it-ebooks.info
■ CONTENTS

x
■Chapter 10: Debugging Applications 215
Getting Started on Your Application 215
Types of Debugging 215
Remote Debugging Overview 216
Debugging C and C++ 217
Building GDB 217
GDB Front Ends 218

Compiling for Debugging 219
Debugging Java 229
Instrumentation 233
Java Instrumentation 235
Instrumentation in Scripting Languages 236
What’s Next 236
■Chapter 11: Kernel Configuration and Development 237
Kernel Project Layout 237
Downloading the Kernel 239
Building the Kernel 241
How Kernel Configuration Works 244
Default Configurations 245
Editing .config By Hand 247
Building the Kernel 247
Building Modules 250
Cleaning Up 251
Open Source Community 252
The Kernel Development Process 252
Contributing to the Linux Kernel 252
Applying Patches 254
What’s Next 255

www.it-ebooks.info
■ CONTENTS
xi
■Chapter 12: Real Time 257
Real-Time Core Concepts 258
The Linux Scheduler 260
Real-Time Scheduler 260
Real-Time Implementation in Linux 261

Getting the Patch 262
Real-Time Programming Practices 264
The One Real-Time Process 264
Lock Memory 264
Avoid the Heap 265
Asking for Priority Inheritance Mutexes 265
I/O Is Nondeterministic 266
Using Thread Pools 266
LatencyTOP 267
Common Hardware Pitfalls 270
System Management Interrupts 270
VGA Console 270
DMA Bus Mastering 270
Summary 271
■Chapter 13: Using Open Source Software Projects 273
Using Open Source Packages 273
How an Open Source Project Is Structured 274
The Project Team Isn’t Your Extended Workforce 275
Understand the Licensing 275
Downloading 277
Using Source Control Systems to Fetch Code 278
Cross-Compiling 282
Using configure 282
Building and Installing 288

www.it-ebooks.info
■ CONTENTS

xii
Commonly Used Projects 289

DirectFB 289
Dropbear 289
QT/Qtopia 289
JamVM 289
Rzsz 290
Netcat 290
TinyXML 290
Micro_httpd 290
Stupid-FTPd 291
Quagga 291
Tslib 291
fgetty 291
■Chapter 14: BusyBox 293
How a BusyBox-Based System Is Structured 293
Building a BusyBox-Based System 294
Download the Software 295
Configure 295
What Makes BusyBox Small? 302
Creating Your Own Applet 303
Create the Applet Code 303
Getting Help 307
What’s Next 307
■Chapter 15: System Design 309
The Big Picture 309
Configuring the Boot Loader and Kernel 310
U-Boot 310
Other Boot loaders 313
Execute in Place 313
www.it-ebooks.info
■ CONTENTS

xiii
Selecting a Root File System 313
Block-Based File Systems 314
MTD File Systems 318
RAM Buffer–Based File Systems 319
File System Pairings 320
Assembling a Root File System 320
Create the Staging Area 320
Create a Directory Skeleton 321
Gather Libraries and Required Files 321
Create Initialization Scripts 323
Set Ownership and Permissions 327
Security 328
Built-In Security 328
SELinux 329
PAM 332
What’s Next 334
■Chapter 16: System Tuning 335
Three or Fewer Megabytes 335
16–32 Megabytes 336
More than a Gigabyte 336
Reducing the Size of the Root File System 337
Start from Zero 337
Compiling to Save Space 340
Reducing the Size of the Kernel 343
Removing Unneeded Features and Drivers 344
Minimizing Boot Time 349
Reducing Kernel Boot-Up Time 350
Measuring Kernel Boot-Up Times 352
Reducing Root File System Startup Times 356

What’s Next 361
www.it-ebooks.info
■ CONTENTS

xiv
■Chapter 17: Deploying Applications 363
Deployment for Embedded Devices 363
Requirements 364
Industrial Design 365
Mechanical Design 365
Electrical Engineering 366
Manufacturing Engineering 367
Software Design 367
Software Engineering 368
Manufacturing 369
Deployment Strategies and Tactics 371
Boot Loaders 372
In General 372
UBOOT: Configuring Initial Parameters 373
Expect 374
Boot Loaders Are Just Programs 377
Deployment Root File Systems 378
Application Files and Libraries 379
First Field Update at the Factory 381
What’s Next 381
■Chapter 18: Handling Field Updates 383
Root File System Updates 383
Basic Strategies 384
Forklift Upgrade 384
Parallel Systems 388

Do It Yourself 389
Using Package Managers 390
Initramfs Root File Systems 401
Kernel Updates 401
Basic Strategies 402
www.it-ebooks.info
■ CONTENTS
xv
Modules 403
Forklift 405
Field Update Failures 406
Report Failure, Stop 406
Failsafe Root File System 406
Failsafe Kernel 406
In Summary 407
■Index 409
www.it-ebooks.info
■ CONTENTS

xvi
About the Author
■ Gene Sally got mixed-up with computers at a young age, his fascination sparked by an Apple II, with
the Lemon cooling system add-on, no less. As a software professional, Gene got his first job writing make
files and then moved on to more exciting (for certain values of exciting) things like accounting,
insurance processing, and social services systems. He first used Linux to set up a shared Internet
connection and later used it when working on software that tested telecommunication management
software; Gene was happy that a decent Unix-like environment could be had for free, and Linux became
his axe of choice. Gene next found himself at a start-up that specialized in tools and distributions for
embedded Linux, working in a variety of roles including engineer, trainer, technical support phone-
answerer-guy, podcaster, and marketer. Presently, Gene is working at a company that creates safety

products for retirement and assisted-living homes.
Gene resides outside of Pittsburgh, Pennsylvania in the rolling hills north of the city with his wife and
three sons. When not working, writing, playing with kids, or tending to the never-ending repair list at
home, Gene cycles, skis, and hikes throughout western Pennsylvania and eastern Ohio.

www.it-ebooks.info
■ CONTENTS
xvii
About the Technical Reviewer
■ William von Hagen (Bi ll) has been a UNIX system administrator for over 20
years and a Linux fanatic since the early 1990s. He has worked as a systems
programmer, system administrator, writer, application developer, drummer, and
documentation manager. Bill has written or pco-written books on such topics as
Ubuntu Linux, GCC, Linux Server Hacks, Linux Filesystems, SUSE Linux, Red Hat
Linux, SGML, and Mac OS X.


www.it-ebooks.info
■ CONTENTS

xviii
Acknowledgments
First, I thank the good Lord for providing me with time, prosperity, curiosity, vigor, intellect, and health;
I hope this work puts these gifts to proper use. During the time I spent writing this book, I received
tremendous support from my family. I couldn’t have done it without my wife and kids: you helped more
than you know.
Writing a book is a team effort, and I am fortunate that the team working on this book was as excellent as
any author could have ever expected. Thank you Bill von Hagen for being my technical reviewer, and
Michelle Lowman and Frank Pohlmann for being my editors. All of the editors actually read what was
written and provided feedback that made this book much better than it would have been without their

efforts. I would also like to thank the production team at Apress, who created the cover, laid out the
pages, and amazingly turned a collection of documents into the book you’re holding now. Special thanks
goes to James Markham, who somehow managed to tolerate my inability to meet a deadline with more
patience than I deserved. Last, but not least, the open source community has provided me with an
excellent education about Linux, both in mail and newsgroup traffic and in the source code itself.
www.it-ebooks.info

xix
Introduction
When I got started in embedded Linux nearly a decade ago, the question was, “Should I even use an
operating system?” Going with Linux frequently meant porting the operating system to run on your
target hardware and building to the tools to do so. Much has changed over the years, to the point that
Linux is selected by default for many projects, and the decisions revolve around what features of the
operating system can be used on the project. The question today is, “How should I configure my Linux
distribution?” In technology terms, this is a seismic shift in developer attitudes in a very short time
frame.
Linux is so pervasive in the embedded space that embedded processors and boards ship with Linux by
default. Buyers simply expect that the board will boot Linux and they’ll have the tools they need for
embedded development provided along with the hardware. Unlike in the early days of Linux, as a
developer, you won’t be porting Linux to your board but rather configuring an already-running Linux
kernel and root file system so that they suit your application.
With this background in mind, I wrote this book from the perspective of a user who is starting their
project with a Linux distribution already running on the board. It may not the the distribution that
eventually ships with the product, but it will likely serve as a starting point. Tasks like building the cross-
compiler from scratch are documented in the book so you understand the process, but you will probably
use a cross-compiler that has been provided with the board so you can concentrate on the application.
However, learning how to build and configure the tools for a Linux system isn’t a wasted effort, because
when you need to squeeze every bit of memory out of your system, this is an essential skill.
Furthermore, with new System on a Chip (SOC) designs, the Linux distribution that comes on the board
has all the drivers necessary for the devices on the chip. Only in the rarest events is driver development

necessary. This means that most engineers spend time customizing the kernel rather than building new
kernel components, and the total time spent doing any sort of kernel configuration or development is a
fraction of what it was in years past.
As the processors in embedded devices become more powerful, developers are finding they can use
languages other than C for development. It’s common for C++ to be used for development as well as
other higher-level language like Python, TCL, Java, and even Perl or PHP. To somebody who started
doing embedded in assembly, using a language like Perl on an embedded target is nearly heresy, if not
outright apostasy; however, these higher-level languages greatly increase the productivity of embedded
development. In an industry where time-to-market is paramount, higher-level languages will become
more mainstream.
Embedded projects have a development process unlike other software projects. First there is the design
process, which usually involves creating a special enclosure and a user interface that’s probably a small
LCD display and some buttons; but more important are the deployment and update of the software. The
code for the project isn’t put on a CD or a web site but must be downloaded on the board along with the
Linux distribution. After the initial installation of the software, you’ll likely want to update the software
with new versions that contain bug fixes and other goodies. Depending on how your system is
configured, updating your system may be a project in itself.
www.it-ebooks.info
■ INTRODUCTION

xx
If you’re starting an embedded project for your work or have purchased one of the many, now very
inexpensive board targeted to hobbyists, I wish you the best of luck in your endeavors. Using Linux in an
embedded project is easier, and more fun, than ever.

www.it-ebooks.info
C H A P T E R 1

■ ■ ■


1

About Embedded Linux
Linux is an incredible piece of software. It’s an operating system that’s just as at home running on IBM’s
zSeries supercomputers as it is on a cell phone, manufacturing device, network switch, or even cow
milking machine. What’s more incredible is that this software is currently maintained by thousands of
the best software engineers and it is available for
free
.
Linux didn’t start as an embedded operating system. Linux was created by a Finnish university
student (Linus Torvalds) who was smart enough to make his work available to all, take input from others
and, most important, delegate to other talented engineers. As the project grew, it attracted other talented
engineers who were able to contribute to Linux, increasing the burgeoning project’s value and visibility
and thus bootstrapping a virtuous cycle that continues to this day.
Linux was first written to run on the Intel IA-32 architecture and was first ported to a Motorola
processor. The porting process was difficult enough that Linus Torvalds decided to rethink the
architecture so that it could be easily ported, creating a clean interface between the processor-
dependent parts of the software and those that are architecture independent. This design decision paved
the way for Linux to be ported to other processors.
Linux is just a kernel, which by itself isn’t that useful. An embedded Linux system, or any Linux
system for that matter, uses software from many other projects in order to provide a complete operating
system. The Linux kernel is written largely in C (with some assembler) and uses the GNU tool set, such as
make; the GCC compiler; programs that provide an interface to the kernel; and a host of others that
you’ll encounter in this book. Much of this software already existed at Linux’s genesis, and, fortunately,
much of it was written with portability in mind. The fact that this software could be used on an
embedded system or could be modified to make it suitable for embedded deployment contributed
greatly to the acceptance of Linux for devices other than desktop machines.
■ NNote Linux exists in no small part because of the GNU (Gnu’s Not Unix) project, which was (and still is)
developing an open source implementation of Unix. The GNU project provided a high-quality compiler and
command-line make environment along with basic utilities expected on a Unix-like system.

This book takes you through using Linux for your embedded project. Because Linux and its
associated projects are open source, you learn how to build everything you need for an embedded
project from scratch. The entire Linux environment has advanced to the point that this undertaking is no
longer a quixotic exercise; it falls squarely within the reach of any engineer willing to put in a reasonable
amount of time and effort. Building a complete Linux system is the best training for creating a small
Linux system; as a result, doing so is more than a morale-building exercise.
www.it-ebooks.info
CHAPTER 1 ■ ABOUT EMBEDDED LINUX

2
Why Use Embedded Linux?
Embedded Linux is just like the Linux distributions running on millions of desktops and servers
worldwide, but it’s adapted to a specific use case. On desktop and server machines, memory, processor
cycles, power consumption, and storage space are limited resources—they just aren’t as limiting as they
are for embedded devices. A few extra MB or GB of storage can be nothing but rounding errors when
you’re configuring a desktop or server. In the embedded field, resources matter because they drive the
unit cost of a device that may be produced in the millions; or the extra memory may require additional
batteries, which add weight. A processor with a high clock speed produces heat; some environments
have very tight heat budgets, so only so much cooling is available. As such, most of the efforts in
embedded programming, if you’re using Linux or some other operating system, focus on making the
most with limited resources.
Compared to other embedded operating systems, such as VxWorks, Integrity, and Symbian, Linux
isn’t the most svelte option. Some embedded applications use frameworks such as ThreadX
1
for
application support; the framework runs directly on the hardware, eschewing an operating system
altogether. Other options involve skipping the framework and instead writing code that runs directly on
the device’s processor. The biggest difference between using a traditional embedded operating system
and Linux is the separation between the kernel and the applications. Under Linux, applications run in a
execution context completely separate from the kernel. There’s no way for the application to access

memory or resources other than what the kernel allocates. This level of process protection means that a
defective program is isolated from kernel and other programs, resulting in a more secure and survivable
system. All of this protection comes at a cost.
Despite its increased resource overhead compared to other options, the adoption of Linux
continues to increase. That means engineers working on projects consider the increased overhead of
Linux worth the additional cost. Granted, in recent years, the costs and power demands of system-on-
chip (SOC) processors has decreased to the point that they cost no more than a low-power 8-bit
microcontroller from the past, so using a more sophisticated processor is an option when it might not
have been before. Many design solutions use off-the-shelf SOC processors and don’t run the leads from
chip for the Ethernet, video, or other unused components.
Linux has flourished because it provides capabilities and features that can’t be made available with
other embedded solutions. Those capabilities are essential to implementing the ever more sophisticated
designs used to differentiate devices in today’s market. The open source nature of Linux means
embedded engineers can take advantage of the continual development happening in the open source
environment, which happens at a pace that no single software vendor can match.
Technical Reasons to Use Embedded Linux
The technical qualities of Linux drives its adoption. Linux is more than the Linux kernel project. That
software is also at the forefront of technical development, meaning that Linux is the right choice for
solving today’s technical problems as well as being the choice for the foreseeable future.
For example, an embedded Linux system includes software such as the following:


1
I can’t comment about the usefulness or features of ThreadX, but I can attest that the stuffed monkeys given away at
every trade show for the last ten years are adorable. This company also sponsored a booth one year that had actors in
Star Trek
get-ups explaining what ThreadX did; I wasn’t paying attention, but I got another stuffed monkey after the
presentation.

www.it-ebooks.info

CHAPTER 1 ■ ABOUT EMBEDDED LINUX

3

SSL/SSH:
The OpenSSH project is the most commonly used encryption and
security mechanism today. The open nature of the project means that thousands
of security experts are constantly evaluating it; when problems are found, updates
occur in a matter of hours, provided the update is not included with the exploit
itself.

Apache and other web servers:
The Apache web server finds its way into
embedded devices that need a full-featured web server. For devices with less
demanding requirements, users can pick from smaller web servers like Boa,
lighttp, and (a personal favorite) micro_httpd.

The C Library:
The Linux environment has a wealth of options in this area, from
the fully featured GNU C Library to the minimalist dietlibc. If you’re new to
embedded Linux development, having a choice in this area reinforces the open
nature of open source.

Berkeley sockets (IP):
Many projects move to Linux from another operating system
because of the complete, high-performance network stack included in the
operating system. A networked device is becoming the rule and not the exception.
The following sections explain why the Linux operating system is the best technological fit for
embedded development.
Standards Based

The Linux operating system and accompanying open source projects adhere to industry standards; in
most cases, the implementation available in open source is the canonical, or
reference
, implementation
of a standard. A reference implementation embodies the interpretation of the specification and is the
basis for conformance testing. In short, the reference implementation is the standard by which others
are measured.
If you’re new to the notion of a reference implementation, it may be a little confusing. Take for
example the Portable Operating System Interface for Unix (POSIX) for handling threads and interprocess
communication, commonly called
pthreads
. The POSIX group, part of the Institute of Electrical and
Electronics Engineers (IEEE) is a committee that designs APIs for accomplishing the tasks of interacting
with a thread but leaves the implementation of that standard to another group. In practice, when work
begins on a standard, one or more of the participants on the committee volunteer to create the code to
bring the standard to life, creating the reference implementation. The reference implementation
includes a test suite; other implementations consider the passage of the test suite as evidence that the
code works as per the specification.
Using standards-based software is not only about quality but also about independence. Basing a
project on software that adheres to standards reduces the chances of lock-in due to vendor-specific
features. A vendor may be well meaning, but the benefits of those extra features are frequently
outweighed by the lack of interoperability and freedom that silently become part of the transaction and
frequently don’t receive the serious consideration they merit.
Standards are increasingly important in a world where many embedded devices are connected,
many times to arbitrary systems rather than just to each other. The Ethernet is one such connection
method, but others abound, like Zigbee, CANbus, and SCSI, to name a few.
www.it-ebooks.info

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×