You are previewing Embedded Linux for Developers.
O'Reilly logo
Embedded Linux for Developers

Book Description

Leverage the power of Linux to develop captivating and powerful embedded Linux projects

About This Book

  • Explore the best practices for all embedded product development stages

  • Learn about the compelling features offered by the Yocto Project, such as customization, virtualization, and many more

  • Minimize project costs by using open source tools and programs

  • Who This Book Is For

    If you are a developer who wants to build embedded systems using Linux, this book is for you. It is the ideal guide for you if you want to become proficient and broaden your knowledge. A basic understanding of C programming and experience with systems programming is needed. Experienced embedded Yocto developers will find new insight into working methodologies and ARM specific development competence.

    What You Will Learn

  • Use the Yocto Project in the embedded Linux development process

  • Get familiar with and customize the bootloader for a board

  • Discover more about real-time layer, security, virtualization, CGL, and LSB

  • See development workflows for the U-Boot and the Linux kernel, including debugging and optimization

  • Understand the open source licensing requirements and how to comply with them when cohabiting with proprietary programs

  • Optimize your production systems by reducing the size of both the Linux kernel and root filesystems

  • Understand device trees and make changes to accommodate new hardware on your device

  • Design and write multi-threaded applications using POSIX threads

  • Measure real-time latencies and tune the Linux kernel to minimize them

  • In Detail

    Embedded Linux is a complete Linux distribution employed to operate embedded devices such as smartphones, tablets, PDAs, set-top boxes, and many more. An example of an embedded Linux distribution is Android, developed by Google.

    This learning path starts with the module Learning Embedded Linux Using the Yocto Project. It introduces embedded Linux software and hardware architecture and presents information about the bootloader. You will go through Linux kernel features and source code and get an overview of the Yocto Project components available.

    The next module Embedded Linux Projects Using Yocto Project Cookbook takes you through the installation of a professional embedded Yocto setup, then advises you on best practices. Finally, it explains how to quickly get hands-on with the Freescale ARM ecosystem and community layer using the affordable and open source Wandboard embedded board.

    Moving ahead, the final module Mastering Embedded Linux Programming takes you through the product cycle and gives you an in-depth description of the components and options that are available at each stage. You will see how functions are split between processes and the usage of POSIX threads.

    By the end of this learning path, your capabilities will be enhanced to create robust and versatile embedded projects.

    This Learning Path combines some of the best that Packt has to offer in one complete, curated package. It includes content from the following Packt products:

  • Learning Embedded Linux Using the Yocto Project by Alexandru Vaduva

  • Embedded Linux Projects Using Yocto Project Cookbook by Alex González

  • Mastering Embedded Linux Programming by Chris Simmonds

  • Style and approach

    This comprehensive, step-by-step, pragmatic guide enables you to build custom versions of Linux for new embedded systems with examples that are immediately applicable to your embedded developments. Practical examples provide an easy-to-follow way to learn Yocto project development using the best practices and working methodologies. Coupled with hints and best practices, this will help you understand embedded Linux better.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Embedded Linux for Developers
      1. Table of Contents
      2. Embedded Linux for Developers
      3. Embedded Linux for Developers
      4. Credits
      5. Preface
        1. What this learning path covers
        2. What you need for this learning path
        3. Who this learning path is for
        4. Reader feedback
        5. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      6. 1. Module 1
        1. 1. Introduction
          1. Advantages of Linux and open source systems
          2. Embedded systems
            1. General description
            2. Examples
          3. Introducing GNU/Linux
          4. Introduction to the Yocto Project
            1. Buildroot
            2. OpenEmbedded
          5. Summary
        2. 2. Cross-compiling
          1. Introducing toolchains
          2. Components of toolchains
          3. Delving into C libraries
          4. Working with toolchains
            1. Advice on robust programming
            2. Generating the toolchain
          5. The Yocto Project reference
          6. Summary
        3. 3. Bootloaders
          1. The role of the bootloader
          2. Comparing various bootloaders
          3. Delving into the bootloader cycle
          4. The U-Boot bootloader
            1. Booting the U-Boot options
            2. Porting U-Boot
          5. The Yocto Project
          6. Summary
        4. 4. Linux Kernel
          1. The role of the Linux kernel
          2. Delving into the features of the Linux kernel
            1. Memory mapping and management
              1. Page cache and page writeback
              2. The process address space
            2. Process management
            3. Process scheduling
            4. System calls
            5. The virtual file system
          3. Interrupts
            1. Bottom halves
            2. Methods to perform kernel synchronization
          4. Timers
          5. Linux kernel interaction
            1. The development process
            2. Kernel porting
            3. Community interaction
          6. Kernel sources
            1. Configuring kernel
            2. Compiling and installing the kernel
            3. Cross-compiling the Linux kernel
          7. Devices and modules
          8. Debugging a kernel
          9. The Yocto Project reference
          10. Summary
        5. 5. The Linux Root Filesystem
          1. Interacting with the root filesystem
            1. Delving into the filesystem
            2. Device drivers
            3. Filesystem options
          2. Understanding BusyBox
          3. Minimal root filesystem
          4. The Yocto Project
          5. Summary
        6. 6. Components of the Yocto Project
          1. Poky
          2. Eclipse ADT plug-ins
          3. Hob and Toaster
          4. Autobuilder
          5. Lava
          6. Wic
          7. Summary
        7. 7. ADT Eclipse Plug-ins
          1. The Application Development Toolkit
            1. Setting up the environment
          2. Eclipse IDE
            1. QEMU emulator
            2. Debugging
            3. Profiling and tracing
            4. The Yocto Project bitbake commander
          3. Summary
        8. 8. Hob, Toaster, and Autobuilder
          1. Hob
          2. Toaster
          3. Autobuilder
          4. Summary
        9. 9. Wic and Other Tools
          1. Swabber
          2. Wic
          3. LAVA
          4. Summary
        10. 10. Real-time
          1. Understanding GPOS and RTOS
          2. PREEMPT_RT
            1. Applying the PREEMPT_RT patch
            2. The Yocto Project -rt kernel
            3. Disadvantages of the PREEMPT_RT patches
          3. Linux real-time applications
          4. Benchmarking
          5. Meta-realtime
          6. Summary
        11. 11. Security
          1. Security in Linux
          2. SELinux
          3. Grsecurity
          4. Security for the Yocto Project
          5. Meta-security and meta-selinux
            1. Meta-security
            2. Meta-selinux
          6. Summary
        12. 12. Virtualization
          1. Linux virtualization
            1. SDN and NFV
            2. NFV
            3. ETSI NFV
            4. SDN
            5. OPNFV
          2. Virtualization support for the Yocto Project
          3. Summary
        13. 13. CGL and LSB
          1. Linux Standard Base
          2. Carrier grade options
            1. Carrier Grade Linux
            2. Automotive Grade Linux
            3. Carrier Grade Virtualization
          3. Specific support for the Yocto Project
          4. Summary
      7. 2. Module 2
        1. 1. The Build System
          1. Introduction
          2. Setting up the host system
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          3. Installing Poky
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          4. Creating a build directory
            1. How to do it...
            2. How it works...
            3. There's more...
          5. Building your first image
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
          6. Explaining the Freescale Yocto ecosystem
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          7. Installing support for Freescale hardware
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          8. Building Wandboard images
            1. How to do it...
            2. How it works...
            3. See also
          9. Troubleshooting your Wandboard's first boot
            1. Getting ready
            2. How to do it...
            3. There's more...
          10. Configuring network booting for a development setup
            1. Getting ready
              1. Installing a TFTP server
              2. Installing an NFS server
            2. How to do it...
          11. Sharing downloads
            1. Getting ready
            2. How to do it...
          12. Sharing the shared state cache
            1. How to do it...
            2. There's more...
          13. Setting up a package feed
            1. Getting ready
              1. Versioning packages
            2. How to do it...
            3. See also
          14. Using build history
            1. How to do it...
            2. How it works...
              1. Looking at the build history
            3. There's more...
          15. Working with build statistics
            1. How to do it...
            2. How it works...
            3. There's more...
          16. Debugging the build system
            1. Getting ready
              1. Finding recipes
              2. Dumping BitBake's environment
              3. Using the development shell
            2. How to do it...
              1. Task log and run files
              2. Adding logging to recipes
              3. Looking at dependencies
              4. Debugging BitBake
              5. Error reporting tool
            3. There's more...
        2. 2. The BSP Layer
          1. Introduction
          2. Creating a custom BSP layer
            1. How to do it...
            2. How it works...
            3. There's more...
              1. Adding a new machine
              2. Adding a custom device tree to the Linux kernel
              3. Adding a custom U-Boot machine
              4. Adding a custom formfactor file
          3. Introducing system development workflows
            1. How to do it...
            2. How it works...
              1. External development
              2. Working directory development
              3. External source development
          4. Adding a custom kernel and bootloader
            1. Getting Ready
              1. Finding the Linux kernel source
              2. Finding the U-Boot source
              3. Developing using a Git repository fork
            2. How to do it...
            3. How it works...
          5. Explaining Yocto's Linux kernel support
            1. How to do it...
            2. How it works...
            3. See also
          6. Describing Linux's build system
            1. How to do it...
            2. How it works...
            3. There's more...
          7. Configuring the Linux kernel
            1. Getting ready
            2. How to do it...
            3. There's more...
              1. Using configuration fragments
          8. Building the Linux kernel
            1. How to do it...
            2. How it works...
              1. External development
              2. External source development
              3. Working directory development
          9. Building external kernel modules
            1. Getting ready
            2. How to do it...
            3. There's more...
          10. Debugging the Linux kernel and modules
            1. How to do it...
            2. How it works...
            3. There's more...
              1. Using dynamic debug
              2. Rate-limiting debug messages
            4. See also
          11. Debugging the Linux kernel booting process
            1. How to do it...
            2. How it works...
              1. Dumping the kernel's printk buffer from the bootloader
            3. There's more...
          12. Using the kernel function tracing system
            1. Getting ready...
            2. How to do it...
            3. How it works...
            4. There's more...
              1. Filtering function traces
              2. Enabling trace options
              3. Using the function tracer on oops
              4. Getting a stack trace for a given function
              5. Configuring the function tracer at boot
            5. See also
          13. Managing the device tree
            1. Getting ready
            2. How to do it...
            3. How it works...
              1. The compatible property
              2. The Wandboard device tree file
              3. Defining buses and memory-addressable devices
            4. There's more...
              1. Modifying and compiling the device tree in Yocto
            5. See also
          14. Debugging device tree issues
            1. How to do it...
            2. How it works...
              1. Looking at the device tree from U-Boot
              2. Looking at the device tree from the Linux kernel
        3. 3. The Software Layer
          1. Introduction
          2. Exploring an image's contents
            1. Getting ready
            2. How to do it...
            3. How it works...
          3. Adding a new software layer
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
          4. Selecting a specific package version and providers
            1. How to do it...
              1. How do we select which provider to use?
              2. How do we select which version to use?
              3. How do we select which version not to use?
          5. Adding supported packages
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
              1. Configuring packages
          6. Adding new packages
            1. Getting ready
            2. How to do it...
            3. How it works...
              1. Package licensing
              2. Fetching package contents
              3. Specifying task overrides
              4. Configuring packages
              5. Splitting into several packages
              6. Setting machine-specific variables
          7. Adding data, scripts, or configuration files
            1. How to do it...
          8. Managing users and groups
            1. Getting ready
            2. How to do it...
            3. There's more...
          9. Using the sysvinit initialization manager
            1. Getting ready
            2. How to do it...
          10. Using the systemd initialization manager
            1. Getting ready
            2. How to do it...
            3. There's more...
              1. Installing systemd unit files
          11. Installing package-installation scripts
            1. Getting ready
            2. How to do it...
            3. How it works...
          12. Reducing the Linux kernel image size
            1. How to do it...
            2. How it works...
          13. Reducing the root filesystem image size
            1. How to do it...
            2. How it works...
          14. Releasing software
            1. Getting ready
            2. How to do it...
            3. There's more…
            4. See also
          15. Analyzing your system for compliance
            1. How to do it...
            2. There's more
          16. Working with open source and proprietary code
            1. How to do it...
            2. How it works...
              1. The U-Boot bootloader
              2. The Linux kernel
              3. Glibc
              4. BusyBox
              5. The Qt framework
              6. The X Windows system
            3. There's more...
            4. See also
        4. 4. Application Development
          1. Introduction
          2. Preparing and using an SDK
            1. Getting ready
            2. How to do it...
          3. Using the Application Development Toolkit
            1. Getting ready
            2. How to do it...
            3. How it works...
          4. Using the Eclipse IDE
            1. Getting ready
            2. How to do it...
            3. There's more...
            4. See also
          5. Developing GTK+ applications
            1. Getting ready
            2. How to do it...
            3. There's more...
          6. Using the Qt Creator IDE
            1. Getting ready
            2. How to do it...
          7. Developing Qt applications
            1. Getting ready
            2. How to do it...
            3. There's more...
          8. Describing workflows for application development
            1. How to do it...
            2. How it works...
              1. External development
              2. Working directory development
              3. External source development
          9. Working with GNU make
            1. How to do it...
            2. See also
          10. Working with the GNU build system
            1. Getting ready
            2. How to do it...
            3. See also
          11. Working with the CMake build system
            1. Getting ready
            2. How to do it...
            3. See also
          12. Working with the SCons builder
            1. Getting ready
            2. How to do it...
            3. See also
          13. Developing with libraries
            1. Getting ready
              1. Building a static library
              2. Building a shared dynamic library
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          14. Working with the Linux framebuffer
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          15. Using the X Windows system
            1. Getting ready
            2. How to do it...
            3. There's more...
            4. See also
          16. Using Wayland
            1. Getting ready
            2. How to do it...
            3. There's more...
            4. See also
          17. Adding Python applications
            1. Getting ready
            2. How to do it...
            3. There's more...
          18. Integrating the Oracle Java Runtime Environment
            1. Getting ready
            2. How to do it...
            3. There's more...
          19. Integrating the Open Java Development Kit
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          20. Integrating Java applications
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
        5. 5. Debugging, Tracing, and Profiling
          1. Introduction
          2. Analyzing core dumps
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. See also
          3. Native GDB debugging
            1. Getting ready
            2. How to do it...
            3. There's more...
            4. See also
          4. Cross GDB debugging
            1. Getting ready
            2. How to do it...
            3. How it works...
          5. Using strace for application debugging
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. See also
          6. Using the kernel's performance counters
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          7. Using static kernel tracing
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          8. Using dynamic kernel tracing
            1. Getting ready
            2. How to do it...
            3. There's more...
            4. See also
          9. Using dynamic kernel events
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
          10. Exploring Yocto's tracing and profiling tools
            1. Getting ready
            2. How to do it...
            3. There's more...
          11. Tracing and profiling with perf
            1. Getting ready
            2. How to do it...
            3. How it works...
              1. Reading tracing data
            4. There's more...
              1. Profile charts
              2. Using perf as strace substitute
            5. See also
          12. Using SystemTap
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. See also
          13. Using OProfile
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
            5. See also
          14. Using LTTng
            1. Getting ready
            2. How to do it...
            3. How it works...
              1. Extending application profiling
            4. There's more...
            5. See also
          15. Using blktrace
            1. Getting ready
            2. How to do it...
            3. How it works...
            4. There's more...
      8. 3. Module 3
        1. 1. Starting Out
          1. Selecting the right operating system
          2. The players
          3. Project lifecycle
            1. The four elements of embedded Linux
          4. Open source
            1. Licenses
          5. Hardware for embedded Linux
          6. Hardware used in this book
            1. The BeagleBone Black
            2. QEMU
          7. Software used in this book
          8. Summary
        2. 2. Learning About Toolchains
          1. What is a toolchain?
          2. Types of toolchain - native versus cross toolchain
            1. CPU architectures
          3. Choosing the C library
          4. Finding a toolchain
            1. Building a toolchain using crosstool-NG
            2. Installing crosstool-NG
            3. Selecting the toolchain
          5. Anatomy of a toolchain
            1. Finding out about your cross compiler
            2. The sysroot, library, and header files
          6. Other tools in the toolchain
          7. Looking at the components of the C library
          8. Linking with libraries: static and dynamic linking
            1. Static libraries
            2. Shared libraries
              1. Understanding shared library version numbers
          9. The art of cross compiling
            1. Simple makefiles
            2. Autotools
              1. An example: SQLite
            3. Package configuration
          10. Problems with cross compiling
          11. Summary
        3. 3. All About Bootloaders
          1. What does a bootloader do?
          2. The boot sequence
            1. Phase 1: ROM code
            2. Phase 2: SPL
            3. Phase 3: TPL
          3. Booting with UEFI firmware
          4. Moving from bootloader to kernel
          5. Introducing device trees
            1. Device tree basics
            2. The reg property
            3. Phandles and interrupts
            4. Device tree include files
            5. Compiling a device tree
          6. Choosing a bootloader
          7. U-Boot
            1. Building U-Boot
            2. Installing U-Boot
            3. Using U-Boot
              1. Environment variables
              2. Boot image format
              3. Loading images
            4. Booting Linux
              1. Automating the boot with U-Boot scripts
            5. Porting U-Boot to a new board
            6. Kconfig and U-Boot
              1. Board-specific files
              2. Configuration header files
            7. Building and testing
            8. Falcon mode
          8. Barebox
            1. Getting Barebox
            2. Building Barebox
          9. Summary
        4. 4. Porting and Configuring the Kernel
          1. What does the kernel do?
          2. Choosing a kernel
            1. Kernel development cycle
            2. Stable and long term support releases
            3. Vendor support
            4. Licensing
          3. Building the kernel
            1. Getting the source
            2. Understanding kernel configuration
            3. Using LOCALVERSION to identify your kernel
            4. Kernel modules
          4. Compiling
            1. Compiling the kernel image
            2. Compiling device trees
            3. Compiling modules
          5. Cleaning kernel sources
          6. Booting your kernel
            1. BeagleBone Black
            2. QEMU
            3. Kernel panic
            4. Early user space
            5. Kernel messages
            6. Kernel command line
          7. Porting Linux to a new board
            1. With a device tree
            2. Without a device tree
          8. Additional reading
          9. Summary
        5. 5. Building a Root Filesystem
          1. What should be in the root filesystem?
            1. Directory layout
            2. Staging directory
              1. POSIX file access permissions
              2. File ownership permissions in the staging directory
          2. Programs for the root filesystem
            1. The init program
            2. Shell
            3. Utilities
            4. BusyBox to the rescue!
              1. Building BusyBox
            5. ToyBox – an alternative to BusyBox
          3. Libraries for the root filesystem
            1. Reducing size by stripping
          4. Device nodes
          5. The proc and sysfs filesystems
            1. Mounting filesystems
          6. Kernel modules
          7. Transfering the root filesystem to the target
          8. Creating a boot ramdisk
            1. Standalone ramdisk
            2. Booting the ramdisk
              1. Booting with QEMU
              2. Booting the BeagleBone Black
              3. Mounting proc
            3. Building a ramdisk cpio into the kernel image
              1. Another way to build a kernel with ramdisk
            4. The old initrd format
          9. The init program
          10. Configuring user accounts
            1. Adding user accounts to the root filesystem
          11. Starting a daemon process
          12. A better way of managing device nodes
            1. An example using devtmpfs
            2. An example using mdev
            3. Are static device nodes so bad after all?
          13. Configuring the network
            1. Network components for glibc
          14. Creating filesystem images with device tables
            1. Putting the root filesytem onto an SD card
          15. Mounting the root filesystem using NFS
            1. Testing with QEMU
            2. Testing with BeagleBone Black
            3. Problems with file permissions
          16. Using TFTP to load the kernel
          17. Additional reading
          18. Summary
        6. 6. Selecting a Build System
          1. No more rolling your own embedded Linux
          2. Build systems
          3. Package formats and package managers
          4. Buildroot
            1. Background
            2. Stable releases and support
            3. Installing
            4. Configuring
            5. Running
            6. Creating a custom BSP
              1. U-Boot
              2. Linux
              3. Build
            7. Adding your own code
              1. Overlay
              2. Adding a package
            8. License compliance
          5. The Yocto Project
            1. Background
            2. Stable releases and support
            3. Installing the Yocto Project
            4. Configuring
            5. Building
            6. Running
            7. Layers
              1. BitBake and recipes
            8. Customizing images via local.conf
            9. Writing an image recipe
            10. Creating an SDK
            11. License audit
          6. Further reading
          7. Summary
        7. 7. Creating a Storage Strategy
          1. Storage options
            1. NOR flash
            2. NAND flash
            3. Managed flash
              1. MultiMediaCard and secure digital cards
              2. eMMC
              3. Other types of managed flash
          2. Accessing flash memory from the bootloader
            1. U-Boot and NOR flash
            2. U-Boot and NAND flash
            3. U-Boot and MMC, SD and eMMC
          3. Accessing flash memory from Linux
            1. Memory technology devices
              1. MTD partitions
              2. MTD device drivers
              3. The MTD character device, mtd
              4. The MTD block device, mtdblock
              5. Logging kernel oops to MTD
              6. Simulating NAND memory
            2. The MMC block driver
          4. Filesystems for flash memory
            1. Flash translation layers
          5. Filesystems for NOR and NAND flash memory
            1. JFFS2
              1. Summary nodes
              2. Clean markers
              3. Creating a JFFS2 filesystem
            2. YAFFS2
              1. Creating a YAFFS2 filesystem
            3. UBI and UBIFS
              1. UBI
              2. UBIFS
          6. Filesystems for managed flash
            1. Flashbench
            2. Discard and TRIM
            3. Ext4
            4. F2FS
            5. FAT16/32
          7. Read-only compressed filesystems
            1. squashfs
          8. Temporary filesystems
          9. Making the root filesystem read-only
          10. Filesystem choices
          11. Updating in the field
            1. Granularity: file, package, or image?
            2. Atomic image update
          12. Further reading
          13. Summary
        8. 8. Introducing Device Drivers
          1. The role of device drivers
          2. Character devices
          3. Block devices
          4. Network devices
          5. Finding out about drivers at runtime
            1. Getting information from sysfs
            2. The devices: /sys/devices
            3. The drivers: /sys/class
            4. The block drivers: /sys/block
          6. Finding the right device driver
          7. Device drivers in user-space
            1. GPIO
              1. Handling interrupts from GPIO
            2. LEDs
            3. I2C
            4. SPI
          8. Writing a kernel device driver
            1. Designing a character device interface
            2. Anatomy of a device driver
              1. Compile and load
          9. Loading kernel modules
          10. Discovering hardware configuration
            1. Device trees
            2. Platform data
            3. Linking hardware with device drivers
          11. Additional reading
          12. Summary
        9. 9. Starting up - the init Program
          1. After the kernel has booted
          2. Introducing the init programs
          3. BusyBox init
            1. Buildroot init scripts
          4. System V init
            1. inittab
            2. The init.d scripts
            3. Adding a new daemon
            4. Starting and stopping services
          5. systemd
            1. Building systemd with the Yocto Project and Buildroot
              1. Introducing targets, services, and units
                1. Units
                2. Services
                3. Targets
            2. How systemd boots the system
            3. Adding your own service
            4. Adding a watchdog
            5. Implications for embedded Linux
          6. Further reading
          7. Summary
        10. 10. Learning About Processes and Threads
          1. Process or thread?
          2. Processes
            1. Creating a new process
            2. Terminating a process
            3. Running a different program
            4. Daemons
            5. Inter-process communication
              1. Message-based IPC
                1. Unix (or local) sockets
                2. FIFOs and named pipes
                3. POSIX message queues
              2. Summary of message-based IPC
              3. Shared memory-based IPC
                1. POSIX shared memory
          3. Threads
            1. Creating a new thread
            2. Terminating a thread
            3. Compiling a program with threads
            4. Inter-thread communication
            5. Mutual exclusion
            6. Changing conditions
            7. Partitioning the problem
          4. Scheduling
            1. Fairness versus determinism
            2. Timeshare policies
              1. Niceness
            3. Real-time policies
            4. Choosing a policy
            5. Choosing a real-time priority
          5. Further reading
          6. Summary
        11. 11. Managing Memory
          1. Virtual memory basics
          2. Kernel space memory layout
            1. How much memory does the kernel use?
          3. User space memory layout
          4. Process memory map
          5. Swap
            1. Swap to compressed memory (zram)
          6. Mapping memory with mmap
            1. Using mmap to allocate private memory
            2. Using mmap to share memory
            3. Using mmap to access device memory
          7. How much memory does my application use?
          8. Per-process memory usage
            1. Using top and ps
            2. Using smem
            3. Other tools to consider
          9. Identifying memory leaks
            1. mtrace
            2. Valgrind
          10. Running out of memory
          11. Further reading
          12. Summary
        12. 12. Debugging with GDB
          1. The GNU debugger
          2. Preparing to debug
          3. Debugging applications using GDB
          4. Remote debugging using gdbserver
            1. Setting up the Yocto Project
            2. Setting up Buildroot
          5. Starting to debug
            1. Connecting GDB and gdbserver
            2. Setting the sysroot
            3. GDB command files
            4. Overview of GDB commands
              1. Breakpoints
              2. Running and stepping
              3. Information commands
            5. Running to a breakpoint
          6. Debugging shared libraries
            1. The Yocto Project
            2. Buildroot
            3. Other libraries
          7. Just-in-time debugging
          8. Debugging forks and threads
          9. Core files
            1. Using GDB to look at core files
          10. GDB user interfaces
            1. Terminal user interface
            2. Data display debugger
            3. Eclipse
          11. Debugging kernel code
            1. Debugging kernel code with kgdb
            2. A sample debug session
            3. Debugging early code
            4. Debugging modules
            5. Debugging kernel code with kdb
            6. Looking at an oops
            7. Preserving the oops
          12. Additional reading
          13. Summary
        13. 13. Profiling and Tracing
          1. The observer effect
            1. Symbol tables and compile flags
          2. Beginning to profile
          3. Profiling with top
            1. Poor man's profiler
          4. Introducing perf
            1. Configuring the kernel for perf
            2. Building perf with the Yocto Project
            3. Building perf with Buildroot
            4. Profiling with perf
            5. Call graphs
            6. perf annotate
          5. Other profilers: OProfile and gprof
          6. Tracing events
          7. Introducing Ftrace
            1. Preparing to use Ftrace
            2. Using Ftrace

            3. Dynamic Ftrace and trace filters
            4. Trace events
          8. Using LTTng
            1. LTTng and the Yocto Project
            2. LTTng and Buildroot
            3. Using LTTng for kernel tracing
          9. Using Valgrind for application profiling
          10. Callgrind
          11. Helgrind
          12. Using strace to show system calls
          13. Summary
        14. 14. Real-time Programming
          1. What is real-time?
          2. Identifying the sources of non-determinism
          3. Understanding scheduling latency
          4. Kernel preemption
          5. The real-time Linux kernel (PREEMPT_RT)
          6. Threaded interrupt handlers
          7. Preemptible kernel locks
          8. Getting the PREEMPT_RT patches
            1. The Yocto Project and PREEMPT_RT
          9. High resolution timers
          10. Avoiding page faults in a real-time application
          11. Interrupt shielding
          12. Measuring scheduling latencies
            1. cyclictest
            2. Using Ftrace
            3. Combining cyclictest and Ftrace
          13. Further reading
          14. Summary
      9. A. Bibliography
      10. Index