Mastering Embedded Linux Programming - Second Edition

Master the techniques needed to build great, efficient embedded devices on Linux

Mastering Embedded Linux Programming - Second Edition

Chris Simmonds

3 customer reviews
Master the techniques needed to build great, efficient embedded devices on Linux
Mapt Subscription
FREE
$29.99/m after trial
eBook
$28.00
RRP $39.99
Save 29%
Print + eBook
$49.99
RRP $49.99
What do I get with a Mapt Pro subscription?
  • Unlimited access to all Packt’s 5,000+ eBooks and Videos
  • Early Access content, Progress Tracking, and Assessments
  • 1 Free eBook or Video to download and keep every month after trial
What do I get with an eBook?
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with Print & eBook?
  • Get a paperback copy of the book delivered to you
  • Download this book in EPUB, PDF, MOBI formats
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
What do I get with a Video?
  • Download this Video course in MP4 format
  • DRM FREE - read and interact with your content when you want, where you want, and how you want
  • Access this title in the Mapt reader
$0.00
$28.00
$49.99
$29.99p/m after trial
RRP $39.99
RRP $49.99
Subscription
eBook
Print + eBook
Start 30 Day Trial
Subscribe and access every Packt eBook & Video.
 
  • 5,000+ eBooks & Videos
  • 50+ New titles a month
  • 1 Free eBook/Video to keep every month
Start Free Trial
 
Preview in Mapt

Book Details

ISBN 139781787283282
Paperback478 pages

Book Description

Embedded Linux runs many of the devices we use every day, from smart TVs to WiFi routers, test equipment to industrial controllers - all of them have Linux at their heart. Linux is a core technology in the implementation of the inter-connected world of the Internet of Things.

The comprehensive guide shows you the technologies and techniques required to build Linux into embedded systems. You will begin by learning about the fundamental elements that underpin all embedded Linux projects: the toolchain, the bootloader, the kernel, and the root filesystem. You’ll see how to create each of these elements from scratch, and how to automate the process using Buildroot and the Yocto Project.

Moving on, you’ll find out how to implement an effective storage strategy for flash memory chips, and how to install updates to the device remotely once it is deployed. You’ll also get to know the key aspects of writing code for embedded Linux, such as how to access hardware from applications, the implications of writing multi-threaded code, and techniques to manage memory in an efficient way. The final chapters show you how to debug your code, both in applications and in the Linux kernel, and how to profile the system so that you can look out for performance bottlenecks.

By the end of the book, you will have a complete overview of the steps required to create a successful embedded Linux system.

Table of Contents

Chapter 1: Starting Out
Selecting the right operating system
The players
Project life cycle
Open source
Hardware for embedded Linux
Hardware used in this book
Software used in this book
Summary
Chapter 2: Learning About Toolchains
Introducing toolchains
Finding a toolchain
Building a toolchain using crosstool-NG
Anatomy of a toolchain
Linking with libraries – static and dynamic linking
The art of cross compiling
Summary
Chapter 3: All About Bootloaders
What does a bootloader do?
The boot sequence
Booting with UEFI firmware
Moving from bootloader to kernel
Introducing device trees
Choosing a bootloader
U-Boot
Barebox
Summary
Chapter 4: Configuring and Building the Kernel
What does the kernel do?
Choosing a kernel
Building the kernel
Compiling – Kbuild
Booting the kernel
Porting Linux to a new board
Additional reading
Summary
Chapter 5: Building a Root Filesystem
What should be in the root filesystem?
Transferring the root filesystem to the target
Creating a boot initramfs
The init program
Configuring user accounts
A better way of managing device nodes
Configuring the network
Creating filesystem images with device tables
Mounting the root filesystem using NFS
Using TFTP to load the kernel
Additional reading
Summary
Chapter 6: Selecting a Build System
Build systems
Package formats and package managers
Buildroot
The Yocto Project
Further reading
Summary
Chapter 7: Creating a Storage Strategy
Storage options
Accessing flash memory from the bootloader
Accessing flash memory from Linux
Filesystems for flash memory
Filesystems for NOR and NAND flash memory
Filesystems for managed flash
Read-only compressed filesystems
Temporary filesystems
Making the root filesystem read-only
Filesystem choices
Further reading
Summary
Chapter 8: Updating Software in the Field
What to update?
The basics of software update
Types of update mechanism
OTA updates
Using Mender for local updates
Using Mender for OTA updates
Summary
Chapter 9: Interfacing with Device Drivers
The role of device drivers
Character devices
Block devices
Network devices
Finding out about drivers at runtime
Finding the right device driver
Device drivers in user space
Writing a kernel device driver
Discovering the hardware configuration
Additional reading
Summary
Chapter 10: Starting Up – The init Program
After the kernel has booted
Introducing the init programs
BusyBox init
System V init
systemd
Further reading
Summary
Chapter 11: Managing Power
Measuring power usage
Scaling the clock frequency
Selecting the best idle state
Powering down peripherals
Putting the system to sleep
Further reading
Summary
Chapter 12: Learning About Processes and Threads
Process or thread?
Processes
Threads
Scheduling
Further reading
Summary
Chapter 13: Managing Memory
Virtual memory basics
Kernel space memory layout
User space memory layout
The process memory map
Swapping
Mapping memory with mmap
How much memory does my application use?
Per-process memory usage
Identifying memory leaks
Running out of memory
Further reading
Summary
Chapter 14: Debugging with GDB
The GNU debugger
Preparing to debug
Debugging applications
Just-in-time debugging
Debugging forks and threads
Core files
GDB user interfaces
Debugging kernel code
Further reading
Summary
Chapter 15: Profiling and Tracing
The observer effect
Beginning to profile
Profiling with top
Poor man's profiler
Introducing perf
Other profilers – OProfile and gprof
Tracing events
Introducing Ftrace
Using LTTng
Using Valgrind
Using strace
Summary
Chapter 16: Real-Time Programming
What is real time?
Identifying sources of non-determinism
Understanding scheduling latency
Kernel preemption
The real-time Linux kernel (PREEMPT_RT)
Preemptible kernel locks
High-resolution timers
Avoiding page faults
Interrupt shielding
Measuring scheduling latencies
Further reading
Summary

What You Will Learn

  • Evaluate the Board Support Packages offered by most manufacturers of a system on chip or embedded module
  • Use Buildroot and the Yocto Project to create embedded Linux systems quickly and efficiently
  • Update IoT devices in the field without compromising security
  • Reduce the power budget of devices to make batteries last longer
  • Interact with the hardware without having to write kernel device drivers
  • Debug devices remotely using GDB, and see how to measure the performance of the systems using powerful tools such as perk, ftrace, and valgrind
  • Find out how to configure Linux as a real-time operating system

Authors

Table of Contents

Chapter 1: Starting Out
Selecting the right operating system
The players
Project life cycle
Open source
Hardware for embedded Linux
Hardware used in this book
Software used in this book
Summary
Chapter 2: Learning About Toolchains
Introducing toolchains
Finding a toolchain
Building a toolchain using crosstool-NG
Anatomy of a toolchain
Linking with libraries – static and dynamic linking
The art of cross compiling
Summary
Chapter 3: All About Bootloaders
What does a bootloader do?
The boot sequence
Booting with UEFI firmware
Moving from bootloader to kernel
Introducing device trees
Choosing a bootloader
U-Boot
Barebox
Summary
Chapter 4: Configuring and Building the Kernel
What does the kernel do?
Choosing a kernel
Building the kernel
Compiling – Kbuild
Booting the kernel
Porting Linux to a new board
Additional reading
Summary
Chapter 5: Building a Root Filesystem
What should be in the root filesystem?
Transferring the root filesystem to the target
Creating a boot initramfs
The init program
Configuring user accounts
A better way of managing device nodes
Configuring the network
Creating filesystem images with device tables
Mounting the root filesystem using NFS
Using TFTP to load the kernel
Additional reading
Summary
Chapter 6: Selecting a Build System
Build systems
Package formats and package managers
Buildroot
The Yocto Project
Further reading
Summary
Chapter 7: Creating a Storage Strategy
Storage options
Accessing flash memory from the bootloader
Accessing flash memory from Linux
Filesystems for flash memory
Filesystems for NOR and NAND flash memory
Filesystems for managed flash
Read-only compressed filesystems
Temporary filesystems
Making the root filesystem read-only
Filesystem choices
Further reading
Summary
Chapter 8: Updating Software in the Field
What to update?
The basics of software update
Types of update mechanism
OTA updates
Using Mender for local updates
Using Mender for OTA updates
Summary
Chapter 9: Interfacing with Device Drivers
The role of device drivers
Character devices
Block devices
Network devices
Finding out about drivers at runtime
Finding the right device driver
Device drivers in user space
Writing a kernel device driver
Discovering the hardware configuration
Additional reading
Summary
Chapter 10: Starting Up – The init Program
After the kernel has booted
Introducing the init programs
BusyBox init
System V init
systemd
Further reading
Summary
Chapter 11: Managing Power
Measuring power usage
Scaling the clock frequency
Selecting the best idle state
Powering down peripherals
Putting the system to sleep
Further reading
Summary
Chapter 12: Learning About Processes and Threads
Process or thread?
Processes
Threads
Scheduling
Further reading
Summary
Chapter 13: Managing Memory
Virtual memory basics
Kernel space memory layout
User space memory layout
The process memory map
Swapping
Mapping memory with mmap
How much memory does my application use?
Per-process memory usage
Identifying memory leaks
Running out of memory
Further reading
Summary
Chapter 14: Debugging with GDB
The GNU debugger
Preparing to debug
Debugging applications
Just-in-time debugging
Debugging forks and threads
Core files
GDB user interfaces
Debugging kernel code
Further reading
Summary
Chapter 15: Profiling and Tracing
The observer effect
Beginning to profile
Profiling with top
Poor man's profiler
Introducing perf
Other profilers – OProfile and gprof
Tracing events
Introducing Ftrace
Using LTTng
Using Valgrind
Using strace
Summary
Chapter 16: Real-Time Programming
What is real time?
Identifying sources of non-determinism
Understanding scheduling latency
Kernel preemption
The real-time Linux kernel (PREEMPT_RT)
Preemptible kernel locks
High-resolution timers
Avoiding page faults
Interrupt shielding
Measuring scheduling latencies
Further reading
Summary

Book Details

ISBN 139781787283282
Paperback478 pages
Read More
From 3 reviews

Read More Reviews

Recommended for You

Embedded Linux Development using Yocto Project Cookbook - Second Edition Book Cover
Embedded Linux Development using Yocto Project Cookbook - Second Edition
$ 35.99
$ 25.20
Mastering Kali Linux for Advanced Penetration Testing - Second Edition Book Cover
Mastering Kali Linux for Advanced Penetration Testing - Second Edition
$ 39.99
$ 28.00
Mastering ROS for Robotics Programming - Second Edition Book Cover
Mastering ROS for Robotics Programming - Second Edition
$ 39.99
$ 28.00
Mastering iOS 11 Programming - Second Edition Book Cover
Mastering iOS 11 Programming - Second Edition
$ 39.99
$ 28.00
Mastering Concurrency Programming with Java 9 - Second Edition Book Cover
Mastering Concurrency Programming with Java 9 - Second Edition
$ 39.99
$ 28.00
Kali Linux Cookbook - Second Edition Book Cover
Kali Linux Cookbook - Second Edition
$ 35.99
$ 25.20