Programming Embedded Systems

Höfundar: Michael Barr; Anthony Massa (Útgáfa: 2)
Programming Embedded Systems

Kaup valmöguleikar

If you have programming experience and a familiarity with C--the dominant language in embedded systems--Programming Embedded Systems, Second Edition is exactly what you need to get started with embedded software. This software is ubiquitous, hidden away inside our watches, DVD players, mobile phones, anti-lock brakes, and even a few toasters. The military uses embedded software to guide missiles, detect enemy aircraft, and pilot UAVs.

Communication satellites, deep-space probes, and many medical instruments would have been nearly impossible to create without embedded software. The first edition of Programming Embedded Systems taught the subject to tens of thousands ofpeople around the world and is now considered the bible of embedded programming. This second edition has been updated to cover all the latest hardware designs and development methodologies.

The techniques and code examples presented here are directly applicable to real-world embedded software projects of all sorts. Examples use the free GNU software programming tools, the eCos and Linux operating systems, and a low-cost hardware platform specially developed for this book. If you obtain these tools along withProgramming Embedded Systems, Second Edition, you'll have a full environment for exploring embedded systems in depth.

But even if you work with different hardware and software, the principles covered in this bookapply. Whether you are new to embedded systems or have done embedded work before, you'll benefit from the topics in this book, which include: How building and loading programs differ from desktop or servercomputers Basic debugging techniques--a critical skill when working withminimally endowed embedded systems Handling different types of memory Interrupts, and the monitoring and control of on-chip and externalperipherals Determining whether you have real-time requirements, and whetheryour operating system and application can meet those requirements Task synchronization with real-time operating systems and embeddedLinux Optimizing embedded software for size, speed, and power consumption Working examples for eCos and embedded Linux So whether you're writing your first embedded program, designing thelatest generation of hand-held whatchamacalits, or managing the peoplewho do, this book is for you.

Programming EmbeddedSystems will help you develop the knowledge and skills youneed to achieve proficiency with embedded software. Praise for the first edition:"This lively and readable book is the perfect introduction for those venturing into embedded systems software development for the first time. It provides in one place all the important topics necessary to orient programmers to the embedded development process.

Nánar um bókina

Útgefandi
O'Reilly Media, Inc.
ISBN
9780596553289
Print ISBN
9780596009830
Format
ePub
Útgáfa
2
Höfundar
Michael Barr; Anthony Massa
Tungumál
English
Útgefið
2006-10-11
Prent takmörkun á líftíma
100
Prent takmörkun
30
Afritunar takmörkun
2

Kaflar

  • Front Matter
  • Other resources from O’Reilly
  • Table of Contents
  • Foreword
  • Preface
  • Why We Wrote This Book
  • Intended Audience
  • Organization
  • Conventions, Typographical and Otherwise
  • Obtaining the Examples Online
  • Using Code Examples
  • Comments and Questions
  • Safari® Enabled
  • Personal Comments and Acknowledgments
  • From Michael Barr
  • From Anthony Massa
  • CHAPTER 1 Introduction
  • What Is an Embedded System?
  • History and Future
  • Real-Time Systems
  • Figure 1-1. A range of example real-time systems
  • Variations on a Theme
  • Common System Components
  • Figure 1-2. A generic embedded system
  • Figure 1-3. (a) Basic embedded software diagram and (b) a more complex embedded software diagram
  • Requirements That Affect Design Choices
  • Table 1-1. Common design requirements for embedded systems
  • Embedded Design Examples
  • Digital Watch
  • Video Game Player
  • Mars Rover
  • Life As an Embedded Software Developer
  • The C Language: The Lowest Common Denominator
  • Other Embedded Languages
  • Choosing a Language for the Book
  • Consistent Coding Practices
  • A Few Words About Hardware
  • Fixed Width Integers: Sometimes Size Matters
  • Figure 1-4. The Arcom VIPER-Lite development boards
  • CHAPTER 2 Getting to Know the Hardware
  • Understanding the Big Picture
  • Figure 2-1. Block diagram for the print server
  • Hardware Basics
  • Figure 2-2. Block diagram for the print server on Arcom board
  • Schematic Fundamentals
  • Figure 2-3. Basic schematic symbols
  • Figure 2-4. Example schematic
  • Examine the Landscape
  • Memory Map
  • Figure 2-5. Example timing diagram
  • Figure 2-6. Memory map for the Arcom board
  • Learn How to Communicate
  • Getting to Know the Processor
  • Processors in General
  • The PXA255 XScale Processor
  • Study the External Peripherals
  • Initialize the Hardware
  • Figure 2-7. The hardware and software initialization process
  • CHAPTER 3 Your First Embedded Program
  • Hello, World!
  • The Blinking LED Program
  • Figure 3-1. Arcom board add-on module containing the green LED
  • The ledInit Function
  • Table 3-1. PXA255 GPIO registersa
  • Figure 3-2. PXA255 processor GPDR0 register
  • I/O Space Register Access
  • The ledToggle Function
  • The delay_ms Function
  • The Role of the Infinite Loop
  • CHAPTER 4 Compiling, Linking, and Locating
  • The Build Process
  • Figure 4-1. The embedded software development process
  • Figure 4-2. The split between host and target
  • Compiling
  • Linking
  • Startup code
  • Locating
  • Debug Monitors
  • Building the Blinking LED Program
  • Compile
  • Figure 4-3. Compiling the Blinking LED program
  • Link and Locate
  • Figure 4-4. Linking and locating the Blinking LED program
  • Format the Output File
  • Another Linking Method
  • A Quick Look at Makefiles
  • CHAPTER 5 Downloading and Debugging
  • Downloading the Blinking LED Program
  • Figure 5-1. Software development cycle
  • Debug Monitors
  • RedBoot
  • Downloading with RedBoot
  • Running programs with RedBoot
  • RedBoot Networking Support
  • When in ROM…
  • Managing ROM with RedBoot
  • Remote Debuggers
  • Figure 5-2. Components of a remote debug session
  • Debugging on the Arcom Board
  • GDB Connection Problems
  • Debug Tip: Using the Memory Map for Symbol Value Lookup
  • Emulators
  • Other Useful Tools
  • Simulators
  • Figure 5-3. A common debugger frontend
  • Debug Tip: Hardware Verification Using a Simulator
  • Hardware Tools
  • Figure 5-4. A typical logic analyzer display
  • Debug Tip: External Triggering
  • Figure 5-5. Using I/O signals for debug and performance measurements
  • Finding Pin 1
  • Figure 5-6. Identifying pin 1 on an IC
  • Lint
  • Version Control
  • Dig into the Hardware
  • CHAPTER 6 Memory
  • Types of Memory
  • Figure 6-1. Common memory types in embedded systems
  • Types of RAM
  • DRAM Controllers
  • Types of ROM
  • Hybrid Types
  • Table 6-1. Memory device characteristics
  • Direct Memory Access
  • Endian Issues
  • Endianness in Devices
  • Figure 6-2. (a) Little-endian memory, (b) big-endian memory
  • Endianness in Networking
  • Memory Testing
  • Common Memory Problems
  • Electrical wiring problems
  • Figure 6-3. Possible wiring problems
  • Missing memory chips
  • Improperly inserted chips
  • Developing a Test Strategy
  • Data bus test
  • Table 6-2. Consecutive data values for an 8-bit walking 1’s test
  • Address bus test
  • Device test
  • Table 6-3. Data values for an 8-bit increment test
  • Putting it all together
  • Validating Memory Contents
  • Checksums
  • Cyclic Redundancy Checks
  • Table 6-4. International standard CRC parameters
  • Using Flash Memory
  • Working with Flash Memory
  • Flash Drivers
  • CHAPTER 7 Peripherals
  • Control and Status Registers
  • Bit Manipulation
  • Testing bits
  • Setting bits
  • Clearing bits
  • Toggling bits
  • Shifting bits
  • Bitmasks
  • Bitmask Macros
  • Bitfields
  • Unique Registers
  • Struct Overlays
  • Table 7-1. Timer peripheral struct address offsets
  • The Device Driver Philosophy
  • Figure 7-1. Embedded system software layers
  • A Serial Device Driver
  • Figure 7-2. Arcom board serial port block diagram
  • Register interface
  • State variables
  • Initialization routine
  • Device driver API
  • Testing the Serial Device Driver
  • Extending the Functionality of the Serial Device Driver
  • Device Driver Design
  • CHAPTER 8 Interrupts
  • Overview
  • Figure 8-1. Interrupt wiring
  • Interrupts and Related Events
  • Table 8-1. Partial interrupt list for PXA255 processor
  • Priorities
  • Table 8-2. ARM processor exception and interrupt priorities
  • Levels and Edges
  • Figure 8-2. Level- and edge-sensitive interrupt signals
  • Enabling and Disabling
  • Figure 8-3. PXA255 Interrupt Controller Mask Register
  • Interrupt Map
  • Table 8-3. ARM interrupt vector table
  • Table 8-4. Partial interrupt map for the Arcom board
  • Interrupt Service Routine
  • Figure 8-4. Software flow during interrupt
  • Shared Data and Race Conditions
  • Figure 8-5. Example race condition
  • The Improved Blinking LED Program
  • How Timers Work
  • Figure 8-6. PXA255 processor timer 0 registers
  • Watchdog Timers
  • Summary of Interrupt Issues
  • Time Sharing
  • CHAPTER 9 Putting It All Together
  • Application Overview
  • Figure 9-1. The Monitor and Control application
  • Working with Serial Ports
  • Command-Line Interface Processing
  • CHAPTER 10 Operating Systems
  • History and Purpose
  • The Scheduler
  • Real-Time Scheduling
  • Figure 10-1. Scheduling outcome examples
  • Figure 10-2. Priority scheduling of two tasks
  • Figure 10-3. Priority scheduling of three tasks
  • Scheduling Points
  • Locking and Unlocking
  • Tasks
  • Task States
  • Figure 10-4. Possible states of a task
  • Context switch
  • Figure 10-5. A context switch
  • The idle task
  • Task Context
  • Task Priorities
  • Rate monotonic scheduling
  • Figure 10-6. Example showing unschedulable task set
  • Task Mechanics
  • Figure 10-7. Basic task operation
  • Task Synchronization
  • Application Programming Interfaces
  • Mutexes and Semaphores
  • Deadlock and priority inversion
  • Figure 10-8. An example of priority inversion
  • Message Passing
  • Other Functionality
  • Interrupt Handling
  • Real-Time Characteristics
  • To Use or Not to Use an RTOS
  • RTOS Selection Process
  • Additional Resources
  • CHAPTER 11 eCos Examples
  • Introduction
  • Task Mechanics
  • Mutex Task Synchronization
  • Semaphore Task Synchronization
  • Figure 11-1. Arcom board add-on module’s SW0 button
  • Message Passing
  • Switch Debouncing
  • eCos Interrupt Handling
  • CHAPTER 12 Embedded Linux Examples
  • Introduction
  • Accessing Hardware in Linux
  • Task Mechanics
  • Mutex Task Synchronization
  • Semaphore Task Synchronization
  • Message Passing
  • CHAPTER 13 Extending Functionality
  • Common Peripherals
  • Inter-Integrated Circuit Bus
  • Figure 13-1. Example I2C bus structure
  • Figure 13-2. Format of a transaction on an I2C bus
  • Serial Peripheral Interface
  • Serial Bit Banging
  • Figure 13-3. Example SPI bus structure
  • Programmable Logic
  • Programmable Logic Device
  • Complex Programmable Logic Device
  • Figure 13-4. CPLD internal structure
  • Field Programmable Gate Array
  • Figure 13-5. FPGA internal structure
  • Pulse Width Modulation
  • Analog circuits
  • Digital control
  • Figure 13-6. PWM signals with varying duty cycles
  • Figure 13-7. A simple PWM circuit
  • Networking for All Devices Great and Small
  • Benefits of Network Support
  • Figure 13-8. Example of web-based management with a network stack
  • Networking Solutions for Embedded Systems
  • Advantages of Web-based Management
  • Figure 13-9. Common network protocol components
  • CHAPTER 14 Optimization Techniques
  • Increasing Code Efficiency
  • Decreasing Code Size
  • Problems with Optimizing Compilers
  • Reducing Memory Usage
  • Power-Saving Techniques
  • Processor Modes
  • Clock Frequency
  • Table 14-1. PXA255 power consumption comparison
  • External Memory Access
  • Limiting the Impact of C++
  • Embedded C++
  • Back Matter
  • APPENDIX A The Arcom VIPER-Lite Development Kit
  • Figure A-1. Arcom VIPER-Lite development system
  • APPENDIX B Setting Up Your Software Development Environment
  • Windows Host Installation
  • Cygwin Installation
  • GNU Software Tools Installation
  • Linux Host Installation
  • GNU Software Tools Installation
  • Example Code Installation
  • APPENDIX C Building the GNU Software Tools
  • Extracting the Source Files
  • Building the Toolchain
  • APPENDIX D Setting Up the eCos Development Environment
  • The eCos Build Environment
  • eCos Source Code Installation
  • Building the eCos Library
  • APPENDIX E Setting Up the Embedded Linux Development Environment
  • Linux Build Environment Setup
  • Embedded Linux Examples
  • Building the Linux Examples
  • Downloading and Running the Linux Examples
  • Debugging Embedded Linux Examples
  • Index
  • About the Authors
  • Colophon