Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Embedded Linux Development Using Yocto Project Cookbook
Embedded Linux Development Using Yocto Project Cookbook

Embedded Linux Development Using Yocto Project Cookbook: Practical recipes to help you leverage the power of Yocto to build exciting Linux-based systems , Second Edition

eBook
€8.99 €29.99
Paperback
€36.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Embedded Linux Development Using Yocto Project Cookbook

The BSP Layer

In this chapter, we will cover the following recipes:

  • Creating a custom BSP layer
  • Adding a custom kernel and bootloader
  • Building the U-Boot bootloader
  • Describing Linux's build system
  • Configuring the Linux kernel
  • Building the Linux kernel
  • Building external kernel modules
  • Debugging the Linux kernel and modules
  • Debugging the Linux kernel booting process
  • Using the kernel tracing system
  • Managing the device tree
  • Debugging device tree issues

Introduction

In the previous chapter, we became comfortable with the build system and the reference hardware we are using. We built images, ran them, and learned how to customize and optimize our build system.

Now we have our build environment ready with the Yocto Project, it's time to think about beginning development work on our embedded Linux project.

Most embedded Linux projects require both custom hardware and software. An early task in the development process is to test different hardware reference boards and select one to base our design on. As we saw in the Building Wandboard images recipe in Chapter 1, The Build System, for this book we have chosen the Wandboard, an NXP i.MX6-based platform, as it is an affordable and open board, which makes it perfect for our needs.

The Wandboard uses a SoM that is then mounted into a carrier board and sold as a single-board...

Creating a custom BSP layer

The changes needed to support a new hardware platform, or machine, are kept on a separate Yocto layer, called a BSP layer. This separation is best for future updates and patches to the system. A BSP layer can support any number of new machines and any new software feature that is linked to the hardware itself.

How to do it...

By convention, Yocto layer names start with meta, short for metadata. A BSP layer may then add a bsp keyword, and finally a unique name. We will call our layer meta-bsp-custom.

There are several ways to create a new layer:

  • Manually, once you know what is required
  • By copying the meta-skeleton layer included in Poky
  • By using the yocto-layer command-line tool

You can have a...

Adding a custom kernel and bootloader

The BSP that encapsulates the hardware modifications for a given platform is mostly located in the bootloader, usually U-Boot (Das U-Boot) for ARM devices, and the Linux kernel. Both U-Boot and the Linux kernel have upstream development trees, at git.denx.de and kernel.org respectively, but it is very common for manufacturers of embedded hardware to provide their own trees for both bootloader and kernel.

Development in U-Boot and the Linux kernel is usually done externally to Yocto, as they are easy and quicker to build using a cross-compilation toolchain, like the one provided by Yocto's SDK.

The development work is then integrated into Yocto in one of two ways:

  • With patches added to the kernel and U-Boot bbappend files. This method will build the same source as the reference design board we are using as a base, and apply our changes...

Building the U-Boot bootloader

We have seen how to modify the Yocto build system to both modify a U-Boot or Linux kernel recipe by adding patches or by building from a modified Git repository. Now we will see how to modify and build the U-Boot source in order to introduce our changes.

Even though the Yocto Project is very flexible, it is best not to use the Yocto Project build system while developing the BSP. The U-Boot and Linux kernel binaries are separate artifacts and can be programmed individually, so it is faster and less error-prone to just build them using the standalone Yocto SDK and not the Yocto build system. This also abstracts BSP developers from the complexities of the Yocto build system.

This may not apply to the Linux-Yocto kernel types, as in that case the Yocto Project provides specific tools to aid development.
...

Describing Linux's build system

The Linux kernel is a monolithic kernel and, as such, shares the same address space. Although it has the ability to load modules at runtime, the kernel must contain all the symbols the module uses at compilation time. Once the module is loaded, it will share the kernel's address space too.

The kernel build system (kbuild), uses conditional compilation to decide which parts of the kernel are compiled. kbuild is independent of the Yocto build system.

In this recipe, we will explain how kbuild works.

How to do it...

The kernel kbuild system reads its configuration at build time from a .config text file in the kernel root directory. This is referred to as the kernel configuration file...

Configuring the Linux kernel

The Linux kernel contains a set of default machine configurations. For ARM, these are under the arch/arm/configs directory on the Linux source. The Yocto Project, however, uses a copy of this configuration file inside the BSP layer metadata. This enables the use of different configuration files for different purposes.

In this recipe, we will see how to configure the Linux kernel and add the resulting configuration file to our BSP layer.

Getting ready

Before configuring the kernel, we need to provide a default configuration for our machine, which is the one the Yocto project uses to configure a kernel. When defining a new machine in your BSP layer, you need to provide a defconfig file.

The Wandboard...

Building the Linux kernel

As was the case with U-Boot, Linux kernel development is quicker and less error-prone when using the Yocto SDK to build it. However, for smaller changes, the Yocto build system can also be used.

In this recipe, we will show you how to build and modify the Linux kernel source both with Yocto's SDK and the Yocto build system, and boot our target device with it.

How to do it...

We will use the Yocto Project's SDK already installed in your host:

  1. Prepare the environment as follows:
$ source /opt/poky/2.4/environment-setup-cortexa9hf-neon-poky-linux-gnueabi  
  1. Configure the kernel with the default machine configuration:
$ cd /opt/yocto/linux-wandboard
$ cp /opt/yocto/fsl-community-bsp/sources...

Introduction


In the previous chapter, we became comfortable with the build system and the reference hardware we are using. We built images, ran them, and learned how to customize and optimize our build system.

Now we have our build environment ready with the Yocto Project, it's time to think about beginning development work on our embedded Linux project.

Most embedded Linux projects require both custom hardware and software. An early task in the development process is to test different hardware reference boards and select one to base our design on. As we saw in the Building Wandboard images recipe in Chapter 1, The Build System, for this book we have chosen the Wandboard, an NXP i.MX6-based platform, as it is an affordable and open board, which makes it perfect for our needs.

The Wandboard uses a SoM that is then mounted into a carrier board and sold as a single-board computer. As the schematics are open, the SoM could be used with a different carrier board design for a much more specific product...

Creating a custom BSP layer


The changes needed to support a new hardware platform, or machine, are kept on a separate Yocto layer, called a BSP layer. This separation is best for future updates and patches to the system. A BSP layer can support any number of new machines and any new software feature that is linked to the hardware itself.

How to do it...

By convention, Yocto layer names start with meta, short for metadata. A BSP layer may then add a bsp keyword, and finally a unique name. We will call our layer meta-bsp-custom.

There are several ways to create a new layer:

  • Manually, once you know what is required
  • By copying the meta-skeleton layer included in Poky
  • By using the yocto-layer command-line tool

You can have a look at the meta-skeleton layer in Poky and see that it includes the following elements:

  • A layer.conf file, where the layer configuration variables are set
  • A COPYING.MIT license file
  • Several directories named with the recipes- prefix with example recipes for BusyBox, the Linux kernel...

Adding a custom kernel and bootloader


The BSP that encapsulates the hardware modifications for a given platform is mostly located in the bootloader, usually U-Boot (Das U-Boot) for ARM devices, and the Linux kernel. Both U-Boot and the Linux kernel have upstream development trees, at git.denx.de and http://kernel.org/ respectively, but it is very common for manufacturers of embedded hardware to provide their own trees for both bootloader and kernel.

Development in U-Boot and the Linux kernel is usually done externally to Yocto, as they are easy and quicker to build using a cross-compilation toolchain, like the one provided by Yocto's SDK.

The development work is then integrated into Yocto in one of two ways:

  • With patches added to the kernel and U-Boot bbappend files. This method will build the same source as the reference design board we are using as a base, and apply our changes over it. This is what we have seen in the previous recipe.
  • Using a different Git repository, forked from the Linux...

Building the U-Boot bootloader


We have seen how to modify the Yocto build system to both modify a U-Boot or Linux kernel recipe by adding patches or by building from a modified Git repository. Now we will see how to modify and build the U-Boot source in order to introduce our changes.

Even though the Yocto Project is very flexible, it is best not to use the Yocto Project build system while developing the BSP. The U-Boot and Linux kernel binaries are separate artifacts and can be programmed individually, so it is faster and less error-prone to just build them using the standalone Yocto SDK and not the Yocto build system. This also abstracts BSP developers from the complexities of the Yocto build system.

Note

This may not apply to the Linux-Yocto kernel types, as in that case the Yocto Project provides specific tools to aid development.

Getting ready

We will use a Yocto toolchain to build the U-Boot source externally from the Yocto build system. The Yocto project has precompiled SDKs for both 32...

Describing Linux's build system


The Linux kernel is a monolithic kernel and, as such, shares the same address space. Although it has the ability to load modules at runtime, the kernel must contain all the symbols the module uses at compilation time. Once the module is loaded, it will share the kernel's address space too.

The kernel build system (kbuild), uses conditional compilation to decide which parts of the kernel are compiled. kbuild is independent of the Yocto build system.

In this recipe, we will explain how kbuild works.

How to do it...

The kernel kbuild system reads its configuration at build time from a .config text file in the kernel root directory. This is referred to as the kernel configuration file. It is a text file where each line contains a single configuration variable that starts with the CONFIG_ prefix.

There are multiple ways to modify a kernel configuration file:

  1. Manually editing the .config file, although this is not recommended.
  2. Using one of the user interfaces the kernel...

Configuring the Linux kernel


The Linux kernel contains a set of default machine configurations. For ARM, these are under the arch/arm/configs directory on the Linux source. The Yocto Project, however, uses a copy of this configuration file inside the BSP layer metadata. This enables the use of different configuration files for different purposes.

In this recipe, we will see how to configure the Linux kernel and add the resulting configuration file to our BSP layer.

Getting ready

Before configuring the kernel, we need to provide a default configuration for our machine, which is the one the Yocto project uses to configure a kernel. When defining a new machine in your BSP layer, you need to provide a defconfig file.

The Wandboard's defconfig file is stored under sources/meta-freescale-3rdparty/recipes-kernel/linux/linux-wandboard/defconfig.

This will be the base defconfig file for our custom hardware, so we copy it to our BSP layer:

$ cd /opt/yocto/fsl-community-bsp/sources$ mkdir -p meta-bsp-custom...
Left arrow icon Right arrow icon

Key benefits

  • Optimize your Yocto setup to speed up development and debug build issues
  • Use what is quickly becoming the standard embedded Linux product builder framework—the Yocto Project
  • Recipe-based implementation of best practices to optimize your Linux system

Description

The Yocto Project has become the de facto distribution build framework for reliable and robust embedded systems with a reduced time to market.You'll get started by working on a build system where you set up Yocto, create a build directory, and learn how to debug it. Then, you'll explore everything about the BSP layer, from creating a custom layer to debugging device tree issues. In addition to this, you’ll learn how to add a new software layer, packages, data, scripts, and configuration files to your system. You will then cover topics based on application development, such as using the Software Development Kit and how to use the Yocto project in various development environments. Toward the end, you will learn how to debug, trace, and profile a running system. This second edition has been updated to include new content based on the latest Yocto release.

Who is this book for?

If you are an embedded Linux developer with the basic knowledge of Yocto Project, this book is an ideal way to broaden your knowledge with recipes for embedded development.

What you will learn

  • Optimize your Yocto Project setup to speed up development and debug build issues
  • Use Docker containers to build Yocto Project-based systems
  • Take advantage of the user-friendly Toaster web interface to the Yocto Project build system
  • Build and debug the Linux kernel and its device trees
  • Customize your root filesystem with already-supported and new Yocto packages
  • Optimize your production systems by reducing the size of both the Linux kernel and root filesystems
  • Explore the mechanisms to increase the root filesystem security
  • Understand the open source licensing requirements and how to comply with them when cohabiting with proprietary programs
  • Create recipes, and build and run applications in C, C++, Python, Node.js, and Java

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 25, 2018
Length: 456 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788392921
Vendor :
Linux Foundation
Category :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Jan 25, 2018
Length: 456 pages
Edition : 2nd
Language : English
ISBN-13 : 9781788392921
Vendor :
Linux Foundation
Category :

Packt Subscriptions

See our plans and pricing
Modal Close icon
€18.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
€189.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts
€264.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just €5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total 120.97
Mastering Embedded Linux Programming
€41.99
Embedded Linux Development Using Yocto Project Cookbook
€36.99
Embedded Linux Development using Yocto Projects
€41.99
Total 120.97 Stars icon
Banner background image

Table of Contents

6 Chapters
The Build System Chevron down icon Chevron up icon
The BSP Layer Chevron down icon Chevron up icon
The Software Layer Chevron down icon Chevron up icon
Application Development Chevron down icon Chevron up icon
Debugging, Tracing, and Profiling Chevron down icon Chevron up icon
Other Books You May Enjoy Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Half star icon Empty star icon 3.6
(7 Ratings)
5 star 42.9%
4 star 14.3%
3 star 14.3%
2 star 14.3%
1 star 14.3%
Filter icon Filter
Top Reviews

Filter reviews by




Weetit Wanalertlak Jul 06, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Thank you for a good book. Docker method of Yocto compilation works great.
Amazon Verified review Amazon
frv Oct 21, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Explains very well how to work in a YOCTO build environment for setting up a Linux distribution
Amazon Verified review Amazon
Sergio Prado Jun 27, 2018
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This is one of the best Yocto Project's books around. It is very practical, well structured and easy to read, with a lot of examples for embedded development. Beginners and advanced users will benefit from the concepts presented in the book. Highly recommended!
Amazon Verified review Amazon
M. Salamon Jan 02, 2020
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Good explained and practical oriented book. For advanced Yocto users more details and topics will be needed.
Amazon Verified review Amazon
Tony Mar 03, 2018
Full star icon Full star icon Full star icon Empty star icon Empty star icon 3
This book is virtually solid text, pretty much like a spec you might be given at work.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

How do I buy and download an eBook? Chevron down icon Chevron up icon

Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.

If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.

Please Note: Packt eBooks are non-returnable and non-refundable.

Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:

  • You may make copies of your eBook for your own use onto any machine
  • You may not pass copies of the eBook on to anyone else
How can I make a purchase on your website? Chevron down icon Chevron up icon

If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:

  1. Register on our website using your email address and the password.
  2. Search for the title by name or ISBN using the search option.
  3. Select the title you want to purchase.
  4. Choose the format you wish to purchase the title in; if you order the Print Book, you get a free eBook copy of the same title. 
  5. Proceed with the checkout process (payment to be made using Credit Card, Debit Cart, or PayPal)
Where can I access support around an eBook? Chevron down icon Chevron up icon
  • If you experience a problem with using or installing Adobe Reader, the contact Adobe directly.
  • To view the errata for the book, see www.packtpub.com/support and view the pages for the title you have.
  • To view your account details or to download a new copy of the book go to www.packtpub.com/account
  • To contact us directly if a problem is not resolved, use www.packtpub.com/contact-us
What eBook formats do Packt support? Chevron down icon Chevron up icon

Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.

You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.

What are the benefits of eBooks? Chevron down icon Chevron up icon
  • You can get the information you need immediately
  • You can easily take them with you on a laptop
  • You can download them an unlimited number of times
  • You can print them out
  • They are copy-paste enabled
  • They are searchable
  • There is no password protection
  • They are lower price than print
  • They save resources and space
What is an eBook? Chevron down icon Chevron up icon

Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.

When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.

For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.