Preparing the Yocto Project environment based on Mender demo environment

Introduction

This tutorial will cover how to re-use existing Yocto Project environments that are available on Mender Hub which enables you to target a large variety of devices.

This is a high-level tutorial and the intention is not to cover the Yocto Project in detail. For detailed information we recommend that you read the Yocto Project Mega-Manual

Prerequisites

To follow this tutorial, you will need:

  • One of the supported devices listed in Board integrations - Yocto Project You will only need the device to test the final result and you can complete the majority of the tutorial without an device.
  • Enough Free Memory: Your development host should have at least 50 GBytes of free disk space for building images.
  • A Supported Linux Distribution: You should have a reasonably current Linux-based host system. You will have the best results with a recent release of Fedora, openSUSE, Debian, Ubuntu, or CentOS as these releases are frequently tested against the Yocto Project® and officially supported
  • Required Packages for the Build Host:

To install the required packages on a Debian based distribution (Ubuntu etc) run:

sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib \
     build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
     xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \
     xterm

Instructions for other Linux distributions (Fedora, CentOS, etc) you can find here.

Setup environment based on Mender demo

On Mender Hub we have a Board Integration - Yocto section which contains tutorials on how to setup Yocto Project environments for various boards and all the listed boards will have Mender integrated, meaning you are ready to perform robust OTA updates from day one.

The Mender demo environment contains a higher level of abstraction then you would typically get from using the Yocto Project, but in the end it is the same steps performed as explained in Preparing the Yocto Project environment from scratch with the addition of a Mender integration which enables OTA updates on your device from the start.

These are the steps that you would need to perform to setup an environment for Raspberry Pi 3.

NOTE. This is also described in Raspberry Pi 3 Model B/B+ - #22, and you should follow the tutorial in that post to actually setup the environment for a Raspberry Pi 3. Below is just an extract to explain the different steps in detail.

Set the Yocto Project branch you are building for:

# set to your branch, make sure it is supported (see table above)
export BRANCH="warrior"

Create a directory for your mender-raspberrypi setup to live in and clone the
meta information.

mkdir mender-raspberrypi && cd mender-raspberrypi

To simply management of cloning multiple Yocto Project layers, in the Mender demo environment we utilize repo - The Multiple Git Repository Tool that is designed for this specific case. This tool was initially developed by Google and is used e.g in management of Android source code. For further information you can vist the Repo Command Reference. We only use the init and sync commands to fetch sources.

Initialize repo manifest:

repo init -u https://github.com/mendersoftware/meta-mender-community \
           -m meta-mender-raspberrypi/scripts/manifest-raspberrypi.xml \
           -b ${BRANCH}

Fetch layers in manifest:

repo sync

Initialize the build environment:

source setup-environment raspberrypi

Please note that the setup-environment script is something that is provided in the Mender demo environment and works as a wrapper around oe-init-build-env which is provided by Poky. To understand what this script actually does you can inspect the source in meta-mender-community/scipts

That is it, the environment is ready to build images for Raspberry Pi 3. How to actually build images is covered in the Working with images using Yocto Project tutorial.

Conclusion

In this tutorial we covered the basics on how to setup Yocto Project environment from scratch, targeting Raspberry Pi 3 while also covering some basic terms such as “layers”. Hopefully this will be helpful in getting you started quickly without the need of digging to deep in to the Yocto Project internals.

If you look trough the available boards in Board Integration - Yocto section you will see that the instructions to setup the Yocto Project environment is very similar across different boards with only minor changes to the outlined steps described above. This makes it easy to reuse on different boards or projects.

For further reading I would recommend the following links:


If this tutorial was useful to you, please press like, or leave a thank you note to the contributor who put valuable time into this and made it available to you. It will be much appreciated!

1 Like