Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Embedded Linux Development Using Yocto Project Cookbook

You're reading from   Embedded Linux Development Using Yocto Project Cookbook Practical recipes to help you leverage the power of Yocto to build exciting Linux-based systems

Arrow left icon
Product type Paperback
Published in Jan 2018
Publisher
ISBN-13 9781788399210
Length 456 pages
Edition 2nd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Alex Gonzalez Alex Gonzalez
Author Profile Icon Alex Gonzalez
Alex Gonzalez
Arrow right icon
View More author details
Toc

Table of Contents (7) Chapters Close

Preface 1. The Build System FREE CHAPTER 2. The BSP Layer 3. The Software Layer 4. Application Development 5. Debugging, Tracing, and Profiling 6. Other Books You May Enjoy

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 http://127.0.0.1:8000.

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 http://127.0.0.1:8000/admin.

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/manage.py 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:

core-image-base:populate_sdk 

Or for the extensible SDK:

core-image-base:populate_sdk_ext 

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>1.8,<1.9.9 

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

TOASTER_SQLITE_DEFAULT_DIR = os.environ.get('TOASTER_DIR') 
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': '127.0.0.1', # 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 manage.py command with some custom Toaster-specific options. The manage.py 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/manage.py <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.

You have been reading a chapter from
Embedded Linux Development Using Yocto Project Cookbook - Second Edition
Published in: Jan 2018
Publisher:
ISBN-13: 9781788399210
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at R$50/month. Cancel anytime