Mastering Embedded Linux Programming
eBook - ePub

Mastering Embedded Linux Programming

Chris Simmonds

Share book
  1. 418 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Mastering Embedded Linux Programming

Chris Simmonds

Book details
Book preview
Table of contents
Citations

About This Book

Harness the power of Linux to create versatile and robust embedded solutions

About This Book

  • Create efficient and secure embedded devices using Linux
  • Minimize project costs by using open source tools and programs
  • Explore each component technology in depth, using sample implementations as a guide

Who This Book Is For

This book is ideal for Linux developers and system programmers who are already familiar with embedded systems and who want to know how to create best-in-class devices. A basic understanding of C programming and experience with systems programming is needed.

What You Will Learn

  • Understand the role of the Linux kernel and select an appropriate role for your application
  • Use Buildroot and Yocto to create embedded Linux systems quickly and efficiently
  • Create customized bootloaders using U-Boot
  • Employ perf and ftrace to identify performance bottlenecks
  • Understand device trees and make changes to accommodate new hardware on your device
  • Write applications that interact with Linux device drivers
  • Design and write multi-threaded applications using POSIX threads
  • Measure real-time latencies and tune the Linux kernel to minimize them

In Detail

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 begin by learning about toolchains, bootloaders, the Linux kernel, and how to configure a root filesystem to create a basic working device. You will then learn how to use the two most commonly used build systems, Buildroot and Yocto, to speed up and simplify the development process. Building on this solid base, the next section considers how to make best use of raw NAND/NOR flash memory and managed flash eMMC chips, including mechanisms for increasing the lifetime of the devices and to perform reliable in-field updates. Next, you need to consider what techniques are best suited to writing applications for your device. We will then see how functions are split between processes and the usage of POSIX threads, which have a big impact on the responsiveness and performance of the final device The closing sections look at the techniques available to developers for profiling and tracing applications and kernel code using perf and ftrace.

Style and approach

This book is an easy-to-follow and pragmatic guide consisting of an in-depth analysis of the implementation of embedded devices. Each topic has a logical approach to it; this coupled with hints and best practices helps you understand embedded Linux better.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Mastering Embedded Linux Programming an online PDF/ePUB?
Yes, you can access Mastering Embedded Linux Programming by Chris Simmonds in PDF and/or ePUB format, as well as other popular books in Computer Science & Operating Systems. We have over one million books available in our catalogue for you to explore.

Information

Year
2015
ISBN
9781784392536
Edition
1

Mastering Embedded Linux Programming


Table of Contents

Mastering Embedded Linux Programming
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Errata
Piracy
Questions
1. Starting Out
Selecting the right operating system
The players
Project lifecycle
The four elements of embedded Linux
Open source
Licenses
Hardware for embedded Linux
Hardware used in this book
The BeagleBone Black
QEMU
Software used in this book
Summary
2. Learning About Toolchains
What is a toolchain?
Types of toolchain - native versus cross toolchain
CPU architectures
Choosing the C library
Finding a toolchain
Building a toolchain using crosstool-NG
Installing crosstool-NG
Selecting the toolchain
Anatomy of a toolchain
Finding out about your cross compiler
The sysroot, library, and header files
Other tools in the toolchain
Looking at the components of the C library
Linking with libraries: static and dynamic linking
Static libraries
Shared libraries
Understanding shared library version numbers
The art of cross compiling
Simple makefiles
Autotools
An example: SQLite
Package configuration
Problems with cross compiling
Summary
3. All About Bootloaders
What does a bootloader do?
The boot sequence
Phase 1: ROM code
Phase 2: SPL
Phase 3: TPL
Booting with UEFI firmware
Moving from bootloader to kernel
Introducing device trees
Device tree basics
The reg property
Phandles and interrupts
Device tree include files
Compiling a device tree
Choosing a bootloader
U-Boot
Building U-Boot
Installing U-Boot
Using U-Boot
Environment variables
Boot image format
Loading images
Booting Linux
Automating the boot with U-Boot scripts
Porting U-Boot to a new board
Kconfig and U-Boot
Board-specific files
Configuration header files
Building and testing
Falcon mode
Barebox
Getting Barebox
Building Barebox
Summary
4. Porting and Configuring the Kernel
What does the kernel do?
Choosing a kernel
Kernel development cycle
Stable and long term support releases
Vendor support
Licensing
Building the kernel
Getting the source
Understanding kernel configuration
Using LOCALVERSION to identify your kernel
Kernel modules
Compiling
Compiling the kernel image
Compiling device trees
Compiling modules
Cleaning kernel sources
Booting your kernel
BeagleBone Black
QEMU
Kernel panic
Early user space
Kernel messages
Kernel command line
Porting Linux to a new board
With a device tree
Without a device tree
Additional reading
Summary
5. Building a Root Filesystem
What should be in the root filesystem?
Directory layout
Staging directory
POSIX file access permissions
File ownership permissions in the staging directory
Programs for the root filesystem
The init program
Shell
Utilities
BusyBox to the rescue!
Building BusyBox
ToyBox – an alternative to BusyBox
Libraries for the root filesystem
Reducing size by stripping
Device nodes
The proc and sysfs filesystems
Mounting filesystems
Kernel modules
Transfering the root filesystem to the target
Creating a boot ramdisk
Standalone ramdisk
Booting the ramdisk
Booting with QEMU
Booting the BeagleBone Black
Mounting proc
Building a ramdisk cpio into the kernel image
Another way to build a kernel with ramdisk
The old initrd format
The init program
Configuring user accounts
Adding user accounts to the root filesystem
Starting a daemon process
A better way of managing device nodes
An example using devtmpfs
An example using mdev
Are static device nodes so bad after all?
Configuring the network
Network components for glibc
Creating filesystem images with device tables
Putting the root filesytem onto an SD card
Mounting the root filesystem using NFS
Testing with QEMU
Testing with BeagleBone Black
Problems with file permissions
Using TFTP to load the kernel
Additional reading
Summary
6. Selecting a Build System
No more rolling your own embedded Linux
Build systems
Package formats and package managers
Buildroot
Background
Stable releases and support
Installing
Configuring
Running
Creating a custom BSP
U-Boot
Linux
Build
Adding your own code
Overlay
Adding a package
License compliance
The Yocto Project
Background
Stable releases and support
Installing the Yocto Project
Configuring
Building
Running
Layers
BitBake and recipes
Customizing images via local.conf
Writing an image recipe
Creating an SDK
License audit
Further reading
Summary
7. Creating a Storage Strategy
Storage options
NOR flash
NAND flash
Managed flash
MultiMediaCard and secure digital cards
eMMC
Other types of managed flash
Accessing flash memory from the bootloader
U-Boot and NOR flash
U-Boot and NAND flash
U-Boot and MMC, SD and eMMC
Accessing flash memory from Linux
Memory technology devices
MTD partitions
MTD device drivers
The MTD character device, mtd
The MTD block device, mtdblock
Logging kernel oops to MTD
Simulating NAND memory
The MMC block driver
Filesystems for flash memory
Flash translation layers
Filesystems for NOR and NAND flash memory
JFFS2
Summary nodes
Clean markers
Creating a JFFS2 filesystem
YAFFS2
Creating a YAFFS2 filesystem
UBI and UBIFS
UBI
UBIFS
Filesystems for managed flash
Flashbench
Discard and TRIM
Ext4
F2FS
FAT16/32
Read-only compressed filesystems
squashfs
Temporary filesystems
Making the root filesystem read-only
Filesystem choices
Updating in the field
Granularity: file, package, or image?
Atomic image update
Further reading
Summary
8. Introducing Device Drivers
The role of device drivers
Character devices
Block devices
Network devices
Finding out about drivers at runtime
Getting information from sysfs
The devices: /sys/devices
The drivers: /sys/class
The block drivers: /sys/block
Finding the right device driver
Device drivers in user-space
GPIO
Handling interrupts from...

Table of contents