1. Trang chủ
  2. » Công Nghệ Thông Tin

Pro Linux Embedded Systems doc

445 982 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 445
Dung lượng 6,86 MB

Nội dung

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- ny@springer-sbm.com , or visit http://www.springeronline.com. 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 info@apress.com, or visit http://www.apress.com. 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 http://www.apress.com/info/bulksales. 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 http://www.apress.com. 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 [...]... 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... 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 xvii www.it-ebooks.info ■... 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... 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 1 www.it-ebooks.info CHAPTER 1 ■ ABOUT EMBEDDED LINUX 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... people away from Linux “You may have the source code, but you’ll never figure anything out … it’s so complex,” the fear mongers say The Linux code base is well written and documented If you’re capable of writing a commercial embedded Linux application, you no doubt have the ability to understand the Linux project—or any other open source project, for that matter 10,000-Foot Embedded Linux Development... ABOUT EMBEDDED LINUX At runtime, an embedded Linux system contains the following software components: • Boot loader: What gets the operating system loaded and running on the board • Kernel: The software that manages the hardware and the processes • Root file system: Everything under the / directory, containing the programs run by the kernel Every Linux system has a root file system Embedded systems. .. other, they’re a keeper 13 www.it-ebooks.info CHAPTER 1 ■ ABOUT EMBEDDED LINUX Just typing mount shows all the file systems mounted Most Linux systems have several file systems mounted, but all the file systems are mounted relative to the root file system When the Linux kernel boots, it must be able to mount a root file system During the boot process, the root file system can be replaced with another,... 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:... space, and other process specific information After it’s created, a process can’t access the memory space of another process unless both have negotiated a shared memory pool; but even access to that memory pool doesn’t give access to an arbitrary address in another process Processes in Linux can contain multiple execution threads A thread shares the process space and resources of the process that started... why some engineers choose Linux over other lighter-weight solutions 4 www.it-ebooks.info CHAPTER 1 ■ ABOUT EMBEDDED LINUX Memory Management and Linux Linux uses a virtual memory-management system The concept of virtual memory has been around since the early 1960s and is simple: the process sees its memory as a vector of bytes; and when the program reads or writes to memory, the processor, in conjunction . 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. 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

Ngày đăng: 24/03/2014, 01:21

TỪ KHÓA LIÊN QUAN