Skip to content

Recommendations and Tips about Yocto

The yocto project has a Recipe Style Guide.

This page gives other general recommendations about how to write Yocto files, based on conventions followed in Yocto public layers.

BBPATH

BBPATH is used by Yocto to locate classes (.bbclass) and configuration files (.conf), and some others.

When a file is searched in BBPATH the order of directories in BBPATH determines which file finally gets selected.

In your conf/bblayers.conf, populate BBLAYERS with the most important layers first.

Eg:

BBLAYERS ?= " \
  $##OEROOT##/../meta-welma \
  $##OEROOT##/meta \
  ...

In this example the file meta-welma/files/fs-perms.txt takes precedence over poky/meta/files/fs-perms.txt.

Fetching with a passphrase-protected private SSH key

When your SSH private key (used for fetching git repositories) is protected by a passphrase, bitbake will not be able to interact with you to get this passphrase for fetching, and will fail.

You can work this around as follows:

$ eval `ssh-agent -s`
$ ssh-add <your-private-key>
$ bitbake <your-recipe>
$ kill $SSH_AGENT_PID

Devtool

Devtool may help in some situations, but has limitations.

devtool modify and overrides

This paragraph deals with the situation where bitbake builds your recipe correctly but devtool modify raises the following error:

devtool modify RECIPE
...
ERROR: Importing patch '0001.patch'
FileNotFoundError(2, 'No such file or directory')

A possible workaround is to use:

devtool modify --no-overrides RECIPE

The error can happen if you have these 2 mechanisms used in a recipe at the same time:

  • Patches added by overrides on SRC_URI
  • And patches added by overrides on FILESPATH (via MACHINEOVERRIDES, etc.)

Example:

  • In your recipe:

    SRC_URI += "file://0001.patch"
    
    SRC_URI:append:qemuarm-welma = " file://0002.patch"
    

  • In your files (in the directory of the recipe, searched through FILESPATH):

    files/
    ├── 0002.patch
    └── qemuarm-welma
        └── 0001.patch
    

  • In your MACHINEOVERRIDES: qemuarm-welma

devtool modify and do_patch:append

If you have custom patching in do_patch:append() and other patches added by overrides on SRC_URI, then you may encounter an error like:

devtool modify RECIPE
...
ERROR: ExecutionError('git checkout devtool', 1, '', 'error: The following
untracked working tree files would be overwritten by checkout:\n\t...\nPle
ase move or remove them before you switch branches.\nAborting\n')

There again, a possible workaround is:

devtool modify --no-overrides RECIPE