The Yocto Project allows users to create custom Linux distributions for emedded and IoT software. It is an open source project, calloborated on by the Linux foundation and other big names in the tech industry. Its big advantage is that it can work on a variety of architectures including some that are not as mainstream or widespread, like ARM, MIPS, PowerPC, x86, and x86-64.
In this tutorial, you will learn the basics of how to use Yocto. We will take you through the step by step instructions to get started with creating your own Linux distribution for an embedded system.
In this tutorial you will learn:
- What is Yocto used for?
- How to create a Linux distro with Yocto
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Software||Yocto, git, various prerequisites|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Yocto Linux: Tutorial Basics
To get started with Yocto, users can download Poky. Poky is a reference Linux distro that Yocto has built as an example. The easiest way to create your own distro is to just edit the files that are used to build Poky.
In addition, developers will supply user configuration, Meta files, Machine BSP configuration, and policy configuration. A custom distribution can then be compiled. The Yocto Project has a great diagram on their website that helps explain the build process:
Image source: Yocto software overview
Building a Linux distribution with Yocto Project – step by step instructions
- The process of using Yocto is very well documented for Ubuntu systems, so it is our recommendation that you use it for your host system. You can still use a lot of other distros, but will need to refer to the system requirements page to learn what prerequisite packages are needed. On Ubuntu or any Debian based system, you can use the following command to install all needed package dependencies:
$ sudo apt install gawk wget git diffstat unzip texinfo gcc build-essential chrpath socat cpio python3 python3-pip python3-pexpect xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev pylint xterm python3-subunit mesa-common-dev zstd liblz4-tool
- Next, we will clone the Yocto git archive which contains all the Poky files.
kirkstoneis the latest build name at the time of this writing.
$ git clone -b kirkstone git://git.yoctoproject.org/poky.git
- Next, go into the
pokydirectory and initialize the build. This will generate a few configuration files for us, and a new directory.
$ cd poky $ source oe-init-build-env build
Your terminal will automatically change to the
builddirectory after executing the
- Proceed with editing the
local.conffile to your liking. This is where you choose your target architecture, what packages your distro will work with (RPM or DEB), and other settings. Anything you choose not to edit will automatically accept the default values. Technically, you do not have to edit anything.
$ sudo nano conf/local.conf
- Next, use the
bitbakecommand to begin compiling.
$ bitbake core-image-sato
This process may take upwards of a couple hours to complete, depending on the hardware of your computer and connection speed. Many resources will be downloaded and compiled.
The result when the command finishes will be your binary files inside the
build directory and
In this tutorial, we saw how to use Yocto to build a custom Linux distribution for embedded devices. We have only scraped the surface here, as using Yocto can get extremely complex and the configurations can be done on a very granular scale. Yocto is a godsend to developers that want to use Linux on their embedded devices, and want to customize the software instead of relying on mainstream distros and trying to strip away the unnecessary parts before build time.