This is a high-level tutorial and the intention is not to cover the Yocto Project in depth. If you are interested in detailed information, we recommend that you read the Yocto Project Mega-Manual.
This tutorial will cover how to add packages to any given image utilizing
To follow this tutorial, you will need:
- A configured Yocto environment. Please take a look at one of the following if you do not have this prepared:
- Enough Free Memory: Your system should have at least 50 Gbytes of free disk space for building images.
For the sake of this tutorial lets set a couple of requirements that we want to accomplish on our target device.
We would like our image to contain the following:
inotify-tools is a C library and a set of command-line programs for Linux providing a simple interface to inotify. These programs can be used to monitor and act upon filesystem events
Additionally we would like the following packages that are suitable for development:
- SSH server running on the device
- gdb, gdbserver and strace installed on the device
- evtest, i2c-tools, ethtool, fbset, memtester
- these are all applications useful during testing debugging various parts of the system
Building a package
Bitbake supports building individual packages. In the following example I will compile and package
This will not include
inotify-tools in any image and it will only create a
inotify-tools package, one can actually inspect and see that it created several packages:
ls -1 tmp/deploy/rpm/*/inotify-tools-* tmp/deploy/rpm/cortexa7t2hf_neon_vfpv4/inotify-tools-3.14+git0+1df9af4d6c-r0.cortexa7t2hf_neon_vfpv4.rpm tmp/deploy/rpm/cortexa7t2hf_neon_vfpv4/inotify-tools-dbg-3.14+git0+1df9af4d6c-r0.cortexa7t2hf_neon_vfpv4.rpm tmp/deploy/rpm/cortexa7t2hf_neon_vfpv4/inotify-tools-dev-3.14+git0+1df9af4d6c-r0.cortexa7t2hf_neon_vfpv4.rpm tmp/deploy/rpm/cortexa7t2hf_neon_vfpv4/inotify-tools-doc-3.14+git0+1df9af4d6c-r0.cortexa7t2hf_neon_vfpv4.rpm tmp/deploy/rpm/cortexa7t2hf_neon_vfpv4/inotify-tools-src-3.14+git0+1df9af4d6c-r0.cortexa7t2hf_neon_vfpv4.rpm
cortexa7t2hf_neon_vfpv4 architecture string might be different in your environment depending on what device you are targeting.
I will not cover in detail how these where created but if you are interested there is a very detailed explanation in the Yocto Project Mega Manual that explains all the steps executed when we ran
How to figure out what packages are available?
Before we move on, I wanted to quickly cover some tricks on how to look up what packages actually are available within Yocto as this is not not always to figure out, especially since you might not have that specific layer in your environment that provides a recipe for the desired package.
The best tool for looking up recipes/packages is the OpenEmbedded Layer Index which keeps an index of all provided packages of the layers that are registered at the site (most are).
If you are interested in getting a list of available packages in your current environment you can run:
The output of above command can of course be filtering using some simple shell tricks, e.g to find provided
python3 modules you can run:
bitbake-layers show-recipes | grep python3-*
Customizing images using
The simplest way of adding a package to an image target is with small modification to
A simple way of ensuring that
inotify-tools is installed to any give image is by adding the following to
echo 'IMAGE_INSTALL_append = " inotify-tools"' >> conf/local.conf
IMAGE_INSTALL - Image recipes set IMAGE_INSTALL to specify the packages to install into an image.
_append - This is an override that will append the specific string to a variable. The space at the beginning is important!
And if we now build
core-image-base it will have included the
We can add one more entry to add the packages that we want for our development image:
echo 'IMAGE_INSTALL_append = " dropbear gdb gdbserver strace evtest i2c-tools ethtool fbset memtester"' >> conf/local.conf
With these changes we are ensuring that regardless what image you build the above defined packages will be included.
local.conf is considered a “local file” and any changes made to this file are not preserved should you reset your build environment. It is also encouraged not to try to use this file for any other purpose then temporary local modifications. Have a look at the How to create custom images using Yocto Project tutorial which covers how do accomplish a similar result as defined here in a more sustainable way.
In this tutorial we have covered the basics of how install packages utilizing
local.conf in the Yocto Project, in the hopes that it will help you get started quickly without need of digging to deep in Yocto Project internals.
For further reading visit:
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!