Book Image

Embedded Linux Development Using Yocto Project Cookbook - Second Edition

By : Alex Gonzalez
Book Image

Embedded Linux Development Using Yocto Project Cookbook - Second Edition

By: Alex Gonzalez

Overview of this book

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.
Table of Contents (13 chapters)
Title Page
Packt Upsell

Using the Toaster web interface

Toaster is a web application interface to the Yocto Project's build system built on the Django framework with a database backend to store and represent build data. It replaces the Hob user interface, which could be found on releases prior to Yocto 1.8. The welcome page is shown next:

Welcome to Toaster

It allows you to perform the following actions:

  • Configure local or remote builds
  • Manage layers
  • Set configuration variables
  • Set build targets
  • Start builds either from the command line (analysis mode) or the web UI (managed mode)
  • Collect and represent build data
  • Browse final images
  • List installed packages
  • See build variable values
  • Explore recipes, packages, and task dependencies
  • Examine build warnings, errors, and trace messages
  • Provide build performance statistics
  • Examine build tasks and use of shared state cache

Getting ready

In order to run the Toaster Django web application, your host machine needs to be set up as follows:

$ sudo apt-get install python3-pip
$ pip3 install --user -r /opt/yocto/poky/bitbake/toaster-requirements.txt

How to do it...

Toaster can be started with the following commands:

$ cd /opt/yocto/poky$ source oe-init-build-env$ source toaster start

/opt/yocto/poky/bitbake/bin/toaster is a shell script that will set up Toaster's environment, load the default configuration and database migrations, connect to the OpenEmbedded Layer Index, and download information about the metadata layers it has available for the current release, as well as starting the web server and the runbuilds poller process.

To access the web user interface, go to

By default, Toaster binds to localhost on port 8000, but this can be specified as follows:

$ source toaster start webport=<IP>:<PORT>

Administrator interface

The administrator interface can be accessed at

This administration interface can be used to configure Toaster itself, but it needs a superuser account to be created from the directory that contains the Toaster database:

$ cd /opt/yocto/poky/build$ ../bitbake/lib/toaster/ createsuperuser

Starting a build

Toaster can run two different types of builds:

  1. You can manually start a build on the terminal and Toaster will monitor it. You can then use the Toaster web UI to explore the build results. The following image shows the command line builds page:

Toaster command line builds

  1. You can also use the Toaster web interface to create a new project. This will be named build-toaster-<project_id> and will be created inside the Poky directory:

Toaster's create a new project wizard

You can use the TOASTER_DIR configuration variable to specify a different build directory for Toaster.

When creating a Toaster project, you can choose between two different types:

  • Local builds: This uses the local Poky clone on your computer. Using this build type limits the build to the layers available on the Yocto Project, openembedded-core, meta-poky, and meta-yocto-bsp. Other layers would need to be manually imported using the Import Layer page.
  • Yocto Project builds: When a Yocto Project release is chosen, Toaster fetches the source from the Yocto Project upstream Git repositories, and updates it every time you run a build. In this mode, compatible layers can be selected, including BSP layers that allow you to build for different machines. The Toaster project configuration page looks like the following:

Toaster's project configuration page

Customizing images with Toaster

After an image is built, Toaster offers the possibility to create a custom image based on that image's recipe where packages can easily be added/removed.

Building SDKs with Toaster

You can instruct Toaster to build both the standard and the extensible SDK by specifying the populate_sdk and populate_sdk_ext tasks to the target image. For example, to create SDKs for the core-image-base target image, you would use the following.

For the standard SDK:


Or for the extensible SDK:


We will learn more about using SDKs on Chapter 4, Application Development.

How it works...

The version of Django that Toaster uses is specified on the /opt/yocto/poky/bitbake/toaster-requirements.txt file, for example:


Django and hence Toaster store data in a relational database. The backend configuration is done in the /opt/yocto/poky/bitbake/lib/toaster/toastermain/ file as follows:

DATABASES = {                                                                       
    'default': {                                                                    
        # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.                
        'ENGINE': 'django.db.backends.sqlite3',                                     
        # DB name or full path to database file if using sqlite3.                   
        'NAME': "%s/toaster.sqlite" % TOASTER_SQLITE_DEFAULT_DIR,                   
        'USER': '',                                                                 
        'PASSWORD': '',                                                             
        #'HOST': '', # e.g. mysql server                                   
        #'PORT': '3306', # e.g. mysql port                                          

By default, Toaster will create a toaster.sqlite database on the configured TOASTER_DIR path. For production servers, MySQL is the recommended backend.

Django has a built in object-relational mapper, Django ORM, which automates the transfer of data from the relational database to Python objects and allows database accesses in Python code. The initial state of the database is created from a set of fixtures (data dumps) under /opt/yocto/poky/bitbake/lib/toaster/orm/fixtures. Toaster fixtures are in XML format:

  • settings.xml: This contains Toaster and BitBake variable settings. Some of these can be changed through the Toaster administrative interface.
  • poky.xml and oe-core.xml: These are defaults for both the Poky and OE-core builds.
  • custom.xml: This allows you to override data on any of the preceding fixtures with a custom configuration. XML, JSON, and YAML formats are all supported.

When Toaster is launched, these Django fixtures are used to populate its database with initial data.

Toaster has extended the Django command with some custom Toaster-specific options. The management script needs to be invoked from the build directory, which contains the Toaster database:

$ cd /opt/yocto/poky/build$ /opt/yocto/poky/bitbake/lib/toaster/ <command> [<command option>]

The commands can be the following:

From /opt/yocto/poky/bitbake/lib/toaster/toastermain/managements/commands/:

  • buildlist: This returns the current build list including their build IDs
  • buildelete <build_id>: This deletes all build dates for the build specified by its build ID
  • checksocket: This verifies that Toaster can bind to the provided IP address and port
  • perf: This is a sanity check that measures performance by returning page loading times

From /opt/yocto/poky/bitbake/lib/toaster/orm/managements/commands/:

  • lsupdates: This updates the local layer index cache

From /opt/yocto/poky/bitbake/lib/toaster/bldcontrol/managements/commands/:

  • checksettings: This verifies that the existing Toaster database settings are enough to start a build
  • runbuilds: This launches scheduled builds

There's more...

Toaster enables you to set up a build server on a shared hosted/cloud environment that allows you to:

  • Use it with multiple users
  • Distribute it across several build hosts
  • Handle heavy loads

Typically, when setting up Toaster on a shared hosted environment, the Apache web server and MySQL as a database backend are used.

Installation instructions for this type of production server can be found in the Yocto Project's Toaster User Manual. The installation can be spread across different hosts for load sharing.