Embedded Linux System Design and Development

Book description

Embedded Linux System Design and Development contains a full development roadmap for embedded Linux systems. It facilitates movement to embedded Linux from traditional real-time operating systems, and describes the system design model containing embedded Linux. This book delivers practical solutions for writing, debugging, and profiling applications and drivers in embedded Linux, and for understanding Linux BSP architecture. It enables you to understand: MTD model for flash based embedded storage; real-time programming using POSIX.1b real-time extensions; various drivers such as serial, I2C and USB gadgets; uClinux architecture and its programming model; and the embedded Linux graphics subsystem. The text also promotes learning of methods to reduce system boot time, optimize memory and storage, and find memory leaks and corruption in applications.

Table of contents

  1. Front cover (1/2)
  2. Front cover (2/2)
  3. Dedication
  4. Contents (1/2)
  5. Contents (2/2)
  6. Foreword
  7. Preface
    1. Benefits to the Reader
    2. Audience
      1. Primary Audience
      2. Secondary Audience
    3. Background
    4. Downloading Source Code
  8. Acknowledgments
  9. Introduction
  10. About the Authors
  11. Chapter 1
    1. Introduction
      1. 1.1 History of Embedded Linux
        1. 1.1.1 Year 1999
        2. 1.1.2 Year 2000
        3. 1.1.3 Year 2001
        4. 1.1.4 Year 2002
        5. 1.1.5 Year 2003
        6. 1.1.6 Year 2004
      2. 1.2 Why Embedded Linux?
        1. 1.2.1 Vendor Independence
        2. 1.2.2 Time to Market
        3. 1.2.3 Varied Hardware Support
        4. 1.2.4 Low Cost
          1. Development Cost
          2. Training and Hiring Costs
          3. Runtime Royalty
        5. 1.2.5 Open Source
        6. 1.2.6 Standards (POSIX®) Compliance
      3. 1.3 Embedded Linux Versus Desktop Linux
      4. 1.4 Frequently Asked Questions
        1. 1.4.1 Is Linux Too Large?
        2. 1.4.2 Is Linux Real-Time Enough?
        3. 1.4.3 How Can I Protect My Proprietary Software?
        4. 1.4.4 Should I Buy a Commercial Embedded Linux Distribution?
        5. 1.4.5 Which Embedded Linux Distribution Do I Choose?
      5. 1.5 Embedded Linux Distributions (1/3)
      6. 1.5 Embedded Linux Distributions (2/3)
      7. 1.5 Embedded Linux Distributions (3/3)
        1. 1.5.1 BlueCat Linux
          1. Features
          2. Development Environment
          3. Documentation
          4. Support
        2. 1.5.2 Cadenux
          1. Features
          2. Development Environment
          3. Documentation
          4. Support
        3. 1.5.3 Denx
          1. Features
          2. Development Environment
          3. Documentation
          4. Support
        4. 1.5.4 Embedded Debian (Emdebian)
          1. Features
          2. Development Environment
          3. Documentation
          4. Support
        5. 1.5.5 ELinOS (SYSGO)
          1. Features
          2. Development Environment
          3. Documentation
          4. Support
        6. 1.5.6 Metrowerks
          1. Features
          2. Development Environment
          3. Documentation
          4. Support
        7. 1.5.7 MontaVista Linux
          1. Features
          2. Development Environment
          3. Documentation
          4. Support
        8. 1.5.8 RTLinuxPro™
          1. Features
          2. Development Environment
          3. Documentation
          4. Support
        9. 1.5.9 TimeSys Linux
          1. Features
          2. Development Environment
          3. Documentation
          4. Support
      8. 1.6 Porting Roadmap
      9. Notes
  12. Chapter 2
    1. Getting Started
      1. 2.1 Architecture of Embedded Linux
        1. 2.1.1 Real-Time Executive
        2. 2.1.2 Monolithic Kernels
        3. 2.1.3 Microkernel
      2. 2.2 Linux Kernel Architecture
        1. 2.2.1 Hardware Abstraction Layer (HAL)
        2. 2.2.2 Memory Manager
        3. 2.2.3 Scheduler
        4. 2.2.4 File System
        5. 2.2.5 IO Subsystem
        6. 2.2.6 Networking Subsystems
        7. 2.2.7 IPC
      3. 2.3 User Space
      4. 2.4 Linux Start-Up Sequence (1/2)
      5. 2.4 Linux Start-Up Sequence (2/2)
        1. 2.4.1 Boot Loader Phase
          1. Hardware Initialization
          2. Downloading Kernel Image and Initial Ram Disk
          3. Setting Up Arguments
          4. Jumping to Kernel Entry Point
        2. 2.4.2 Kernel Start-Up
          1. CPU/Platform-Specific Initialization
          2. Subsystem Initialization
          3. Driver Initialization
          4. Mounting Root File System
          5. Doing Initcall and Freeing Initial Memory
          6. Moving to User Space
        3. 2.4.3 User Space Initialization
          1. The /sbin/init Process and /etc/inittab
          2. The rc.sysinit File
          3. Starting Services
      6. 2.5 GNU Cross-Platform Toolchain (1/3)
      7. 2.5 GNU Cross-Platform Toolchain (2/3)
      8. 2.5 GNU Cross-Platform Toolchain (3/3)
        1. 2.5.1 Building Toolchain
          1. Picking a Target Name
          2. Picking the Right Version Combination
          3. Any Patches Available?
          4. Choosing a Directory Structure and Setting Variables
          5. Building Binutils
          6. Obtain Suitable Kernel Headers
          7. Building Minimal GCC
          8. Building Glibc
          9. Recompiling Full-Featured GCC
        2. 2.5.2 Building Toolchain for MIPS
          1. Source Directory Listing
          2. Building Binutils
          3. Setting Kernel Headers
          4. Building Minimal GCC
          5. Building Glibc
          6. Building GCC with Threads and Additional Languages
  13. Chapter 3
    1. Board Support Package
      1. 3.1 Inserting BSP in Kernel Build Procedure
      2. 3.2 The Boot Loader Interface
      3. 3.3 Memory Map (1/2)
      4. 3.3 Memory Map (2/2)
        1. 3.3.1 The Processor Memory Map - MIPS Memory Model
        2. 3.3.2 Board Memory Map
        3. 3.3.3 Software Memory Map
          1. Linux Kernel Layout
          2. Boot Memory Allocators
          3. Setting Up Memory and IO Mappings
          4. Setting Up the Zone Allocators
      5. 3.4 Interrupt Management
      6. 3.5 The PCI Subsystem
        1. 3.5.1 Uniqueness of PCI Architecture
          1. Memory Map Issues
          2. Configuration Space Access
          3. Interrupt Routing on the Board
        2. 3.5.2 PCI Software Architecture
          1. PCI BSP
      7. 3.6 Timers
      8. 3.7 UART
        1. 3.7.1 Implementing the Console
        2. 3.7.2 The KGDB Interface
      9. 3.8 Power Management (1/2)
      10. 3.8 Power Management (2/2)
        1. 3.8.1 Hardware and Power Management
        2. 3.8.2 Power Management Standards
        3. 3.8.3 Supporting Processor’s Power-Saving Modes
        4. 3.8.4 Unified Driver Framework for Power Management
        5. 3.8.5 Power Management Applications
  14. Chapter 4
    1. Embedded Storage
      1. 4.1 Flash Map
      2. 4.2 MTD-Memory Technology Device
        1. 4.2.1 The MTD Model
        2. 4.2.2 Flash Chips
        3. 4.2.3 Flash Disks
      3. 4.3 MTD Architecture
        1. 4.3.1 mtd_info Data Structure
        2. 4.3.2 Interface Between MTD Core and Low-Level Flash Drivers
      4. 4.4 Sample MTD Driver for NOR Flash (1/2)
      5. 4.4 Sample MTD Driver for NOR Flash (2/2)
      6. 4.5 The Flash-Mapping Drivers (1/2)
      7. 4.5 The Flash-Mapping Drivers (2/2)
        1. 4.5.1 Filling up mtd_info for NOR Flash Chip
        2. 4.5.2 Filling up mtd_info for NAND Flash Chip
        3. 4.5.3 Registering mtd_info
          1. Partitioning
          2. Concatenation
        4. 4.5.4 Sample Mapping Driver for NOR Flash
      8. 4.6 MTD Block and Character Devices
      9. 4.7 Mtdutils Package
      10. 4.8 Embedded File Systems
        1. 4.8.1 Ramdisk
        2. 4.8.2 RAMFS
        3. 4.8.3 CRAMFS (Compressed RAM File System)
        4. 4.8.4 Journaling Flash File Systems - JFFS and JFFS2
        5. 4.8.5 NFS - Network File System
        6. 4.8.6 PROC File System
      11. 4.9 Optimizing Storage Space
        1. 4.9.1 Kernel Space Optimization
        2. 4.9.2 Application Space Optimization
          1. Library Optimizer
          2. Smaller C Libraries
        3. 4.9.3 Applications for Embedded Linux
          1. Busybox
          2. Tinylogin
          3. Ftp Server
          4. Web Server
      12. 4.10 Tuning Kernel Memory
  15. Chapter 5
    1. Embedded Drivers
      1. 5.1 Linux Serial Driver (1/2)
      2. 5.1 Linux Serial Driver (2/2)
        1. 5.1.1 Driver Initialization and Start-Up
        2. 5.1.2 Data Transmission
        3. 5.1.3 Data Reception
        4. 5.1.4 Interrupt Handler
        5. 5.1.5 Termios Settings
      3. 5.2 Ethernet Driver (1/2)
      4. 5.2 Ethernet Driver (2/2)
        1. 5.2.1 Device Initialization and Clean-Up
        2. 5.2.2 Data Transmission and Reception
      5. 5.3 I2C Subsystem on Linux (1/2)
      6. 5.3 I2C Subsystem on Linux (2/2)
        1. 5.3.1 I2C Bus
        2. 5.3.2 I2C Software Architecture
          1. Algorithm and Bus Adapter Driver
          2. I2C Slave and Client Drivers
      7. 5.4 USB Gadgets (1/2)
      8. 5.4 USB Gadgets (2/2)
        1. 5.4.1 USB Basics
        2. 5.4.2 Ethernet Gadget Driver
      9. 5.5 Watchdog Timer
      10. 5.6 Kernel Modules
        1. 5.6.1 Module APIs
        2. 5.6.2 Module Loading and Unloading
      11. Notes
  16. Chapter 6
    1. Porting Applications
      1. 6.1 Architectural Comparison
      2. 6.2 Application Porting Roadmap
        1. 6.2.1 Decide Porting Strategy
          1. One-Process Model
          2. Multiprocess Model
        2. 6.2.2 Write an Operating System Porting Layer (OSPL)
        3. 6.2.3 Write a Kernel API Driver
      3. 6.3 Programming with Pthreads (1/3)
      4. 6.3 Programming with Pthreads (2/3)
      5. 6.3 Programming with Pthreads (3/3)
        1. 6.3.1 Thread Creation and Exit
        2. 6.3.2 Thread Synchronization
          1. Pthreads Mutex
          2. Pthreads Condition Variable
        3. 6.3.3 Thread Cancellation
        4. 6.3.4 Detached Threads
      6. 6.4 Operating System Porting Layer (OSPL) (1/2)
      7. 6.4 Operating System Porting Layer (OSPL) (2/2)
        1. 6.4.1 RTOS Mutex APIs Emulation
        2. 6.4.2 RTOS Task APIs Emulation
          1. User-Space Task APIs Emulation
          2. Kernel Task APIs Emulation
        3. 6.4.3 IPC and Timer APIs Emulation
      8. 6.5 Kernel API Driver (1/2)
      9. 6.5 Kernel API Driver (2/2)
        1. 6.5.1 Writing User-Space Stubs
        2. 6.5.2 Kapi Driver Implementation
        3. 6.5.3 Using the Kapi Driver
      10. Note
  17. Chapter 7
    1. Real-Time Linux
      1. 7.1 Real-Time Operating System
      2. 7.2 Linux and Real-Time
        1. 7.2.1 Interrupt Latency
        2. 7.2.2 ISR Duration
        3. 7.2.3 Scheduler Latency
          1. Kernel Preemption
          2. Low-Latency Patches
        4. 7.2.4 Scheduler Duration
          1. Making the Scheduler Real-Time: The O(1) Scheduler
          2. Context Switch Time
        5. 7.2.5 User-Space Real-Time
      3. 7.3 Real-Time Programming in Linux (1/9)
      4. 7.3 Real-Time Programming in Linux (2/9)
      5. 7.3 Real-Time Programming in Linux (3/9)
      6. 7.3 Real-Time Programming in Linux (4/9)
      7. 7.3 Real-Time Programming in Linux (5/9)
      8. 7.3 Real-Time Programming in Linux (6/9)
      9. 7.3 Real-Time Programming in Linux (7/9)
      10. 7.3 Real-Time Programming in Linux (8/9)
      11. 7.3 Real-Time Programming in Linux (9/9)
        1. 7.3.1 Process Scheduling
          1. Scheduling Class
          2. Priority
          3. Timeslice
          4. Scheduling Functions
        2. 7.3.2 Memory Locking
          1. Memory Locking Functions
          2. Effective Locking Using Linker Script
          3. Effective Locking Using GCC Section Attribute
          4. Points to Remember
        3. 7.3.3 POSIX Shared Memory
          1. Linux Implementation
          2. Points to Remember
        4. 7.3.4 POSIX Message Queues
          1. Asynchronous Notification
          2. Linux Implementation
          3. Points to Remember
        5. 7.3.5 POSIX Semaphores
          1. Points to Remember
        6. 7.3.6 Real-Time Signals
          1. Main Application
          2. Parent Process
          3. Child Process
        7. 7.3.7 POSIX.1b Clock and Timers
          1. High-Resolution Timers
          2. Points to Remember
        8. 7.3.8 Asynchronous I/O
          1. AIO Control Block
          2. AIO Functions
          3. List-Directed I/O
          4. Linux Implementation
          5. Points to Remember
      12. 7.4 Hard Real-Time Linux (1/2)
      13. 7.4 Hard Real-Time Linux (2/2)
        1. 7.4.1 Real-Time Application Interface (RTAI)
          1. HAL
          2. Schedulers
          3. LXRT
          4. IPC
          5. Miscellaneous Modules
          6. Writing RTAI Applications
        2. 7.4.2 ADEOS
          1. ADEOS and Linux
  18. Chapter 8
    1. Building and Debugging
      1. 8.1 Building the Kernel (1/2)
      2. 8.1 Building the Kernel (2/2)
        1. 8.1.1 Understanding Build Procedure
        2. 8.1.2 The Configuration Process
        3. 8.1.3 Kernel Makefile Framework
      3. 8.2 Building Applications
        1. 8.2.1 Cross-Compiling Using Configure
        2. 8.2.2 Troubleshooting Configure Script
      4. 8.3 Building the Root File System
      5. 8.4 Integrated Development Environment
        1. 8.4.1 Eclipse
        2. 8.4.2 KDevelop
        3. 8.4.3 TimeStorm
        4. 8.4.4 CodeWarrior
      6. 8.5 Debugging Virtual Memory Problems (1/3)
      7. 8.5 Debugging Virtual Memory Problems (2/3)
      8. 8.5 Debugging Virtual Memory Problems (3/3)
        1. 8.5.1 Debugging Memory Leaks
          1. mtrace
          2. dmalloc
        2. 8.5.2 Debugging Memory Overflows
        3. 8.5.3 Debugging Memory Corruption
      9. 8.6 Kernel Debuggers
      10. 8.7 Profiling (1/3)
      11. 8.7 Profiling (2/3)
      12. 8.7 Profiling (3/3)
        1. 8.7.1 eProf-An Embedded Profiler
          1. eProf Implementation
        2. 8.7.2 OProfile
        3. 8.7.3 Kernel Function Instrumentation
          1. KFI Toolset
          2. Using KFI
          3. Porting KFI
      13. Notes
  19. Chapter 9
    1. Embedded Graphics
      1. 9.1 Graphics System
      2. 9.2 Linux Desktop Graphics-The X Graphics System
        1. 9.2.1 Embedded Systems and X
      3. 9.3 Introduction to Display Hardware
        1. 9.3.1 Display System
        2. 9.3.2 Input Interface
      4. 9.4 Embedded Linux Graphics
      5. 9.5 Embedded Linux Graphics Driver
        1. 9.5.1 Linux Frame Buffer Interface
          1. The Power of mmap
          2. Setting Up Frame Buffer Driver
        2. 9.5.2 Frame Buffer Internals
      6. 9.6 Windowing Environments, Toolkits, and Applications (1/3)
      7. 9.6 Windowing Environments, Toolkits, and Applications (2/3)
      8. 9.6 Windowing Environments, Toolkits, and Applications (3/3)
        1. 9.6.1 Nano-X
          1. Nano-X Architecture
          2. Getting Started with Nano-X
          3. Building a Sample Nano-X Application
          4. Nano-X Toolkit
      9. 9.7 Conclusion
      10. Notes
  20. Chapter 10
    1. uClinux
      1. 10.1 Linux on MMU-Less Systems
        1. 10.1.1 Linux Versus uClinux
          1. Process Address Space and Memory Protection
          2. User Mode and Kernel Mode
          3. Demand Paging and Swapping
      2. 10.2 Program Load and Execution (1/3)
      3. 10.2 Program Load and Execution (2/3)
      4. 10.2 Program Load and Execution (3/3)
        1. 10.2.1 Fully Relocatable Binaries (FRB)
        2. 10.2.2 Position Independent Code (PIC)
          1. eXecute In Place (XIP)
        3. 10.2.3 bFLT File Format
        4. 10.2.4 Loading a bFLT File
          1. FRB Case
          2. PIC Case
      5. 10.3 Memory Management (1/2)
      6. 10.3 Memory Management (2/2)
        1. 10.3.1 Heap
          1. Memory Allocation
          2. Memory Fragmentation
          3. Defragmenting Memory
        2. 10.3.2 Stack
      7. 10.4 File / Memory Mapping-The Intricacies of mmap() in uClinux
      8. 10.5 Process Creation
      9. 10.6 Shared Libraries
        1. 10.6.1 uClinux Shared Library Implementation (libN.so)
      10. 10.7 Porting Applications to uClinux
        1. 10.7.1 Creating uClinux Programs
          1. Creating Fully Relocatable Binaries
          2. Creating PIC Binaries
        2. 10.7.2 Creating Shared Libraries in uClinux
        3. 10.7.3 Using Shared Library in an Application
        4. 10.7.4 Memory Limitations
        5. 10.7.5 mmap Limitations
        6. 10.7.6 Process-Level Limitations
      11. 10.8 XIP-eXecute In Place
        1. 10.8.1 Hardware Requirements
        2. 10.8.2 Software Requirements
      12. 10.9 Building uClinux Distribution
      13. Notes
  21. Appendix A
    1. Booting Faster
      1. Techniques for Cutting Down Bootloader Initialization
      2. Tuning Kernel for Decreased Boot-Up Time
      3. Tuning User Space for Decreased Boot-Up Time
      4. Measuring Boot-Up Time
  22. Appendix B
    1. GPL and Embedded Linux
      1. User-Space Applications
      2. Kernel
      3. Points to Remember
      4. Notes
  23. Back Cover

Product information

  • Title: Embedded Linux System Design and Development
  • Author(s): P. Raghavan, Amol Lad, Sriram Neelakandan
  • Release date: December 2005
  • Publisher(s): Auerbach Publications
  • ISBN: 9781420031614