If you cannot work with one of the Linux kernel versions supported by existing linux-yocto recipes, you can still make use of the Yocto Project Linux kernel tooling by working with your own sources. When you use your own sources, you will not be able to leverage the existing kernel Metadata and stabilization work of the linux-yocto sources. However, you will be able to manage your own Metadata in the same format as the linux-yocto sources. Maintaining format compatibility facilitates converging with linux-yocto on a future, mutually-supported kernel version.
To help you use your own sources, the Yocto Project provides a
linux-yocto custom recipe
(linux-yocto-custom.bb
) that uses
kernel.org
sources
and the Yocto Project Linux kernel tools for managing
kernel Metadata.
You can find this recipe in the
poky
Git repository of the
Yocto Project Source Repository
at:
poky/meta-skeleton/recipes-kernel/linux/linux-yocto-custom.bb
Here are some basic steps you can use to work with your own sources:
Copy the linux-yocto-custom.bb
recipe to your layer and give it a meaningful name.
The name should include the version of the Linux kernel you
are using (e.g.
linux-yocto-myproject_3.19.bb
,
where "3.19" is the base version of the Linux kernel
with which you would be working).
In the same directory inside your layer,
create a matching directory
to store your patches and configuration files (e.g.
linux-yocto-myproject
).
Make sure you have either a
defconfig
file or configuration
fragment files.
When you use the linux-yocto-custom.bb
recipe, you must specify a configuration.
If you do not have a defconfig
file,
you can run the following:
$ make defconfig
After running the command, copy the resulting
.config
to the
files
directory as "defconfig" and
then add it to the
SRC_URI
variable in the recipe.
Edit the following variables in your recipe as appropriate for your project:
SRC_URI
:
The SRC_URI
should specify
a Git repository that uses one of the supported Git
fetcher protocols (i.e. file
,
git
, http
,
and so forth).
The SRC_URI
variable should
also specify either a defconfig
file or some configuration fragment files.
The skeleton recipe provides an example
SRC_URI
as a syntax reference.
LINUX_VERSION
:
The Linux kernel version you are using (e.g.
"3.19").
LINUX_VERSION_EXTENSION
:
The Linux kernel CONFIG_LOCALVERSION
that is compiled into the resulting kernel and visible
through the uname
command.
SRCREV
:
The commit ID from which you want to build.
PR
:
Treat this variable the same as you would in any other
recipe.
Increment the variable to indicate to the OpenEmbedded
build system that the recipe has changed.
PV
:
The default PV
assignment is
typically adequate.
It combines the LINUX_VERSION
with the Source Control Manager (SCM) revision
as derived from the
SRCPV
variable.
The combined results are a string with
the following form:
3.19.11+git1+68a635bf8dfb64b02263c1ac80c948647cc76d5f_1+218bd8d2022b9852c60d32f0d770931e3cf343e2
While lengthy, the extra verbosity in PV
helps ensure you are using the exact
sources from which you intend to build.
COMPATIBLE_MACHINE
:
A list of the machines supported by your new recipe.
This variable in the example recipe is set
by default to a regular expression that matches
only the empty string, "(^$)".
This default setting triggers an explicit build
failure.
You must change it to match a list of the machines
that your new recipe supports.
For example, to support the qemux86
and qemux86-64
machines, use
the following form:
COMPATIBLE_MACHINE = "qemux86|qemux86-64"
Provide further customizations to your recipe as needed just as you would customize an existing linux-yocto recipe. See the "Modifying an Existing Recipe" section for information.