<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.yoctoproject.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Alen+Sunnny+Mathew</id>
	<title>Yocto Project - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.yoctoproject.org/wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Alen+Sunnny+Mathew"/>
	<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/Special:Contributions/Alen_Sunnny_Mathew"/>
	<updated>2026-06-04T17:44:45Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.5</generator>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85395</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85395"/>
		<updated>2022-07-20T12:35:28Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;&#039;Yocto Project Quick Build&#039;&#039;&#039; =&lt;br /&gt;
== Kirkstone (4.0.2)==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the  [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files Locating Yocto Project Source Files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using  [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache Shared State Cache] mirrors and enabling [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence Hash Equivalence ]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory ]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Start the Build==&lt;br /&gt;
&lt;br /&gt;
Continue with the following command to build an OS image for the target, which is core-image-sato in this example:&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-sato&lt;br /&gt;
For information on using the bitbake command, see the [https://docs.yoctoproject.org/overview-manual/concepts.html#bitbake BitBake] section in the Yocto Project Overview and Concepts Manual, or see The [https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-intro.html#the-bitbake-command BitBake Command] in the BitBake User Manual.&lt;br /&gt;
&lt;br /&gt;
== Simulate Your Image Using QEMU==&lt;br /&gt;
once the image is build , you can start QEMU with the following commands.&lt;br /&gt;
  $ runqemu qemux86-64&lt;br /&gt;
&lt;br /&gt;
[https://docs.yoctoproject.org/dev-manual/qemu.html#using-the-quick-emulator-qemu The Quick EMUlator (QEMU)] Yocto Project Development Tasks Manual will gives you more understanding about running QEMU.&lt;br /&gt;
&lt;br /&gt;
== Exit QEMU:== &lt;br /&gt;
Exit QEMU by either clicking on the shutdown icon or by typing Ctrl-C in the QEMU transcript window from which you evoked QEMU.&lt;br /&gt;
&lt;br /&gt;
= Build an example project on the host for testing (optional) =&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85394</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85394"/>
		<updated>2022-07-20T12:33:43Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= &#039;&#039;&#039;Yocto Project Quick Build&#039;&#039;&#039; =&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the  [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files Locating Yocto Project Source Files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using  [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache Shared State Cache] mirrors and enabling [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence Hash Equivalence ]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory ]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Start the Build==&lt;br /&gt;
&lt;br /&gt;
Continue with the following command to build an OS image for the target, which is core-image-sato in this example:&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-sato&lt;br /&gt;
For information on using the bitbake command, see the [https://docs.yoctoproject.org/overview-manual/concepts.html#bitbake BitBake] section in the Yocto Project Overview and Concepts Manual, or see The [https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-intro.html#the-bitbake-command BitBake Command] in the BitBake User Manual.&lt;br /&gt;
&lt;br /&gt;
== Simulate Your Image Using QEMU==&lt;br /&gt;
once the image is build , you can start QEMU with the following commands.&lt;br /&gt;
  $ runqemu qemux86-64&lt;br /&gt;
&lt;br /&gt;
[https://docs.yoctoproject.org/dev-manual/qemu.html#using-the-quick-emulator-qemu The Quick EMUlator (QEMU)] Yocto Project Development Tasks Manual will gives you more understanding about running QEMU.&lt;br /&gt;
&lt;br /&gt;
== Exit QEMU:== &lt;br /&gt;
Exit QEMU by either clicking on the shutdown icon or by typing Ctrl-C in the QEMU transcript window from which you evoked QEMU.&lt;br /&gt;
&lt;br /&gt;
= Build an example project on the host for testing (optional) =&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85393</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85393"/>
		<updated>2022-07-20T12:31:42Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Build an example project on the host for testing (optional) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the  [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files Locating Yocto Project Source Files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using  [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache Shared State Cache] mirrors and enabling [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence Hash Equivalence ]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory ]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Start the Build==&lt;br /&gt;
&lt;br /&gt;
Continue with the following command to build an OS image for the target, which is core-image-sato in this example:&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-sato&lt;br /&gt;
For information on using the bitbake command, see the [https://docs.yoctoproject.org/overview-manual/concepts.html#bitbake BitBake] section in the Yocto Project Overview and Concepts Manual, or see The [https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-intro.html#the-bitbake-command BitBake Command] in the BitBake User Manual.&lt;br /&gt;
&lt;br /&gt;
== Simulate Your Image Using QEMU==&lt;br /&gt;
once the image is build , you can start QEMU with the following commands.&lt;br /&gt;
  $ runqemu qemux86-64&lt;br /&gt;
&lt;br /&gt;
[https://docs.yoctoproject.org/dev-manual/qemu.html#using-the-quick-emulator-qemu The Quick EMUlator (QEMU)] Yocto Project Development Tasks Manual will gives you more understanding about running QEMU.&lt;br /&gt;
&lt;br /&gt;
== Exit QEMU:== &lt;br /&gt;
Exit QEMU by either clicking on the shutdown icon or by typing Ctrl-C in the QEMU transcript window from which you evoked QEMU.&lt;br /&gt;
&lt;br /&gt;
= Build an example project on the host for testing (optional) =&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85392</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85392"/>
		<updated>2022-07-20T11:53:44Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Exit QEMU: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the  [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files Locating Yocto Project Source Files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using  [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache Shared State Cache] mirrors and enabling [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence Hash Equivalence ]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory ]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Start the Build==&lt;br /&gt;
&lt;br /&gt;
Continue with the following command to build an OS image for the target, which is core-image-sato in this example:&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-sato&lt;br /&gt;
For information on using the bitbake command, see the [https://docs.yoctoproject.org/overview-manual/concepts.html#bitbake BitBake] section in the Yocto Project Overview and Concepts Manual, or see The [https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-intro.html#the-bitbake-command BitBake Command] in the BitBake User Manual.&lt;br /&gt;
&lt;br /&gt;
== Simulate Your Image Using QEMU==&lt;br /&gt;
once the image is build , you can start QEMU with the following commands.&lt;br /&gt;
  $ runqemu qemux86-64&lt;br /&gt;
&lt;br /&gt;
[https://docs.yoctoproject.org/dev-manual/qemu.html#using-the-quick-emulator-qemu The Quick EMUlator (QEMU)] Yocto Project Development Tasks Manual will gives you more understanding about running QEMU.&lt;br /&gt;
&lt;br /&gt;
== Exit QEMU:== &lt;br /&gt;
Exit QEMU by either clicking on the shutdown icon or by typing Ctrl-C in the QEMU transcript window from which you evoked QEMU.&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85391</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85391"/>
		<updated>2022-07-20T11:52:37Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Simulate Your Image Using QEMU */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the  [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files Locating Yocto Project Source Files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using  [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache Shared State Cache] mirrors and enabling [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence Hash Equivalence ]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory ]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Start the Build==&lt;br /&gt;
&lt;br /&gt;
Continue with the following command to build an OS image for the target, which is core-image-sato in this example:&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-sato&lt;br /&gt;
For information on using the bitbake command, see the [https://docs.yoctoproject.org/overview-manual/concepts.html#bitbake BitBake] section in the Yocto Project Overview and Concepts Manual, or see The [https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-intro.html#the-bitbake-command BitBake Command] in the BitBake User Manual.&lt;br /&gt;
&lt;br /&gt;
== Simulate Your Image Using QEMU==&lt;br /&gt;
once the image is build , you can start QEMU with the following commands.&lt;br /&gt;
  $ runqemu qemux86-64&lt;br /&gt;
&lt;br /&gt;
[https://docs.yoctoproject.org/dev-manual/qemu.html#using-the-quick-emulator-qemu The Quick EMUlator (QEMU)] Yocto Project Development Tasks Manual will gives you more understanding about running QEMU.&lt;br /&gt;
&lt;br /&gt;
= Exit QEMU: = &lt;br /&gt;
Exit QEMU by either clicking on the shutdown icon or by typing Ctrl-C in the QEMU transcript window from which you evoked QEMU.&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85390</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85390"/>
		<updated>2022-07-20T11:51:20Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Simulate Your Image Using QEMU */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the  [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files Locating Yocto Project Source Files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using  [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache Shared State Cache] mirrors and enabling [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence Hash Equivalence ]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory ]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Start the Build==&lt;br /&gt;
&lt;br /&gt;
Continue with the following command to build an OS image for the target, which is core-image-sato in this example:&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-sato&lt;br /&gt;
For information on using the bitbake command, see the [https://docs.yoctoproject.org/overview-manual/concepts.html#bitbake BitBake] section in the Yocto Project Overview and Concepts Manual, or see The [https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-intro.html#the-bitbake-command BitBake Command] in the BitBake User Manual.&lt;br /&gt;
&lt;br /&gt;
== Simulate Your Image Using QEMU==&lt;br /&gt;
once the image is build , you can start QEMU with the following commands.&lt;br /&gt;
  $ runqemu qemux86-64&lt;br /&gt;
&lt;br /&gt;
[https://docs.yoctoproject.org/dev-manual/qemu.html#using-the-quick-emulator-qemu The Quick EMUlator (QEMU)] Yocto Project Development Tasks Manual will gives you more understanding about running QEMU.&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85389</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85389"/>
		<updated>2022-07-20T11:46:34Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Start the Build */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the  [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files Locating Yocto Project Source Files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using  [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache Shared State Cache] mirrors and enabling [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence Hash Equivalence ]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory ]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Start the Build==&lt;br /&gt;
&lt;br /&gt;
Continue with the following command to build an OS image for the target, which is core-image-sato in this example:&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-sato&lt;br /&gt;
For information on using the bitbake command, see the [https://docs.yoctoproject.org/overview-manual/concepts.html#bitbake BitBake] section in the Yocto Project Overview and Concepts Manual, or see The [https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-intro.html#the-bitbake-command BitBake Command] in the BitBake User Manual.&lt;br /&gt;
&lt;br /&gt;
== Simulate Your Image Using QEMU==&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85388</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85388"/>
		<updated>2022-07-20T11:40:12Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Build a baseline image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the  [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files Locating Yocto Project Source Files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using  [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache Shared State Cache] mirrors and enabling [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence Hash Equivalence ]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory ]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Start the Build==&lt;br /&gt;
&lt;br /&gt;
Continue with the following command to build an OS image for the target, which is core-image-sato in this example:&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-sato&lt;br /&gt;
For information on using the bitbake command, see the [https://docs.yoctoproject.org/overview-manual/concepts.html#bitbake BitBake] section in the Yocto Project Overview and Concepts Manual, or see The [https://docs.yoctoproject.org/bitbake/2.0/bitbake-user-manual/bitbake-user-manual-intro.html#the-bitbake-command BitBake Command] in the BitBake User Manual.&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85387</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85387"/>
		<updated>2022-07-20T11:36:19Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Use Git to Clone Poky */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the  [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files Locating Yocto Project Source Files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using  [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache Shared State Cache] mirrors and enabling [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence Hash Equivalence ]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory ]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85386</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85386"/>
		<updated>2022-07-20T11:35:33Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Building Your Image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using  [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache Shared State Cache] mirrors and enabling [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence Hash Equivalence ]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory ]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85385</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85385"/>
		<updated>2022-07-20T11:33:30Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Building Your Image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy Network Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the  [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the  [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory Build Directory], which is build in this case and is located in the [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory Source Directory ]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using Shared State Cache [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache]mirrors and enabling Hash Equivalence [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85384</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85384"/>
		<updated>2022-07-20T11:30:43Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the [https://docs.yoctoproject.org/ Yocto Quickstart]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory], which is build in this case and is located in the Source Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using Shared State Cache [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache]mirrors and enabling Hash Equivalence [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85383</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85383"/>
		<updated>2022-07-20T11:28:50Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [https://docs.yoctoproject.org/ref-manual/index.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory], which is build in this case and is located in the Source Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using Shared State Cache [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache]mirrors and enabling Hash Equivalence [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85382</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85382"/>
		<updated>2022-07-20T11:26:36Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required Host packages for your host system to support Yocto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto (Kirkstone 4.0.2) ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory], which is build in this case and is located in the Source Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using Shared State Cache [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache]mirrors and enabling Hash Equivalence [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85381</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85381"/>
		<updated>2022-07-20T11:25:25Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Building Your Image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory], which is build in this case and is located in the Source Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using Shared State Cache [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache]mirrors and enabling Hash Equivalence [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory]:&lt;br /&gt;
&lt;br /&gt;
  BB_SIGNATURE_HANDLER = &amp;quot;OEEquivHash&amp;quot;&lt;br /&gt;
  BB_HASHSERVE = &amp;quot;auto&amp;quot;&lt;br /&gt;
  BB_HASHSERVE_UPSTREAM = &amp;quot;typhoon.yocto.io:8687&amp;quot;&lt;br /&gt;
  SSTATE_MIRRORS ?= &amp;quot;file://.* https://sstate.yoctoproject.org/all/PATH;downloadfilename=PATH&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85380</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85380"/>
		<updated>2022-07-20T11:24:10Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Building Your Image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory], which is build in this case and is located in the Source Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Source-Directory]. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using Shared State Cache [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache]mirrors and enabling Hash Equivalence [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory]:&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85379</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85379"/>
		<updated>2022-07-20T11:23:01Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Building Your Image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory], which is build in this case and is located in the Source Directory. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using Shared State Cache [https://docs.yoctoproject.org/overview-manual/concepts.html#shared-state-cache]mirrors and enabling Hash Equivalence [https://docs.yoctoproject.org/overview-manual/concepts.html#hash-equivalence]. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
To use such mirrors, uncomment the below lines in your conf/local.conf file in the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory]:&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85378</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85378"/>
		<updated>2022-07-20T11:18:25Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Building Your Image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory], which is build in this case and is located in the Source Directory. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
2.Examine Your Local Configuration File: When you set up the build environment, a local configuration file named local.conf becomes available in a conf subdirectory of the Build Directory. For this example, the defaults are set to build for a qemux86 target, which is suitable for emulation. The package manager used is set to the RPM package manager.&lt;br /&gt;
Tip:&lt;br /&gt;
You can significantly speed up your build and guard against fetcher failures by using Shared State Cache mirrors and enabling Hash Equivalence. This way, you can use pre-built artifacts rather than building them. This is relevant only when your network and the server that you use can download these artifacts faster than you would be able to build them.&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85377</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85377"/>
		<updated>2022-07-20T11:16:32Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Building Your Image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
Among other things, the script creates the Build Directory [https://docs.yoctoproject.org/ref-manual/terms.html#term-Build-Directory], which is build in this case and is located in the Source Directory. After the script runs, your current working directory is set to the Build Directory. Later, when the build completes, the Build Directory contains all the files created during the build.&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85376</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85376"/>
		<updated>2022-07-20T11:14:06Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Building Your Image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85375</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85375"/>
		<updated>2022-07-20T11:12:39Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Building Your Image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ source oe-init-build-env&lt;br /&gt;
    You had no conf/local.conf file. This configuration file has therefore been&lt;br /&gt;
    created for you with some default values. You may wish to edit it to, for&lt;br /&gt;
    example, select a different MACHINE (target hardware). See conf/local.conf&lt;br /&gt;
    for more information as common configuration options are commented.&lt;br /&gt;
&lt;br /&gt;
    You had no conf/bblayers.conf file. This configuration file has therefore&lt;br /&gt;
    been created for you with some default values. To add additional metadata&lt;br /&gt;
    layers into your configuration please add entries to conf/bblayers.conf.&lt;br /&gt;
&lt;br /&gt;
    The Yocto Project has extensive documentation about OE including a reference&lt;br /&gt;
    manual which can be found at:&lt;br /&gt;
    https://docs.yoctoproject.org&lt;br /&gt;
&lt;br /&gt;
    For more information about OpenEmbedded see their website:&lt;br /&gt;
    https://www.openembedded.org/&lt;br /&gt;
&lt;br /&gt;
    ### Shell environment set up for builds. ###&lt;br /&gt;
&lt;br /&gt;
    You can now run &#039;bitbake &amp;lt;target&amp;gt;&#039;&lt;br /&gt;
&lt;br /&gt;
    Common targets are:&lt;br /&gt;
    core-image-minimal&lt;br /&gt;
    core-image-full-cmdline&lt;br /&gt;
    core-image-sato&lt;br /&gt;
    core-image-weston&lt;br /&gt;
    meta-toolchain&lt;br /&gt;
    meta-ide-support&lt;br /&gt;
&lt;br /&gt;
    You can also run generated QEMU images with a command like &#039;runqemu qemux86-64&#039;&lt;br /&gt;
&lt;br /&gt;
    Other commonly useful commands are:&lt;br /&gt;
    - &#039;devtool&#039; and &#039;recipetool&#039; handle common recipe tasks&lt;br /&gt;
    - &#039;bitbake-layers&#039; handles common layer tasks&lt;br /&gt;
    - &#039;oe-pkgdata-util&#039; handles common target package tasks&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85374</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85374"/>
		<updated>2022-07-20T11:09:37Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Configure the build environment to build an emulator image */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Building Your Image ==&lt;br /&gt;
&lt;br /&gt;
to build an image follow the instructions below.The build process creates an entire Linux distribution, including the toolchain, from source&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
If you are working behind a firewall and your build host is not set up for proxies, you may face problems with the build process when fetching source code (e.g. fetcher failures or Git failures).&lt;br /&gt;
&lt;br /&gt;
If you do not know your proxy settings, consult your local network infrastructure resources and get that information. A good starting point could also be to check your web browser settings. Finally, you can find more information on the “Working Behind a Network Proxy” [https://wiki.yoctoproject.org/wiki/Working_Behind_a_Network_Proxy] page of the Yocto Project Wiki.&lt;br /&gt;
&lt;br /&gt;
1.Initialize the Build Environment: From within the poky directory, run the oe-init-build-env [https://docs.yoctoproject.org/ref-manual/structure.html#oe-init-build-env] environment setup script to define Yocto Project’s build environment on your build host.&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85373</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85373"/>
		<updated>2022-07-20T11:02:17Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required packages for your host system to support Yocto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required Host packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85372</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85372"/>
		<updated>2022-07-20T11:01:09Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Use Git to Clone Poky */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files [https://docs.yoctoproject.org/dev-manual/start.html#locating-yocto-project-source-files] section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85371</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85371"/>
		<updated>2022-07-20T10:59:44Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Use Git to Clone Poky */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
For more options and information about accessing Yocto Project related repositories, see the Locating Yocto Project Source Files section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85370</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85370"/>
		<updated>2022-07-20T10:59:01Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Use Git to Clone Poky */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
For this example, check out the kirkstone branch based on the Kirkstone release:&lt;br /&gt;
  $ git checkout -t origin/kirkstone -b my-kirkstone&lt;br /&gt;
    Branch &#039;my-kirkstone&#039; set up to track remote branch &#039;kirkstone&#039; from &#039;origin&#039;.&lt;br /&gt;
    Switched to a new branch &#039;my-kirkston&lt;br /&gt;
The previous Git checkout command creates a local branch named my-kirkstone. The files available to you in that branch exactly match the repository’s files in the kirkstone release branch.&lt;br /&gt;
&lt;br /&gt;
Note that you can regularly type the following command in the same directory to keep your local files in sync with the release branch:&lt;br /&gt;
&lt;br /&gt;
  $ git pull&lt;br /&gt;
    Already up-to-date.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85369</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85369"/>
		<updated>2022-07-20T10:50:23Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Use Git to Clone Poky */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
Go to Releases wiki page, and choose a release codename (such as kirkstone), corresponding to either the latest stable release or a Long Term Support release.&lt;br /&gt;
&lt;br /&gt;
Then move to the poky directory and take a look at existing branches:&lt;br /&gt;
&lt;br /&gt;
  $ cd poky&lt;br /&gt;
  $ git branch -a&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85368</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85368"/>
		<updated>2022-07-20T10:42:06Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Use Git to Clone Poky */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
  $ git clone git://git.yoctoproject.org/poky&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85367</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85367"/>
		<updated>2022-07-20T10:40:28Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Download and extract the Yocto 2.0 (Jethro) release */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Use Git to Clone Poky==&lt;br /&gt;
&lt;br /&gt;
Once you complete the setup instructions for your machine, you need to get a copy of the Poky repository on your build host. Use the following commands to clone the Poky repository.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85366</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85366"/>
		<updated>2022-07-20T10:06:22Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0.2 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85365</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85365"/>
		<updated>2022-07-20T09:59:08Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required packages for your host system to support Yocto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
For host package requirements on all supported Linux distributions, see the Required Packages for the Build Host section in the Yocto Project Reference Manual.&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85364</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85364"/>
		<updated>2022-07-20T09:58:09Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required packages for your host system to support Yocto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [https://docs.yoctoproject.org/]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85363</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85363"/>
		<updated>2022-07-20T09:55:44Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required packages for your host system to support Yocto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
    python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85362</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85362"/>
		<updated>2022-07-20T09:55:28Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required packages for your host system to support Yocto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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 &lt;br /&gt;
  python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85361</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85361"/>
		<updated>2022-07-20T09:54:40Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ &lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85360</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85360"/>
		<updated>2022-07-20T09:53:30Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
Compatible Linux Distribution:&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
 * 50 Gbytes of free disk space&lt;br /&gt;
 * Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see &lt;br /&gt;
 the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in &lt;br /&gt;
 the Yocto Project Development Tasks Manual.&lt;br /&gt;
 * Git 1.8.3.1 or greater&lt;br /&gt;
 * tar 1.28 or greater&lt;br /&gt;
 * Python 3.6.0 or greater.&lt;br /&gt;
 * gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
 * familiar with basic Linux admin tasks&lt;br /&gt;
 * aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
 * using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
 * working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ &lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85359</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85359"/>
		<updated>2022-07-20T09:51:29Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
If your build host does not meet any of these three listed version requirements, you can take steps to prepare the system so that you can still use the Yocto Project. See the Required Git, tar, Python and gcc Versions section in the Yocto Project Reference Manual for information.&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ &lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85358</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85358"/>
		<updated>2022-07-20T09:50:32Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Make sure your Build Host meets the following requirements:&lt;br /&gt;
&lt;br /&gt;
* 50 Gbytes of free disk space&lt;br /&gt;
* Runs a supported Linux distribution (i.e. recent releases of Fedora, openSUSE, CentOS, Debian, or Ubuntu). For a list of Linux distributions that support the Yocto Project, see the Supported Linux Distributions section in the Yocto Project Reference Manual. For detailed information on preparing your build host, see the Preparing the Build Host section in the Yocto Project Development Tasks Manual.&lt;br /&gt;
* Git 1.8.3.1 or greater&lt;br /&gt;
* tar 1.28 or greater&lt;br /&gt;
* Python 3.6.0 or greater.&lt;br /&gt;
* gcc 5.0 or greater.&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ &lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85357</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85357"/>
		<updated>2022-07-20T09:48:21Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required packages for your host system to support Yocto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ &lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85356</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85356"/>
		<updated>2022-07-20T09:47:22Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required packages for your host system to support Yocto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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&lt;br /&gt;
python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85355</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85355"/>
		<updated>2022-07-20T09:46:55Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required packages for your host system to support Yocto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
You must install essential host packages on your build host. The following command installs the host packages based on an Ubuntu distribution:&lt;br /&gt;
&lt;br /&gt;
  $ 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&lt;br /&gt;
&lt;br /&gt;
python3-jinja2 libegl1-mesa libsdl1.2-dev pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85354</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85354"/>
		<updated>2022-07-20T09:45:24Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Obtain the required packages for your host system to support Yocto */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ 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 pylint3 xterm python3-subunit mesa-common-dev zstd liblz4-tool&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
	<entry>
		<id>https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85353</id>
		<title>Building your own recipes from first principles</title>
		<link rel="alternate" type="text/html" href="https://wiki.yoctoproject.org/wiki/index.php?title=Building_your_own_recipes_from_first_principles&amp;diff=85353"/>
		<updated>2022-07-20T09:41:37Z</updated>

		<summary type="html">&lt;p&gt;Alen Sunnny Mathew: /* Overview */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
This walk-through has the aim of taking you from a clean system through to building and packaging an example project for inclusion in an image.&lt;br /&gt;
&lt;br /&gt;
You may already have Yocto installed and just be looking to work with recipes for the first time, in which case you can jump forward to the section you find most relevant, &amp;lt;br/&amp;gt;&lt;br /&gt;
such as [[#Build an example project on the host for testing (optional)|building an example package on the host to test]] or [[#Build an example package based on a git repository commit|building an example package from a git commit]].&lt;br /&gt;
&lt;br /&gt;
The following assumptions are made. You are:&lt;br /&gt;
&lt;br /&gt;
* familiar with basic Linux admin tasks&lt;br /&gt;
* aware of the Yocto Project Reference Manual [http://www.yoctoproject.org/docs/current/ref-manual/ref-manual.html here].&lt;br /&gt;
* using [https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes Ubuntu 14.04 LTS] as your host build system&lt;br /&gt;
* working with Yocto 4.0 (Kirkstone) release&lt;br /&gt;
&lt;br /&gt;
== Obtain the required packages for your host system to support Yocto ==&lt;br /&gt;
&lt;br /&gt;
First we will install the required host packages for Ubuntu as detailed in the quickstart, i.e.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm nano&lt;br /&gt;
&lt;br /&gt;
Full details of system requirements and installation can be found in the Yocto Quickstart [http://www.yoctoproject.org/docs/2.0/yocto-project-qs/yocto-project-qs.html here]&lt;br /&gt;
&lt;br /&gt;
Add some other packages which will be needed for the walk-through below.&lt;br /&gt;
&lt;br /&gt;
  $ sudo apt-get install autoconf libtool rpm&lt;br /&gt;
&lt;br /&gt;
== Download and extract the Yocto 2.0 (Jethro) release ==&lt;br /&gt;
&lt;br /&gt;
At the time of writing, the current release of Yocto (2.0) can be found [https://www.yoctoproject.org/downloads/core/jethro20 here]&lt;br /&gt;
 &lt;br /&gt;
  $ cd ~&lt;br /&gt;
  $ mkdir yocto&lt;br /&gt;
  $ cd yocto&lt;br /&gt;
  $ wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.0/poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
  $ tar xjvf poky-jethro-14.0.0.tar.bz2&lt;br /&gt;
&lt;br /&gt;
This will get you the Yocto 2.0 base meta-data and the bitbake tool. You can also add in extra layers, usually of the form &amp;quot;meta-foo&amp;quot; to provide machine support and additional functionality.&lt;br /&gt;
&lt;br /&gt;
== Configure the build environment to build an emulator image ==&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ source oe-init-build-env build_qemux86&lt;br /&gt;
&lt;br /&gt;
This will create a build tree in &amp;quot;build_qemux86&amp;quot; although you could use a different name if you so wish with no adverse effects. &lt;br /&gt;
&lt;br /&gt;
It is entirely possible to have many build trees in parallel in different folders and to switch between them using &amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;oe-init-build-env&amp;lt;/code&amp;gt; will create a default configuration file in &amp;lt;code&amp;gt;conf/local/conf&amp;lt;/code&amp;gt; which will build an emulator image suitable for execution with &amp;lt;code&amp;gt;qemu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Build a baseline image ==&lt;br /&gt;
&lt;br /&gt;
After configuring the environment you will be left in the build_qemux86 folder.&lt;br /&gt;
&lt;br /&gt;
You should then build a baseline image, which will take some time (numbers of hours)&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
== Build an example project on the host for testing (optional) ==&lt;br /&gt;
&lt;br /&gt;
The most straightforward way to cross-compile projects for different targets within Yocto is to make use of [http://www.gnu.org/savannah-checkouts/gnu/automake/manual/html_node/index.html autotools]&lt;br /&gt;
&lt;br /&gt;
Projects which support &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; provide a set of template files which are then used by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; to generate &amp;lt;code&amp;gt;Makefiles&amp;lt;/code&amp;gt; and associated configuration files which are appropriate to build for the target environment.&lt;br /&gt;
&lt;br /&gt;
A very basic example &#039;Hello World&#039; style project called &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; has been committed to GitHub [https://github.com/DynamicDevices/bbexample here]&lt;br /&gt;
&lt;br /&gt;
If you take a look at the two source files [https://github.com/DynamicDevices/bbexample/blob/master/bbexample.c bbexample.c] and [https://github.com/DynamicDevices/bbexample/blob/master/bbexamplelib.c bbexamplelib.c] you can see the main entry point prints a Hello World message, then calls a function exported by the shared library which also prints a message.&lt;br /&gt;
&lt;br /&gt;
Discussion of &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; template configuration is outside the scope of this guide, but the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; project is based on the &#039;Quick and Dirty&#039; example which can be found [http://www.niksula.cs.hut.fi/~mkomu/docs/autohowto.html here]&lt;br /&gt;
&lt;br /&gt;
The project itself builds an executable, &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which has a dependency on a shared library &amp;lt;code&amp;gt;libbbexample.so&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To build the project on the host independently of Yocto first clone the example repository &lt;br /&gt;
&lt;br /&gt;
  $ mkdir ~/host&lt;br /&gt;
  $ cd ~/host&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/bbexample&lt;br /&gt;
&lt;br /&gt;
Then run the autotools, configure the build, and make the project&lt;br /&gt;
&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ ./autogen.sh&lt;br /&gt;
  $ ./configure&lt;br /&gt;
  $ make&lt;br /&gt;
&lt;br /&gt;
Following a successful compilation you will have a number of new files in the root of the build folder. &lt;br /&gt;
&lt;br /&gt;
There is a new executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; which depends upon a shared library &amp;lt;code&amp;gt;.libs/libbbexample.so&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As this project has been built to run on the host you can &lt;br /&gt;
&lt;br /&gt;
  ./bbexample&lt;br /&gt;
&lt;br /&gt;
It will output &lt;br /&gt;
&lt;br /&gt;
  Hello Yocto World...&lt;br /&gt;
  Hello World (from a shared library!)&lt;br /&gt;
&lt;br /&gt;
So you have now shown that you can successfully fetch configure and build the project on the host. &lt;br /&gt;
&lt;br /&gt;
Next we will look at how Yocto automates the this process of fetching, configuring and building, then also installs and packages the output files.&lt;br /&gt;
&lt;br /&gt;
== Adding new recipes to the build system ==&lt;br /&gt;
&lt;br /&gt;
There are different ways to add new recipes to Yocto. &lt;br /&gt;
&lt;br /&gt;
One way is to simply create a new recipe_version.bb file in a recipe-foo/recipe folder within one of the existing layers used by Yocto.&lt;br /&gt;
&lt;br /&gt;
=== Placing a recipe in an existing layer (example only) ===&lt;br /&gt;
&lt;br /&gt;
For example you could&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-yocto&lt;br /&gt;
  $ mkdir recipes-example&lt;br /&gt;
  $ mkdir bbexample&lt;br /&gt;
  $ cd bbexample&lt;br /&gt;
  $ wget https://raw.githubusercontent.com/DynamicDevices/meta-example/master/recipes-example/bbexample/bbexample_1.0.bb&lt;br /&gt;
&lt;br /&gt;
The recipe will then be picked up by bitbake and you can build the recipe with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build-qemux86&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
=== Using a new layer for recipes ===&lt;br /&gt;
&lt;br /&gt;
A preferred method for adding recipes to the build environment, and the method you should use with this guide, is to place them within a new layer. &lt;br /&gt;
&lt;br /&gt;
Layers isolate particular sets of build meta-data based on machine, functionality or similar, and help to keep the environment clean.&lt;br /&gt;
&lt;br /&gt;
An example layer, meta-example, has been created using the &amp;lt;code&amp;gt;yocto-layer&amp;lt;/code&amp;gt; command and committed into a GitHub repository [https://github.com/DynamicDevices/meta-example here].&lt;br /&gt;
&lt;br /&gt;
To use a new layer such as this you first clone the git repository and then add the layer to your bitbake configuration in &amp;lt;code&amp;gt;conf/bblayers.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0&lt;br /&gt;
  $ git clone https://github.com/DynamicDevices/meta-example&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ nano conf/bblayers.conf&lt;br /&gt;
&lt;br /&gt;
Your &amp;lt;code&amp;gt;bblayers.conf&amp;lt;/code&amp;gt; should look similar to this&lt;br /&gt;
&lt;br /&gt;
  # LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf&lt;br /&gt;
  # changes incompatibly&lt;br /&gt;
  LCONF_VERSION = &amp;quot;6&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBPATH = &amp;quot;${TOPDIR}&amp;quot;&lt;br /&gt;
  BBFILES ?= &amp;quot;&amp;quot;&lt;br /&gt;
  &lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
  BBLAYERS_NON_REMOVABLE ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Make the new layer visible to &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by adding a line to &amp;lt;code&amp;gt;BBLAYERS&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  BBLAYERS ?= &amp;quot; \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-yocto-bsp \&lt;br /&gt;
    /home/user/yocto/poky-jethro-14.0.0/meta-example \&lt;br /&gt;
    &amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can see the recipes in the new layer.&lt;br /&gt;
&lt;br /&gt;
You will also see when &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; runs and shows the Build Configuration that the repository branch and hash of your layer is shown which is useful to know, particularly when comparing notes with others as to why a build fails, e.g.&lt;br /&gt;
&lt;br /&gt;
  Build Configuration:&lt;br /&gt;
  BB_VERSION        = &amp;quot;1.28.0&amp;quot;&lt;br /&gt;
  BUILD_SYS         = &amp;quot;x86_64-linux&amp;quot;&lt;br /&gt;
  NATIVELSBSTRING   = &amp;quot;Ubuntu-14.04&amp;quot;&lt;br /&gt;
  TARGET_SYS        = &amp;quot;i586-poky-linux&amp;quot;&lt;br /&gt;
  MACHINE           = &amp;quot;qemux86&amp;quot;&lt;br /&gt;
  DISTRO            = &amp;quot;poky&amp;quot;&lt;br /&gt;
  DISTRO_VERSION    = &amp;quot;2.0&amp;quot;&lt;br /&gt;
  TUNE_FEATURES     = &amp;quot;m32 i586&amp;quot;&lt;br /&gt;
  TARGET_FPU        = &amp;quot;&amp;quot;&lt;br /&gt;
  meta              &lt;br /&gt;
  meta-yocto        &lt;br /&gt;
  meta-yocto-bsp    = &amp;quot;&amp;lt;unknown&amp;gt;:&amp;lt;unknown&amp;gt;&amp;quot;&lt;br /&gt;
  meta-example      = &amp;quot;master:5ee4f20b041bc886b1d2d913ac11814057317634&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a git repository commit ==&lt;br /&gt;
&lt;br /&gt;
==== The bbexample recipe ====&lt;br /&gt;
 &lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the git repository&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; corresponds to a particular commit into that repository (it is also possible to specify a branch)&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;${WORKDIR}/git&amp;quot;&amp;lt;/code&amp;gt; which is the default location to which the retrieved git repository will be checked out and unpacked. &lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source from the git repository, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a remote source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-rt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-rt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a git checkout, with the major difference being we are building from a remote tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
We are using a release archived that was manually uploaded to GitHub. The archive corresponds to the bbexample source code tagged at v1.0. This is the preferred approach to using dynamically generated GitHub archives, as the checksums of these archives can change intermittently when they are regenerated. Manually uploaded archives will not change.&lt;br /&gt;
&lt;br /&gt;
This tagged archive is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to retrieve and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to the remote source archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;https://github.com/DynamicDevices/bbexample/releases/download/v1.0/bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-rt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here but instead we have &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; values for md5sum and an sha256sum check-sums &lt;br /&gt;
&lt;br /&gt;
As you would expect, these correspond to the particular check-sums generated by those algorithms when run over the entire archive.&lt;br /&gt;
&lt;br /&gt;
You can generate these by hand by retrieving the file yourself, running &amp;lt;code&amp;gt;md5sum archivename&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum archivename&amp;lt;/code&amp;gt; but it is easier to set these incorrectly and let &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; retrieve the archive and error on incorrect checksums and which point it will tell you what the lines should be.&lt;br /&gt;
&lt;br /&gt;
SRC_URI[md5sum] = &amp;quot;e15723f0d5ac710bbe788cd3a797bc44&amp;quot;&lt;br /&gt;
SRC_URI[sha256sum] = &amp;quot;0b34eb133596348bb6f1a3ef5e05e4d5bf0c88062256affe768d8337d7cc8f83&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the archive uploaded to GitHub.&lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any existing bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-rt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-rt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-rt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-rt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Build an example package based on a local source archive ==&lt;br /&gt;
&lt;br /&gt;
The recipe we are going to build is [https://github.com/DynamicDevices/meta-example/blob/master/recipes-example/bbexample/bbexample-lt_1.0.bb /home/user/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt_1.0.bb]. &lt;br /&gt;
&lt;br /&gt;
This is based on the previous recipe that builds from a remote source release, with the major difference being we are building from a local source tarball.&lt;br /&gt;
&lt;br /&gt;
This tarball may, in theory, contain any sources we wish to build, although sometimes build failures may require patching of the sources, and if &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; is not provided then the recipe may well have to be extended with a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function to ensure appropriate files are installed, and the FILES_${PN} variable modified to ensure installed files are correctly packaged.&lt;br /&gt;
&lt;br /&gt;
For this simple example the release source archive we uploaded to GitHub has been copied locally into the &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer folder tree, &lt;br /&gt;
&lt;br /&gt;
  yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0/bbexample-v1.0.tar.gz&lt;br /&gt;
&lt;br /&gt;
This local file is what we set in the recipe &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; to copy across, unpack, patch (if necessary) and build.&lt;br /&gt;
&lt;br /&gt;
The main points to note are that &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; is set to point to a local file archive&lt;br /&gt;
&lt;br /&gt;
  SRC_URI = &amp;quot;file://bbexample-${PV}.tar.gz&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Ideally we would use both of the variables ${PN} and ${PV} which would be replaced by the recipe name and recipe version, and could usually be expected to map to the naming convention employed for the source archive file. This makes the recipe more generic and easier to update to a new version of the source code by renaming the recipe .bb file. However as I am using a slightly different recipe name, &#039;bbexample-lt&#039; I have hard-coded the names here.&lt;br /&gt;
&lt;br /&gt;
* We provide a search path to ensure &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; can find the archive&lt;br /&gt;
&lt;br /&gt;
FILESEXTRAPATHS_prepend := &amp;quot;${THISDIR}/${PN}-${PV}:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
In this case the above will expand to the following folder, which is where we have placed &amp;lt;code&amp;gt;bbexample-1.0.tar.gz&amp;lt;/code&amp;gt;, and thus &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; will find it to unpack.&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta-example/recipes-example/bbexample/bbexample-lt-1.0&lt;br /&gt;
&lt;br /&gt;
* There is no &amp;lt;code&amp;gt;SRC_REV&amp;lt;/code&amp;gt; here or check-sum for the local archive.&lt;br /&gt;
&lt;br /&gt;
* There is a &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable defined to indicate the type of license to the build environment (MIT) and another variable, &lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;, points to a file within the source tree that will be retrieved, with a corresponding md5 check-sum to ensure that somebody has actually verified the source license file corresponds to that given to the build environment. Also that this file, and thus potentially the license, has not changed over time.&lt;br /&gt;
&lt;br /&gt;
* The source directory for the recipe build, &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; is set to &amp;lt;code&amp;gt;&amp;quot;bbexample-${PV}&amp;quot;&amp;lt;/code&amp;gt; which corresponds to the path to the source-code when extracted from the local archive. &lt;br /&gt;
&lt;br /&gt;
  # Make sure our source directory (for the build) matches the directory structure in the tarball&lt;br /&gt;
  S = &amp;quot;${WORKDIR}/bbexample-${PV}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* We inherit a class called &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; which provides the functionality to enable &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; to automatically build projects with &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support.&lt;br /&gt;
&lt;br /&gt;
* There is a marked absence of a &amp;lt;code&amp;gt;do_install&amp;lt;/code&amp;gt; function, which you may have seen elsewhere, as this is dealt with by the &amp;lt;code&amp;gt;autotools&amp;lt;/code&amp;gt; support&lt;br /&gt;
&lt;br /&gt;
To clean out any previous bbexample files&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -f -c cleansstate bbexample bbexample-rt&lt;br /&gt;
&lt;br /&gt;
To start the build &lt;br /&gt;
&lt;br /&gt;
  $ bitbake bbexample-lt&lt;br /&gt;
&lt;br /&gt;
Bitbake will work through a number of tasks, including fetching the source archive from the local file-system, unpacking, configuring, compiling, installing and packaging the output.&lt;br /&gt;
&lt;br /&gt;
There may be some warnings shown as all three recipes &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; are generating the same output and thus there is some collision of shared files. These warnings may be ignored.&lt;br /&gt;
&lt;br /&gt;
As we are building for the emulator, &amp;lt;code&amp;gt;qemux86&amp;lt;/code&amp;gt;, and are building RPM packages (the default), output packages will be in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm/i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For other machine targets the folder and suffix &amp;lt;code&amp;gt;i586&amp;lt;/code&amp;gt; will be replaced by a different machine-specific name. To find the location of the package you can use&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ find -name bbexample-lt*&lt;br /&gt;
&lt;br /&gt;
(Or instead of &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; use a prefix of the name of the recipe you are building)&lt;br /&gt;
&lt;br /&gt;
This will show you both the main package and the subsidiary packages which &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; builds for each recipe such as -dev, -debug, -staticdev and so forth. For more on this see [http://www.embeddedlinux.org.cn/OEManual/recipes_packages.html here]&lt;br /&gt;
&lt;br /&gt;
Having found the package you can check that the contents are as expected with&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/tmp/deploy/rpm&lt;br /&gt;
  $ rpm -qlp i586/bbexample-lt-1.0-r0.0.i586.rpm&lt;br /&gt;
&lt;br /&gt;
For the &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; recipe we expect to see the cross-compiled executable &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; and the shared library it needs &amp;lt;code&amp;gt;libbbexample.so.1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  /usr&lt;br /&gt;
  /usr/bin&lt;br /&gt;
  /usr/bin/bbexample&lt;br /&gt;
  /usr/lib&lt;br /&gt;
  /usr/lib/libbbexample.so.1&lt;br /&gt;
  /usr/lib/libbbexample.so.1.0.0&lt;br /&gt;
&lt;br /&gt;
You could then add the output of this recipe to your output image by adding something like this to your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample-lt&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Alternatively you could make the new packages available to existing target systems using the Yocto &amp;lt;code&amp;gt;package-management&amp;lt;/code&amp;gt; tools such as &amp;lt;code&amp;gt;smart&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If you wish to build and test your example on the emulator skip forward to [[#Testing the example on a target]]&lt;br /&gt;
&lt;br /&gt;
== Testing the example on an emulated target ==&lt;br /&gt;
&lt;br /&gt;
To to this we first want to add the appropriate recipe to an image and then run up that image in our emulator target. We could of course be targeting a real board, but with the wide variety of boards available this is outside the scope of this guide, and you should consult the documentation provided by your board vendor.&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via local.conf ===&lt;br /&gt;
&lt;br /&gt;
There are a couple of ways (at least!) to add a new package to an image. The simplest is to add the package to a variable within your &amp;lt;code&amp;gt;local.conf&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86/&lt;br /&gt;
  $ nano conf/local.conf&lt;br /&gt;
&lt;br /&gt;
Add a line at the bottom. You may wish to use &amp;lt;code&amp;gt;bbexample-rt&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;bbexample-lt&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt;. There should be no different in the output files.&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL_append = &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Then bitbake an image of your choice. With this method any image you build will have the &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; package added to it.&lt;br /&gt;
&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Adding a package to an image via a .bbappend ===&lt;br /&gt;
&lt;br /&gt;
Alternatively you may wish to add specific packages to specific images, which is generally viewed as better practice.&lt;br /&gt;
&lt;br /&gt;
We are using &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; for this guide. The recipe for this image can be found in&lt;br /&gt;
&lt;br /&gt;
  ~/yocto/poky-jethro-14.0.0/meta/recipes-core/images/core-image-minimal.bb&lt;br /&gt;
&lt;br /&gt;
We are also using our own new &amp;lt;code&amp;gt;meta-example&amp;lt;/code&amp;gt; layer, so this seems an appropriate place to add a .bbappend to extend the original &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; recipe.&lt;br /&gt;
&lt;br /&gt;
We need to recreate the path to the original recipe in our own layer, so&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/meta-example&lt;br /&gt;
  $ mkdir -p recipes-core/images&lt;br /&gt;
  $ cd recipes-core.images&lt;br /&gt;
  $ nano core-image-minimal.bbappend&lt;br /&gt;
&lt;br /&gt;
Add the following line to your empty new file&lt;br /&gt;
&lt;br /&gt;
  IMAGE_INSTALL += &amp;quot; bbexample&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Ensure that you no longer have &amp;lt;code&amp;gt;bbexample&amp;lt;/code&amp;gt; in your &amp;lt;code&amp;gt;conf/local.conf&amp;lt;/code&amp;gt;. It won&#039;t break the build but you want to be sure your .bbappend is working correctly)&lt;br /&gt;
&lt;br /&gt;
Now build the image&lt;br /&gt;
&lt;br /&gt;
  $ cd ~/yocto/poky-jethro-14.0.0/build_qemux86&lt;br /&gt;
  $ bitbake core-image-minimal&lt;br /&gt;
&lt;br /&gt;
=== Running the image in the emulator ===&lt;br /&gt;
&lt;br /&gt;
To run up the image, simply use&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86&lt;br /&gt;
&lt;br /&gt;
This will boot the emulator, load up the image, you&#039;ll see a kernel loading and with &amp;lt;code&amp;gt;core-image-minimal&amp;lt;/code&amp;gt; a console prompt. If you were building, say &amp;lt;code&amp;gt;core-image-sato&amp;lt;/code&amp;gt; instead you would see a basic user interface.&lt;br /&gt;
&lt;br /&gt;
If you find that your keymap is incorrect you might wish to set this explicitly, for example&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-gb&#039;&lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
  $ runqemu qemux86 qemuparams=&#039;-k en-us&#039;&lt;br /&gt;
&lt;br /&gt;
Log into the emulator as &#039;root&#039;, no password and run the example&lt;br /&gt;
&lt;br /&gt;
 $ bbexample&lt;br /&gt;
&lt;br /&gt;
You will see the Hello World output!&lt;br /&gt;
&lt;br /&gt;
[[File:Bbexample.png|800px]]&lt;br /&gt;
&lt;br /&gt;
== Recipe gotchas ==&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source folder ${S} ===&lt;br /&gt;
&lt;br /&gt;
It is extremely important to make sure that the source folder, the &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; variable is set correctly.&lt;br /&gt;
&lt;br /&gt;
When retrieving files from git repositories, or when archives are unpacked, it is entirely possible that the source folder default will not be correct for the actual unpacked location of the sources.&lt;br /&gt;
&lt;br /&gt;
If this happens the build will fail, often with a message that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; file cannot be found, as this is checked early on in the unpack.&lt;br /&gt;
&lt;br /&gt;
To check through this one option is to drop into a development shell with&lt;br /&gt;
&lt;br /&gt;
  $ bitbake -c devshell recipename&lt;br /&gt;
&lt;br /&gt;
This will drop you into the configured location of &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt;. If the sources defined in &amp;lt;code&amp;gt;SRC_URI&amp;lt;/code&amp;gt; seemed to be retrieved correctly but you see nothing in your devshell, excepting perhaps a &amp;lt;code&amp;gt;patches&amp;lt;/code&amp;gt; folder, this is a good indication that the code has been unpacked into a different folder.&lt;br /&gt;
&lt;br /&gt;
  $ cd ..&lt;br /&gt;
  $ ls&lt;br /&gt;
&lt;br /&gt;
You often will see another folder in the directory level about &amp;lt;code&amp;gt;${S}&amp;lt;/code&amp;gt; which contains the source code.&lt;br /&gt;
&lt;br /&gt;
This being the case you need to exit your devshell and edit your recipe to modify the source directory to point to the correct location. e.g.&lt;br /&gt;
&lt;br /&gt;
  ${S} = &amp;quot;${WORKDIR}/correctfoldername&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Dropping back into the devshell should then show the correct files, and you should be able to make progress with the build&lt;br /&gt;
&lt;br /&gt;
=== Incorrect license checksum ===&lt;br /&gt;
&lt;br /&gt;
This can occur, particularly when upgrading a recipe to use a new repository commit or source archive version, as the licensing file may have changed.&lt;br /&gt;
&lt;br /&gt;
If this does occur it is important to check through the new licensing file to ensure that the build environment is still being given correct information on the type of license for the source code.&lt;br /&gt;
&lt;br /&gt;
It may also be that a minor textual change has been made to the file (e.g. new copyright date) which doesn&#039;t affect the type of the license itself.&lt;br /&gt;
&lt;br /&gt;
Having satisfied yourself that the &amp;lt;code&amp;gt;LICENSE&amp;lt;/code&amp;gt; variable in the recipe reports the correct license type you can update the license checksum to that reported by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; by modifying &amp;lt;code&amp;gt;LIC_FILES_CHKSUM&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect source archive checksum ===&lt;br /&gt;
&lt;br /&gt;
You should be aware that sometimes maintainers re-release archives under the same name but with updated contents. Should this happen the check-sum check will fail and you will have to look into whether this is because of a corrupted download (check the downloaded archive in ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads) or because the archive has actually been changed.&lt;br /&gt;
&lt;br /&gt;
* You can try removing the archive from the downloads folder, and the corresponding .done file. The archive will then be downloaded again which may work if there was a corrupt/interrupted download (although in my experience this occurrence is unlikely).&lt;br /&gt;
&lt;br /&gt;
* Alternatively the archive may have changed and you may wish to use the new archive, in which case you will need to update the check-sums in the recipe to those you calculate yourself on the archive with &amp;lt;code&amp;gt;md5sum&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sha256sum&amp;lt;/code&amp;gt;, or simply use what &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt; calculates and provides for you in the log.&lt;br /&gt;
&lt;br /&gt;
  SRC_URI[md5sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
  SRC_URI[sha256sum] = &amp;quot;???&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* Lastly you may be able to source the correct archive file from a mirror or through Googling, in which case you can drop it into the &amp;lt;code&amp;gt;downloads&amp;lt;/code&amp;gt; folder for use by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the latter two cases you may wish to feed the issue back to the Yocto mailing list (or other relevant mailing list for the layer in which the recipe resides) as this type of thing means mirrored copies of primary sources become out of sync, and the layer/mirror maintainers may wish to address the issue.&lt;br /&gt;
&lt;br /&gt;
=== Missing source archive ===&lt;br /&gt;
&lt;br /&gt;
This is less of an issue than it has been in the past as primary sources are now mirrored in one or more locations, not least by the Yocto project itself.&lt;br /&gt;
&lt;br /&gt;
You can also set up your own mirror sources, which is dealt with [[How_do_I#Q:How do I create my own source download mirror? | here]]&lt;br /&gt;
&lt;br /&gt;
However for a one-off missing archive it is often quickest and easiest to Google to find it, then drop it into the ~/yocto/poky-jethro-14.0.0/build_qemux86/downloads folder, creating an empty .done file with&lt;br /&gt;
&lt;br /&gt;
  $ touch archivename.done&lt;br /&gt;
&lt;br /&gt;
It should then be picked up and used by &amp;lt;code&amp;gt;bitbake&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Feedback ==&lt;br /&gt;
&lt;br /&gt;
This is a living document. Please feel free to send comments, questions, corrections to Alex Lennon [mailto://ajlennon@dynamicdevices.co.uk here]&lt;/div&gt;</summary>
		<author><name>Alen Sunnny Mathew</name></author>
	</entry>
</feed>